From a70ed095e933ceb89ffb28a86c63080153e107cd Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 6 Nov 2025 17:26:48 +0100 Subject: [PATCH] Update gestione save e ricalcolo BOM x BEAM --- Lux.API/Lux.API.csproj | 2 +- Lux.API/appsettings.json | 3 +- Lux.UI/Components/Compo/EditBom.razor | 19 +- Lux.UI/Components/Compo/EditBom.razor.cs | 35 +++ .../Compo/FileMan/BtlPreview.razor.cs | 95 ++++---- Lux.UI/Components/Compo/OfferRowMan.razor | 4 +- Lux.UI/Components/Compo/OfferRowMan.razor.cs | 214 +++++++++++++----- Lux.UI/Lux.UI.csproj | 2 +- Lux.UI/appsettings.json | 3 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 12 files changed, 269 insertions(+), 114 deletions(-) diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index d53af18e..daa7f078 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2511.0610 + 0.9.2511.0616 diff --git a/Lux.API/appsettings.json b/Lux.API/appsettings.json index daf94e32..a15138a6 100644 --- a/Lux.API/appsettings.json +++ b/Lux.API/appsettings.json @@ -80,6 +80,7 @@ "ImageBaseUrl": "https://iis01.egalware.com/lux/srv/api/window/", "ImageCalcTag": "svg-preview", "ImageLiveTag": "svg", - "ImageFileTag": "svgfile" + "ImageFileTag": "svgfile", + "FileSharePath": "\\\\stor01\\TEAM DRIVES\\40_FileUpload\\LuxUploads" } } diff --git a/Lux.UI/Components/Compo/EditBom.razor b/Lux.UI/Components/Compo/EditBom.razor index 7ee0f337..dc0c1fff 100644 --- a/Lux.UI/Components/Compo/EditBom.razor +++ b/Lux.UI/Components/Compo/EditBom.razor @@ -7,6 +7,10 @@ Class Descrizione @* Cod *@ + @if (ShowVolume) + { + Vol + } Qty UnitPrice Importo @@ -31,6 +35,10 @@ + @if (ShowVolume) + { + @($"{item.Value.Volume:N3}") + } @($"{item.Value.Qty:N3}") @($"{item.Value.PriceEff:C2}") @($"{item.Value.TotalCost:C2}") @@ -49,6 +57,10 @@ @item.Value.ClassCode @item.Value.ItemCode @* @item.Value.DescriptionCode *@ + @if (ShowVolume) + { + @($"{item.Value.Volume:N3}") + } @($"{item.Value.Qty:N3}") @($"{item.Value.PriceEff:C2}") @($"{item.Value.TotalCost:C2}") @@ -58,7 +70,12 @@ - @BomList.Count record + @BomList.Count materiali + @if (ShowVolume) + { + @($"{VolTotale:N3}") + } + @($"{QtyTotale:N3}") tot: @($"{ImportoTotale:C2}") diff --git a/Lux.UI/Components/Compo/EditBom.razor.cs b/Lux.UI/Components/Compo/EditBom.razor.cs index d85213bc..401d0acb 100644 --- a/Lux.UI/Components/Compo/EditBom.razor.cs +++ b/Lux.UI/Components/Compo/EditBom.razor.cs @@ -1,5 +1,6 @@ using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data.DbModel.Items; +using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using EgwMultiEngineManager.Data; using Microsoft.AspNetCore.Components; @@ -14,6 +15,9 @@ namespace Lux.UI.Components.Compo [Parameter] public List BomList { get; set; } = null!; + [Parameter] + public OfferRowModel CurrRowRec { get; set; } = null!; + [Parameter] public EventCallback> EC_Updated { get; set; } @@ -37,9 +41,40 @@ namespace Lux.UI.Components.Compo } } + protected double QtyTotale + { + get + { + double valTot = 0; + if (bomDict != null) + { + valTot = bomDict.Sum(x => x.Value.Qty); + } + return valTot; + } + } + + protected double VolTotale + { + get + { + double valTot = 0; + if (bomDict != null) + { + valTot = bomDict.Sum(x => x.Value.Volume); + } + return valTot; + } + } + #endregion Protected Properties + private bool ShowVolume + { + get => CurrRowRec.Envir == Constants.EXECENVIRONMENTS.BEAM || CurrRowRec.Envir == Constants.EXECENVIRONMENTS.WALL; + } + #region Protected Methods protected void DoCancel() diff --git a/Lux.UI/Components/Compo/FileMan/BtlPreview.razor.cs b/Lux.UI/Components/Compo/FileMan/BtlPreview.razor.cs index 73372ffb..b8b3d4b2 100644 --- a/Lux.UI/Components/Compo/FileMan/BtlPreview.razor.cs +++ b/Lux.UI/Components/Compo/FileMan/BtlPreview.razor.cs @@ -20,7 +20,7 @@ namespace Lux.UI.Components.Compo.FileMan public OfferRowModel CurrItem { get; set; } [Parameter] - public EventCallback> EC_DoUpdate { get; set; } + public EventCallback> EC_ReqSave { get; set; } [Parameter] public EventCallback EC_OnClose { get; set; } @@ -84,57 +84,68 @@ namespace Lux.UI.Components.Compo.FileMan using var reader = new StreamReader(stream); string rawContent = await reader.ReadToEndAsync(); - // calcolo il nome del file trusted... - string trustedFileName = Path.GetRandomFileName(); - CurrItem.FileResource = trustedFileName; - CurrItem.FileName = file.Name; - CurrItem.FileSize = rawContent.LongCount(); - // aggiungo contenuto come SerStruct (in attesa di valutare FS save...) - CurrItem.SerStruct = rawContent; - // salvo sul DB i dati (nome, nome sicuro, size...) - await DLService.OffertRowUpdateFileData(CurrItem); - - // parametri richiesta - fileArgs.Add("FileName", $"{file.Name}"); - fileArgs.Add("SerializedData", rawContent); - fileArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}"); - fileArgs.Add("SubMode", "2"); - fileArgs.Add("Height", "1200"); - fileArgs.Add("Width", "1800"); - // invio! - CalcRequestDTO calcRequestDTO = new CalcRequestDTO() + // se ho contenuto nel file... + if (!string.IsNullOrEmpty(rawContent)) { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM, - DictExec = fileArgs - }; - // richiesta PNG - await ICService.CallRestPost($"{ApiUrl}/{GenericBasePath}", $"{CalcTag}/{CurrItem.OfferRowUID}", calcRequestDTO); - - - // aggiungo info x BOM - bomArgs.Add("FileName", $"{file.Name}"); - bomArgs.Add("SerializedData", rawContent); - bomArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.BOM}"); - // ...infine chiedo anche la BOM! - calcRequestDTO = new CalcRequestDTO() - { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM, - DictExec = bomArgs - }; - // richiesta BOM - await ICService.CallRestPost($"{ApiUrl}/{GenericBasePath}", $"{CalcTag}/{CurrItem.OfferRowUID}", calcRequestDTO); + // elimino vecchio file... richiedendo save senza parametri + Dictionary dictSave = new Dictionary(); + await EC_ReqSave.InvokeAsync(dictSave); + // calcolo il nome del file trusted... + string trustedFileName = Path.GetRandomFileName(); + CurrItem.FileResource = trustedFileName; + CurrItem.FileName = file.Name; + CurrItem.FileSize = rawContent.LongCount(); #if false - // salvo in locale il file: SISTEMARE PERMESSI - saveFileContent(EditFileRecord.OfferRowUID, trustedFileName, rawContent); + // aggiungo contenuto come SerStruct (in attesa di valutare FS save...) + CurrItem.SerStruct = rawContent; #endif + // salvo sul DB i dati (nome, nome sicuro, size...) + await DLService.OffertRowUpdateFileData(CurrItem); + + // parametri richiesta + fileArgs.Add("FileName", $"{file.Name}"); + fileArgs.Add("SerializedData", rawContent); + fileArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}"); + fileArgs.Add("SubMode", "2"); + fileArgs.Add("Height", "1200"); + fileArgs.Add("Width", "1800"); + // invio! + CalcRequestDTO calcRequestDTO = new CalcRequestDTO() + { + EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM, + DictExec = fileArgs + }; + // richiesta PNG + await ICService.CallRestPost($"{ApiUrl}/{GenericBasePath}", $"{CalcTag}/{CurrItem.OfferRowUID}", calcRequestDTO); + + + // aggiungo info x BOM + bomArgs.Add("FileName", $"{file.Name}"); + bomArgs.Add("SerializedData", rawContent); + bomArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.BOM}"); + // ...infine chiedo anche la BOM! + calcRequestDTO = new CalcRequestDTO() + { + EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM, + DictExec = bomArgs + }; + // richiesta BOM + await ICService.CallRestPost($"{ApiUrl}/{GenericBasePath}", $"{CalcTag}/{CurrItem.OfferRowUID}", calcRequestDTO); + + dictSave.Add("secureName", trustedFileName); + dictSave.Add("content", rawContent); + await EC_ReqSave.InvokeAsync(dictSave); + + } } #endregion Private Methods private void CloseEdit(Microsoft.AspNetCore.Components.Web.MouseEventArgs args) { - _ = EC_OnClose.InvokeAsync(true); + // false --> NON salvo serializzato eprché ho già salvato l file x cui NON ricalcola la BOM + _ = EC_OnClose.InvokeAsync(false); } } } \ No newline at end of file diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor b/Lux.UI/Components/Compo/OfferRowMan.razor index 241269ac..e6a7d040 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor +++ b/Lux.UI/Components/Compo/OfferRowMan.razor @@ -15,7 +15,7 @@ CalcTag="@calcTag" GenericBasePath="@genericBasePath" ImgBasePath="@imgBasePath" - EC_DoUpdate="SaveFile" + EC_ReqSave="SaveFile" EC_OnClose="CloseEdit"> } @@ -321,7 +321,7 @@ else diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index fa533653..f11b2ee7 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Components.Forms; using Microsoft.IdentityModel.Tokens; using Microsoft.JSInterop; using Newtonsoft.Json; +using NLog; using WebWindowComplex; using WebWindowComplex.DTO; using static EgwCoreLib.Lux.Core.Enums; @@ -314,7 +315,6 @@ namespace Lux.UI.Components.Compo CurrEditMode = EditMode.RecData; } - /// /// Edit del file: /// - abilitazione fileUpload @@ -330,7 +330,7 @@ namespace Lux.UI.Components.Compo // preparazione dati da record corrente PrepareWindowData(EditRecord.SerStruct); // reset prev - prevJwd = ""; + prevJwd = ""; #endif } @@ -589,6 +589,7 @@ namespace Lux.UI.Components.Compo #region Private Fields + private static Logger Log = LogManager.GetCurrentClassLogger(); private List AllColors = new(); private List AllConfEnvir = new(); @@ -615,6 +616,11 @@ namespace Lux.UI.Components.Compo private List AvailProfileList = new List(); + /// + /// Base path x network share files + /// + private string basePath = "unsafe_uploads"; + private string calcTag = "calc"; private List? CurrBomList = null; @@ -630,10 +636,10 @@ namespace Lux.UI.Components.Compo private int currPage = 1; + private string currPng = ""; private List currProfList = new List(); private string currSvg = ""; - private string currPng = ""; /// /// Record in Edit corrente @@ -755,6 +761,7 @@ namespace Lux.UI.Components.Compo private void ConfInit() { + basePath = Config.GetValue("ServerConf:FileSharePath") ?? "unsafe_uploads"; apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; imgBasePath = Config.GetValue("ServerConf:ImageBaseUrl") ?? ""; genericBasePath = Config.GetValue("ServerConf:GenericBaseUrl") ?? ""; @@ -837,10 +844,10 @@ namespace Lux.UI.Components.Compo if (currArgs.msgUid.Equals($"{pngChannel}:{EditRecord.OfferRowUID}")) { currPng = currArgs.newMessage; - // non devo passarlo al componente di gestione finestre... + // non devo passarlo al componente... #if false // salvo in live data... - CurrData.SvgPreview = currSvg; + CurrData.SvgPreview = currSvg; #endif } await InvokeAsync(StateHasChanged); @@ -1064,6 +1071,27 @@ namespace Lux.UI.Components.Compo } } + /// + /// Eliminazione file (old) + /// + /// Nome secure da impiegare + /// Contenuto file + private bool removeOldFile(string folderPath, string secureName) + { + bool answ = false; + if (!string.IsNullOrEmpty(folderPath)) + { + // calcolo path file... + string filePath = Path.Combine(basePath, folderPath, secureName); + // se esiste... + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + } + return answ; + } + /// /// Effettua vera richiesta della BOM /// @@ -1085,10 +1113,25 @@ namespace Lux.UI.Components.Compo DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.BOM}"); // UID cablato x ora... DictExec.Add("UID", currRec.OfferRowUID); - DictExec.Add(serKey, currRec.SerStruct); - - // aggiungo comunque filename... - DictExec.Add("FileName", $"{currRec.FileName}"); + // aggiungo file secondo ambiente... + switch (currRec.Envir) + { + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW: + DictExec.Add(serKey, currRec.SerStruct); + break; + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM: + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WALL: + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.CABINET: + // rileggo da file... + string folderPath = $"SO-{currRec.OfferID:X8}"; + string rawData = loadFileContent(folderPath, currRec.FileResource); + DictExec.Add(serKey, rawData); + DictExec.Add("FileName", currRec.FileName); + break; + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.NULL: + default: + break; + } CalcRequestDTO req = new CalcRequestDTO() { @@ -1102,9 +1145,47 @@ namespace Lux.UI.Components.Compo await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{currRec.OfferRowUID}", req); } + /// + /// Salvataggio dei dati del file caricato + /// + /// Dizionario info file + private void SaveFile(Dictionary fileDict) + { + // verifico di essere in edit... + if (EditRecord != null) + { + string folderPath = $"SO-{EditRecord.OfferID:X8}"; + // verifico di avere parametri... + if (fileDict != null && fileDict.Count > 0) + { + string secureName = ""; + string content = ""; + if (fileDict.ContainsKey("secureName")) + { + secureName = fileDict["secureName"]; + } + if (fileDict.ContainsKey("content")) + { + content = fileDict["content"]; + } + if (!string.IsNullOrEmpty(folderPath) && !string.IsNullOrEmpty(secureName) && !string.IsNullOrEmpty(content)) + { + // salvo! + saveFileContent(folderPath, secureName, content); + } + } + // altrimenti signifca cleanup eventuale vecchio file... + else + { + removeOldFile(folderPath, EditRecord.FileResource); + } + } + } + /// /// Esegue salvataggio del file ricevuto /// + /// Path relativo x file (tipicamente UID parent order) /// Nome secure da impiegare /// Contenuto file private bool saveFileContent(string folderPath, string secureName, string content) @@ -1113,43 +1194,50 @@ namespace Lux.UI.Components.Compo if (!string.IsNullOrEmpty(folderPath)) { // calcolo path file... - string filePath = Path.Combine("unsafe_uploads", folderPath, secureName); - File.WriteAllText(filePath, content); + string filePath = Path.Combine(basePath, folderPath, secureName); + string? directoryPath = Path.GetDirectoryName(filePath); + try + { + if (!string.IsNullOrEmpty(directoryPath)) + { + Directory.CreateDirectory(directoryPath); + } + File.WriteAllText(filePath, content); + } + catch (Exception exc) + { + Log.Error($"Exception on save{Environment.NewLine}{exc}"); + } } return answ; } - /// - /// Salvataggio dei dati del file caricato + /// Restituisce il contenuto del file salvato /// - /// Dizionario info file - private void SaveFile(Dictionary fileDict) + /// + /// + /// + private string loadFileContent(string folderPath, string secureName) { - // verifico di avere parametri... - if (fileDict != null && fileDict.Count > 0) + string answ = ""; + if (!string.IsNullOrEmpty(folderPath)) { - string folderPath = ""; - string secureName = ""; - string content = ""; - if (fileDict.ContainsKey("folderPath")) + try { - folderPath = fileDict["folderPath"]; + // calcolo path file... + string filePath = Path.Combine(basePath, folderPath, secureName); + if (File.Exists(filePath)) + { + answ = File.ReadAllText(filePath); + } } - if (fileDict.ContainsKey("secureName")) + catch (Exception exc) { - secureName = fileDict["secureName"]; - } - if (fileDict.ContainsKey("content")) - { - content = fileDict["content"]; - } - if (!string.IsNullOrEmpty(folderPath) && !string.IsNullOrEmpty(secureName) && !string.IsNullOrEmpty(content)) - { - // salvo! - saveFileContent(folderPath, secureName, content); + Log.Error($"Exception on loadFileContent{Environment.NewLine}{exc}"); } } + return answ; } /// @@ -1200,6 +1288,37 @@ namespace Lux.UI.Components.Compo } } + /// + /// Verifia ammissibilità display btn ricalcolo BOM da item + /// + /// + /// + private bool ShowBom(OfferRowModel reqItem) + { + bool answ = false; + if (DisplayMode == Enums.DisplayMode.Edit) + { + switch (reqItem.Envir) + { + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW: + answ = !string.IsNullOrEmpty(reqItem.SerStruct) && reqItem.SerStruct.Length > 2; + break; + + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM: + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WALL: + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.CABINET: + // da cambiare con ricerca file su disco?!? + answ = !string.IsNullOrEmpty(reqItem.FileResource) && !string.IsNullOrEmpty(reqItem.FileName); + break; + + case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.NULL: + default: + break; + } + } + return answ; + } + /// /// Elenco SalesOfferRows calcolabili: /// - contengono serializzazione come JWD @@ -1239,35 +1358,6 @@ namespace Lux.UI.Components.Compo } } - /// - /// Verifia ammissibilità display btn ricalcolo BOM da item - /// - /// - /// - private bool ShowBom(OfferRowModel reqItem) - { - bool answ = false; - if (DisplayMode == Enums.DisplayMode.Edit) - { - switch (reqItem.Envir) - { - case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW: - answ = string.IsNullOrEmpty(reqItem.SerStruct) && reqItem.SerStruct.Length > 2; - break; - case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM: - case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WALL: - case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.CABINET: - // da cambiare con ricerca file su disco?!? - answ = string.IsNullOrEmpty(reqItem.SerStruct) && reqItem.SerStruct.Length > 2; - break; - case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.NULL: - default: - break; - } - } - return answ; - } - /// /// Filtro e paginazione /// diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index fa1db90a..9e8b5631 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 0.9.2511.0610 + 0.9.2511.0616 diff --git a/Lux.UI/appsettings.json b/Lux.UI/appsettings.json index efd933d7..9007ba16 100644 --- a/Lux.UI/appsettings.json +++ b/Lux.UI/appsettings.json @@ -87,6 +87,7 @@ "ImageCalcTag": "live", "ImageFileTag": "cache", "ImageLiveTag": "svg", - "BaseUrl": "/lux/ui/" + "BaseUrl": "/lux/ui/", + "FileSharePath": "\\\\stor01\\TEAM DRIVES\\40_FileUpload\\LuxUploads" } } diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 9d10e8ab..6610edb0 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 0.9.2511.0610

+

Versione: 0.9.2511.0616


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 5026efda..95367acd 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2511.0610 +0.9.2511.0616 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index b97b7928..7dfa66cf 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2511.0610 + 0.9.2511.0616 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false