diff --git a/MP.SPEC/Components/ParamsFilter.razor.cs b/MP.SPEC/Components/ParamsFilter.razor.cs index eae78d0e..9930b251 100644 --- a/MP.SPEC/Components/ParamsFilter.razor.cs +++ b/MP.SPEC/Components/ParamsFilter.razor.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Components; using MP.SPEC.Data; -using System.Runtime.CompilerServices; namespace MP.SPEC.Components { @@ -170,6 +169,14 @@ namespace MP.SPEC.Components SelFilter = new SelectFluxParams(); ListMacchine = await MDService.MacchineWithFlux(); ListFlux = await MDService.ParametriGetFilt(selMacchina); + + var configData = await MDService.ConfigGetAll(); + var currRec = configData.FirstOrDefault(x => x.Chiave == "numOreAnticipoSnapshot"); + if (currRec != null) + { + int.TryParse(currRec.Valore, out numOreAnticipoSnapshot); + } + await FilterChanged.InvokeAsync(SelFilter); } @@ -182,7 +189,7 @@ namespace MP.SPEC.Components currFilt.CurrPage = 0; currFilt.lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}"; currFilt.dtMax = RoundDatetime(5); - currFilt.dtMin = RoundDatetime(5).AddDays(-1); + currFilt.dtMin = RoundDatetime(5).AddHours(-numOreAnticipoSnapshot); SelFilter = currFilt; } @@ -196,19 +203,19 @@ namespace MP.SPEC.Components protected async Task takeSnapshot() { - // indico snapshot fatto - snapshotDone = true; - startTimer(); // fermo udpate liveUpdate = false; // se non ho data rif uso adesso... DateTime dtMax = selDtMax == null ? RoundDatetime(5) : (DateTime)selDtMax; - DateTime dtMin = selDtMin == null ? RoundDatetime(5).AddDays(-1) : (DateTime)selDtMin; + DateTime dtMin = selDtMin == null ? RoundDatetime(5).AddHours(-numOreAnticipoSnapshot) : (DateTime)selDtMin; // aggiungo 2 sec dtMax = dtMax.AddSeconds(15); //dtMin = dtMin.AddMinutes(-30); await MDService.DossiersTakeParamsSnapshotLast(selMacchina, dtMin, dtMax); lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}"; + // indico snapshot fatto + snapshotDone = true; + startTimer(); } protected void toggleParams() @@ -237,15 +244,17 @@ namespace MP.SPEC.Components private static System.Timers.Timer aTimer = new System.Timers.Timer(); private List? ListFlux = null; - private List? ListMacchine = null; - + private int numOreAnticipoSnapshot = 5; private bool snapshotDone = false; #endregion Private Fields #region Private Properties + [Inject] + private NavigationManager NavManager { get; set; } = null!; + private DateTime? selDtMax { get => SelFilter.dtMax; @@ -265,6 +274,7 @@ namespace MP.SPEC.Components } } } + private DateTime? selDtMin { get => SelFilter.dtMin; @@ -285,9 +295,6 @@ namespace MP.SPEC.Components } } - [Inject] - private NavigationManager NavManager { get; set; } = null!; - private bool showEditPar { get; set; } = false; private string snapMode diff --git a/MP.SPEC/appsettings.json b/MP.SPEC/appsettings.json index f99535b9..f4116e61 100644 --- a/MP.SPEC/appsettings.json +++ b/MP.SPEC/appsettings.json @@ -15,6 +15,6 @@ "ServerConf": { "maxAge": "2000", "cacheCheckArtUsato": 2, - "redisLongTimeCache": 15 + "redisLongTimeCache": 15 } }