90 lines
3.0 KiB
C#
90 lines
3.0 KiB
C#
namespace EgwCoreLib.Lux.Data.Services.Production
|
|
{
|
|
public class ProductionGroupService : BaseServ, IProductionGroupService
|
|
{
|
|
#region Public Constructors
|
|
|
|
public ProductionGroupService(
|
|
IConfiguration config,
|
|
IConnectionMultiplexer redis,
|
|
IProductionGroupRepository repo) : base(config, redis)
|
|
{
|
|
_className = "ProdGroup";
|
|
_repo = repo;
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
/// <inheritdoc />
|
|
public async Task<List<ProductionGroupModel>> GetByOrderAsync(int orderID)
|
|
{
|
|
return await TraceAsync($"{_className}.ByOrd", async (activity) =>
|
|
{
|
|
return await GetOrSetCacheAsync(
|
|
$"{_redisBaseKey}:{_className}:ByOrd:{orderID}",
|
|
async () => await _repo.GetByOrderAsync(orderID),
|
|
UltraLongCache
|
|
);
|
|
});
|
|
}
|
|
/// <inheritdoc />
|
|
public async Task<List<ProductionGroupModel>> GetByOrderRowAsync(int orderRowID)
|
|
{
|
|
return await TraceAsync($"{_className}.ByOrdRow", async (activity) =>
|
|
{
|
|
return await GetOrSetCacheAsync(
|
|
$"{_redisBaseKey}:{_className}:ByOrdRow:{orderRowID}",
|
|
async () => await _repo.GetByOrderRowAsync(orderRowID),
|
|
UltraLongCache
|
|
);
|
|
});
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<List<ProductionGroupModel>> GetByOrderStateAsync(OrderStates reqState)
|
|
{
|
|
return await TraceAsync($"{_className}.ByOrdState", async (activity) =>
|
|
{
|
|
return await GetOrSetCacheAsync(
|
|
$"{_redisBaseKey}:{_className}:ByOrdState:{reqState}",
|
|
async () => await _repo.GetByOrderStateAsync(reqState),
|
|
UltraLongCache
|
|
);
|
|
});
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public async Task<bool> UpsertBalanceAsync(string uID, string rGroup, string rawBalance)
|
|
{
|
|
return await TraceAsync($"{_className}.UpsertBalance", async (activity) =>
|
|
{
|
|
string operation = "UpsertBalance";
|
|
bool success = false;
|
|
|
|
if (string.IsNullOrWhiteSpace(uID) || string.IsNullOrWhiteSpace(rGroup) || string.IsNullOrWhiteSpace(rawBalance))
|
|
return false;
|
|
|
|
success = await _repo.UpsertBalanceAsync(uID, rGroup, rawBalance);
|
|
|
|
activity?.SetTag("db.operation", operation);
|
|
if (success)
|
|
{
|
|
await ClearCacheAsync($"{_redisBaseKey}:{_className}");
|
|
}
|
|
|
|
return success;
|
|
});
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private readonly string _className;
|
|
private readonly IProductionGroupRepository _repo;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |