From 1525dd1da1e6cd6ceaff75ca418ced42055c339a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 29 Oct 2025 16:19:24 +0100 Subject: [PATCH] Fix x evitare doppia chiamata iniziale --- Test.UI/Components/Pages/EditJWD.razor.cs | 105 +++++++++++------- WebWindowComplex/WebWindowComplex.csproj | 4 +- .../WebWindowConfigurator.csproj | 6 +- 3 files changed, 72 insertions(+), 43 deletions(-) diff --git a/Test.UI/Components/Pages/EditJWD.razor.cs b/Test.UI/Components/Pages/EditJWD.razor.cs index 3dd9cb9..364dac9 100644 --- a/Test.UI/Components/Pages/EditJWD.razor.cs +++ b/Test.UI/Components/Pages/EditJWD.razor.cs @@ -28,7 +28,6 @@ namespace Test.UI.Components.Pages #region Public Methods - public void Dispose() { DLService.PipeSvg.EA_NewMessage -= PipeSvg_EA_NewMessage; @@ -45,11 +44,11 @@ namespace Test.UI.Components.Pages /// protected LivePayload CurrData = new LivePayload(); - protected string prevJwd = ""; - protected string currJwd = "..."; - protected Dictionary m_CurrArgs = new Dictionary(); protected Dictionary currGroupShape = new Dictionary(); protected Dictionary currHwOption = new Dictionary(); + protected string currJwd = "..."; + protected Dictionary m_CurrArgs = new Dictionary(); + protected string prevJwd = ""; /// /// Configurazione elenchi anagrafiche @@ -123,6 +122,17 @@ namespace Test.UI.Components.Pages #region Protected Methods + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + // This only runs once the interactive circuit is established + Console.WriteLine("Now interactive!"); + // JS interop or data fetches go here + isInteractive = true; + } + } + protected override async Task OnInitializedAsync() { ConfInit(); @@ -182,8 +192,14 @@ namespace Test.UI.Components.Pages private Hardware hardwareMassUpdate; + private string hwOptionChannel = ""; private string imgBasePath = ""; + /// + /// Semaforo x definire se sia già in modalità ionterattiva o di prerendering + /// + private bool isInteractive = false; + private string materialMassUpdate; private string outClose = ""; @@ -192,10 +208,8 @@ namespace Test.UI.Components.Pages private string profileMassUpdate; - private string svgChannel = ""; private string shapeChannel = ""; - private string hwOptionChannel = ""; - + private string svgChannel = ""; private string windowUid = "CurrWindow"; #endregion Private Fields @@ -223,46 +237,36 @@ namespace Test.UI.Components.Pages hwOptionChannel = Config.GetValue("ServerConf:HwOptChannel") ?? ""; } + /// + /// Esecuzione richiesta + /// + /// + /// private async Task ExecRequest(Dictionary CurrArgs) { - outClose = ""; - outSave = ""; - // verifico se contiene JWD, lo aggiorno - if (CurrArgs.ContainsKey("Jwd")) + // Proseguo solo se sono in interattivo (NO prerender pagina) + if (isInteractive) { - currJwd = CurrArgs["Jwd"]; - CurrData.CurrJwd = currJwd; - } - // se il SSE variato --> invio - if (!currJwd.Equals(prevJwd) || !EgwCoreLib.Lux.Core.DictUtils.DictAreEqual(m_CurrArgs, CurrArgs)) - { - m_CurrArgs = CurrArgs; - prevJwd = currJwd; - CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); - calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - calcRequestDTO.DictExec = m_CurrArgs; - // chiamo la chiamata POST alla API, che manda la richiesta via REDIS - await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); - } - } - - private async void PipeShape_EA_NewMessage(object? sender, EventArgs e) - { - // aggiorno visualizzazione - PubSubEventArgs currArgs = (PubSubEventArgs)e; - // conversione on-the-fly SVG da mostrare - if (!string.IsNullOrEmpty(currArgs.newMessage) && currArgs.newMessage.Length > 2) - { - if (currArgs.msgUid.StartsWith($"{shapeChannel}:{windowUid}")) + outClose = ""; + outSave = ""; + // verifico se contiene JWD, lo aggiorno + if (CurrArgs.ContainsKey("Jwd")) { - // deserializzo il dizionario delle risposte... - var rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage); - currGroupShape = rawDict ?? new Dictionary(); - CurrData.DictShape = currGroupShape; + currJwd = CurrArgs["Jwd"]; + CurrData.CurrJwd = currJwd; + } + // se il SSE variato --> invio + if (!currJwd.Equals(prevJwd) || !EgwCoreLib.Lux.Core.DictUtils.DictAreEqual(m_CurrArgs, CurrArgs)) + { + m_CurrArgs = CurrArgs; + prevJwd = currJwd; + CalcRequestDTO calcRequestDTO = new CalcRequestDTO(); + calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + calcRequestDTO.DictExec = m_CurrArgs; + // chiamo la chiamata POST alla API, che manda la richiesta via REDIS + await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{CalcUid}", calcRequestDTO); } - await InvokeAsync(StateHasChanged); } - await Task.Delay(1); } private async void PipeHwOption_EA_NewMessage(object? sender, EventArgs e) @@ -306,6 +310,25 @@ namespace Test.UI.Components.Pages await Task.Delay(1); } + private async void PipeShape_EA_NewMessage(object? sender, EventArgs e) + { + // aggiorno visualizzazione + PubSubEventArgs currArgs = (PubSubEventArgs)e; + // conversione on-the-fly SVG da mostrare + if (!string.IsNullOrEmpty(currArgs.newMessage) && currArgs.newMessage.Length > 2) + { + if (currArgs.msgUid.StartsWith($"{shapeChannel}:{windowUid}")) + { + // deserializzo il dizionario delle risposte... + var rawDict = JsonConvert.DeserializeObject>(currArgs.newMessage); + currGroupShape = rawDict ?? new Dictionary(); + CurrData.DictShape = currGroupShape; + } + await InvokeAsync(StateHasChanged); + } + await Task.Delay(1); + } + private async void PipeSvg_EA_NewMessage(object? sender, EventArgs e) { // aggiorno visualizzazione diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 08a8c58..e1e04cf 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.2914 + 2.7.10.2916 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -180,6 +180,8 @@ + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 162964d..3568d74 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 2.7.10.2914 + 2.7.10.2916 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -251,6 +251,10 @@ + + + +