diff --git a/MP.SPEC/Components/ListPARAMS.razor.cs b/MP.SPEC/Components/ListPARAMS.razor.cs index 2ef8726a..31574c02 100644 --- a/MP.SPEC/Components/ListPARAMS.razor.cs +++ b/MP.SPEC/Components/ListPARAMS.razor.cs @@ -3,6 +3,7 @@ using Microsoft.JSInterop; using MP.Data.DatabaseModels; using MP.SPEC.Data; using System.Diagnostics; +using MP.Data; namespace MP.SPEC.Components { @@ -156,6 +157,7 @@ namespace MP.SPEC.Components protected async Task resetSel() { currRecord = null; + setDtMax(); await RecordSel.InvokeAsync(null); } @@ -163,6 +165,8 @@ namespace MP.SPEC.Components { currRecord = selRec; SelFilter.IdxMacchina = selRec.IdxMacchina; + SelDtMax = selRec.dtEvento; + //selDtMin = RoundDatetime(5).AddHours(-25); await reloadData(false); await RecordSel.InvokeAsync(selRec); } @@ -224,8 +228,33 @@ namespace MP.SPEC.Components private DateTime? SelDtMax { get => SelFilter.dtMax; + set => SelFilter.dtMax = value; + } + protected void setDtMax() + { + // copio il filtro + var currFilt = SelFilter; + // fermo update + currFilt.LiveUpdate = true; + currFilt.CurrPage = 0; + currFilt.lastUpdate = $"{DateTime.Now:yyyy/MM/dd HH:mm:ss}"; + currFilt.dtMax = RoundDatetime(5); + currFilt.dtMin = RoundDatetime(5).AddHours(-25); + SelFilter = currFilt; } + /// + /// Inizializzazione con periodo e arrotondamento + /// + /// + /// + public static DateTime RoundDatetime(int minRound) + { + TimeSpan DayElapsed = DateTime.Now.Subtract(DateTime.Today); + int minDay = (int)Math.Ceiling((double)(DayElapsed.TotalMinutes / minRound)) * minRound; + DateTime endRounded = DateTime.Today.AddMinutes(minDay); + return endRounded; + } private int totalCount { get => _totalCount; diff --git a/MP.SPEC/Components/ParamsFilter.razor b/MP.SPEC/Components/ParamsFilter.razor index 769761eb..ae01c039 100644 --- a/MP.SPEC/Components/ParamsFilter.razor +++ b/MP.SPEC/Components/ParamsFilter.razor @@ -38,7 +38,7 @@ - +