From 3f839c17f11a9bb7dd3f9ce4d16ffa6d2451be66 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 24 Mar 2026 07:25:55 +0100 Subject: [PATCH] Completo move CalcRuidService --- .../Services/General/CalcRuidService.cs | 2 +- .../Services/General/ICalcRuidService.cs | 2 +- .../Services/StatsCollectService.cs | 3 +- Lux.API/Controllers/ProdController.cs | 1 + .../Compo/Config/HardwareMan.razor.cs | 123 ++++---- .../Compo/Config/ProfileMan.razor.cs | 278 +++++++++--------- .../Components/Compo/OfferCommonPar.razor.cs | 1 + .../Compo/Stats/HistoricalStats.razor.cs | 80 ++--- .../Compo/Stats/RealTimeStats.razor.cs | 88 +++--- .../Compo/Stats/RealTimeStatsOld.razor | 1 + Lux.UI/Components/Pages/Offers.razor.cs | 1 + Lux.UI/Components/Pages/Orders.razor.cs | 1 + .../Components/Pages/WorkLoadBalance.razor.cs | 1 + 13 files changed, 297 insertions(+), 285 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Services/General/CalcRuidService.cs b/EgwCoreLib.Lux.Data/Services/General/CalcRuidService.cs index d107783b..61467697 100644 --- a/EgwCoreLib.Lux.Data/Services/General/CalcRuidService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/CalcRuidService.cs @@ -8,7 +8,7 @@ using StackExchange.Redis; using static Egw.Window.Data.Enums; using static EgwCoreLib.Lux.Core.Enums; -namespace EgwCoreLib.Lux.Data.Services +namespace EgwCoreLib.Lux.Data.Services.General { /// /// Gestione servizio indice richieste diff --git a/EgwCoreLib.Lux.Data/Services/General/ICalcRuidService.cs b/EgwCoreLib.Lux.Data/Services/General/ICalcRuidService.cs index e58f5bf9..151c47c6 100644 --- a/EgwCoreLib.Lux.Data/Services/General/ICalcRuidService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/ICalcRuidService.cs @@ -3,7 +3,7 @@ using EgwCoreLib.Lux.Data.DbModel.Stats; using StackExchange.Redis; using static EgwCoreLib.Lux.Core.Enums; -namespace EgwCoreLib.Lux.Data.Services +namespace EgwCoreLib.Lux.Data.Services.General { /// /// Interfaccia servizio indice richieste diff --git a/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs b/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs index eb451839..cba4d2a0 100644 --- a/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs +++ b/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs @@ -1,4 +1,5 @@ -using Microsoft.Extensions.Configuration; +using EgwCoreLib.Lux.Data.Services.General; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; diff --git a/Lux.API/Controllers/ProdController.cs b/Lux.API/Controllers/ProdController.cs index 68a6d12a..c22a5713 100644 --- a/Lux.API/Controllers/ProdController.cs +++ b/Lux.API/Controllers/ProdController.cs @@ -1,4 +1,5 @@ using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using EgwMultiEngineManager.Data; using Lux.API.Services; using Microsoft.AspNetCore.Mvc; diff --git a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs index 9872b6a1..286b03c7 100644 --- a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs @@ -1,11 +1,10 @@ using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data.DbModel.Config; -using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using EgwMultiEngineManager.Data; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; -using System.Threading.Tasks; namespace Lux.UI.Components.Compo.Config { @@ -23,53 +22,8 @@ namespace Lux.UI.Components.Compo.Config #endregion Public Methods - #region Protected Properties - - [Inject] - protected ConfigDataService CDService { get; set; } = null!; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected ICalcRuidService CRService { get; set; } = null!; - - [Inject] - protected CalcRequestService CService { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - protected string SearchVal - { - get => searchVal; - set - { - if (searchVal != value) - { - searchVal = value; - ReloadData(); - UpdateTable(); - } - } - } - - #endregion Protected Properties - #region Protected Methods - /// - /// Richiesta update elenco HW preferiti/configurati - /// - protected async Task DoReqUpdate() - { - // chiamata richiesta update da calc - await callRefreshHwList(confHw); - } - protected override void OnInitialized() { apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; @@ -84,23 +38,6 @@ namespace Lux.UI.Components.Compo.Config UpdateTable(); } - protected void ResetSearch() - { - SearchVal = ""; - } - - protected void SaveNumRec(int newNum) - { - numRecord = newNum; - UpdateTable(); - } - - protected void SavePage(int newNum) - { - currPage = newNum; - UpdateTable(); - } - #endregion Protected Methods #region Private Fields @@ -139,8 +76,40 @@ namespace Lux.UI.Components.Compo.Config get => string.IsNullOrEmpty(searchVal) ? "btn-outline-light" : "btn-primary"; } + [Inject] + private ConfigDataService CDService { get; set; } = null!; + + [Inject] + private IConfiguration Config { get; set; } = null!; + + [Inject] + private ICalcRuidService CRService { get; set; } = null!; + + [Inject] + private CalcRequestService CService { get; set; } = null!; + + [Inject] + private DataLayerServices DLService { get; set; } = null!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + private string searchVal { get; set; } = string.Empty; + private string SearchVal + { + get => searchVal; + set + { + if (searchVal != value) + { + searchVal = value; + ReloadData(); + UpdateTable(); + } + } + } + #endregion Private Properties #region Private Methods @@ -178,6 +147,15 @@ namespace Lux.UI.Components.Compo.Config await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req); } + /// + /// Richiesta update elenco HW preferiti/configurati + /// + private Task DoReqUpdate() + { + // chiamata richiesta update da calc + return callRefreshHwList(confHw); + } + /// /// Ricevuto update da Calc x elenco HW: aggiorno! /// @@ -213,6 +191,23 @@ namespace Lux.UI.Components.Compo.Config totalCount = AllRecords.Count; } + private void ResetSearch() + { + SearchVal = ""; + } + + private void SaveNumRec(int newNum) + { + numRecord = newNum; + UpdateTable(); + } + + private void SavePage(int newNum) + { + currPage = newNum; + UpdateTable(); + } + /// /// Filtro e paginazione /// diff --git a/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs b/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs index 77b50094..f910790c 100644 --- a/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs @@ -2,6 +2,7 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.Services; using EgwCoreLib.Lux.Data.Services.Config; +using EgwCoreLib.Lux.Data.Services.General; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; @@ -21,119 +22,8 @@ namespace Lux.UI.Components.Compo.Config #endregion Public Methods - #region Protected Properties - - [Inject] - protected ConfigDataService CDService { get; set; } = null!; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected ICalcRuidService CRService { get; set; } = null!; - - [Inject] - protected CalcRequestService CService { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected IConfProfileService CPService { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - protected string SearchVal - { - get => searchVal; - set - { - if (searchVal != value) - { - searchVal = value; - _ = FullUpdate(); - } - } - } - - #endregion Protected Properties - #region Protected Methods - protected void DoCloseDetail(bool args) - { - DetReq = ""; - currDispl = null; - } - - /// - /// Eliminazione record - /// - /// - protected async Task DoDelete(ProfileModel selRec) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.Code} | {selRec.Description}")) - return; - - isLoading = true; - await InvokeAsync(StateHasChanged); - // esegue eliminazione del record... - await CPService.DeleteAsync(selRec); - - // segnalo update x reload - await ReloadData(); - UpdateTable(); - } - - /// - /// Edit record selezionato - /// - /// - protected void DoEdit(ProfileModel curRec) - { - EditRecord = curRec; - } - /// - /// Salvataggio record - /// - /// - protected async Task DoSave(ProfileModel curRec) - { - await CPService.UpsertAsync(curRec); - EditRecord = null; - await ReloadData(); - UpdateTable(); - } - - /// - /// Richiesta update elenco HW preferiti/configurati - /// - protected Task DoReqUpdate() - { - // chiamata richiesta update da calc - return callRefreshProfList(); - } - - /// - /// Update soglie da elenco profili - /// - /// - - protected Task DoReqUpdateThresh() - { - // chiamata richiesta update da calc - return callRefreshProfThresh(); - } - - /// - /// Reset selezione - /// - protected void DoReset() - { - EditRecord = null; - } - protected override void OnInitialized() { apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; @@ -148,35 +38,6 @@ namespace Lux.UI.Components.Compo.Config UpdateTable(); } - protected void ResetSearch() - { - SearchVal = ""; - } - - protected void SaveNumRec(int newNum) - { - numRecord = newNum; - UpdateTable(); - } - - protected void SavePage(int newNum) - { - currPage = newNum; - UpdateTable(); - } - - protected void ShowData(ProfileModel currRec) - { - DetReq = "Data"; - currDispl = currRec; - } - - protected void ShowThresh(ProfileModel currRec) - { - DetReq = "Threshold"; - currDispl = currRec; - } - #endregion Protected Methods #region Private Fields @@ -223,13 +84,47 @@ namespace Lux.UI.Components.Compo.Config get => string.IsNullOrEmpty(searchVal) ? "btn-outline-light" : "btn-primary"; } + [Inject] + private ConfigDataService CDService { get; set; } = null!; + + [Inject] + private IConfiguration Config { get; set; } = null!; + + [Inject] + private IConfProfileService CPService { get; set; } = null!; + + [Inject] + private ICalcRuidService CRService { get; set; } = null!; + + [Inject] + private CalcRequestService CService { get; set; } = null!; + private string cssBtnThresh { get => ListRecords != null && ListRecords.Count > 0 ? "btn-info" : "btn-secondary disabled"; } + [Inject] + private DataLayerServices DLService { get; set; } = null!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + private string searchVal { get; set; } = string.Empty; + private string SearchVal + { + get => searchVal; + set + { + if (searchVal != value) + { + searchVal = value; + _ = FullUpdate(); + } + } + } + #endregion Private Properties #region Private Methods @@ -310,6 +205,79 @@ namespace Lux.UI.Components.Compo.Config return answ; } + private void DoCloseDetail(bool args) + { + DetReq = ""; + currDispl = null; + } + + /// + /// Eliminazione record + /// + /// + private async Task DoDelete(ProfileModel selRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler eliminare il record? Dettagli: {selRec.Code} | {selRec.Description}")) + return; + + isLoading = true; + await InvokeAsync(StateHasChanged); + // esegue eliminazione del record... + await CPService.DeleteAsync(selRec); + + // segnalo update x reload + await ReloadData(); + UpdateTable(); + } + + /// + /// Edit record selezionato + /// + /// + private void DoEdit(ProfileModel curRec) + { + EditRecord = curRec; + } + + /// + /// Richiesta update elenco HW preferiti/configurati + /// + private Task DoReqUpdate() + { + // chiamata richiesta update da calc + return callRefreshProfList(); + } + + private Task DoReqUpdateThresh() + { + // chiamata richiesta update da calc + return callRefreshProfThresh(); + } + + /// + /// Update soglie da elenco profili + /// + /// + /// + /// Reset selezione + /// + private void DoReset() + { + EditRecord = null; + } + + /// + /// Salvataggio record + /// + /// + private async Task DoSave(ProfileModel curRec) + { + await CPService.UpsertAsync(curRec); + EditRecord = null; + await ReloadData(); + UpdateTable(); + } + private async Task FullUpdate() { await ReloadData(); @@ -327,7 +295,6 @@ namespace Lux.UI.Components.Compo.Config await InvokeAsync(StateHasChanged); } - private async Task ReloadData() { isLoading = true; @@ -350,6 +317,35 @@ namespace Lux.UI.Components.Compo.Config isLoading = false; } + private void ResetSearch() + { + SearchVal = ""; + } + + private void SaveNumRec(int newNum) + { + numRecord = newNum; + UpdateTable(); + } + + private void SavePage(int newNum) + { + currPage = newNum; + UpdateTable(); + } + + private void ShowData(ProfileModel currRec) + { + DetReq = "Data"; + currDispl = currRec; + } + + private void ShowThresh(ProfileModel currRec) + { + DetReq = "Threshold"; + currDispl = currRec; + } + /// /// Filtro e paginazione /// diff --git a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs index 3ce84e00..26641a27 100644 --- a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs +++ b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs @@ -3,6 +3,7 @@ using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using EgwCoreLib.Lux.Data.Services.Config; +using EgwCoreLib.Lux.Data.Services.General; using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; diff --git a/Lux.UI/Components/Compo/Stats/HistoricalStats.razor.cs b/Lux.UI/Components/Compo/Stats/HistoricalStats.razor.cs index 5ff0393d..5c53b179 100644 --- a/Lux.UI/Components/Compo/Stats/HistoricalStats.razor.cs +++ b/Lux.UI/Components/Compo/Stats/HistoricalStats.razor.cs @@ -1,50 +1,12 @@ using EgwCoreLib.Lux.Data.DbModel.Stats; -using Microsoft.JSInterop; -using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; namespace Lux.UI.Components.Compo.Stats { public partial class HistoricalStats { - #region Protected Properties - - protected string btnReload => needReload ? "btn-primary" : "btn-secondary"; - - [Inject] - protected ICalcRuidService Calc { get; set; } = null!; - - protected DateTime dtFrom - { - get => periodoSel.Inizio; - set - { - if (periodoSel.Inizio != value) - { - periodoSel.Inizio = value; - needReload = true; - } - } - } - - protected DateTime dtTo - { - get => periodoSel.Fine; - set - { - if (periodoSel.Fine != value) - { - periodoSel.Fine = value; - needReload = true; - } - } - } - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - #endregion Protected Properties - #region Protected Methods protected override async Task OnInitializedAsync() @@ -81,6 +43,44 @@ namespace Lux.UI.Components.Compo.Stats #endregion Private Fields + #region Private Properties + + private string btnReload => needReload ? "btn-primary" : "btn-secondary"; + + [Inject] + private ICalcRuidService Calc { get; set; } = null!; + + private DateTime dtFrom + { + get => periodoSel.Inizio; + set + { + if (periodoSel.Inizio != value) + { + periodoSel.Inizio = value; + needReload = true; + } + } + } + + private DateTime dtTo + { + get => periodoSel.Fine; + set + { + if (periodoSel.Fine != value) + { + periodoSel.Fine = value; + needReload = true; + } + } + } + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + #endregion Private Properties + #region Private Methods /// diff --git a/Lux.UI/Components/Compo/Stats/RealTimeStats.razor.cs b/Lux.UI/Components/Compo/Stats/RealTimeStats.razor.cs index f718131f..6bce8939 100644 --- a/Lux.UI/Components/Compo/Stats/RealTimeStats.razor.cs +++ b/Lux.UI/Components/Compo/Stats/RealTimeStats.razor.cs @@ -1,6 +1,6 @@ using EgwCoreLib.Lux.Core; using EgwCoreLib.Lux.Core.Stats; -using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; @@ -18,42 +18,6 @@ namespace Lux.UI.Components.Compo.Stats #endregion Public Methods - #region Protected Properties - - [Inject] - protected ICalcRuidService Calc { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - protected int NumDays - { - get => numDay; - set - { - if (numDay != value) - { - numDay = value > 1 ? value : 1; - _ = ReloadStatsRT(); - } - } - } - - protected int RefPeriod - { - get => refrPeriod; - set - { - if (refrPeriod != value) - { - refrPeriod = value > 1 ? value : 1; - _ = ReloadStatsRT(); - } - } - } - - #endregion Protected Properties - #region Protected Methods protected override async Task OnAfterRenderAsync(bool firstRender) @@ -75,23 +39,73 @@ namespace Lux.UI.Components.Compo.Stats #region Private Fields private CancellationTokenSource? _cts; + private Dictionary BorderColors = new Dictionary(); + private Dictionary DataseElapsed = new Dictionary(); + private Dictionary DatasetCount = new Dictionary(); + private Dictionary> DSBarCount = new Dictionary>(); + private Dictionary> DSBarElapsed = new Dictionary>(); + private Dictionary FillColors = new Dictionary(); + private DateTime lastUpdate = DateTime.Now; + private List ListX = new List(); + private int numDay = 3; + private int refrPeriod = 5; + private List rtProcStats = new List(); + private Enums.RuidGroupMode SelGroup = Enums.RuidGroupMode.Hour; + private Enums.RuidTagMode SelMode = Enums.RuidTagMode.Envir; + private StatsRealtimeDto? stats; #endregion Private Fields + #region Private Properties + + [Inject] + private ICalcRuidService Calc { get; set; } = null!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + private int NumDays + { + get => numDay; + set + { + if (numDay != value) + { + numDay = value > 1 ? value : 1; + _ = ReloadStatsRT(); + } + } + } + + private int RefPeriod + { + get => refrPeriod; + set + { + if (refrPeriod != value) + { + refrPeriod = value > 1 ? value : 1; + _ = ReloadStatsRT(); + } + } + } + + #endregion Private Properties + #region Private Methods private async Task OnGroupChanged(Enums.RuidGroupMode value) diff --git a/Lux.UI/Components/Compo/Stats/RealTimeStatsOld.razor b/Lux.UI/Components/Compo/Stats/RealTimeStatsOld.razor index 100e7eaf..40c50b13 100644 --- a/Lux.UI/Components/Compo/Stats/RealTimeStatsOld.razor +++ b/Lux.UI/Components/Compo/Stats/RealTimeStatsOld.razor @@ -1,5 +1,6 @@ @using EgwCoreLib.Lux.Core.Stats @using EgwCoreLib.Lux.Data.Services +@using EgwCoreLib.Lux.Data.Services.General @inject CalcRuidService Calc @inject IJSRuntime JSRuntime @implements IDisposable diff --git a/Lux.UI/Components/Pages/Offers.razor.cs b/Lux.UI/Components/Pages/Offers.razor.cs index a7f9d035..8f9f5daf 100644 --- a/Lux.UI/Components/Pages/Offers.razor.cs +++ b/Lux.UI/Components/Pages/Offers.razor.cs @@ -5,6 +5,7 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using EgwCoreLib.Lux.Data.Services.Config; +using EgwCoreLib.Lux.Data.Services.General; using EgwCoreLib.Lux.Data.Services.Production; using EgwCoreLib.Lux.Data.Services.Sales; using Microsoft.AspNetCore.Components; diff --git a/Lux.UI/Components/Pages/Orders.razor.cs b/Lux.UI/Components/Pages/Orders.razor.cs index 3e1c4ff7..fe7e7398 100644 --- a/Lux.UI/Components/Pages/Orders.razor.cs +++ b/Lux.UI/Components/Pages/Orders.razor.cs @@ -5,6 +5,7 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using EgwCoreLib.Lux.Data.Services.Config; +using EgwCoreLib.Lux.Data.Services.General; using EgwCoreLib.Lux.Data.Services.Production; using EgwCoreLib.Lux.Data.Services.Sales; using Microsoft.AspNetCore.Components; diff --git a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs index ca6e2be1..b0cceed6 100644 --- a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs +++ b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs @@ -4,6 +4,7 @@ using EgwCoreLib.Lux.Data.DbModel.Production; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.General; using EgwCoreLib.Lux.Data.Services.Production; using EgwCoreLib.Lux.Data.Services.Sales; using EgwCoreLib.Lux.Data.Services.Utils;