|
|
|
@ -1,17 +1,17 @@
|
|
|
|
using System;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
using Enyim.Caching;
|
|
|
|
using Enyim.Caching;
|
|
|
|
using Expedience.Infrastructure.Models;
|
|
|
|
using Expedience.Infrastructure.Models;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Expedience.Infrastructure
|
|
|
|
namespace Expedience.Infrastructure
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public interface IRepository : IDisposable
|
|
|
|
public interface IExpedienceRepository : IDisposable
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Task<List<DutyCompletionRecord>> GetDutyCompletionRecords(string expac, CancellationToken cancellationToken);
|
|
|
|
Task<List<DutyCompletionRecord>> GetDutyCompletionRecords(string expac, CancellationToken cancellationToken);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class ExpedienceRepository : IRepository
|
|
|
|
public class ExpedienceRepository : IExpedienceRepository
|
|
|
|
{
|
|
|
|
{
|
|
|
|
private readonly ExpedienceContext _dbContext;
|
|
|
|
private readonly ExpedienceContext _dbContext;
|
|
|
|
private readonly IMemcachedClient _memcachedClient;
|
|
|
|
private readonly IMemcachedClient _memcachedClient;
|
|
|
|
@ -31,9 +31,8 @@ namespace Expedience.Infrastructure
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var records = await _dbContext.DutyCompletionRecords.FromSqlInterpolated($"CALL get_dutycompletionrecords {expac}")
|
|
|
|
var records = await _dbContext.DutyCompletionRecords.FromSqlInterpolated($"SELECT * FROM public.get_dutycompletionrecords({expac})")
|
|
|
|
.ToListAsync();
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
|
|
await _memcachedClient.AddAsync(cacheKey, records, TimeSpan.FromMinutes(10));
|
|
|
|
await _memcachedClient.AddAsync(cacheKey, records, TimeSpan.FromMinutes(10));
|
|
|
|
|
|
|
|
|
|
|
|
return records;
|
|
|
|
return records;
|
|
|
|
@ -42,7 +41,7 @@ namespace Expedience.Infrastructure
|
|
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_dbContext.Dispose();
|
|
|
|
_memcachedClient.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|