From 1dfd0c60d18d60c57cc8f4db710bac4f2cd54410 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 12 Mar 2026 16:55:18 +0100 Subject: [PATCH] Aggiunta gestione currMode x plantParameters x forzare parametri --- GWMS.UI/Data/GWMSDataService.cs | 12 +- GWMS.UI/GWMS.UI.csproj | 2 +- GWMS.UI/Pages/PlantParameters.razor | 2 +- GWMS.UI/Pages/PlantParameters.razor.cs | 392 ++++++++++++------------- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 7 files changed, 200 insertions(+), 214 deletions(-) diff --git a/GWMS.UI/Data/GWMSDataService.cs b/GWMS.UI/Data/GWMSDataService.cs index 64b25be..c7b6dbc 100644 --- a/GWMS.UI/Data/GWMSDataService.cs +++ b/GWMS.UI/Data/GWMSDataService.cs @@ -1,32 +1,22 @@ using GWMS.Data; using GWMS.Data.DatabaseModels; using GWMS.Data.DTO; -using IdentityModel.OidcClient; -using k8s.Models; using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.UI.Services; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Caching.Distributed; -using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using NLog; -using OpenTelemetry.Resources; -using Org.BouncyCastle.Asn1.IsisMtt.Ocsp; -using Org.BouncyCastle.Asn1.Pkcs; using StackExchange.Redis; using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; -using System.Numerics; using System.Text; using System.Threading.Tasks; using static GWMS.Data.IobObjects; -using static Humanizer.In; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database; namespace GWMS.UI.Data { @@ -219,7 +209,7 @@ namespace GWMS.UI.Data /// /// Esecuzione cleanup + recupero allarmi - /// + /// < /// /// /// diff --git a/GWMS.UI/GWMS.UI.csproj b/GWMS.UI/GWMS.UI.csproj index 5de92ac..656eb16 100644 --- a/GWMS.UI/GWMS.UI.csproj +++ b/GWMS.UI/GWMS.UI.csproj @@ -2,7 +2,7 @@ net6.0 - 1.2.2603.0409 + 1.2.2603.1216 95c9f021-52d1-4390-a670-5810b7b777b0 true true diff --git a/GWMS.UI/Pages/PlantParameters.razor b/GWMS.UI/Pages/PlantParameters.razor index 5cfa93a..897dc69 100644 --- a/GWMS.UI/Pages/PlantParameters.razor +++ b/GWMS.UI/Pages/PlantParameters.razor @@ -74,7 +74,7 @@ { - @if (record.writable) + @if (record.writable || editAll) { if (currRecord == null) { diff --git a/GWMS.UI/Pages/PlantParameters.razor.cs b/GWMS.UI/Pages/PlantParameters.razor.cs index bb230ee..534878a 100644 --- a/GWMS.UI/Pages/PlantParameters.razor.cs +++ b/GWMS.UI/Pages/PlantParameters.razor.cs @@ -1,5 +1,4 @@ using GWMS.Data.DatabaseModels; -using GWMS.Data.DTO; using GWMS.UI.Data; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components; @@ -18,30 +17,168 @@ namespace GWMS.UI.Pages [Authorize(Roles = "SuperAdmin, Admin, User")] public partial class PlantParameters : ComponentBase, IDisposable { + #region Public Methods + + public void Dispose() + { + aTimer.Stop(); + aTimer.Dispose(); + AppMService.EA_SearchUpdated -= OnSeachUpdated; + } + + public async void OnSeachUpdated() + { + await UpdateData(); + StateHasChanged(); + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + protected int totalCount + { + get + { + int answ = 0; + if (ListRecords != null) + { + answ = ListRecords.Count; + } + return answ; + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected void ElapsedTimer(Object source, System.Timers.ElapsedEventArgs e) + { + var pUpd = Task.Run(async () => + { + await ReloadData(); + await InvokeAsync(StateHasChanged); + }); + pUpd.Wait(); + } + + protected override void OnInitialized() + { + var currMode = GetQueryParm("currMode"); + if (!string.IsNullOrWhiteSpace(currMode)) + { + editAll = currMode.Equals("debug"); + } + } + + protected override async Task OnInitializedAsync() + { + AppMService.ShowSearch = false; + AppMService.PageName = "Parametri Impianto"; + AppMService.PageIcon = "fas fa-folder-open pr-2"; + AppMService.EA_SearchUpdated += OnSeachUpdated; + StartTimer(); + await ReloadAllData(); + } + + protected void StartTimer() + { + int tOutPeriod = 3000; + int.TryParse(Configuration["ReloadParamTimer"], out tOutPeriod); + aTimer = new System.Timers.Timer(tOutPeriod); + aTimer.Elapsed += ElapsedTimer; + aTimer.Enabled = true; + aTimer.Start(); + } + + #endregion Protected Methods + #region Private Fields private static System.Timers.Timer aTimer; + private static NLog.Logger Log = LogManager.GetCurrentClassLogger(); - private objItem currRecord = null; - private List ListRecords; - private List PlantsList; - - #endregion Private Fields - - #region Protected Fields /// /// Valore PlantId filtrato da claim /// - protected int ClaimPlantId = -1; + private int ClaimPlantId = -1; - #endregion Protected Fields + private objItem currRecord = null; + + private bool editAll = false; + + private List ListRecords; + + private List PlantsList; + + #endregion Private Fields #region Private Properties + [Inject] + private MessageService AppMService { get; set; } + + [Inject] + private AuthenticationStateProvider AuthenticationStateProvider { get; set; } + [Inject] private IConfiguration Configuration { get; set; } + [Inject] + private GWMSDataService DataService { get; set; } + + private DateTime DateEnd + { + get + { + DateTime answ = DateTime.Today.AddDays(1); + if (AppMService.Order_Filter != null) + { + answ = AppMService.Order_Filter.DateEnd; + } + return answ; + } + set + { + if (!AppMService.Order_Filter.DateEnd.Equals(value)) + { + AppMService.Order_Filter.DateEnd = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + private DateTime DateStart + { + get + { + DateTime answ = DateTime.Today.AddDays(-1); + if (AppMService.Order_Filter != null) + { + answ = AppMService.Order_Filter.DateStart; + } + return answ; + } + set + { + if (!AppMService.Order_Filter.DateStart.Equals(value)) + { + AppMService.Order_Filter.DateStart = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + private bool isLoading { get; set; } = false; private string SelPlantCode @@ -85,98 +222,33 @@ namespace GWMS.UI.Pages #endregion Private Properties - #region Protected Properties - - [Inject] - protected MessageService AppMService { get; set; } - - [Inject] - protected AuthenticationStateProvider AuthenticationStateProvider { get; set; } - - [Inject] - protected GWMSDataService DataService { get; set; } - - protected DateTime DateEnd - { - get - { - DateTime answ = DateTime.Today.AddDays(1); - if (AppMService.Order_Filter != null) - { - answ = AppMService.Order_Filter.DateEnd; - } - return answ; - } - set - { - if (!AppMService.Order_Filter.DateEnd.Equals(value)) - { - AppMService.Order_Filter.DateEnd = value; - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); - } - } - } - - protected DateTime DateStart - { - get - { - DateTime answ = DateTime.Today.AddDays(-1); - if (AppMService.Order_Filter != null) - { - answ = AppMService.Order_Filter.DateStart; - } - return answ; - } - set - { - if (!AppMService.Order_Filter.DateStart.Equals(value)) - { - AppMService.Order_Filter.DateStart = value; - var pUpd = Task.Run(async () => await ReloadData()); - pUpd.Wait(); - } - } - } - - protected bool editAll - { - get - { - bool answ = false; - var currMode = GetQueryParm("currMode"); - if (!string.IsNullOrEmpty(currMode)) - { - answ = currMode.Equals("debug"); - } - return answ; - } - } - - [Inject] - protected IJSRuntime JSRuntime { get; set; } - - [Inject] - protected NavigationManager NavManager { get; set; } - - protected int totalCount - { - get - { - int answ = 0; - if (ListRecords != null) - { - answ = ListRecords.Count; - } - return answ; - } - } - - #endregion Protected Properties - #region Private Methods + private string checkSelect(string uid) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.uid == uid) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + private void Edit(objItem selRecord) + { + currRecord = selRecord; + } + + private async Task ForceReload() + { + await ReloadData(); + } + /// /// Recupero Claims dell'utente... /// @@ -201,54 +273,15 @@ namespace GWMS.UI.Pages } } - private async Task ReloadData() - { - isLoading = true; - ListRecords = null; - try - { - ListRecords = await DataService.getCurrObjItems(SelPlantCode); - } - catch (Exception exc) - { - Log.Error($"Eccezione in ReloadData:{Environment.NewLine}{exc}"); - } - isLoading = false; - } - - #endregion Private Methods - - #region Protected Methods - - protected void Edit(objItem selRecord) - { - currRecord = selRecord; - } - - protected async Task ForceReload() - { - await ReloadData(); - } - // Blazor: get query parm from the URL - protected string GetQueryParm(string parmName) + private string GetQueryParm(string parmName) { var uriBuilder = new UriBuilder(NavManager.Uri); var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query); return q[parmName] ?? ""; } - protected override async Task OnInitializedAsync() - { - AppMService.ShowSearch = false; - AppMService.PageName = "Parametri Impianto"; - AppMService.PageIcon = "fas fa-folder-open pr-2"; - AppMService.EA_SearchUpdated += OnSeachUpdated; - StartTimer(); - await ReloadAllData(); - } - - protected async Task ReloadAllData() + private async Task ReloadAllData() { isLoading = true; PlantsList = null; @@ -272,7 +305,22 @@ namespace GWMS.UI.Pages await ReloadData(); } - protected async Task RemoveItem(objItem selRecord) + private async Task ReloadData() + { + isLoading = true; + ListRecords = null; + try + { + ListRecords = await DataService.getCurrObjItems(SelPlantCode); + } + catch (Exception exc) + { + Log.Error($"Eccezione in ReloadData:{Environment.NewLine}{exc}"); + } + isLoading = false; + } + + private async Task RemoveItem(objItem selRecord) { if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler rimuovere il parametro {selRecord.uid} ({selRecord.name})?")) return; @@ -284,77 +332,25 @@ namespace GWMS.UI.Pages await ReloadAllData(); } - protected void ResetData() + private void ResetData() { DataService.rollBackEdit(currRecord); currRecord = null; } - protected void Select(objItem selRecord) + private void Select(objItem selRecord) { // applico filtro da selezione currRecord = selRecord; } - protected async Task UpdateData() + private async Task UpdateData() { currRecord = null; await DataService.PlantsAnalisysResetAsync(AppMService.Order_Filter); await ReloadData(); } - #endregion Protected Methods - - #region Public Methods - - public string checkSelect(string uid) - { - string answ = ""; - if (currRecord != null) - { - try - { - answ = (currRecord.uid == uid) ? "table-info" : ""; - } - catch - { } - } - return answ; - } - - public void Dispose() - { - aTimer.Stop(); - aTimer.Dispose(); - AppMService.EA_SearchUpdated -= OnSeachUpdated; - } - - public void ElapsedTimer(Object source, System.Timers.ElapsedEventArgs e) - { - var pUpd = Task.Run(async () => - { - await ReloadData(); - await InvokeAsync(StateHasChanged); - }); - pUpd.Wait(); - } - - public async void OnSeachUpdated() - { - await UpdateData(); - StateHasChanged(); - } - - public void StartTimer() - { - int tOutPeriod = 3000; - int.TryParse(Configuration["ReloadParamTimer"], out tOutPeriod); - aTimer = new System.Timers.Timer(tOutPeriod); - aTimer.Elapsed += ElapsedTimer; - aTimer.Enabled = true; - aTimer.Start(); - } - - #endregion Public Methods + #endregion Private Methods } } \ No newline at end of file diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 6cfc8f2..2f10f09 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ GWMS - Gas Warehouse Management System -

Versione: 1.2.2603.0409

+

Versione: 1.2.2603.1216


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 62030f0..193fa0d 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.2.2603.0409 +1.2.2603.1216 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 1c378c5..8aac760 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.2.2603.0409 + 1.2.2603.1216 http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html false