From edaa834a9c9344bb078400e37e13969900b4e2ad Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 18 Mar 2026 13:15:07 +0100 Subject: [PATCH] Completato sostituzione metodi (DA TESTARE!!!) --- .../Controllers/LuxController.cs | 2 +- .../Services/DataLayerServices.cs | 44 +++++++-------- .../Services/Sales/IOrderRowService.cs | 2 +- .../Services/Sales/OrderRowService.cs | 2 +- Lux.API/Controllers/FileController.cs | 9 ++-- Lux.UI/Components/Compo/OrderRowMan.razor.cs | 53 ++++++++++--------- .../Components/Pages/WorkLoadBalance.razor.cs | 8 +-- 7 files changed, 63 insertions(+), 57 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index df9b9f1d..e8e1aace 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -401,7 +401,7 @@ namespace EgwCoreLib.Lux.Data.Controllers return answ; } -#if true +#if false /// /// Elimina riga e sposta eventuali righe successive... /// diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index 694330a6..6ed2e959 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -349,7 +349,7 @@ namespace EgwCoreLib.Lux.Data.Services return answ; } -#if true +#if false /// /// Effettua eliminazione della riga Ordine /// @@ -640,7 +640,28 @@ namespace EgwCoreLib.Lux.Data.Services LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } + + /// + /// Aggiorna stato riga ordine al valore richiesto + /// + /// + /// + /// + public async Task OrderRowUpdateState(int orderRowID, OrderStates reqState) + { + using var activity = StartActivity(); + string source = "DB+REDIS"; + // calcolo + bool fatto = await dbController.OrderRowUpdateState(orderRowID, reqState); + // svuoto cache... + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdGroup:*"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + return fatto; + } #endif /// /// Validazione record: @@ -664,27 +685,6 @@ namespace EgwCoreLib.Lux.Data.Services } - /// - /// Aggiorna stato riga ordine al valore richiesto - /// - /// - /// - /// - public async Task OrderRowUpdateState(int orderRowID, OrderStates reqState) - { - using var activity = StartActivity(); - string source = "DB+REDIS"; - // calcolo - bool fatto = await dbController.OrderRowUpdateState(orderRowID, reqState); - // svuoto cache... - await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); - await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); - await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdGroup:*"); - activity?.SetTag("data.source", source); - LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); - return fatto; - } - /// /// Elenco completo Fasi diff --git a/EgwCoreLib.Lux.Data/Services/Sales/IOrderRowService.cs b/EgwCoreLib.Lux.Data/Services/Sales/IOrderRowService.cs index 5bc591d0..621d7ea8 100644 --- a/EgwCoreLib.Lux.Data/Services/Sales/IOrderRowService.cs +++ b/EgwCoreLib.Lux.Data/Services/Sales/IOrderRowService.cs @@ -32,7 +32,7 @@ namespace EgwCoreLib.Lux.Data.Services.Sales Task UpdateSerStructAsync(int OrderRowID, string serStruct); - Task OrderRowUpdateState(int orderRowID, OrderStates reqState); + Task UpdateStateAsync(int orderRowID, OrderStates reqState); Task UpsertAsync(OrderRowModel upsRec); diff --git a/EgwCoreLib.Lux.Data/Services/Sales/OrderRowService.cs b/EgwCoreLib.Lux.Data/Services/Sales/OrderRowService.cs index 4a0d6ada..10856e87 100644 --- a/EgwCoreLib.Lux.Data/Services/Sales/OrderRowService.cs +++ b/EgwCoreLib.Lux.Data/Services/Sales/OrderRowService.cs @@ -367,7 +367,7 @@ namespace EgwCoreLib.Lux.Data.Services.Sales /// ID Riga Order da aggiornare /// Serializzazione oggetto (es JWD) /// - public async Task OrderRowUpdateState(int orderRowID, OrderStates reqState) + public async Task UpdateStateAsync(int orderRowID, OrderStates reqState) { return await TraceAsync($"{_className}.UpdateSerStruct", async (activity) => { diff --git a/Lux.API/Controllers/FileController.cs b/Lux.API/Controllers/FileController.cs index 66a1bacb..b4633601 100644 --- a/Lux.API/Controllers/FileController.cs +++ b/Lux.API/Controllers/FileController.cs @@ -23,7 +23,7 @@ namespace Lux.API.Controllers public FileController(DataLayerServices DLService, IOfferRowService iORService, ImageCacheService imgServ, ILogger logger) { _imgService = imgServ; - _ORService = iORService; + _OffRService = iORService; _DSService = DLService; _logger = logger; } @@ -133,12 +133,12 @@ namespace Lux.API.Controllers // a seconda del tipo leggo da 2 aree db diverse... if (objType == "POR") { - var currPOR = await _DSService.OrderRowGetByUID(id); + var currPOR = await _OrdRService.GetByUidAsync(id); jsonContent = currPOR?.SerStruct ?? ""; } else if (objType == "SOR") { - var currSOR = await _ORService.GetByUidAsync(id); + var currSOR = await _OffRService.GetByUidAsync(id); jsonContent = currSOR?.SerStruct ?? ""; } // se NON vuoto --> converto byte stream... @@ -189,7 +189,8 @@ namespace Lux.API.Controllers #region Private Properties private DataLayerServices _DSService { get; set; } - private IOfferRowService _ORService { get; set; } + private IOfferRowService _OffRService { get; set; } + private IOrderRowService _OrdRService { get; set; } private ImageCacheService _imgService { get; set; } #endregion Private Properties diff --git a/Lux.UI/Components/Compo/OrderRowMan.razor.cs b/Lux.UI/Components/Compo/OrderRowMan.razor.cs index 6ae4f3d4..069ee9c6 100644 --- a/Lux.UI/Components/Compo/OrderRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OrderRowMan.razor.cs @@ -342,30 +342,27 @@ namespace Lux.UI.Components.Compo [Inject] private ConfigDataService CDService { get; set; } = null!; + [Inject] + private IConfGlassService CGService { get; set; } = null!; + [Inject] private IConfiguration Config { get; set; } = null!; + [Inject] + private IConfProfileService CPService { get; set; } = null!; + [Inject] private CalcRuidService CRService { get; set; } = null!; [Inject] private CalcRequestService CService { get; set; } = null!; - [Inject] - private IConfGlassService CGService { get; set; } = null!; - - [Inject] - private IConfProfileService CPService { get; set; } = null!; - [Inject] private IConfWoodService CWService { get; set; } = null!; [Inject] private DataLayerServices DLService { get; set; } = null!; - [Inject] - private IOrderService OrdService { get; set; } = null!; - [Inject] private IEnvirParamService EPService { get; set; } = null!; @@ -486,6 +483,12 @@ namespace Lux.UI.Components.Compo get => CurrRecord.OrderID; } + [Inject] + private IOrderRowService OrdRService { get; set; } = null!; + + [Inject] + private IOrderService OrdService { get; set; } = null!; + [Inject] private ProdService PService { get; set; } = null!; @@ -539,7 +542,7 @@ namespace Lux.UI.Components.Compo if (doSave) { // salvo su DB! - await DLService.OrderRowUpdateSerStruct(EditRecord.OrderRowID, prevJwd); + await OrdRService.UpdateSerStructAsync(EditRecord.OrderRowID, prevJwd); // salvo nel record corrente! EditRecord.SerStruct = prevJwd; updateBom = true; @@ -728,9 +731,9 @@ namespace Lux.UI.Components.Compo StepPrice = rec2clone.StepPrice, }; // salvo sul DB - await DLService.OrderRowUpsert(newRec); + await OrdRService.UpsertAsync(newRec); // chiamo update record che non hanno UID x questo ordine - var list2fix = await DLService.OrderRowFixUid(OrderID); + var list2fix = await OrdRService.FixUidAsync(OrderID); if (list2fix != null && list2fix.Count > 0) { // rileggo i miei record... @@ -760,7 +763,7 @@ namespace Lux.UI.Components.Compo if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler eliminare la riga corrente?
Codice: {rec2del.OrderRowUID} | {rec2del.Note} | importo tot: {rec2del.TotalPrice}")) return; - await DLService.OrderRowDelete(rec2del); + await OrdRService.DeleteAsync(rec2del); // elimino cache img await ICService.DeleteSvgAsync(rec2del.OrderRowUID, rec2del.Envir); await ReloadData(); @@ -847,7 +850,7 @@ namespace Lux.UI.Components.Compo { isLoading = true; // salvo record modificato... - await DLService.OrderRowUpsert(curRec); + await OrdRService.UpsertAsync(curRec); // reset CurrEditMode = EditMode.None; EditRecord = null; @@ -1072,7 +1075,7 @@ namespace Lux.UI.Components.Compo var listCalc = SorListCalc(); foreach (var item in listCalc) { - await DLService.OrderRowUpdateAwaitState(item.OrderRowID, true, true); + await OrdRService.UpdateAwaitStateAsync(item.OrderRowID, true, true); // poich� non � gestito evento ritorno update window interno si "scassa" --> try catch/ if FALSE try { @@ -1081,7 +1084,7 @@ namespace Lux.UI.Components.Compo string rProfile = CurrSel.GetVal("Profile"); string rWood = CurrSel.GetVal("Wood"); var newSerStruct = SerialMan.MassUpdate((string)item.SerStruct, null, null, rColor, rWood, rGlass, rProfile); - await DLService.OrderRowUpdateSerStruct(item.OrderRowID, newSerStruct); + await OrdRService.UpdateSerStructAsync(item.OrderRowID, newSerStruct); } catch { } @@ -1089,7 +1092,7 @@ namespace Lux.UI.Components.Compo await InvokeAsync(StateHasChanged); // verifica preliminare UID - await DLService.OrderRowFixUid(OrderID); + await OrdRService.FixUidAsync(OrderID); // ricalcolo di tutte le BOM e relativi prezzi... foreach (var item in listCalc) @@ -1117,13 +1120,13 @@ namespace Lux.UI.Components.Compo var listCalc = SorListCalc(); foreach (var item in listCalc) { - await DLService.OrderRowUpdateAwaitState(item.OrderRowID, true, true); + await OrdRService.UpdateAwaitStateAsync(item.OrderRowID, true, true); } await InvokeAsync(StateHasChanged); // verifica preliminare UID - await DLService.OrderRowFixUid(OrderID); - await DLService.OrderRowFixImgType(OrderID); + await OrdRService.FixUidAsync(OrderID); + await OrdRService.FixImgTypeAsync(OrderID); // ricalcolo di tutte le BOM e relativi prezzi... foreach (var item in listCalc) @@ -1435,7 +1438,7 @@ namespace Lux.UI.Components.Compo { if (OrderID > 0) { - AllRecords = await DLService.OrderRowGetByOffer(OrderID); + AllRecords = await OrdRService.GetByParentAsync(OrderID); totalCount = AllRecords.Count(); // faccio un controllo/fix dei record int numFix = await DLService.OrderRowListValidate(AllRecords); @@ -1538,7 +1541,7 @@ namespace Lux.UI.Components.Compo // salvo richiesta BOM su record currRec.AwaitBom = true; currRec.AwaitPrice = true; - await DLService.OrderRowUpdateAwaitState(currRec.OrderRowID, true, true); + await OrdRService.UpdateAwaitStateAsync(currRec.OrderRowID, true, true); // preparo la domanda serializzata Dictionary DictExec = new Dictionary(); @@ -1719,7 +1722,7 @@ namespace Lux.UI.Components.Compo foreach (var item in AllRecords) { item.AwaitPrice = awaitPrice; - await DLService.OrderRowUpdateAwaitState(item.OrderRowID, null, awaitPrice, flushCache); + await OrdRService.UpdateAwaitStateAsync(item.OrderRowID, null, awaitPrice, flushCache); } } @@ -1811,7 +1814,7 @@ namespace Lux.UI.Components.Compo if (EditRecord != null) { // salvo BOM nel record corrente... - bool fatto = await DLService.OrderRowUpdateBom(EditRecord.OrderRowID, newBomList); + bool fatto = await OrdRService.UpdateBomAsync(EditRecord.OrderRowID, newBomList); // ricalcolo offerta completa await ReloadData(); UpdateTable(); @@ -1868,7 +1871,7 @@ namespace Lux.UI.Components.Compo EditRecord.FileName = file.Name; EditRecord.FileSize = rawContent.LongCount(); // salvo sul DB i dati (nome, nome sicuro, size...) - await DLService.OrderRowUpdateFileData(EditRecord); + await OrdRService.UpdateFileDataAsync(EditRecord); // parametri richiesta fileArgs.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.PREVIEW}"); diff --git a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs index 0882afec..1f2aec34 100644 --- a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs +++ b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs @@ -77,6 +77,8 @@ namespace Lux.UI.Components.Pages [Inject] private DataLayerServices DLService { get; set; } = null!; + [Inject] + private IOrderRowService OrdRService { get; set; } = null!; [Inject] private IGenValService GVService { get; set; } = default!; @@ -258,7 +260,7 @@ namespace Lux.UI.Components.Pages // aggiorno sales order status a ProdOdl creato foreach (var ordRowId in ordRowIdList) { - await DLService.OrderRowUpdateState(ordRowId, OrderStates.ProdOdlCreated); + await OrdRService.UpdateStateAsync(ordRowId, OrderStates.ProdOdlCreated); } } } @@ -394,7 +396,7 @@ namespace Lux.UI.Components.Pages private async Task ReloadData() { // prendo solo ordini stimati (NON ancora bilanciati o pianificati) - ListEstimRecords = await DLService.OrderRowGetByStateMin(OrderStates.Estimated, PeriodoSel.Inizio, PeriodoSel.Fine); + ListEstimRecords = await OrdRService.GetByStateMinAsync(OrderStates.Estimated, PeriodoSel.Inizio, PeriodoSel.Fine); ListBalancedRecords = await DLService.ProdGroupByOrderState(OrderStates.Assigned); ListOdl = await DLService.ProdOdlAssignGetAsync(); } @@ -410,7 +412,7 @@ namespace Lux.UI.Components.Pages return; // resetto riga ordine... - await DLService.OrderRowUpdateState(OrderRowID, OrderStates.Estimated); + await OrdRService.UpdateStateAsync(OrderRowID, OrderStates.Estimated); await ReloadData(); }