diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index e3cbc159..0d23400f 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -552,9 +552,9 @@ namespace MP.Data.Controllers /// /// /// Restitusice list dei record statistiche raccolti (da integrare a quelli rpesenti in Redis...) - public async Task> FluxLogDataRedux(string idxMaccSel, List fluxList, Periodo currPeriodo, Enum.ValSelection valMode, Enum.DataInterval intReq, int maxItem) + public async Task> FluxLogDataRedux(string idxMaccSel, List fluxList, Periodo currPeriodo, Enum.ValSelection valMode, Enum.DataInterval intReq, int maxItem) { - List procStats = new List(); + List procStats = new List(); Log.Info($"Inizio FluxLogDataRedux | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio} --> {currPeriodo.Fine}"); TimeSpan step = TimeSpan.FromHours(1); switch (intReq) @@ -667,7 +667,7 @@ namespace MP.Data.Controllers } // fermo cronometro e salvo su DB... sw.Stop(); - DTO.StatDedupDTO currStat = new DTO.StatDedupDTO() + StatDedupDTO currStat = new StatDedupDTO() { IdxMacchina = idxMaccSel, CodFlux = item, @@ -678,11 +678,6 @@ namespace MP.Data.Controllers }; procStats.Add(currStat); } - -#if false - // salvo le statistiche di processing... - fatto = LogFLDedupInsert(procStats); -#endif Log.Info($"FINE FluxLogDataRedux | idxMaccSel: {idxMaccSel} | periodo: {currPeriodo.Inizio} --> {currPeriodo.Fine}"); return procStats; } @@ -712,7 +707,8 @@ namespace MP.Data.Controllers var dbResult = dbCtx .Database - .ExecuteSqlRaw("EXEC man.stp_Utility_Maintanance @FlgExec, @FlgUpdStat, @FlgSave, @min_page_count, @min_avg_fragmentation_in_percent, @max_avg_fragmentation_per_rebuild", pFlgExec, pFlgUpdStat, pFlgSave, pMinPgCnt, pMinAvgFrag, pMaxAvgFrag); + .ExecuteSqlRaw("EXEC man.stp_Utility_Maintanance"); + //.ExecuteSqlRaw("EXEC man.stp_Utility_Maintanance @FlgExec, @FlgUpdStat, @FlgSave, @min_page_count, @min_avg_fragmentation_in_percent, @max_avg_fragmentation_per_rebuild", pFlgExec, pFlgUpdStat, pFlgSave, pMinPgCnt, pMinAvgFrag, pMaxAvgFrag); fatto = true; } Log.Info($"FINE ForceDbMaint"); diff --git a/MP.SPEC/Components/FLStatusList.razor.cs b/MP.SPEC/Components/FLStatusList.razor.cs index cf06f3a1..f25e8b8c 100644 --- a/MP.SPEC/Components/FLStatusList.razor.cs +++ b/MP.SPEC/Components/FLStatusList.razor.cs @@ -18,6 +18,8 @@ namespace MP.SPEC.Components [Parameter] public EventCallback E_TotalCount { get; set; } + [Parameter] + public EventCallback E_TotalRec { get; set; } [Parameter] public string IdxMaccSel { get; set; } = ""; @@ -80,6 +82,18 @@ namespace MP.SPEC.Components } } } + protected int TotalRecords + { + get => totRecords; + set + { + if (totRecords != value) + { + totRecords = value; + E_TotalRec.InvokeAsync(value).ConfigureAwait(false); + } + } + } #endregion Protected Properties @@ -104,6 +118,7 @@ namespace MP.SPEC.Components lastPeriodo = CurrPeriodo; ListComplete = await MDataServ.ParetoFluxLog(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine); TotalCount = ListComplete.Count; + TotalRecords = ListComplete.Sum(x => x.Qty); FluxList = ListComplete.Select(x => x.CodFlux).ToList(); } // esegue paginazione @@ -133,6 +148,7 @@ namespace MP.SPEC.Components private string idxMaccLast = ""; private bool isProcessing = false; private int totalCount = 0; + private int totRecords = 0; #endregion Private Fields diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index a087def9..591f287a 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1,5 +1,4 @@ using EgwCoreLib.Utils; -using Microsoft.AspNetCore.Razor.TagHelpers; using MP.Data; using MP.Data.Conf; using MP.Data.DatabaseModels; @@ -692,6 +691,24 @@ namespace MP.SPEC.Data return answ; } + /// + /// Funzione di Data Reduction x FluxLog + /// + /// Macchina + /// Elenco FL da processare + /// Periodo + /// modalità sel valore + /// intervallo di analisi + /// max num per intervallo + /// + public async Task FluxLogDataRedux(string idxMaccSel, List fluxList, DtUtils.Periodo currPeriodo, ValSelection valMode, DataInterval intReq, int maxItem) + { + List procStats = await dbController.FluxLogDataRedux(idxMaccSel, fluxList, currPeriodo, valMode, intReq, maxItem); + // effettuo merge statistiche... + ProcStatMerge(procStats); + await FlushCacheFluxLog(); + } + public List FluxLogDtoGetByFlux(string Valore) { List answ = new List(); @@ -761,6 +778,22 @@ namespace MP.SPEC.Data return result; } + /// + /// Stored manutenzione del DB + /// + /// Esegue realmente il task + /// Aggiornamento statistiche + /// Salvataggio + /// def: 1000 + /// def: 10 + /// def: 50 + /// + public async Task ForceDbMaint(bool doExec = true, bool doUpdStat = true, bool doSave = true, int minPgCnt = 1000, int minAvgFrag = 10, int maxAvgFragReb = 50) + { + dbController.ForceDbMaint(doExec, doUpdStat, doSave, minPgCnt, minAvgFrag, maxAvgFragReb); + await FlushCacheFluxLog(); + } + /// /// Init ricetta /// @@ -1417,6 +1450,27 @@ namespace MP.SPEC.Data return dbResult; } + /// + /// Restituisce le statistiche di processo correnti x depluplica FluxLog + /// + /// + public List ProcFLStats() + { + List actStats = new List(); + string currKey = $"{Utils.redisStatsProcFL}"; + // recupero i record statistiche correnti + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + var rawStats = JsonConvert.DeserializeObject>($"{rawData}"); + if (rawStats != null) + { + actStats = rawStats; + } + } + return actStats; + } + /// /// Ricerca ricetta su MongoDB dato PODL /// @@ -1712,6 +1766,45 @@ namespace MP.SPEC.Data return TimeSpan.FromMinutes(rndValue); } + protected bool ProcStatMerge(List procStats) + { + bool answ = false; + List actStats = ProcFLStats(); + // se fosse vuoto --> add diretto + if (actStats.Count == 0) + { + actStats.AddRange(procStats); + } + else + { + // aggiorno su redis i record statistiche 1:1... + foreach (var recStat in procStats) + { + // cerco se ci fosse x aggiornare + var currRec = actStats.Where(x => x.IdxMacchina == recStat.IdxMacchina + && x.CodFlux == recStat.CodFlux + && x.Interval == recStat.Interval + && x.Num4Int == recStat.Num4Int).FirstOrDefault(); + // se trovato aggiorno + if (currRec != null) + { + currRec.ProcTime += recStat.ProcTime; + currRec.NumRec += recStat.NumRec; + } + // altrimenti aggiungo + else + { + actStats.Add(recStat); + } + } + } + // salvo record statistiche + var rawData = JsonConvert.SerializeObject(actStats); + string currKey = $"{Utils.redisStatsProcFL}"; + redisDb.StringSet(currKey, rawData); + return answ; + } + #endregion Protected Methods #region Private Fields @@ -1773,100 +1866,6 @@ namespace MP.SPEC.Data await RedisFlushPatternAsync(pattern); } - /// - /// Funzione di Data Reduction x FluxLog - /// - /// Macchina - /// Elenco FL da processare - /// Periodo - /// modalità sel valore - /// intervallo di analisi - /// max num per intervallo - /// - public async Task FluxLogDataRedux(string idxMaccSel, List fluxList, DtUtils.Periodo currPeriodo, ValSelection valMode, DataInterval intReq, int maxItem) - { - List procStats = await dbController.FluxLogDataRedux(idxMaccSel, fluxList, currPeriodo, valMode, intReq, maxItem); - // effettuo merge statistiche... - ProcStatMerge(procStats); - await FlushCacheFluxLog(); - } - - /// - /// Restituisce le statistiche di processo correnti x depluplica FluxLog - /// - /// - public List ProcFLStats() - { - List actStats = new List(); - string currKey = $"{Utils.redisStatsProcFL}"; - // recupero i record statistiche correnti - RedisValue rawData = redisDb.StringGet(currKey); - if (rawData.HasValue) - { - var rawStats = JsonConvert.DeserializeObject>($"{rawData}"); - if (rawStats != null) - { - actStats = rawStats; - } - } - return actStats; - } - - protected bool ProcStatMerge(List procStats) - { - bool answ = false; - List actStats = ProcFLStats(); - // se fosse vuoto --> add diretto - if (actStats.Count == 0) - { - actStats.AddRange(procStats); - } - else - { - // aggiorno su redis i record statistiche 1:1... - foreach (var recStat in procStats) - { - // cerco se ci fosse x aggiornare - var currRec = actStats.Where(x => x.IdxMacchina == recStat.IdxMacchina - && x.CodFlux == recStat.CodFlux - && x.Interval == recStat.Interval - && x.Num4Int == recStat.Num4Int).FirstOrDefault(); - // se trovato aggiorno - if (currRec != null) - { - currRec.ProcTime += recStat.ProcTime; - currRec.NumRec += recStat.NumRec; - } - // altrimenti aggiungo - else - { - actStats.Add(recStat); - } - } - } - // salvo record statistiche - var rawData = JsonConvert.SerializeObject(actStats); - string currKey = $"{Utils.redisStatsProcFL}"; - redisDb.StringSet(currKey, rawData); - return answ; - } - - /// - /// Stored manutenzione del DB - /// - /// Esegue realmente il task - /// Aggiornamento statistiche - /// Salvataggio - /// def: 1000 - /// def: 10 - /// def: 50 - /// - public async Task ForceDbMaint(bool doExec = true, bool doUpdStat = true, bool doSave = true, int minPgCnt = 1000, int minAvgFrag = 10, int maxAvgFragReb = 50) - { - dbController.ForceDbMaint(doExec, doUpdStat, doSave, minPgCnt, minAvgFrag, maxAvgFragReb); - await FlushCacheFluxLog(); - } - #endregion Private Methods } } \ No newline at end of file diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 0180a490..3c287af7 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2310.2318 + 6.16.2310.2319 diff --git a/MP.SPEC/Pages/FluxLogStatus.razor b/MP.SPEC/Pages/FluxLogStatus.razor index 2984c76b..bb940f4e 100644 --- a/MP.SPEC/Pages/FluxLogStatus.razor +++ b/MP.SPEC/Pages/FluxLogStatus.razor @@ -33,19 +33,22 @@
@if (isProcessing) { - + } else { - + }