Ancora refactor metodi + documentazione
This commit is contained in:
@@ -491,14 +491,12 @@ namespace MP.Data.Controllers
|
||||
{
|
||||
//query = query.Where(x => x.Tipo.ToLower() == tipoArt.ToLower());
|
||||
query = query.Where(x => EF.Functions.Like(x.Tipo, tipoArt));
|
||||
|
||||
}
|
||||
// filtro azienda
|
||||
if (azienda != "*")
|
||||
{
|
||||
//query = query.Where(x => x.Azienda.ToLower() == azienda.ToLower());
|
||||
query = query.Where(x => EF.Functions.Like(x.Azienda, azienda));
|
||||
|
||||
}
|
||||
// filtro ricerca
|
||||
if (!string.IsNullOrWhiteSpace(searchVal))
|
||||
@@ -520,7 +518,6 @@ namespace MP.Data.Controllers
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli NON IMPIEGATI (da stored stp_ART_getUsed) Async
|
||||
/// </summary>
|
||||
@@ -1076,20 +1073,16 @@ namespace MP.Data.Controllers
|
||||
/// <param name="CodFlux">*=tutti, altrimenti solo selezionato</param>
|
||||
/// <param name="MaxRec">numero massimo record da restituire</param>
|
||||
/// <returns></returns>
|
||||
public List<FluxLogModel> FluxLogGetLastFilt(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec)
|
||||
public async Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec)
|
||||
{
|
||||
List<FluxLogModel> dbResult = new List<FluxLogModel>();
|
||||
using (var dbCtx = new MoonPro_FluxContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux))
|
||||
.OrderByDescending(x => x.dtEvento)
|
||||
.Take(MaxRec)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
using var dbCtx = new MoonPro_FluxContext(_configuration);
|
||||
return await dbCtx
|
||||
.DbSetFluxLog
|
||||
.AsNoTracking()
|
||||
.Where(x => (x.dtEvento >= DtMin && x.dtEvento <= DtMax) && (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodFlux == "*" || x.CodFlux == CodFlux))
|
||||
.OrderByDescending(x => x.dtEvento)
|
||||
.Take(MaxRec)
|
||||
.ToListAsync() ?? new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1629,7 +1622,7 @@ namespace MP.Data.Controllers
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
@@ -1805,7 +1798,6 @@ namespace MP.Data.Controllers
|
||||
.Select(i => i.IdxMacchina)
|
||||
.Distinct()
|
||||
.ToListAsync() ?? new();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1541,7 +1541,7 @@ namespace MP.IOC.Data
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(SpecDbController.FluxLogGetLastFilt(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec));
|
||||
result = await SpecDbController.FluxLogGetLastFiltAsync(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec);
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
if (string.IsNullOrEmpty(canCacheParametri))
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace MP.SPEC.Components
|
||||
dataTo = (DateTime)SelDtMax;
|
||||
}
|
||||
|
||||
SearchRecords = await MDService.FluxLogGetLastFilt(dataTo, dataFrom, SelMacchina, SelFlux, MaxRecord, RefreshPeriod / 1000);
|
||||
SearchRecords = await MDService.FluxLogGetLastFiltAsync(dataTo, dataFrom, SelMacchina, SelFlux, MaxRecord, RefreshPeriod / 1000);
|
||||
totalCount = SearchRecords.Count;
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
await Task.Delay(1);
|
||||
|
||||
@@ -571,7 +571,7 @@ namespace MP.SPEC.Data
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "DossiersGetLastFiltAsync",
|
||||
cacheKey: currKey,
|
||||
expiration: getRandTOut(redisLongTimeCache),
|
||||
expiration: getRandTOut(redisLongTimeCache * 5),
|
||||
fetchFunc: async () => await dbController.DossiersGetLastFiltAsync(IdxMacchina, CodArticolo, DtStart, DtEnd, MaxRec) ?? new List<DossierModel>(),
|
||||
tagList: [Utils.redisDossByMac]
|
||||
);
|
||||
@@ -1055,50 +1055,26 @@ namespace MP.SPEC.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ultimi n record flux log dato idxMaccSel e flusso (ordinato x data registrazione)
|
||||
/// Elenco FluxLog in modalità filtro
|
||||
/// </summary>
|
||||
/// <param name="DtMax">Data massima x eventi</param>
|
||||
/// <param name="DtMin">Data minima x eventi</param>
|
||||
/// <param name="IdxMacchina">* = tutte, altrimenti solo x una data idxMaccSel</param>
|
||||
/// <param name="CodFlux">*=tutti, altrimenti solo selezionato</param>
|
||||
/// <param name="MaxRec">numero massimo record da restituire</param>
|
||||
/// <param name="redisCacheSec">durata cache in secondi</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<FluxLogModel>> FluxLogGetLastFilt(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec, double redisCacheSec)
|
||||
public async Task<List<FluxLogModel>> FluxLogGetLastFiltAsync(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec, double redisCacheSec)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("FluxLogGetLastFilt");
|
||||
List<FluxLogModel>? result = new List<FluxLogModel>();
|
||||
string source = "DB";
|
||||
string currKey = $"{Utils.redisFluxLogFilt}:{IdxMacchina}:{CodFlux}:{MaxRec}:{DtMax:yyyyMMddHHmm}:{DtMin:yyyyMMddHHmm}";
|
||||
// cerco in redis dato valore sel idxMaccSel...
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<FluxLogModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.FluxLogGetLastFilt(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec));
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
if (string.IsNullOrEmpty(canCacheParametri))
|
||||
{
|
||||
canCacheParametri = await ConfigTryGetAsync("SPEC_ParametriEnableRedisCache");
|
||||
}
|
||||
if (canCacheParametri != "false")
|
||||
{
|
||||
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisCacheSec));
|
||||
}
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<FluxLogModel>();
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"FluxLogGetLastFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "FluxLogGetLastFiltAsync",
|
||||
cacheKey: currKey,
|
||||
expiration: TimeSpan.FromSeconds(redisCacheSec),
|
||||
fetchFunc: async () => await dbController.FluxLogGetLastFiltAsync(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec) ?? new List<FluxLogModel>(),
|
||||
tagList: [Utils.redisFluxLogFilt]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
+10
-12
@@ -32,6 +32,16 @@ I metodi verranno suddivisi in:
|
||||
- [x] `TemplateKitFiltAsync`
|
||||
- [x] `AnagTipoArtLvAsync`
|
||||
- [x] `ElencoLinkAsync`
|
||||
- [x] `ConfigGetAllAsync`
|
||||
- [x] `DossiersGetLastFiltAsync`
|
||||
- [x] `ElencoGruppiFaseAsync`
|
||||
- [x] `IstKitFiltAsync`
|
||||
- [x] `ListGiacenzeAsync`
|
||||
- [x] `MacchineWithFluxAsync`
|
||||
- [x] `POdlListGetFiltAsync`
|
||||
- [x] `TksScoreAsync`
|
||||
- [x] `WipKitFiltAsync`
|
||||
- [x] `POdlGetByOdlAsync`
|
||||
- [ ] `AnagEventiGeneral`
|
||||
- [ ] `AnagEventiGetByMacch`
|
||||
- [ ] `AnagKeyValGetAll`
|
||||
@@ -39,20 +49,14 @@ I metodi verranno suddivisi in:
|
||||
- [ ] `AnagTipoArtLvAsync`
|
||||
- [ ] `ArticleWithDossier`
|
||||
- [ ] `ConfigGetAll`
|
||||
- [ ] `ConfigGetAllAsync`
|
||||
- [ ] `DbDedupStats`
|
||||
- [ ] `DossiersGetLastFilt`
|
||||
- [ ] `ElencoGruppiFase`
|
||||
- [ ] `ElencoRepartiDTO`
|
||||
- [ ] `ExpiryReloadParamGet`
|
||||
- [ ] `IobInfo`
|
||||
- [ ] `IstKitFilt`
|
||||
- [ ] `ListGiacenze`
|
||||
- [ ] `ListPODL_ByCodArt`
|
||||
- [ ] `MacchineGetFilt`
|
||||
- [ ] `MacchineRecipeArchive`
|
||||
- [ ] `MacchineRecipeConf`
|
||||
- [ ] `MacchineWithFlux`
|
||||
- [ ] `MachIobConf`
|
||||
- [ ] `MseGetAll`
|
||||
- [ ] `OdlByBatch`
|
||||
@@ -61,17 +65,11 @@ I metodi verranno suddivisi in:
|
||||
- [ ] `OperatoriGetFilt`
|
||||
- [ ] `ParametriGetFilt`
|
||||
- [ ] `POdlGetByKey`
|
||||
- [ ] `POdlGetByOdl`
|
||||
- [ ] `POdlListByKitParent`
|
||||
- [ ] `POdlListGetFilt`
|
||||
- [ ] `POdlListGetFiltAsync`
|
||||
- [ ] `ProcFLStats`
|
||||
- [ ] `StatoMacchina`
|
||||
- [ ] `TagConfGetKey`
|
||||
- [ ] `TemplateKitFilt`
|
||||
- [ ] `TksScore`
|
||||
- [ ] `VocabolarioGetAll`
|
||||
- [ ] `WipKitFilt`
|
||||
|
||||
#### Fase 3: Refactoring Metodi di Scrittura e Invalidazione
|
||||
- [ ] `AnagGruppiDelete`
|
||||
|
||||
Reference in New Issue
Block a user