Refresh componente

This commit is contained in:
Samuele Locatelli
2025-10-07 16:14:15 +02:00
parent 0f93d9189d
commit 42a8d8fdc6
13 changed files with 212 additions and 83 deletions
+1
View File
@@ -89,6 +89,7 @@ namespace EgwCoreLib.Lux.Data
if (string.IsNullOrEmpty(connString))
{
#if DEBUG
//connString = "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;";
connString = "Server=mdb.ufficio;port=3306;database=Lux_000_dev;uid=lux_user;pwd=Egal_pwd!;sslmode=None;";
#else
connString = "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;";
+2 -2
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2510.0618</Version>
<Version>0.9.2510.0716</Version>
</PropertyGroup>
<ItemGroup>
@@ -65,7 +65,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Egw.Lux.WebWindow.Base" Version="2.7.10.319" />
<PackageReference Include="Egw.Lux.WebWindow.Base" Version="2.7.10.715" />
<PackageReference Include="NLog" Version="6.0.1" />
<PackageReference Include="NLog.Web.AspNetCore" Version="6.0.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
+3 -2
View File
@@ -7,7 +7,8 @@
},
"ServerConf": {
"BaseUrl": "/lux/srv/",
"PubChannel": "EgwEngineInput",
"SubChannel": "EgwEngineOutput"
"PubChannel": "EgwDevEngineInput",
"SubChannel": "EgwDevEngineOutput",
"ImageBaseUrl": "https://iis01.egalware.com/lux/srv/api/window/"
}
}
+2 -1
View File
@@ -8,6 +8,7 @@
"ServerConf": {
"BaseUrl": "/lux/srv/",
"PubChannel": "EgwEngineInput",
"SubChannel": "EgwEngineOutput"
"SubChannel": "EgwEngineOutput",
"ImageBaseUrl": "https://office.egalware.com/lux/srv/api/window/"
}
}
+2 -2
View File
@@ -56,8 +56,8 @@
},
"ServerConf": {
"CalcTag": "calc",
"PubChannel": "EgwDevEngineInput",
"SubChannel": "EgwDevEngineOutput",
"PubChannel": "EgwEngineInput",
"SubChannel": "EgwEngineOutput",
"SvgChannel": "Egw:svg:img",
"BomChannel": "Egw:bom",
"UpdateChannel": "Egw:update",
+2 -2
View File
@@ -9,8 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Egw.Lux.WebWindow.Base" Version="2.7.10.319" />
<PackageReference Include="Egw.Lux.WebWindowComplex" Version="2.7.10-beta.617" />
<PackageReference Include="Egw.Lux.WebWindow.Base" Version="2.7.10.715" />
<PackageReference Include="Egw.Lux.WebWindowComplex" Version="2.7.10.715" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.17" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="8.0.17" />
</ItemGroup>
+3 -15
View File
@@ -3,23 +3,11 @@
<h1>EDITING</h1>
<h3>@EditRecord.OfferRowUID</h3>
<WebWindowComplex.TableComp IN_ColorMaterialList="@AvailColorMaterialList"
IN_FamilyHardwareList="@AvailFamilyHardwareList"
IN_GlassList="@AvailGlassList"
IN_HardwareList="@AvailHardwareList"
IN_MaterialList="@AvailMaterialList"
<WebWindowComplex.TableComp ListPayload="SetupList"
LiveData="CurrData"
EC_OnUpdate="SaveJWD"
LiveSVG="@currSvg"
CurrJwd="@EditRecord.SerStruct">
EC_OnClose="CloseEdit">
</WebWindowComplex.TableComp>
@*
IN_TemplateDTOList="@AvailTemplateList"
IN_SelTemplate="@SelTemplate"
IN_SelFamilyHardware="@SelFamilyHardware"
IN_SelColorMaterial="@SelColorMaterial"
IN_SelMaterial="@SelMaterial"
IN_SelGlass="@SelGlass"
*@
}
else
{
+187 -49
View File
@@ -11,6 +11,8 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.EntityFrameworkCore.Storage.Json;
using Microsoft.JSInterop;
using NLog.LayoutRenderers;
using WebWindowComplex.DTO;
using static EgwCoreLib.Lux.Core.Enums;
namespace Lux.UI.Components.Compo
@@ -43,6 +45,20 @@ namespace Lux.UI.Components.Compo
#endregion Public Methods
#region Protected Fields
/// <summary>
/// Predisposizione valori live SVG/JWD
/// </summary>
protected LivePayload CurrData = new LivePayload();
/// <summary>
/// Configurazione elenchi anagrafiche
/// </summary>
protected BaseListPayload SetupList = new BaseListPayload();
#endregion Protected Fields
#region Protected Properties
[Inject]
@@ -57,15 +73,15 @@ namespace Lux.UI.Components.Compo
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
[Inject]
protected IWebHostEnvironment HostEnv { get; set; } = null!;
[Inject]
protected ImageCacheService ICService { get; set; } = null!;
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected IWebHostEnvironment HostEnv { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
@@ -78,9 +94,24 @@ namespace Lux.UI.Components.Compo
protected void DoEdit(OfferRowModel curRec)
{
// preparazione dati da record corrente
PrepareWindowData(curRec.SerStruct);
// reset prev
prevJwd = "";
// imposto edit record
EditRecord = curRec;
}
/// <summary>
/// Versione precedente JWD x test e confronto
/// </summary>
private string prevJwd = "";
/// <summary>
/// Versione originale (pre edit)
/// </summary>
private string origJwd = "";
protected void DoSwapMat(OfferRowModel currRow)
{
showChangeMat = true;
@@ -88,6 +119,16 @@ namespace Lux.UI.Components.Compo
CurrBomList = DLService.OffertGetBomList(EditBomRecord);
}
/// <summary>
/// Display fileSize scalato
/// </summary>
/// <param name="size"></param>
/// <returns></returns>
protected string fSize(long size)
{
return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1);
}
/// <summary>
/// Calcolo URL immagine
/// </summary>
@@ -108,6 +149,7 @@ namespace Lux.UI.Components.Compo
protected override async Task OnInitializedAsync()
{
ConfInit();
prevJwd = "";
await ReloadBaseList();
DLService.UpdatePipe.EA_NewMessage += UpdatePipe_EA_NewMessage;
DLService.CalcDonePipe.EA_NewMessage += CalcDonePipe_EA_NewMessage;
@@ -136,6 +178,16 @@ namespace Lux.UI.Components.Compo
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler ricalcolare la BOM?"))
return;
await reqBomUpdate(currRec);
}
/// <summary>
/// Effettua vera richiesta della BOM
/// </summary>
/// <param name="currRec"></param>
/// <returns></returns>
private async Task reqBomUpdate(OfferRowModel currRec)
{
// salvo richiesta BOM su record
currRec.AwaitBom = true;
currRec.AwaitPrice = true;
@@ -173,6 +225,7 @@ namespace Lux.UI.Components.Compo
private List<GenValueModel> AllColors = new();
private List<EnvirParamModel> AllConfEnvir = new();
private List<GlassModel> AllConfGlass = new();
private List<HardwareModel> AllConfHardware = new();
@@ -187,13 +240,13 @@ namespace Lux.UI.Components.Compo
private List<string> AvailColorMaterialList = new List<string>();
private List<string> AvailFamilyHardwareList = new List<string>();
private List<string> AvailGlassList = new List<string>();
private List<Egw.Window.Data.Hardware> AvailHardwareList = new();
private List<string> AvailMaterialList = new List<string>();
private List<string> AvailFamilyHardwareList = new List<string>();
private string calcTag = "calc";
@@ -203,9 +256,10 @@ namespace Lux.UI.Components.Compo
private string currSvg = "";
private OfferRowModel? EditFileRecord = null;
private OfferRowModel? EditBomRecord = null;
private OfferRowModel? EditFileRecord = null;
private OfferRowModel? EditRecord = null;
private string genBasePath = "generic";
@@ -248,6 +302,8 @@ namespace Lux.UI.Components.Compo
if (currArgs.msgUid.Equals($"{subChannel}:{EditRecord.OfferRowUID}"))
{
currSvg = currArgs.newMessage;
// salvo in live data...
CurrData.SvgPreview = currSvg;
}
await InvokeAsync(StateHasChanged);
}
@@ -292,6 +348,29 @@ namespace Lux.UI.Components.Compo
isLoading = false;
}
/// <summary>
/// Preparazione dati x componente edit JWD
/// </summary>
/// <param name="currJwd"></param>
private void PrepareWindowData(string currJwd)
{
// preparo conf oggetti x controllo
SetupList = SetupList = new BaseListPayload()
{
ColorMaterial = AvailColorMaterialList,
FamilyHardware = AvailFamilyHardwareList,
Glass = AvailGlassList,
Hardware = AvailHardwareList,
Material = AvailMaterialList,
TemplateDTO = null
};
CurrData = new LivePayload()
{
CurrJwd = currJwd,
SvgPreview = currSvg
};
}
/// <summary>
/// init classi configurazione
/// </summary>
@@ -343,6 +422,23 @@ namespace Lux.UI.Components.Compo
}
}
/// <summary>
/// Esegue salvataggio del file ricevuto
/// </summary>
/// <param name="secureName">Nome secure da impiegare</param>
/// <param name="content">Contenuto file</param>
private bool saveFileContent(string folderPath, string secureName, string content)
{
bool answ = false;
if (!string.IsNullOrEmpty(folderPath))
{
// calcolo path file...
string filePath = Path.Combine("unsafe_uploads", folderPath, secureName);
File.WriteAllText(filePath, content);
}
return answ;
}
/// <summary>
/// Salvataggio del JWD aggiornato nella mia riga di offerta
/// </summary>
@@ -352,16 +448,38 @@ namespace Lux.UI.Components.Compo
// ...se ho editing
if (EditRecord != null)
{
// SE contiene il mio JWD...
if (args.ContainsKey("JWD"))
// SE contiene il mio Jwd...
if (args.ContainsKey("Jwd"))
{
string serStruct = args["JWD"];
// salvo!
await DLService.OffertRowUpdateSerStruct(EditRecord.OfferRowID, serStruct);
reqDict = args;
string serStruct = reqDict["Jwd"];
// controllo SE variato...
if (!prevJwd.Equals(serStruct))
{
// aggiorno val prev
prevJwd = serStruct;
// aggiorno live data
CurrData.CurrJwd = serStruct;
// chiamo richiesta update
CalcRequestDTO calcRequestDTO = new CalcRequestDTO();
calcRequestDTO.EnvType = EditRecord.Envir;
calcRequestDTO.DictExec = reqDict;
// chiamo la chiamata POST alla API, che manda la richiesta via REDIS
await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{EditRecord.OfferRowUID}", calcRequestDTO);
#if false
// salvo su DB!
await DLService.OffertRowUpdateSerStruct(EditRecord.OfferRowID, serStruct);
#endif
}
}
}
}
/// <summary>
/// Dizionario richieste
/// </summary>
private Dictionary<string, string> reqDict = new Dictionary<string, string>();
private async Task setAwaitPrice(bool awaitPrice, bool flushCache)
{
foreach (var item in AllRecords)
@@ -370,6 +488,14 @@ namespace Lux.UI.Components.Compo
}
}
/// <summary>
/// Toggle visibilità modifica file indicando ID della OfferRow corrente (o zero se deselect)
/// </summary>
private void ToggleFileEdit(OfferRowModel? currRec)
{
EditFileRecord = currRec;
}
/// <summary>
/// salva nel record corrente la BOM aggiornata e poi ricalcola importo...
/// </summary>
@@ -432,9 +558,6 @@ namespace Lux.UI.Components.Compo
isLoading = false;
}
#endregion Private Methods
/// <summary>
/// Esegue lettura file + invio richiesta specifica
/// </summary>
@@ -445,9 +568,10 @@ namespace Lux.UI.Components.Compo
{
if (EditFileRecord != null)
{
Dictionary<string, string> Args = new Dictionary<string, string>();
// init dizionari arg richiesta update
Dictionary<string, string> fileArgs = new Dictionary<string, string>();
// leggo il contenuto del PRIMO (singolo) file
// leggo il contenuto del PRIMO (singolo) file
IBrowserFile file = e.File;
// limite file size (al momento 10 MB)
var maxAllowedSize = 10 * 1024 * 1024;
@@ -464,55 +588,69 @@ namespace Lux.UI.Components.Compo
// salvo sul DB i dati (nome, nome sicuro, size...)
await DLService.OffertRowUpdateFileData(EditFileRecord);
// parametri richiesta
Args.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}");
Args.Add("Btl", rawContent);
// parametri richiesta
fileArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}");
fileArgs.Add("Btl", rawContent);
// invio!
CalcRequestDTO calcRequestDTO = new CalcRequestDTO();
calcRequestDTO.EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM;
calcRequestDTO.DictExec = Args;
calcRequestDTO.DictExec = fileArgs;
await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{EditFileRecord.OfferRowUID}", calcRequestDTO);
#if false
// salvo in locale il file: SISTEMARE PERMESSI
saveFileContent(EditFileRecord.OfferRowUID, trustedFileName, rawContent);
saveFileContent(EditFileRecord.OfferRowUID, trustedFileName, rawContent);
#endif
}
}
/// <summary>
/// Esegue salvataggio del file ricevuto
/// </summary>
/// <param name="secureName">Nome secure da impiegare</param>
/// <param name="content">Contenuto file</param>
private bool saveFileContent(string folderPath, string secureName, string content)
{
bool answ = false;
if (!string.IsNullOrEmpty(folderPath))
{
// calcolo path file...
string filePath = Path.Combine("unsafe_uploads", folderPath, secureName);
File.WriteAllText(filePath, content);
}
return answ;
}
/// <summary>
/// Display fileSize scalato
/// Chiude edit andando eventualmente a salvare
/// </summary>
/// <param name="size"></param>
/// <param name="args"></param>
/// <returns></returns>
protected string fSize(long size)
private async Task CloseEdit(bool doSave)
{
return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1);
}
/// <summary>
/// Toggle visibilità modifica file indicando ID della OfferRow corrente (o zero se deselect)
/// </summary>
private void ToggleFileEdit(OfferRowModel? currRec)
{
EditFileRecord = currRec;
// ...se ho editing
if (EditRecord != null)
{
bool updateBom = false;
// SE richiesto salvataggio...
if (doSave)
{
// salvo su DB!
await DLService.OffertRowUpdateSerStruct(EditRecord.OfferRowID, prevJwd);
updateBom = true;
}
else
// altrimenti ricalcolo valore salvato
{
prevJwd = EditRecord.SerStruct;
CurrData.CurrJwd = EditRecord.SerStruct;
}
if(updateBom)
{
await reqBomUpdate(EditRecord);
}
// aggiorno nel dizionari
if (reqDict.ContainsKey("Jwd"))
{
reqDict["Jwd"] = prevJwd;
}
if (reqDict != null && reqDict.Count > 0)
{
// chiamo richiesta update
CalcRequestDTO calcRequestDTO = new CalcRequestDTO();
calcRequestDTO.EnvType = EditRecord.Envir;
calcRequestDTO.DictExec = reqDict;
// chiamo la chiamata POST alla API, che manda la richiesta via REDIS
await ICService.CallRestPost($"{apiUrl}/{GenericBasePath}", $"{calcTag}/{EditRecord.OfferRowUID}", calcRequestDTO);
}
EditRecord = null;
}
}
#endregion Private Methods
}
}
+5 -5
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2510.0618</Version>
<Version>0.9.2510.0716</Version>
</PropertyGroup>
<ItemGroup>
@@ -17,8 +17,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Egw.Lux.WebWindow.Base" Version="2.7.10.319" />
<PackageReference Include="Egw.Lux.WebWindowComplex" Version="2.7.10-beta.617" />
<PackageReference Include="Egw.Lux.WebWindow.Base" Version="2.7.10.715" />
<PackageReference Include="Egw.Lux.WebWindowComplex" Version="2.7.10.715" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.5.2510.610" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.5.2510.610" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.17" />
@@ -44,8 +44,8 @@
</ItemGroup>
<ItemGroup>
<Folder Include="unsafe_uploads\" />
<Folder Include="wwwroot\images\textures\" />
<Folder Include="unsafe_uploads\" />
<Folder Include="wwwroot\images\textures\" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\post-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath)" />
+2 -2
View File
@@ -64,8 +64,8 @@
"Prog.ApiUrl": "https://localhost:7135/api",
"ImageBaseUrl": "window",
"RouteBaseUrl": "window",
"PubChannel": "EgwDevEngineInput",
"SubChannel": "EgwDevEngineOutput",
"PubChannel": "EgwEngineInput",
"SubChannel": "EgwEngineOutput",
"SvgChannel": "Egw:svg:img",
"BomChannel": "Egw:bom",
"UpdateChannel": "Egw:update",
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2510.0618</h4>
<h4>Versione: 0.9.2510.0716</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2510.0618
0.9.2510.0716
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2510.0618</version>
<version>0.9.2510.0716</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>