From 3f8f97c29e4dcec8dae39289f6e2efd088eee0ee Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 29 Oct 2025 12:38:46 +0100 Subject: [PATCH] update x dizionario optionsXML --- Test.UI/Components/Pages/EditJWD.razor.cs | 34 +++++++++++++--- WebWindowComplex/DTO/LivePayload.cs | 6 +-- WebWindowComplex/TableComp.razor.cs | 40 +++++++++++++------ WebWindowComplex/WebWindowComplex.csproj | 14 ++++++- .../WebWindowConfigurator.csproj | 15 ++++++- 5 files changed, 85 insertions(+), 24 deletions(-) diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 0e14743..3dd9cb9 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -49,7 +49,7 @@ namespace Test.UI.Components.Pages protected string currJwd = "..."; protected Dictionary m_CurrArgs = new Dictionary(); protected Dictionary currGroupShape = new Dictionary(); - protected string currHwOption = ""; + protected Dictionary currHwOption = new Dictionary(); /// /// Configurazione elenchi anagrafiche @@ -147,7 +147,7 @@ namespace Test.UI.Components.Pages CurrJwd = InitialJwd, SvgPreview = currSvg, DictShape = currGroupShape, - OptionsXml = currHwOption + DictOptionsXml = currHwOption }; DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; DLService.PipeShape.EA_NewMessage += PipeShape_EA_NewMessage; @@ -274,10 +274,32 @@ namespace Test.UI.Components.Pages { if (currArgs.msgUid.StartsWith($"{hwOptionChannel}:{windowUid}")) { - // deserializzo il dizionario delle risposte... - //var rawAns = JsonConvert.DeserializeObject(currArgs.newMessage); - currHwOption = currArgs.newMessage; - CurrData.OptionsXml = currHwOption; + /*-------------------------------------- + * FixMe Todo levare !!! + * - try/catch deserializzazione + * - se fallisse metto le stesse opzioni a ttuti i GroupId + **--------------------------------------*/ + Dictionary rawDict = new Dictionary(); + try + { + // deserializzo il dizionario delle risposte... + rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage) ?? new Dictionary(); + } + catch + { } + if (rawDict.Count == 0) + { + //se il dizionario delle shape esiste uso quello... + if (CurrData.DictShape.Count > 0) + { + foreach (var item in CurrData.DictShape) + { + rawDict.Add(item.Key, currArgs.newMessage); + } + } + } + currHwOption = rawDict ?? new Dictionary(); + CurrData.DictOptionsXml = currHwOption; } await InvokeAsync(StateHasChanged); } diff --git a/WebWindowComplex/DTO/LivePayload.cs b/WebWindowComplex/DTO/LivePayload.cs index a941711..2a35b0f 100644 --- a/WebWindowComplex/DTO/LivePayload.cs +++ b/WebWindowComplex/DTO/LivePayload.cs @@ -30,9 +30,9 @@ namespace WebWindowComplex.DTO public Dictionary DictShape { get; set; } = new Dictionary(); /// - /// XML opzioni HW da verifica JWD + /// Dizionario XML opzioni HW da verifica JWD x GroupId /// - public string OptionsXml { get; set; } = string.Empty; + public Dictionary DictOptionsXml { get; set; } = new Dictionary(); #endregion Public Properties @@ -52,7 +52,7 @@ namespace WebWindowComplex.DTO return false; if (SvgPreview != item.SvgPreview) return false; - if (OptionsXml != item.OptionsXml) + if (!DictUtils.DictAreEqual(DictOptionsXml, item.DictOptionsXml)) return false; if (!DictUtils.DictAreEqual(DictShape, item.DictShape)) return false; diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index bb0f976..d36fb35 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -477,8 +477,9 @@ namespace WebWindowComplex /// /// Richiesta calcolo Options HW da JWD /// + /// Lista degli ID numerici dei gruppi da valutare /// - protected async Task DoReqOptHardware() + protected async Task DoReqOptHardware(List groupIdList) { if (m_CurrWindow != null) { @@ -495,6 +496,8 @@ namespace WebWindowComplex Args.Add("Mode", $"{(int)Enums.QuestionModes.HARDWARE}"); Args.Add("SubMode", $"{(int)Enums.QuestionHwSubModes.HARDWAREOPTIONS}"); Args.Add("Jwd", CurrJwd); + string listGroupId = JsonConvert.SerializeObject(groupIdList); + Args.Add("GroupId", listGroupId); await EC_DoUpdate.InvokeAsync(Args); } } @@ -599,7 +602,7 @@ namespace WebWindowComplex prevLiveData = new LivePayload() { CurrJwd = LiveData.CurrJwd, - OptionsXml = LiveData.OptionsXml, + DictOptionsXml = LiveData.DictOptionsXml, DictShape = LiveData.DictShape, SvgPreview = LiveData.SvgPreview }; @@ -695,15 +698,19 @@ namespace WebWindowComplex if (updRequested) { // se mancasse xml opzioni hardware lo chiedo - if (string.IsNullOrEmpty(LiveData.OptionsXml)) + if (LiveData.DictOptionsXml.Count == 0) { - foreach(var item in SashList) + List reqList = SashList.Select(x => x.GroupId).ToList(); + //foreach (var item in SashList) + //{ + // string req = item.SelHardware.Id; + // if (string.IsNullOrEmpty(req)) + // { + // } + //} + if (reqList.Count > 0) { - string req = item.SelHardware.Id; - if (string.IsNullOrEmpty(req)) - { - await DoReqOptHardware(); - } + await DoReqOptHardware(reqList); } } // se mancasse dizionario forme chiamo quello @@ -770,10 +777,15 @@ namespace WebWindowComplex } } // se ho le opzioni hw le aggiungo - if (!string.IsNullOrEmpty(LiveData.OptionsXml)) + if (LiveData.DictOptionsXml.Count > 0) { foreach (var item in SashList) - item.SetHardwareOption(LiveData.OptionsXml); + { + if (LiveData.DictOptionsXml.ContainsKey(item.GroupId)) + { + item.SetHardwareOption(LiveData.DictOptionsXml[item.GroupId]); + } + } } } @@ -1318,10 +1330,12 @@ namespace WebWindowComplex /// nuova sash /// private async Task UpdateHwOptions(Sash newSash) - { + { // richiesta calcolo opzioni hardware per la singola sash group string req = newSash.SelHardware.Id; - await DoReqOptHardware(); + List reqList = new List() { newSash.GroupId }; + // chiamo con gruppo della nuova sash + await DoReqOptHardware(reqList); } /// diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 92e4482..9ad9288 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.2815 + 2.7.10.2912 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -153,6 +153,18 @@ + + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 74ab599..10be022 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.2815 + 2.7.10.2912 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -223,6 +223,19 @@ + + + + + + + + + + + + +