From e6162fa0998a41f68dfb55f15a0a07a748dbd91e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 16 Jul 2025 11:58:02 +0200 Subject: [PATCH] Pulizia codice trend analysis + fix wait udpate task --- MP.Stats/Pages/TrendAnalysis.razor.cs | 76 +++++++-------------------- MP.TaskMan/Services/TaskService.cs | 1 + 2 files changed, 21 insertions(+), 56 deletions(-) diff --git a/MP.Stats/Pages/TrendAnalysis.razor.cs b/MP.Stats/Pages/TrendAnalysis.razor.cs index 7d15f0c7..133b5a88 100644 --- a/MP.Stats/Pages/TrendAnalysis.razor.cs +++ b/MP.Stats/Pages/TrendAnalysis.razor.cs @@ -112,7 +112,7 @@ namespace MP.Stats.Pages switch (value) { case ResolutionLevel.Low: - MaxPoints = NumPoint(SelCount, numSel , 32 , 32); + MaxPoints = NumPoint(SelCount, numSel, 32, 32); break; case ResolutionLevel.Med: @@ -126,49 +126,11 @@ namespace MP.Stats.Pages default: break; } -#if false - switch (value) - { - case ResolutionLevel.Low: - MaxPoints = (int)Math.Round(SelCount / numSel / 32 / (double)scale) * scale; - break; - - case ResolutionLevel.Med: - MaxPoints = (int)Math.Round(SelCount / numSel / 8 / (double)scale) * scale; - break; - - case ResolutionLevel.High: - MaxPoints = (int)Math.Round(SelCount / numSel / (double)scale) * scale; - break; - - default: - break; - } -#endif } } -#if false - // limite minimo 256... - MaxPoints = MaxPoints < 256 ? 256 : MaxPoints; -#endif } } - /// - /// Calcola num punti dato - /// - /// Numero totale valori - /// Numero partizioni (oggetti da disegnare insieme) - /// Fattore di scala richiesto - /// Fattore di scala (=valore minimo garantito) - /// - private int NumPoint(int selCount, int numSel, int factor, double scale) - { - int calcVal = (int)Math.Round((double)(selCount * scale) / numSel / factor / (double)scale); - - return calcVal > scale ? calcVal : (int)scale; - } - [Inject] protected MpStatsService StatService { get; set; } @@ -200,10 +162,6 @@ namespace MP.Stats.Pages protected async Task ResetFilter(SelectData newFilter) { -#if false - SearchRecords = null; - CalcFilt(); -#endif SearchRecords = null; PlotRecords = null; currFilter = SelectData.Init(5, 7); @@ -241,11 +199,15 @@ namespace MP.Stats.Pages #region Private Fields private int _maxPoints = 256; + private ResolutionLevel _reqRes = ResolutionLevel.Med; + private List ConfigList; private int MaxDisplay = 10; + private int NumMacc = 0; + private List PlotRecords = new List(); /// @@ -275,19 +237,6 @@ namespace MP.Stats.Pages #region Private Methods -#if false - /// - /// Calcola il filtro alla data necessaria x arrivare al confronto x mese... - /// - private void CalcFilt() - { - DateTime oggi = DateTime.Now.Date; - DateTime inizio = new DateTime(oggi.Year, oggi.Month, 1).AddMonths(-1); - int numPrev = (int)oggi.Subtract(inizio).TotalDays; - currFilter = SelectData.Init(5, numPrev); - } -#endif - private string confVal(string chiave) { string answ = ""; @@ -346,6 +295,21 @@ namespace MP.Stats.Pages ListMacchine = await StatService.MachineList(true); } + /// + /// Calcola num punti dato + /// + /// Numero totale valori + /// Numero partizioni (oggetti da disegnare insieme) + /// Fattore di scala richiesto + /// Fattore di scala (=valore minimo garantito) + /// + private int NumPoint(int selCount, int numSel, int factor, double scale) + { + int calcVal = (int)Math.Round((double)(selCount * scale) / numSel / factor / (double)scale); + + return calcVal > scale ? calcVal : (int)scale; + } + private async Task ReloadData() { isLoading = true; diff --git a/MP.TaskMan/Services/TaskService.cs b/MP.TaskMan/Services/TaskService.cs index 0a6826ac..15093965 100644 --- a/MP.TaskMan/Services/TaskService.cs +++ b/MP.TaskMan/Services/TaskService.cs @@ -328,6 +328,7 @@ namespace MP.TaskMan.Services public async Task TaskListReorder(int codGroup) { bool dbResult = MLController.TaskListReorder(codGroup); + await Task.Delay(50); // svuoto cache! await FlushCacheAsync(); return dbResult;