Preprocess per cambio metodi Async
This commit is contained in:
@@ -1096,21 +1096,17 @@ namespace MP.Data.Controllers
|
||||
/// Elenco Gruppi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ParetoFluxLogDTO> FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
public async Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
{
|
||||
List<ParetoFluxLogDTO> dbResult = new List<ParetoFluxLogDTO>();
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
|
||||
.AsNoTracking()
|
||||
.GroupBy(x => x.CodFlux)
|
||||
.Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() })
|
||||
.OrderByDescending(x => x.Qty)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
|
||||
.AsNoTracking()
|
||||
.GroupBy(x => x.CodFlux)
|
||||
.Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() })
|
||||
.OrderByDescending(x => x.Qty)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1803,20 +1799,17 @@ namespace MP.Data.Controllers
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> MacchineWithFlux(DateTime dtStart, DateTime dtEnd)
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
List<string> dbResult = new List<string>();
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => x.dtEvento >= dtStart && x.dtEvento <= dtEnd)
|
||||
.Select(i => i.IdxMacchina)
|
||||
.Distinct()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => x.dtEvento >= dtStart && x.dtEvento <= dtEnd)
|
||||
.Select(i => i.IdxMacchina)
|
||||
.Distinct()
|
||||
.ToListAsync() ?? new();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace MP.SPEC.Components
|
||||
SelFilterDossier.MaxRecord = 1000;
|
||||
DateTime dtEnd = SelFilterDossier.DtEnd;
|
||||
DateTime dtStart = dtEnd.Subtract(SelFilterDossier.DtStart).TotalDays < 15 ? SelFilterDossier.DtStart : dtEnd.AddDays(-14);
|
||||
ListMacchine = await MDService.MacchineWithFlux(dtStart, dtEnd);
|
||||
ListMacchine = await MDService.MacchineWithFluxAsync(dtStart, dtEnd);
|
||||
ListArticoli = await MDService.ArticleWithDossierAsync();
|
||||
await FilterChanged.InvokeAsync(SelFilterDossier);
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace MP.SPEC.Components
|
||||
{
|
||||
idxMaccLast = IdxMaccSel;
|
||||
lastPeriodo = CurrPeriodo;
|
||||
ListComplete = await MDataServ.FluxLogPareto(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
|
||||
ListComplete = await MDataServ.FluxLogParetoAsync(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
|
||||
TotalCount = ListComplete.Count;
|
||||
TotalRecords = ListComplete.Sum(x => x.Qty);
|
||||
FluxList = ListComplete.Select(x => x.CodFlux).ToList();
|
||||
|
||||
@@ -181,7 +181,7 @@ namespace MP.SPEC.Components
|
||||
setDtSnap();
|
||||
DateTime dtStart = SelFilter.dtMin != null ? (DateTime)SelFilter.dtMin : DateTime.Now.AddMonths(-1);
|
||||
DateTime dtEnd = SelFilter.dtMax != null ? (DateTime)SelFilter.dtMax : DateTime.Today.AddDays(1);
|
||||
ListMacchine = await MDService.MacchineWithFlux(dtStart, dtEnd);
|
||||
ListMacchine = await MDService.MacchineWithFluxAsync(dtStart, dtEnd);
|
||||
ListFlux = await MDService.ParametriGetFilt(selMacchina);
|
||||
|
||||
var configData = await MDService.ConfigGetAllAsync();
|
||||
|
||||
@@ -1105,9 +1105,9 @@ namespace MP.SPEC.Data
|
||||
/// Elenco Gruppi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ParetoFluxLogDTO>> FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
public async Task<List<ParetoFluxLogDTO>> FluxLogParetoAsync(string idxMacchina, DateTime dtFrom, DateTime dtTo)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("FluxLogPareto");
|
||||
using var activity = ActivitySource.StartActivity("FluxLogParetoAsync");
|
||||
string source = "DB";
|
||||
List<ParetoFluxLogDTO>? result = new List<ParetoFluxLogDTO>();
|
||||
// cerco in redis...
|
||||
@@ -1120,7 +1120,7 @@ namespace MP.SPEC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.FluxLogPareto(idxMacchina, dtFrom, dtTo));
|
||||
result = await dbController.FluxLogParetoAsync(idxMacchina, dtFrom, dtTo);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(redKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
@@ -1132,7 +1132,7 @@ namespace MP.SPEC.Data
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"FluxLogPareto | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"FluxLogParetoAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1545,9 +1545,9 @@ namespace MP.SPEC.Data
|
||||
/// <param name="dtStart"></param>
|
||||
/// <param name="dtEnd"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<string>> MacchineWithFlux(DateTime dtStart, DateTime dtEnd)
|
||||
public async Task<List<string>> MacchineWithFluxAsync(DateTime dtStart, DateTime dtEnd)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("MacchineWithFlux");
|
||||
using var activity = ActivitySource.StartActivity("MacchineWithFluxAsync");
|
||||
List<string>? result = new List<string>();
|
||||
string source = "DB";
|
||||
string currKey = $"{Utils.redisMacByFlux}:{dtStart:yyyyMMddHHmm}:{dtEnd:yyyyMMddHHmm}";
|
||||
@@ -1560,7 +1560,7 @@ namespace MP.SPEC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await dbController.MacchineWithFlux(dtStart, dtEnd);
|
||||
result = await dbController.MacchineWithFluxAsync(dtStart, dtEnd);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
|
||||
@@ -1572,7 +1572,7 @@ namespace MP.SPEC.Data
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"MacchineWithFlux | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"MacchineWithFluxAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user