Aggiunta gestione currMode x plantParameters x forzare parametri

This commit is contained in:
Samuele Locatelli
2026-03-12 16:55:18 +01:00
parent 76f6151f75
commit 1dfd0c60d1
7 changed files with 200 additions and 214 deletions
+1 -11
View File
@@ -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
/// <summary>
/// Esecuzione cleanup + recupero allarmi
/// </summary>
/// </summary><
/// <param name="PlantId"></param>
/// <param name="skipRec"></param>
/// <param name="numRec"></param>
+1 -1
View File
@@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Version>1.2.2603.0409</Version>
<Version>1.2.2603.1216</Version>
<UserSecretsId>95c9f021-52d1-4390-a670-5810b7b777b0</UserSecretsId>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<RunAnalyzersDuringBuild>true</RunAnalyzersDuringBuild>
+1 -1
View File
@@ -74,7 +74,7 @@
{
<tr class="@checkSelect(@record.uid)">
<td class="text-nowrap">
@if (record.writable)
@if (record.writable || editAll)
{
if (currRecord == null)
{
+194 -198
View File
@@ -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<objItem> ListRecords;
private List<PlantDetailModel> PlantsList;
#endregion Private Fields
#region Protected Fields
/// <summary>
/// Valore PlantId filtrato da claim
/// </summary>
protected int ClaimPlantId = -1;
private int ClaimPlantId = -1;
#endregion Protected Fields
private objItem currRecord = null;
private bool editAll = false;
private List<objItem> ListRecords;
private List<PlantDetailModel> 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();
}
/// <summary>
/// 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<bool>("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
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>GWMS - Gas Warehouse Management System</i>
<h4>Versione: 1.2.2603.0409</h4>
<h4>Versione: 1.2.2603.1216</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.2.2603.0409
1.2.2603.1216
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.2.2603.0409</version>
<version>1.2.2603.1216</version>
<url>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/GWMS.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GWMS/stable/0/ChangeLog.html</changelog>
<mandatory>false</mandatory>