From a939079cee0ee0f6e5fc9c0aca96de58ab7afabb Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 14 Dec 2023 17:12:48 +0100 Subject: [PATCH] Fix chiamate multiple x check controlli (ogni 15 sec minimo) --- MP-TAB-SERV/Components/CheckControls.razor.cs | 79 +++++++++++-------- MP-TAB-SERV/MP-TAB-SERV.csproj | 2 +- MP-TAB-SERV/Pages/MachineDetail.razor.cs | 2 +- MP-TAB-SERV/Resources/ChangeLog.html | 2 +- MP-TAB-SERV/Resources/VersNum.txt | 2 +- MP-TAB-SERV/Resources/manifest.xml | 2 +- 6 files changed, 51 insertions(+), 38 deletions(-) diff --git a/MP-TAB-SERV/Components/CheckControls.razor.cs b/MP-TAB-SERV/Components/CheckControls.razor.cs index cf2c1fda..0019ed32 100644 --- a/MP-TAB-SERV/Components/CheckControls.razor.cs +++ b/MP-TAB-SERV/Components/CheckControls.razor.cs @@ -16,15 +16,12 @@ namespace MP_TAB_SERV.Components #region Protected Properties - [Inject] - protected NavigationManager NavMan { get; set; } = null!; - /// /// Determina se dato lo stato dell'impianto si debba mostrare btn fermata perché /// - fermo > xx min (da web.config, es 20') /// - impianto fermo (controllando idxStato: priorità > 1) /// - protected bool ShowInsFermata + protected bool CheckShowInsFermata { get { @@ -55,55 +52,56 @@ namespace MP_TAB_SERV.Components /// /// Verifica necessità visualizzare il check controlli /// - protected bool ShowReqControls + protected async Task CheckShowReqControls() { - get + bool answ = false; + if (RecMSE != null) { - bool answ = false; - if (RecMSE != null) + // SE abilitata gestione controlli... + bool enableCtrl = SMServ.GetConfBool("enableControlli"); + if (enableCtrl) { - // SE abilitata gestione controlli... - bool enableCtrl = SMServ.GetConfBool("enableControlli"); - if (enableCtrl) + int intervalloControlli = SMServ.GetConfInt("intervalloControlli"); + // cerco ultimo controllo fatto + DateTime lastControl = DateTime.Now.AddYears(-1); + try { - int intervalloControlli = SMServ.GetConfInt("intervalloControlli"); - // cerco ultimo controllo fatto - DateTime lastControl = DateTime.Now.AddYears(-1); - try + var tabCtrls = await TabDServ.RegControlliLast(RecMSE.IdxMacchina); + if (tabCtrls != null && tabCtrls.Count > 0) { - var pUpd = Task.Run(async () => + var thisRec = tabCtrls.FirstOrDefault(); + if (thisRec != null) { - await Task.Delay(1); - var tabCtrls = await TabDServ.RegControlliLast(RecMSE.IdxMacchina); - if (tabCtrls != null && tabCtrls.Count > 0) + lastControl = thisRec.DataOra; + if (Math.Abs(DateTime.Now.Subtract(lastControl).TotalMinutes) >= intervalloControlli) { - var thisRec = tabCtrls.FirstOrDefault(); - if (thisRec != null) - { - lastControl = thisRec.DataOra; - if (Math.Abs(DateTime.Now.Subtract(lastControl).TotalMinutes) >= intervalloControlli) - { - answ = true; - } - } + answ = true; } - }); - pUpd.Wait(); + } } - catch - { } } + catch + { } } - return answ; } + return answ; } + [Inject] + protected NavigationManager NavMan { get; set; } = null!; + + protected bool ShowInsFermata { get; set; } = false; + + protected bool ShowReqControls { get; set; } = false; + [Inject] protected SharedMemService SMServ { get; set; } = null!; [Inject] protected TabDataService TabDServ { get; set; } = null!; + protected DateTime lastCheck = DateTime.Today; + protected string lastIdxMacc = ""; #endregion Protected Properties #region Protected Methods @@ -118,6 +116,21 @@ namespace MP_TAB_SERV.Components NavMan.NavigateTo("prod-stop"); } + protected override async Task OnParametersSetAsync() + { + if (RecMSE != null) + { + DateTime adesso = DateTime.Now; + if (adesso.Subtract(lastCheck).TotalSeconds > 15 || lastIdxMacc != RecMSE.IdxMacchina) + { + ShowInsFermata = CheckShowInsFermata; + ShowReqControls = await CheckShowReqControls(); + lastIdxMacc = RecMSE.IdxMacchina; + lastCheck = adesso; + } + } + } + #endregion Protected Methods } } \ No newline at end of file diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index a661d908..d37767e8 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2312.1416 + 6.16.2312.1417 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor.cs b/MP-TAB-SERV/Pages/MachineDetail.razor.cs index 67275899..883ccf3d 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor.cs +++ b/MP-TAB-SERV/Pages/MachineDetail.razor.cs @@ -49,7 +49,7 @@ namespace MP_TAB_SERV.Pages await RefreshMBlock(); } } - await InvokeAsync(StateHasChanged); + //await InvokeAsync(StateHasChanged); } protected async Task RefreshMBlock() diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index 16d6d30f..08b10a53 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2312.1416

+

Versione: 6.16.2312.1417


Note di rilascio: