From dbc819542241eb30c2a939b60e09cbcd57ee949f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 12 Dec 2022 14:07:54 +0100 Subject: [PATCH] Update refresh parametri --- MP.Data/Controllers/MpSpecController.cs | 1 + MP.SPEC/Components/ListPARAMS.razor.cs | 93 +++++++++++---------- MP.SPEC/Data/SelectFluxParams.cs | 5 -- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Pages/PARAMS.razor.cs | 103 +++++++----------------- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 8 files changed, 83 insertions(+), 127 deletions(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 9a40ac55..920ba9b2 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -861,6 +861,7 @@ namespace MP.Data.Controllers public async Task ODLClose(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd) { bool fatto = false; + await Task.Delay(1); if (idxOdl > 0) { using (var dbCtx = new MoonProContext(_configuration)) diff --git a/MP.SPEC/Components/ListPARAMS.razor.cs b/MP.SPEC/Components/ListPARAMS.razor.cs index 654ca456..e296dcb2 100644 --- a/MP.SPEC/Components/ListPARAMS.razor.cs +++ b/MP.SPEC/Components/ListPARAMS.razor.cs @@ -3,12 +3,17 @@ using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.SPEC.Data; using System.Diagnostics; -using MP.Data; namespace MP.SPEC.Components { public partial class ListPARAMS : IDisposable { + #region Public Fields + + public SelectFluxParams? LastFilter = null; + + #endregion Public Fields + #region Public Properties [Parameter] @@ -26,7 +31,7 @@ namespace MP.SPEC.Components #endregion Public Properties #region Public Methods - private SelectFluxParams lastFilter { get; set; } = new SelectFluxParams() { CurrPage = -1 }; + public string checkSelect(FluxLog selRecord) { string answ = ""; @@ -42,33 +47,17 @@ namespace MP.SPEC.Components return answ; } - protected override async Task OnParametersSetAsync() - { - await Task.Delay(1); - // se sono cambiati --> rileggo... - if (!lastFilter.Equals(SelFilter)) - { - lastFilter = SelFilter.clone(); - await reloadData(true); - } - } - - public SelectFluxParams? LastFilter = null; - public void Dispose() { -#if false aTimer.Elapsed -= ElapsedTimer; aTimer.Stop(); - aTimer.Dispose(); -#endif + aTimer.Dispose(); currRecord = null; SearchRecords = null; ListRecords = null; GC.Collect(); } -#if false public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) { if (!isLoading && LiveUpdate) @@ -90,12 +79,13 @@ namespace MP.SPEC.Components aTimer.Interval = deltaTime > 100 ? deltaTime : 100; aTimer.Start(); } - } -#endif + } public async Task reloadData(bool setChanged) { isLoading = true; + SearchRecords = null; + ListRecords = null; DateTime dataFrom = DateTime.Today.AddMonths(-1); DateTime dataTo = DateTime.Now.AddMinutes(5); if (SelFilter != null && SelFilter.dtMin != null) @@ -107,7 +97,7 @@ namespace MP.SPEC.Components dataTo = (DateTime)SelDtMax; } - SearchRecords = await MDService.FluxLogGetLastFilt(dataTo, dataFrom, SelMacchina, SelFlux, MaxRecord, RefreshPeriod/1000); + SearchRecords = await MDService.FluxLogGetLastFilt(dataTo, dataFrom, SelMacchina, SelFlux, MaxRecord, RefreshPeriod / 1000); totalCount = SearchRecords.Count; ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); @@ -118,18 +108,20 @@ namespace MP.SPEC.Components isLoading = false; } -#if false public void StartTimer() { aTimer = new System.Timers.Timer(RefreshPeriod); aTimer.Elapsed += ElapsedTimer; aTimer.Enabled = true; aTimer.Start(); - } -#endif + } #endregion Public Methods + #region Protected Fields + + #endregion Protected Fields + #region Protected Properties [Inject] @@ -147,15 +139,22 @@ namespace MP.SPEC.Components #region Protected Methods -#if false protected override void OnInitialized() { StartTimer(); - } -#endif + } + protected override async Task OnParametersSetAsync() + { + await Task.Delay(1); + // se sono cambiati --> rileggo... + if (!lastFilter.Equals(SelFilter)) + { + lastFilter = SelFilter.clone(); + await reloadData(true); + } + } - //protected int RefreshPeriod { get; set; } = 5000; protected async void OnSeachUpdated() { await InvokeAsync(() => @@ -194,22 +193,16 @@ namespace MP.SPEC.Components #endregion Protected Methods - - private string traduci(string lemma) - { - var answ = MDService.Traduci(lemma, "IT"); - return answ; - } - #region Private Fields -#if false - private static System.Timers.Timer aTimer = null!; -#endif + private static System.Timers.Timer aTimer = null!; private int _totalCount = 0; + private FluxLog? currRecord = null; + private List? ListRecords; + private List? SearchRecords; #endregion Private Fields @@ -224,6 +217,8 @@ namespace MP.SPEC.Components private bool isLoading { get; set; } = false; + private SelectFluxParams lastFilter { get; set; } = new SelectFluxParams() { CurrPage = -1 }; + private bool LiveUpdate { get => SelFilter.LiveUpdate; @@ -234,12 +229,21 @@ namespace MP.SPEC.Components get => SelFilter.MaxRecord; } + [Inject] + private NavigationManager NavManager { get; set; } = null!; + private int numRecord { get => SelFilter.NumRec; set => SelFilter.NumRec = value; } + private DateTime? SelDtMax + { + get => SelFilter.dtMax; + set => SelFilter.dtMax = value; + } + private string SelFlux { get => SelFilter.CodFlux; @@ -249,11 +253,6 @@ namespace MP.SPEC.Components { get => SelFilter.IdxMacchina; } - private DateTime? SelDtMax - { - get => SelFilter.dtMax; - set => SelFilter.dtMax = value; - } private int totalCount { @@ -272,6 +271,12 @@ namespace MP.SPEC.Components #region Private Methods + private string traduci(string lemma) + { + var answ = MDService.Traduci(lemma, "IT"); + return answ; + } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.SPEC/Data/SelectFluxParams.cs b/MP.SPEC/Data/SelectFluxParams.cs index 35836776..10c7ebee 100644 --- a/MP.SPEC/Data/SelectFluxParams.cs +++ b/MP.SPEC/Data/SelectFluxParams.cs @@ -16,7 +16,6 @@ #region Public Properties public string CodFlux { get; set; } = "*"; - public int CurrCount { get; set; } = 0; public int CurrPage { get; set; } = 1; public DateTime? dtMax { get; set; } = null; public DateTime? dtMin { get; set; } = null; @@ -39,7 +38,6 @@ SelectFluxParams clonedData = new SelectFluxParams() { CodFlux = this.CodFlux, - CurrCount = this.CurrCount, CurrPage = this.CurrPage, dtRif = this.dtRif, dtMax = this.dtMax, @@ -61,9 +59,6 @@ if (!(obj is SelectFluxParams item)) return false; - if (CurrCount != item.CurrCount) - return false; - if (IdxMacchina != item.IdxMacchina) return false; diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index e6fa79e9..93010083 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2212.1213 + 6.16.2212.1214 diff --git a/MP.SPEC/Pages/PARAMS.razor.cs b/MP.SPEC/Pages/PARAMS.razor.cs index 1e1daf48..fb4e977c 100644 --- a/MP.SPEC/Pages/PARAMS.razor.cs +++ b/MP.SPEC/Pages/PARAMS.razor.cs @@ -1,66 +1,43 @@ -using Microsoft.AspNetCore.Components; -using MP.Data.DatabaseModels; +using MP.Data.DatabaseModels; using MP.SPEC.Components; using MP.SPEC.Data; -using System.Diagnostics; namespace MP.SPEC.Pages { - public partial class PARAMS : IDisposable + public partial class PARAMS { - public void Dispose() - { - aTimer.Elapsed -= ElapsedTimer; - aTimer.Stop(); - aTimer.Dispose(); - GC.Collect(); - } - public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) - { - if (LiveUpdate) - { - aTimer.Stop(); - currFilter.CurrCount++; - currFilter.dtMax = DateTime.Now.AddSeconds(5); - aTimer.Interval = RefreshPeriod; - aTimer.Start(); - } - } - - public void StartTimer() - { - aTimer = new System.Timers.Timer(RefreshPeriod); - aTimer.Elapsed += ElapsedTimer; - aTimer.Enabled = true; - aTimer.AutoReset = true; - aTimer.Start(); - } - protected int RefreshPeriod - { - get => currFilter.TempoAgg; - } - protected bool LiveUpdate - { - get => currFilter.LiveUpdate; - } - - - - private static System.Timers.Timer aTimer = null!; - #region Protected Fields + protected int CurrCounter = 0; + protected DataPager? pagerODL = null!; #endregion Protected Fields - #region Protected Properties - - - #endregion Protected Properties - #region Protected Methods + protected async Task detailSel(FluxLog newRec) + { + await Task.Delay(1); + var updFilter = currFilter; + DateTime adesso = DateTime.Now.AddSeconds(1); + updFilter.LiveUpdate = (newRec == null); + // sistemo la data di riferimento x eventuale snapshot nel passato + updFilter.dtRif = newRec != null ? newRec.dtEvento : null; + if (newRec != null) + { + updFilter.lastUpdate = updFilter.lastUpdate == "-" ? $"{adesso:yyyy/MM/dd HH:mm:ss}" : updFilter.lastUpdate; + updFilter.IdxMacchina = newRec.IdxMacchina; + //updFilter.CodFlux = newRec.CodFlux; + } + else + { + updFilter.lastUpdate = "-"; + } + // salvo filtro + currFilter = updFilter; + } + protected void ForceReload(int newNum) { numRecord = newNum; @@ -89,7 +66,6 @@ namespace MP.SPEC.Pages modFilter.CurrPage = 1; modFilter.LiveUpdate = (currPage == 1); currFilter = modFilter; - StartTimer(); await Task.Delay(1); isFiltering = false; } @@ -111,27 +87,9 @@ namespace MP.SPEC.Pages totalCount = newTotCount; } - - protected async Task detailSel(FluxLog newRec) + protected void UpdateTotCount(int newTotCount) { - await Task.Delay(1); - var updFilter = currFilter; - DateTime adesso = DateTime.Now.AddSeconds(1); - updFilter.LiveUpdate = (newRec == null); - // sistemo la data di riferimento x eventuale snapshot nel passato - updFilter.dtRif = newRec != null ? newRec.dtEvento : null; - if (newRec != null) - { - updFilter.lastUpdate = updFilter.lastUpdate == "-" ? $"{adesso:yyyy/MM/dd HH:mm:ss}" : updFilter.lastUpdate; - updFilter.IdxMacchina = newRec.IdxMacchina; - //updFilter.CodFlux = newRec.CodFlux; - } - else - { - updFilter.lastUpdate = "-"; - } - // salvo filtro - currFilter = updFilter; + totalCount = newTotCount; } #endregion Protected Methods @@ -181,10 +139,7 @@ namespace MP.SPEC.Pages currFilter = newParams; isLoading = false; } - protected void UpdateTotCount(int newTotCount) - { - totalCount = newTotCount; - } + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 661c3025..09159d86 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2212.1213

+

Versione: 6.16.2212.1214


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index c53d0cbd..77ac8965 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2212.1213 +6.16.2212.1214 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 82282058..d6afba70 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2212.1213 + 6.16.2212.1214 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false