From 12d1090540559359a57407722af12aabf4f7355d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 24 Mar 2026 10:31:19 +0100 Subject: [PATCH] Completo le modifiche del config data service in async x ottimizzare chaimate --- EgwCoreLib.Lux.Data/Services/BaseServ.cs | 2 +- .../Services/DataLayerServices.cs | 4 +-- .../Services/General/CalcRequestService.cs | 2 +- .../Services/General/ConfigDataService.cs | 27 ++++++++++--------- .../Services/General/IConfigDataService.cs | 8 +++--- Lux.API/Controllers/WindowController.cs | 2 +- Lux.API/Services/ExternalMessageProcessor.cs | 10 +++---- .../Compo/Config/HardwareMan.razor.cs | 10 +++---- .../Components/Compo/OfferCommonPar.razor.cs | 4 +-- Lux.UI/Components/Compo/OfferRowMan.razor.cs | 6 ++--- Lux.UI/Components/Compo/OrderRowMan.razor.cs | 6 ++--- .../Compo/Templates/TemplateRowList.razor.cs | 8 +++--- 12 files changed, 45 insertions(+), 44 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Services/BaseServ.cs b/EgwCoreLib.Lux.Data/Services/BaseServ.cs index f63800c3..7f3f27e6 100644 --- a/EgwCoreLib.Lux.Data/Services/BaseServ.cs +++ b/EgwCoreLib.Lux.Data/Services/BaseServ.cs @@ -124,7 +124,7 @@ namespace EgwCoreLib.Lux.Data.Services public MessagePipe PipeProfElement { get; set; } = null!; /// - /// Pipe dei messaggi per ritorno ProfileList calcolate da Engine di calcolo verso interfaccia utente. + /// Pipe dei messaggi per ritorno ProfileListAsync calcolate da Engine di calcolo verso interfaccia utente. /// I messaggi vengono inviati sul canale Redis definito da ChannelProfList. /// public MessagePipe PipeProfList { get; set; } = null!; diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index d00f2fbb..85d4f314 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -204,11 +204,11 @@ namespace EgwCoreLib.Lux.Data.Services } /// - /// MockUp (fake) salvataggio ProfileList sul DB + /// MockUp (fake) salvataggio ProfileListAsync sul DB /// /// UID ricezione (default tipicamente) /// Environment dell'item - /// ProfileList serializzata + /// ProfileListAsync serializzata /// public async Task SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent) { diff --git a/EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs b/EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs index 54415f83..73bff8bb 100644 --- a/EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/CalcRequestService.cs @@ -20,7 +20,7 @@ namespace EgwCoreLib.Lux.Data.Services.General Timeout = TimeSpan.FromSeconds(60), BaseUrl = new Uri($"{apiUrl}/{routeBasePath}") }; - Log.Info("ImageCache Service Started"); + Log.Info("CalcRequest Service Started"); } #endregion Public Constructors diff --git a/EgwCoreLib.Lux.Data/Services/General/ConfigDataService.cs b/EgwCoreLib.Lux.Data/Services/General/ConfigDataService.cs index 5dd70aae..ce6ec629 100644 --- a/EgwCoreLib.Lux.Data/Services/General/ConfigDataService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/ConfigDataService.cs @@ -15,6 +15,7 @@ namespace EgwCoreLib.Lux.Data.Services.General public ConfigDataService(IConfiguration configuration, IConnectionMultiplexer RedisConn) : base(configuration, RedisConn) { // init implicito + _redisBaseKey = configuration.GetValue("ServerConf:RedisBaseKey") ?? "Lux"; Log.Info($"ConfigDataService | Init OK"); } @@ -26,12 +27,12 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Restituisce l'elenco dell'HW valido da cache REDIS /// /// - public List HwModelList(Constants.EXECENVIRONMENTS execEnvironment, string HwReq = "HW.AGB") + public async Task> HwModelListAsync(Constants.EXECENVIRONMENTS execEnvironment, string HwReq = "HW.AGB") { List result = new List(); // leggo obj da redis cache - var currKey = $"{redisBaseKey}:{execEnvironment}:HML:{HwReq}"; - RedisValue rawData = _redisDb.StringGet(currKey); + var currKey = $"{_redisBaseKey}:{execEnvironment}:HML:{HwReq}"; + RedisValue rawData = await _redisDb.StringGetAsync(currKey); // prendo solo i valori validi (Name <> FamilyName) if (rawData.HasValue) { @@ -45,12 +46,12 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Restituisce l'elenco dei profili da cache REDIS /// /// - public List ProfileList(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default") + public async Task> ProfileListAsync(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default") { List result = new List(); // leggo obj da redis cache - var currKey = $"{redisBaseKey}:{execEnvironment}:PROF:LIST:{ProfReq}"; - RedisValue rawData = _redisDb.StringGet(currKey); + var currKey = $"{_redisBaseKey}:{execEnvironment}:PROF:LIST:{ProfReq}"; + RedisValue rawData = await _redisDb.StringGetAsync(currKey); // prendo solo i valori validi (Name <> FamilyName) if (rawData.HasValue) { @@ -64,12 +65,12 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Restituisce l'elenco dei profili da cache REDIS /// /// - public List ProfileThreshList(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default") + public async Task> ProfileThreshListAsync(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default") { List result = new List(); // leggo obj da redis cache - var currKey = $"{redisBaseKey}:{execEnvironment}:PROF:THRESH:{ProfReq}"; - RedisValue rawData = _redisDb.StringGet(currKey); + var currKey = $"{_redisBaseKey}:{execEnvironment}:PROF:THRESH:{ProfReq}"; + RedisValue rawData = await _redisDb.StringGetAsync(currKey); // prendo solo i valori validi (Name <> FamilyName) if (rawData.HasValue) { @@ -83,15 +84,15 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Restituisce il dizionario dei profili + relativa lista soglie da cache REDIS /// /// - public Dictionary> ProfileThreshDict(Constants.EXECENVIRONMENTS execEnvironment) + public async Task>> ProfileThreshDictAsync(Constants.EXECENVIRONMENTS execEnvironment) { Dictionary> result = new Dictionary>(); // recupero profili per ciclare... - List profList = ProfileList(execEnvironment); + List profList = await ProfileListAsync(execEnvironment); foreach (var prof in profList) { // leggo obj da redis cache - var currKey = $"{redisBaseKey}:{execEnvironment}:PROF:THRESH:{prof}"; + var currKey = $"{_redisBaseKey}:{execEnvironment}:PROF:THRESH:{prof}"; RedisValue rawData = _redisDb.StringGet(currKey); // prendo solo i valori validi (Name <> FamilyName) if (rawData.HasValue) @@ -112,7 +113,7 @@ namespace EgwCoreLib.Lux.Data.Services.General #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); - private string redisBaseKey = "Lux"; + private string _redisBaseKey = "Lux"; #endregion Private Fields } diff --git a/EgwCoreLib.Lux.Data/Services/General/IConfigDataService.cs b/EgwCoreLib.Lux.Data/Services/General/IConfigDataService.cs index d9fdde9f..2c4cd68c 100644 --- a/EgwCoreLib.Lux.Data/Services/General/IConfigDataService.cs +++ b/EgwCoreLib.Lux.Data/Services/General/IConfigDataService.cs @@ -17,7 +17,7 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Environment di esecuzione /// Richiesta hardware (default: HW.AGB) /// Elenco di modelli hardware - List HwModelList(Constants.EXECENVIRONMENTS execEnvironment, string HwReq = "HW.AGB"); + Task> HwModelListAsync(Constants.EXECENVIRONMENTS execEnvironment, string HwReq = "HW.AGB"); /// /// Restituisce l'elenco dei profili da cache REDIS @@ -25,7 +25,7 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Environment di esecuzione /// Richiesta profilo (default: Default) /// Elenco di nomi profili - List ProfileList(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default"); + Task> ProfileListAsync(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default"); /// /// Restituisce l'elenco delle soglie dei profili da cache REDIS @@ -33,14 +33,14 @@ namespace EgwCoreLib.Lux.Data.Services.General /// Environment di esecuzione /// Richiesta profilo (default: Default) /// Elenco di nomi profili con soglie - List ProfileThreshList(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default"); + Task> ProfileThreshListAsync(Constants.EXECENVIRONMENTS execEnvironment, string ProfReq = "Default"); /// /// Restituisce il dizionario dei profili + relativa lista soglie da cache REDIS /// /// Environment di esecuzione /// Dizionario profili -> liste di soglie - Dictionary> ProfileThreshDict(Constants.EXECENVIRONMENTS execEnvironment); + Task>> ProfileThreshDictAsync(Constants.EXECENVIRONMENTS execEnvironment); #endregion Public Methods } diff --git a/Lux.API/Controllers/WindowController.cs b/Lux.API/Controllers/WindowController.cs index 3526c32b..0e79471e 100644 --- a/Lux.API/Controllers/WindowController.cs +++ b/Lux.API/Controllers/WindowController.cs @@ -119,7 +119,7 @@ namespace Lux.API.Controllers Stopwatch sw = new Stopwatch(); sw.Start(); string hwReq = id ?? "HW.AGB"; - var answ = _confService.HwModelList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, hwReq); + var answ = await _confService.HwModelListAsync(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, hwReq); if (answ == null || answ.Count == 0) { await sendHwReq(); diff --git a/Lux.API/Services/ExternalMessageProcessor.cs b/Lux.API/Services/ExternalMessageProcessor.cs index 19e15db8..17f84071 100644 --- a/Lux.API/Services/ExternalMessageProcessor.cs +++ b/Lux.API/Services/ExternalMessageProcessor.cs @@ -246,11 +246,11 @@ namespace Lux.API.Services } // gestione ritorno lista profili VALIDI per JWD - if (retData.Args.ContainsKey("ProfileList")) + if (retData.Args.ContainsKey("ProfileListAsync")) { // recupero UID e elenco profili validi - string profList = retData.Args["ProfileList"]; - // salvo ProfileList ricevuta + string profList = retData.Args["ProfileListAsync"]; + // salvo ProfileListAsync ricevuta await cacheService.SaveProfileListAsync(UID, retData.ExecEnvironment, profList); await dbService.SaveProfileListAsync(UID, retData.ExecEnvironment, profList); saved = true; @@ -261,7 +261,7 @@ namespace Lux.API.Services { // recupero UID e elenco profili validi string areaProfList = retData.Args["AreaProfiles"]; - // salvo ProfileList ricevuta + // salvo ProfileListAsync ricevuta await cacheService.SaveProfileElemAsync(UID, retData.ExecEnvironment, areaProfList); saved = true; } @@ -274,7 +274,7 @@ namespace Lux.API.Services // recuperro anche i profile data string profData = retData.Args["ProfileData"]; - // salvo ProfileList ricevuta + // salvo ProfileListAsync ricevuta await cacheService.SaveProfileThreshAsync(UID, retData.ExecEnvironment, threshList, profData); await dbService.SaveProfileThreshAsync(UID, retData.ExecEnvironment, threshList, profData); saved = true; diff --git a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs index 99c652b8..4b21f0a8 100644 --- a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs @@ -34,7 +34,7 @@ namespace Lux.UI.Components.Compo.Config protected override void OnParametersSet() { - ReloadData(); + _ = ReloadData(); UpdateTable(); } @@ -104,7 +104,7 @@ namespace Lux.UI.Components.Compo.Config if (searchVal != value) { searchVal = value; - ReloadData(); + _ = ReloadData(); UpdateTable(); } } @@ -163,15 +163,15 @@ namespace Lux.UI.Components.Compo.Config /// private void PipeHwList_EA_NewMessage(object? sender, EventArgs e) { - ReloadData(); + _ = ReloadData(); UpdateTable(); _ = InvokeAsync(StateHasChanged); } - private void ReloadData() + private async Task ReloadData() { isLoading = true; - AllRecords = CDService.HwModelList(cEnvir, confHw); + AllRecords = await CDService.HwModelListAsync(cEnvir, confHw); // se ho ricerca testuale faccio filtro ulteriore... if (string.IsNullOrEmpty(SearchVal)) { diff --git a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs index ff6b66c7..992e5217 100644 --- a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs +++ b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs @@ -41,14 +41,14 @@ namespace Lux.UI.Components.Compo // leggo dati di base var AllColors = await GVService.GetFiltAsync("WoodCol"); var AllConfGlass = await CGService.GetAllAsync(); - var AllConfProfile = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); + var AllConfProfile = await CDService.ProfileListAsync(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); // se fosse vuoto chiamo update... if (AllConfProfile == null || AllConfProfile.Count == 0) { await callRefreshProfList(); // aspetto 200ms... e richiedo! await Task.Delay(200); - AllConfProfile = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); + AllConfProfile = await CDService.ProfileListAsync(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); } var AllConfWood = await CWService.GetAllAsync(); // conversione tipi diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index 32063070..3310961a 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -1494,18 +1494,18 @@ namespace Lux.UI.Components.Compo AvailProfileList = await CPService.GetAllAsync(); // FixMe Todo: eliminare da REDIS e usare elenco DB solamente... - var rawProfiles = CDService.ProfileList(cEnvir, "Default"); + var rawProfiles = await CDService.ProfileListAsync(cEnvir, "Default"); // se fosse vuoto chiamo update... if (rawProfiles == null || rawProfiles.Count == 0) { await callRefreshProfList(); // aspetto 200ms... e richiedo! await Task.Delay(200); - rawProfiles = CDService.ProfileList(cEnvir, "Default"); + rawProfiles = await CDService.ProfileListAsync(cEnvir, "Default"); } AvailProfileListOld = rawProfiles; - var rawHw = CDService.HwModelList(cEnvir, "HW.AGB"); + var rawHw = await CDService.HwModelListAsync(cEnvir, "HW.AGB"); // hw filtro solo validi... AllConfHardware = rawHw .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) diff --git a/Lux.UI/Components/Compo/OrderRowMan.razor.cs b/Lux.UI/Components/Compo/OrderRowMan.razor.cs index 6910fdc6..450e7625 100644 --- a/Lux.UI/Components/Compo/OrderRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OrderRowMan.razor.cs @@ -1406,18 +1406,18 @@ namespace Lux.UI.Components.Compo AllProdPlant = await PPService.GetAllAsync(); // FixMe ToDo rimuovere vers redis obsolete - var rawProfiles = CDService.ProfileList(cEnvir, "Default"); + var rawProfiles = await CDService.ProfileListAsync(cEnvir, "Default"); // se fosse vuoto chiamo update... if (rawProfiles == null || rawProfiles.Count == 0) { await callRefreshProfList(); // aspetto 200ms... e richiedo! await Task.Delay(200); - rawProfiles = CDService.ProfileList(cEnvir, "Default"); + rawProfiles = await CDService.ProfileListAsync(cEnvir, "Default"); } AvailProfileListOld = rawProfiles; - var rawHw = CDService.HwModelList(cEnvir, "HW.AGB"); + var rawHw = await CDService.HwModelListAsync(cEnvir, "HW.AGB"); // hw filtro solo validi... AllConfHardware = rawHw .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) diff --git a/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs b/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs index a53d8ca9..f4737da0 100644 --- a/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs +++ b/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs @@ -909,7 +909,7 @@ namespace Lux.UI.Components.Compo.Templates { // aggiorno visualizzazione PubSubEventArgs currArgs = (PubSubEventArgs)e; - // conversione on-the-fly ProfileList + // conversione on-the-fly ProfileListAsync if (!string.IsNullOrEmpty(currArgs.newMessage)) { if (currArgs.msgUid.Equals($"{chProfList}:{EditRecord.TemplateRowUID}")) @@ -1059,18 +1059,18 @@ namespace Lux.UI.Components.Compo.Templates AvailProfileList = await CPService.GetAllAsync(); // FixMe Todo: eliminare da REDIS e usare elenco DB solamente... - var rawProfiles = CDService.ProfileList(cEnvir, "Default"); + var rawProfiles = await CDService.ProfileListAsync(cEnvir, "Default"); // se fosse vuoto chiamo update... if (rawProfiles == null || rawProfiles.Count == 0) { await callRefreshProfList(); // aspetto 200ms... e richiedo! await Task.Delay(200); - rawProfiles = CDService.ProfileList(cEnvir, "Default"); + rawProfiles = await CDService.ProfileListAsync(cEnvir, "Default"); } AvailProfileListOld = rawProfiles; - var rawHw = CDService.HwModelList(cEnvir, "HW.AGB"); + var rawHw = await CDService.HwModelListAsync(cEnvir, "HW.AGB"); // hw filtro solo validi... AllConfHardware = rawHw .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase))