diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index 88280b40..f88fce6c 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -601,7 +601,6 @@ namespace EgwCoreLib.Lux.Data.Controllers } return answ; } -#endif /// /// Esegue eliminazione @@ -768,6 +767,8 @@ namespace EgwCoreLib.Lux.Data.Controllers } return answ; } +#endif + /// /// Eliminazione record item diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs index d15349a2..f20ff344 100644 --- a/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Utils/GenValRepository.cs @@ -3,7 +3,7 @@ using Microsoft.EntityFrameworkCore; namespace EgwCoreLib.Lux.Data.Repository.Utils { - internal class GenValRepository : BaseRepository, IGenValRepository + public class GenValRepository : BaseRepository, IGenValRepository { #region Public Constructors diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index e0d0e830..6169ae6b 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -579,7 +579,6 @@ namespace EgwCoreLib.Lux.Data.Services LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } -#endif /// /// Esegue eliminazione + refresh cache @@ -666,6 +665,7 @@ namespace EgwCoreLib.Lux.Data.Services LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } +#endif /// /// Eliminazione record item diff --git a/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs b/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs index 67992d12..fce05f7f 100644 --- a/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs +++ b/EgwCoreLib.Lux.Data/Services/Utils/GenValService.cs @@ -82,7 +82,7 @@ namespace EgwCoreLib.Lux.Data.Services.Utils public async Task MoveAsync(GenValueModel selRec, bool moveUp) { - return await TraceAsync("GenClass.MoveAsync", async (activity) => + return await TraceAsync("GenVal.MoveAsync", async (activity) => { bool success = await _repo.MoveAsync(selRec, moveUp); diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 9e085a22..d81881d1 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2603.1412 + 1.1.2603.1416 diff --git a/Lux.UI/Components/Compo/GenClassMan.razor.cs b/Lux.UI/Components/Compo/GenClassMan.razor.cs index c44b2272..6cab0396 100644 --- a/Lux.UI/Components/Compo/GenClassMan.razor.cs +++ b/Lux.UI/Components/Compo/GenClassMan.razor.cs @@ -33,7 +33,7 @@ namespace Lux.UI.Components.Compo #region Protected Properties [Inject] - protected IGenClassService DLService { get; set; } = null!; + protected IGenClassService GCService { get; set; } = null!; [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -60,7 +60,7 @@ namespace Lux.UI.Components.Compo { ErrorMsg = ""; // faccio upsert record... - await DLService.UpsertAsync(NewRecord); + await GCService.UpsertAsync(NewRecord); // segnalo update x reload await EC_Updated.InvokeAsync(true); NewRecord = null; @@ -96,7 +96,7 @@ namespace Lux.UI.Components.Compo return; // esegue eliminazione del record... - await DLService.DeleteAsync(selRec); + await GCService.DeleteAsync(selRec); // segnalo update x reload await EC_Updated.InvokeAsync(true); @@ -126,7 +126,7 @@ namespace Lux.UI.Components.Compo protected async Task DoSave(GenClassModel currRec) { // faccio upsert record... - await DLService.UpsertAsync(currRec); + await GCService.UpsertAsync(currRec); // segnalo update x reload await EC_Updated.InvokeAsync(true); } diff --git a/Lux.UI/Components/Compo/GenValMan.razor.cs b/Lux.UI/Components/Compo/GenValMan.razor.cs index 610133de..27d27c09 100644 --- a/Lux.UI/Components/Compo/GenValMan.razor.cs +++ b/Lux.UI/Components/Compo/GenValMan.razor.cs @@ -1,6 +1,5 @@ -using EgwCoreLib.Lux.Core; using EgwCoreLib.Lux.Data.DbModel.Utils; -using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; @@ -70,7 +69,7 @@ namespace Lux.UI.Components.Compo #region Protected Properties [Inject] - protected DataLayerServices DLService { get; set; } = null!; + protected IGenValService GVService { get; set; } = null!; [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -115,16 +114,12 @@ namespace Lux.UI.Components.Compo return; // esegue eliminazione del record... - await DLService.GenValDeleteAsync(selRec); + await GVService.DeleteAsync(selRec); EditRecord = null; SelRecord = null; await ReloadData(); UpdateTable(); -#if false - // segnalo update x reload - await EC_Updated.InvokeAsync(true); -#endif } /// @@ -197,7 +192,7 @@ namespace Lux.UI.Components.Compo #region Private Methods - private async Task DoAdd() + private Task DoAdd() { // aggiungo un nuovo record in coda... EditRecord = new GenValueModel() @@ -206,19 +201,7 @@ namespace Lux.UI.Components.Compo ValString = $"Nuovo-{DateTime.Now:yy.MM.ss HH.mm.ss}", Index = totalCount + 1 }; - await DoSave(EditRecord); - } - - /// - /// Esegue spostamento - /// - /// - /// - /// - private async Task MoveRec(GenValueModel curRec, bool moveUp) - { - await DLService.GenValMoveAsync(curRec, moveUp); - await DoCancel(); + return DoSave(EditRecord); } private async Task DoCancel() @@ -230,17 +213,29 @@ namespace Lux.UI.Components.Compo private async Task DoSave(GenValueModel currRec) { // salvo - await DLService.GenValUpsertAsync(currRec); + await GVService.UpsertAsync(currRec); await ResetEdit(); UpdateTable(); EditRecord = null; SelRecord = null; } + /// + /// Esegue spostamento + /// + /// + /// + /// + private async Task MoveRec(GenValueModel curRec, bool moveUp) + { + await GVService.MoveAsync(curRec, moveUp); + await DoCancel(); + } + private async Task ReloadData() { isLoading = true; - AllRecords = await DLService.GenValGetFiltAsync(actFilt.SelCodGroup); + AllRecords = await GVService.GetFiltAsync(actFilt.SelCodGroup); // se ho ricerca testuale faccio filtro ulteriore... if (string.IsNullOrEmpty(actFilt.SearchVal)) { @@ -260,11 +255,11 @@ namespace Lux.UI.Components.Compo totalCount = AllRecords.Count; } - private async Task ResetEdit() + private Task ResetEdit() { // reset edit EditRecord = null; - await ReloadData(); + return ReloadData(); } /// diff --git a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs index ff749be8..5054d4b0 100644 --- a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs +++ b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs @@ -2,6 +2,7 @@ using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; namespace Lux.UI.Components.Compo @@ -21,61 +22,6 @@ namespace Lux.UI.Components.Compo #endregion Public Properties - #region Protected Properties - - [Inject] - protected ConfigDataService CDService { get; set; } = null!; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected CalcRuidService CRService { get; set; } = null!; - - [Inject] - protected CalcRequestService CService { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - /// - /// Gestione selezione Colore - /// - protected string SelColor - { - get => CurrSel.GetVal("Color"); - set => CurrSel.SetVal("Color", value); - } - - /// - /// Gestione selezione Glass - /// - protected string SelGlass - { - get => CurrSel.GetVal("Glass"); - set => CurrSel.SetVal("Glass", value); - } - - /// - /// Gestione selezione Profile - /// - protected string SelProfile - { - get => CurrSel.GetVal("Profile"); - set => CurrSel.SetVal("Profile", value); - } - - /// - /// Gestione selezione Wood - /// - protected string SelWood - { - get => CurrSel.GetVal("Wood"); - set => CurrSel.SetVal("Wood", value); - } - - #endregion Protected Properties - #region Protected Methods protected override void OnInitialized() @@ -89,7 +35,7 @@ namespace Lux.UI.Components.Compo // deserializzo se possibile dal record... CurrSel = new ParamDict(CurrRecord.DictPresel); // leggo dati di base - var AllColors = await DLService.GenValGetFiltAsync("WoodCol"); + var AllColors = await GVService.GetFiltAsync("WoodCol"); var AllConfGlass = await DLService.ConfGlassGetAllAsync(); var AllConfProfile = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); // se fosse vuoto chiamo update... @@ -120,11 +66,15 @@ namespace Lux.UI.Components.Compo #region Private Fields private string apiUrl = ""; + private string calcTag = "calc"; + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + private ParamDict CurrSel = new ParamDict(""); private string genericBasePath = ""; + private bool isLoading = false; private List ListColors = new List(); @@ -137,6 +87,64 @@ namespace Lux.UI.Components.Compo #endregion Private Fields + #region Private Properties + + [Inject] + private ConfigDataService CDService { get; set; } = null!; + + [Inject] + private IConfiguration Config { get; set; } = null!; + + [Inject] + private CalcRuidService CRService { get; set; } = null!; + + [Inject] + private CalcRequestService CService { get; set; } = null!; + + [Inject] + private DataLayerServices DLService { get; set; } = null!; + + [Inject] + private IGenValService GVService { get; set; } = null!; + + /// + /// Gestione selezione Colore + /// + private string SelColor + { + get => CurrSel.GetVal("Color"); + set => CurrSel.SetVal("Color", value); + } + + /// + /// Gestione selezione Glass + /// + private string SelGlass + { + get => CurrSel.GetVal("Glass"); + set => CurrSel.SetVal("Glass", value); + } + + /// + /// Gestione selezione Profile + /// + private string SelProfile + { + get => CurrSel.GetVal("Profile"); + set => CurrSel.SetVal("Profile", value); + } + + /// + /// Gestione selezione Wood + /// + private string SelWood + { + get => CurrSel.GetVal("Wood"); + set => CurrSel.SetVal("Wood", value); + } + + #endregion Private Properties + #region Private Methods /// @@ -173,17 +181,17 @@ namespace Lux.UI.Components.Compo calcTag = Config.GetValue("ServerConf:CalcTag") ?? "calc"; } - private async Task DoCancel() + private Task DoCancel() { - await EC_Close.InvokeAsync(true); + return EC_Close.InvokeAsync(true); } - private async Task DoSave() + private Task DoSave() { // aggiorno valore serializzato... CurrRecord.DictPresel = CurrSel.Serialized; // richiesta update con salvataggio record - await EC_Updated.InvokeAsync(CurrRecord); + return EC_Updated.InvokeAsync(CurrRecord); } #endregion Private Methods diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index 035d4ead..138aa277 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -5,6 +5,7 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.JSInterop; @@ -22,7 +23,7 @@ namespace Lux.UI.Components.Compo #region Public Properties [Parameter] - public OfferModel CurrRecord { get; set; } = null!; + public OfferModel CurrRecord { get; set; } = default!; [Parameter] public DisplayMode DisplayMode { get; set; } = DisplayMode.Standard; @@ -50,21 +51,254 @@ namespace Lux.UI.Components.Compo #endregion Public Methods - #region Protected Fields + #region Protected Methods + + /// + /// Verifica after render x stato interattivo pagina + /// + /// + protected override void OnAfterRender(bool firstRender) + { + if (firstRender) + { + // JS interop or data fetches go here + isInteractive = true; + } + } + + /// + /// init obj + /// + protected override async Task OnInitializedAsync() + { + ConfInit(); + prevJwd = ""; + await ReloadBaseList(); + DLService.PipeUpdate.EA_NewMessage += PipeUpdate_EA_NewMessage; + DLService.PipePng.EA_NewMessage += PipePng_EA_NewMessage; + DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; + DLService.PipeHwOpt.EA_NewMessage += PipeHwOpt_EA_NewMessage; + DLService.PipeProfElement.EA_NewMessage += PipeProfElement_EA_NewMessage; + DLService.PipeProfList.EA_NewMessage += PipeProfList_EA_NewMessage; + DLService.PipeShape.EA_NewMessage += PipeShape_EA_NewMessage; + } + + protected override async Task OnParametersSetAsync() + { + await DLService.OffertRowFixImgType(OfferID); + await ReloadData(); + UpdateTable(); + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + /// + /// Boolean selezione prodotto da aggiungere (template) + /// + private bool addFromTemplate = false; + + private List AllColors = new(); + + private List AllConfEnvir = new(); + + private List AllConfGlass = new(); + + private List AllConfHardware = new(); + + private List AllConfWood = new(); + + private List AllRecords = new List(); + + private string apiUrl = ""; + + private List AvailColorMaterialList = new List(); + + private List AvailFamilyHardwareList = new List(); + + private List AvailGlassList = new List(); + + private List AvailHardwareList = new(); + + private List AvailMaterialList = new List(); + + /// + /// Lista profili da DB + /// + private List AvailProfileList = new(); + + /// + /// Lista profili da Redis (old way) + /// + private List AvailProfileListOld = new List(); + + private Dictionary> AvailThresholdDict = new Dictionary>(); + + /// + /// Base path x network share files + /// + private string basePath = "unsafe_uploads"; + + private string calcTag = "calc"; + + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + + /// + /// Channel update HwOptions + /// + private string chHwOpt = ""; + + /// + /// Channel update PNG + /// + private string chPng = ""; + + /// + /// Channel update Profile List + /// + private string chProfElem = ""; + + /// + /// Channel update Profile List + /// + private string chProfList = ""; + + /// + /// Channel update Shape + /// + private string chShape = ""; + + /// + /// Channel update SVG + /// + private string chSvg = ""; + + private List currAreaProfiles = new(); + + private List? CurrBomList = null; /// /// Predisposizione valori live SVG/JWD /// private LivePayload CurrData = new LivePayload(); + /// + /// Modalit� editint attiva + /// + private EditMode CurrEditMode = EditMode.None; + + private Dictionary currGroupShape = new(); + + private Dictionary currHwOption = new(); + + private int currPage = 1; + + private string currPng = ""; + + private List currProfList = new(); + + private string currSvg = ""; + + /// + /// Record in Edit corrente x modifica file/serializzato + /// + private OfferRowModel? EditRecord = null; + + /// + /// Abilita edit massivo record ITEM + /// + private bool enableMassEdit = false; + + private string genericBasePath = ""; + + private string imgBasePath = ""; + + /// + /// Semaforo x definire se sia gia in modalita ionterattiva o di prerendering + /// + private bool isInteractive = false; + + private bool isLoading = false; + + private List ListAllCatalog = new(); + + private List ListCataloghi = new(); + + private List ListRecords = new(); + + private List ListTemplateAll = new(); + + private int numRecord = 10; + + /// + /// Versione originale (pre edit) + /// + private string origJwd = ""; + + private List PreparedFile = new(); + + /// + /// Versione precedente JWD x test e confronto + /// + private string prevJwd = ""; + + /// + /// Dizionario richieste + /// + private Dictionary reqDict = new Dictionary(); + /// /// Configurazione elenchi anagrafiche /// private BaseListPayload SetupList = new BaseListPayload(); - #endregion Protected Fields + private int totalCount = 0; - #region Protected Properties + #endregion Private Fields + + #region Private Properties + + private Dictionary> AvailThreshold { get; set; } = new Dictionary>() + { + {"Profilo78", new List() { new Threshold(3, "Bottom")}}, + {"ProfiloSaomad", new List(){ new Threshold(3, "Bottom")}} +#if false + {"Profilo78", new List() { new Threshold(3, "Bottom"), new Threshold(1, "Threshold")}}, + {"ProfiloSaomad", new List(){ new Threshold(3, "Bottom"), new Threshold(2, "BottomWaterdrip"), new Threshold(1, "Threshold")}} +#endif + }; + + [Inject] + private ConfigDataService CDService { get; set; } = default!; + + [Inject] + private IConfiguration Config { get; set; } = default!; + + [Inject] + private CalcRuidService CRService { get; set; } = default!; + + [Inject] + private CalcRequestService CService { get; set; } = default!; + + [Inject] + private IWebHostEnvironment CurrEnv { get; set; } = default!; + + [Inject] + private DataLayerServices DLService { get; set; } = default!; + + [Inject] + private FileService FService { get; set; } = default!; + + /// + /// Costo totale calcolato x offerta + /// + private double GrandTotCost + { + get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalCost) : 0; + } /// /// Margine medio calcolato x offerta @@ -120,744 +354,16 @@ namespace Lux.UI.Components.Compo } [Inject] - private IWebHostEnvironment HostEnv { get; set; } = null!; - - #endregion Protected Properties - - #region Protected Methods - - private void ClosePopup() - { - CurrEditMode = EditMode.None; - EditRecord = null; - addFromTemplate = false; - } - - /// - /// Aggiunge una nuova riga vuota come nota sotto il record selezionato oppure in coda... - /// - /// - protected async Task DoAddNote() - { - int numRow = AllRecords.Count + 1; - if (EditRecord != null) - { - numRow = EditRecord.RowNum + 1; - } - OfferRowModel newNote = new OfferRowModel() - { - OfferID = CurrRecord.OfferID, - Envir = CurrRecord.Envir, - RowNum = numRow, - OfferRowUID = "", - Qty = 0, - BomCost = 0, - BomPrice = 0, - StepCost = 0, - StepPrice = 0 - }; - await DLService.OffertRowUpsert(newNote); - await ReloadData(); - UpdateTable(); - } - - /// - /// Aggiunge una nuova riga ordine in coda... - /// - /// - protected async Task DoAddOrderRow(TemplateRowModel selTemplate) - { - int numRow = AllRecords.Count + 1; - if (EditRecord != null) - { - numRow = EditRecord.RowNum + 1; - } - // SOLO SE è un oggetto calcolabile (JWD, BTL...) richiedo update img e BOM - bool needRecalc = (selTemplate.SellingItemNav != null && (selTemplate.SellingItemNav.SourceType == ItemSourceType.Jwd || selTemplate.SellingItemNav.SourceType == ItemSourceType.FileBTL)); - // creo riga! - OfferRowModel newSOR = new OfferRowModel() - { - AwaitBom = needRecalc, - AwaitPrice = needRecalc, - OfferID = CurrRecord.OfferID, - Envir = CurrRecord.Envir, - Inserted = DateTime.Now, - RowNum = numRow, - OfferRowUID = "", - Qty = 1, - SellingItemID = selTemplate.SellingItemID, - SerStruct = selTemplate.SerStruct, - BomCost = 0, - BomPrice = 0, - StepCost = 0, - StepPrice = 0 - }; - // SE FOSSE NON calcolabile aggiungo costi std - if (!needRecalc && selTemplate.SellingItemNav != null) - { - // recupero costi da ancestor - newSOR.BomCost = selTemplate.SellingItemNav?.Cost ?? 0; - newSOR.BomPrice = newSOR.BomCost * (1 + selTemplate.SellingItemNav?.Margin) ?? 1; - newSOR.BomOk = true; - newSOR.ItemOk = true; - newSOR.ProdItemQty = 1; - } - addFromTemplate = false; - var dbRec = await DLService.OffertRowUpsert(newSOR); - // chiamo ricalcolo BOM e IMG... - if (dbRec != null) - { - // SOLO SE è un oggetto calcolabile (JWD, BTL...) richiedo update img e BOM - if (needRecalc) - { - await callBomUpdate(dbRec); - await callImgUpdate(dbRec); - // imposto ad editing record secondo tipo - if (dbRec.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW) - { - DoEditJwd(dbRec); - } - else - { - DoEditFile(dbRec); - } - } - } - await ReloadData(); - UpdateTable(); - } - -#if false - /// - /// Aggiunge una nuova riga ordine in coda... - /// - /// - protected async Task DoAddOrderRowFromSellItem(int sellItemID) - { - int numRow = AllRecords.Count + 1; - if (EditRecord != null) - { - numRow = EditRecord.RowNum + 1; - } - OfferRowModel newSOR = new OfferRowModel() - { - AwaitBom = true, - AwaitPrice = true, - OfferID = CurrRecord.OfferID, - Envir = CurrRecord.Envir, - Inserted = DateTime.Now, - RowNum = numRow, - OfferRowUID = "", - Qty = 1, - SellingItemID = sellItemID, - BomCost = 0, - BomPrice = 0, - StepCost = 0, - StepPrice = 0 - }; - // se è window aggiungo "{}" come serStruct sennò non la prende bene... - if (CurrRecord.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW) - { - newSOR.SerStruct = "{}"; - } - addFromTemplate = false; - await DLService.OffertRowUpsert(newSOR); - await ReloadData(); - UpdateTable(); - } -#endif - - /// - /// Annullamento modifica - /// - /// - /// - protected async Task DoCancel() - { - isLoading = true; - CurrEditMode = EditMode.None; - EditRecord = null; - await Task.Delay(20); - await DLService.FlushCacheOffersAsync(); - await Task.Delay(20); - await ReloadData(); - UpdateTable(); - isLoading = false; - } - - /// - /// Clona riga richiesta - /// - /// - protected async Task DoClone(OfferRowModel rec2clone) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler duplicare la riga corrente?")) - return; - - // calcolo indice riga... - int numRow = totalCount + 1; - OfferRowModel newRec = new OfferRowModel() - { - AwaitBom = true, - AwaitPrice = true, - Envir = rec2clone.Envir, - FileName = rec2clone.FileName, - FileResource = rec2clone.FileResource, - FileSize = rec2clone.FileSize, - Inserted = DateTime.Now, - ItemBOM = rec2clone.ItemBOM, - ItemSteps = rec2clone.ItemSteps, - Modified = DateTime.Now, - Note = rec2clone.Note, - OfferID = OfferID, - OfferRowUID = "", - Qty = rec2clone.Qty, - RowNum = numRow, - SellingItemID = rec2clone.SellingItemID, - SerStruct = rec2clone.SerStruct, - StepCost = rec2clone.StepCost, - StepPrice = rec2clone.StepPrice, - }; - // salvo sul DB - await DLService.OffertRowUpsert(newRec); - // chiamo update record che non hanno UID x questo ordine - await DLService.OffertRowFixImgType(OfferID); - var list2fix = await DLService.OffertRowFixUid(OfferID); - if (list2fix != null && list2fix.Count > 0) - { - // rileggo i miei record... - await ReloadData(); - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - // se UID � tra quelli da ricalcolare... - if (list2fix.Contains(item.OfferRowUID)) - { - // chiedo BOM e immagine - await callBomUpdate(item); - } - } - } - await ReloadData(); - UpdateTable(); - } - - /// - /// Eliminazione riga offerta - /// - /// - /// - protected async Task DoDelete(OfferRowModel rec2del) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler eliminare la riga corrente?
Codice: {rec2del.OfferRowUID} | {rec2del.Note} | importo tot: {rec2del.TotalPrice}")) - return; - - await DLService.OffertRowDelete(rec2del); - // elimino cache img - await ICService.DeleteSvgAsync(rec2del.OfferRowUID, rec2del.Envir); - await ReloadData(); - UpdateTable(); - } - - /// - /// Va in edit della riga richiesta - /// - /// - protected void DoEdit(OfferRowModel curRec) - { - // imposto edit record - EditRecord = curRec; - /// modalita edit: gestione valori campi record - CurrEditMode = EditMode.RecData; - isLoading = false; - } - - /// - /// Edit del file: - /// - abilitazione fileUpload - /// - anteprima grande (live) - /// - /// - protected void DoEditFile(OfferRowModel curRec) - { - EditRecord = curRec; - /// modalit�edit: gestione JWD - CurrEditMode = EditMode.File; - } - - /// - /// Apre editor finestre del record richiesto - /// - /// - protected void DoEditJwd(OfferRowModel curRec) - { - EditRecord = curRec; - /// modalit�edit: gestione JWD - CurrEditMode = EditMode.SerStruc; - // preparazione dati da record corrente - PrepareWindowData(EditRecord.SerStruct); - // reset prev - prevJwd = ""; - } - - /// - /// Salvataggio edit record + reload - /// - /// - /// - protected async Task DoSave(OfferRowModel curRec) - { - isLoading = true; - // salvo record modificato... - await DLService.OffertRowUpsert(curRec); - // reset - CurrEditMode = EditMode.None; - EditRecord = null; - await DLService.FlushCacheOffersAsync(); - await ReloadData(); - UpdateTable(); - isLoading = false; - } - - /// - /// Seleziono riga senza cambiare modalit� editing - /// - /// - protected void DoSelect(OfferRowModel curRec) - { - // imposto edit record - EditRecord = curRec; - /// modalit�edit: gestione valori campi record - CurrEditMode = EditMode.None; - } - - protected async Task DoSelectItem() - { - addFromTemplate = true; - ListCataloghi = ListAllCatalog.Where(x => x.Envir == CurrRecord.Envir).ToList(); - } - - /// - /// Imposta modalita edit ciclo di lavoro - /// - /// - protected void DoSwapJobCycle(OfferRowModel currRow) - { - CurrEditMode = EditMode.JobCycle; - selectBom(currRow); - } - - /// - /// Imposta modalita ad edit BOM - /// - /// - protected void DoSwapMat(OfferRowModel currRow) - { - CurrEditMode = EditMode.BOM; - selectBom(currRow); - } - - /// - /// Display fileSize scalato - /// - /// - /// - protected string fSize(long size) - { - return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1); - } - - /// - /// Formattazione testo come html x display - /// - protected MarkupString HtmlConv(string rawData) - { - return (MarkupString)rawData.Replace(Environment.NewLine, "
").Replace("\n", "
");//.Replace(" ", " "); - } - -#if false - /// - /// Calcolo URL immagine - /// - /// - /// - /// - protected string imgUrl(string imgUid, string env) - { - // cast string su env.. - EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - Enum.TryParse(env, out envir); - return ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); - } -#endif - - /// - /// Calcolo URL immagine - /// - /// - /// - /// - /// - private string imgUrl(EgwCoreLib.Lux.Core.Enums.ImageType tipoImg, string imgUid, string env) - { - string answ = ""; - switch (tipoImg) - { - case EgwCoreLib.Lux.Core.Enums.ImageType.Calculated: - // cast string su env.. - EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - Enum.TryParse(env, out envir); - answ = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); - break; - case EgwCoreLib.Lux.Core.Enums.ImageType.ND: - case EgwCoreLib.Lux.Core.Enums.ImageType.Fixed: - answ = $"{apiUrl}/{imgBasePath}/static/{imgUid}"; - break; - default: - break; - } - - return answ; - } - - /// - /// Forza parametri generali selezionati nell'offerta - /// - /// - protected async Task OfferForceParameters() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler impostare i parametri selezionati per l'offerta?")) - return; - // recupero obj dizionario x i parametri compresi... - ParamDict CurrSel = new ParamDict(CurrRecord.DictPresel); - // metto a waiting tutte le righe con bom... - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - await DLService.OffertRowUpdateAwaitStateAsync(item.OfferRowID, true, true); - // poich� non � gestito evento ritorno update window interno si "scassa" --> try catch/ if FALSE - try - { - string rColor = CurrSel.GetVal("Color"); - string rGlass = CurrSel.GetVal("Glass"); - 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.OffertRowUpdateSerStruct(item.OfferRowID, newSerStruct); - } - catch - { } - } - await InvokeAsync(StateHasChanged); - - // verifica preliminare UID - await DLService.OffertRowFixUid(OfferID); - await DLService.OffertRowFixImgType(OfferID); - - // ricalcolo di tutte le BOM e relativi prezzi... - foreach (var item in listCalc) - { - // chiedo BOM e immagine - await callBomUpdate(item); - } - - //await DoRecalcTemplate(); - } - - /// - /// Aggiornamento costing completo: - /// - verifica UID - /// - ricalcolo BOM - /// - update prezzi - /// - /// - protected async Task OfferUpdateAllCosting() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare/validare in toto l'offerta?")) - return; - - // metto a waiting tutte le righe con bom... - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - await DLService.OffertRowUpdateAwaitStateAsync(item.OfferRowID, true, true); - } - await InvokeAsync(StateHasChanged); - - // verifica preliminare UID - await DLService.OffertRowFixUid(OfferID); - await DLService.OffertRowFixImgType(OfferID); - - // fixme todo da riverificare con calcolo BOM funzionante -#if false - // rileggo i record... - await ReloadData(); -#endif - // ricalcolo di tutte le BOM e relativi prezzi... - foreach (var item in listCalc) - { - // chiedo BOM e immagine - await callBomUpdate(item); - } -#if false - await DoRecalcOffer(); -#endif - } - - /// - /// Verifica e ricalcolo dei prezzi degli items nell'offerta - /// - /// - protected async Task OfferUpdatePrices() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare a costi correnti offerta?")) - return; - - await DoRecalcOffer(true); - } - - /// - /// Verifica after render x stato interattivo pagina - /// - /// - protected override void OnAfterRender(bool firstRender) - { - if (firstRender) - { - // JS interop or data fetches go here - isInteractive = true; - } - } - - /// - /// init obj - /// - protected override async Task OnInitializedAsync() - { - ConfInit(); - prevJwd = ""; - await ReloadBaseList(); - DLService.PipeUpdate.EA_NewMessage += PipeUpdate_EA_NewMessage; - DLService.PipePng.EA_NewMessage += PipePng_EA_NewMessage; - DLService.PipeSvg.EA_NewMessage += PipeSvg_EA_NewMessage; - DLService.PipeHwOpt.EA_NewMessage += PipeHwOpt_EA_NewMessage; - DLService.PipeProfElement.EA_NewMessage += PipeProfElement_EA_NewMessage; - DLService.PipeProfList.EA_NewMessage += PipeProfList_EA_NewMessage; - DLService.PipeShape.EA_NewMessage += PipeShape_EA_NewMessage; - } - - protected override async Task OnParametersSetAsync() - { - await DLService.OffertRowFixImgType(OfferID); - await ReloadData(); - UpdateTable(); - } - - /// - /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) - /// - /// - protected async Task RequestBom(OfferRowModel currRec) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) - return; - - await callBomUpdate(currRec); - } - - /// - /// Css di verifica riga selezionata - /// - /// - /// - protected string RowClass(OfferRowModel selRow) - { - return EditRecord != null && EditRecord.OfferRowID == selRow.OfferRowID ? "table-info" : ""; - } - - #endregion Protected Methods - - #region Private Fields - - private static Logger Log = LogManager.GetCurrentClassLogger(); - - /// - /// Boolean selezione prodotto da aggiungere (template) - /// - private bool addFromTemplate = false; - - private List AllColors = new(); - private List AllConfEnvir = new(); - private List AllConfGlass = new(); - private List AllConfHardware = new(); - private List AllConfWood = new(); - private List AllRecords = new List(); - private string apiUrl = ""; - private List AvailColorMaterialList = new List(); - private List AvailFamilyHardwareList = new List(); - private List AvailGlassList = new List(); - private List AvailHardwareList = new(); - private List AvailMaterialList = new List(); - - /// - /// Lista profili da DB - /// - private List AvailProfileList = new(); - - /// - /// Lista profili da Redis (old way) - /// - private List AvailProfileListOld = new List(); - - private Dictionary> AvailThresholdDict = new Dictionary>(); - - /// - /// Base path x network share files - /// - private string basePath = "unsafe_uploads"; - - private string calcTag = "calc"; - private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - - /// - /// Channel update HwOptions - /// - private string chHwOpt = ""; - - /// - /// Channel update PNG - /// - private string chPng = ""; - - /// - /// Channel update Profile List - /// - private string chProfElem = ""; - - /// - /// Channel update Profile List - /// - private string chProfList = ""; - - /// - /// Channel update Shape - /// - private string chShape = ""; - - /// - /// Channel update SVG - /// - private string chSvg = ""; - - private List currAreaProfiles = new(); - private List? CurrBomList = null; - - /// - /// Modalit� editint attiva - /// - private EditMode CurrEditMode = EditMode.None; - - private Dictionary currGroupShape = new(); - private Dictionary currHwOption = new(); - private int currPage = 1; - private string currPng = ""; - private List currProfList = new(); - private string currSvg = ""; - - /// - /// Record in Edit corrente x modifica file/serializzato - /// - private OfferRowModel? EditRecord = null; - - /// - /// Abilita edit massivo record ITEM - /// - private bool enableMassEdit = false; - - private string genericBasePath = ""; - private string imgBasePath = ""; - - /// - /// Semaforo x definire se sia gia in modalita ionterattiva o di prerendering - /// - private bool isInteractive = false; - - private bool isLoading = false; - private List ListAllCatalog = new(); - private List ListCataloghi = new(); - private List ListRecords = new(); - - private List ListTemplateAll = new(); - - private int numRecord = 10; - - /// - /// Versione originale (pre edit) - /// - private string origJwd = ""; - - private List PreparedFile = new(); - - /// - /// Versione precedente JWD x test e confronto - /// - private string prevJwd = ""; - - /// - /// Dizionario richieste - /// - private Dictionary reqDict = new Dictionary(); - - private int totalCount = 0; - - #endregion Private Fields - - #region Private Properties - - private Dictionary> AvailThreshold { get; set; } = new Dictionary>() - { - {"Profilo78", new List() { new Threshold(3, "Bottom")}}, - {"ProfiloSaomad", new List(){ new Threshold(3, "Bottom")}} -#if false - {"Profilo78", new List() { new Threshold(3, "Bottom"), new Threshold(1, "Threshold")}}, - {"ProfiloSaomad", new List(){ new Threshold(3, "Bottom"), new Threshold(2, "BottomWaterdrip"), new Threshold(1, "Threshold")}} -#endif - }; + private IGenValService GVService { get; set; } = default!; [Inject] - private ConfigDataService CDService { get; set; } = null!; + private IWebHostEnvironment HostEnv { get; set; } = default!; [Inject] - private IConfiguration Config { get; set; } = null!; + private ImageCacheService ICService { get; set; } = default!; [Inject] - private CalcRuidService CRService { get; set; } = null!; - - [Inject] - private CalcRequestService CService { get; set; } = null!; - - [Inject] - private IWebHostEnvironment CurrEnv { get; set; } = null!; - - [Inject] - private DataLayerServices DLService { get; set; } = null!; - - [Inject] - private FileService FService { get; set; } = null!; - - /// - /// Costo totale calcolato x offerta - /// - private double GrandTotCost - { - get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalCost) : 0; - } - - [Inject] - private ImageCacheService ICService { get; set; } = null!; - - [Inject] - private IJSRuntime JSRuntime { get; set; } = null!; + private IJSRuntime JSRuntime { get; set; } = default!; /// /// ID Offerta corrente @@ -1068,6 +574,13 @@ namespace Lux.UI.Components.Compo return CloseEdit(infoSave.ForceSave); } + private void ClosePopup() + { + CurrEditMode = EditMode.None; + EditRecord = null; + addFromTemplate = false; + } + private void ConfInit() { basePath = Config.GetValue("ServerConf:FileSharePath") ?? "unsafe_uploads"; @@ -1111,6 +624,233 @@ namespace Lux.UI.Components.Compo } } + /// + /// Aggiunge una nuova riga vuota come nota sotto il record selezionato oppure in coda... + /// + /// + private async Task DoAddNote() + { + int numRow = AllRecords.Count + 1; + if (EditRecord != null) + { + numRow = EditRecord.RowNum + 1; + } + OfferRowModel newNote = new OfferRowModel() + { + OfferID = CurrRecord.OfferID, + Envir = CurrRecord.Envir, + RowNum = numRow, + OfferRowUID = "", + Qty = 0, + BomCost = 0, + BomPrice = 0, + StepCost = 0, + StepPrice = 0 + }; + await DLService.OffertRowUpsert(newNote); + await ReloadData(); + UpdateTable(); + } + + /// + /// Aggiunge una nuova riga ordine in coda... + /// + /// + private async Task DoAddOrderRow(TemplateRowModel selTemplate) + { + int numRow = AllRecords.Count + 1; + if (EditRecord != null) + { + numRow = EditRecord.RowNum + 1; + } + // SOLO SE è un oggetto calcolabile (JWD, BTL...) richiedo update img e BOM + bool needRecalc = (selTemplate.SellingItemNav != null && (selTemplate.SellingItemNav.SourceType == ItemSourceType.Jwd || selTemplate.SellingItemNav.SourceType == ItemSourceType.FileBTL)); + // creo riga! + OfferRowModel newSOR = new OfferRowModel() + { + AwaitBom = needRecalc, + AwaitPrice = needRecalc, + OfferID = CurrRecord.OfferID, + Envir = CurrRecord.Envir, + Inserted = DateTime.Now, + RowNum = numRow, + OfferRowUID = "", + Qty = 1, + SellingItemID = selTemplate.SellingItemID, + SerStruct = selTemplate.SerStruct, + BomCost = 0, + BomPrice = 0, + StepCost = 0, + StepPrice = 0 + }; + // SE FOSSE NON calcolabile aggiungo costi std + if (!needRecalc && selTemplate.SellingItemNav != null) + { + // recupero costi da ancestor + newSOR.BomCost = selTemplate.SellingItemNav?.Cost ?? 0; + newSOR.BomPrice = newSOR.BomCost * (1 + selTemplate.SellingItemNav?.Margin) ?? 1; + newSOR.BomOk = true; + newSOR.ItemOk = true; + newSOR.ProdItemQty = 1; + } + addFromTemplate = false; + var dbRec = await DLService.OffertRowUpsert(newSOR); + // chiamo ricalcolo BOM e IMG... + if (dbRec != null) + { + // SOLO SE è un oggetto calcolabile (JWD, BTL...) richiedo update img e BOM + if (needRecalc) + { + await callBomUpdate(dbRec); + await callImgUpdate(dbRec); + // imposto ad editing record secondo tipo + if (dbRec.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW) + { + DoEditJwd(dbRec); + } + else + { + DoEditFile(dbRec); + } + } + } + await ReloadData(); + UpdateTable(); + } + + /// + /// Annullamento modifica + /// + /// + /// + private async Task DoCancel() + { + isLoading = true; + CurrEditMode = EditMode.None; + EditRecord = null; + await Task.Delay(20); + await DLService.FlushCacheOffersAsync(); + await Task.Delay(20); + await ReloadData(); + UpdateTable(); + isLoading = false; + } + + /// + /// Clona riga richiesta + /// + /// + private async Task DoClone(OfferRowModel rec2clone) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler duplicare la riga corrente?")) + return; + + // calcolo indice riga... + int numRow = totalCount + 1; + OfferRowModel newRec = new OfferRowModel() + { + AwaitBom = true, + AwaitPrice = true, + Envir = rec2clone.Envir, + FileName = rec2clone.FileName, + FileResource = rec2clone.FileResource, + FileSize = rec2clone.FileSize, + Inserted = DateTime.Now, + ItemBOM = rec2clone.ItemBOM, + ItemSteps = rec2clone.ItemSteps, + Modified = DateTime.Now, + Note = rec2clone.Note, + OfferID = OfferID, + OfferRowUID = "", + Qty = rec2clone.Qty, + RowNum = numRow, + SellingItemID = rec2clone.SellingItemID, + SerStruct = rec2clone.SerStruct, + StepCost = rec2clone.StepCost, + StepPrice = rec2clone.StepPrice, + }; + // salvo sul DB + await DLService.OffertRowUpsert(newRec); + // chiamo update record che non hanno UID x questo ordine + await DLService.OffertRowFixImgType(OfferID); + var list2fix = await DLService.OffertRowFixUid(OfferID); + if (list2fix != null && list2fix.Count > 0) + { + // rileggo i miei record... + await ReloadData(); + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + // se UID � tra quelli da ricalcolare... + if (list2fix.Contains(item.OfferRowUID)) + { + // chiedo BOM e immagine + await callBomUpdate(item); + } + } + } + await ReloadData(); + UpdateTable(); + } + + /// + /// Eliminazione riga offerta + /// + /// + /// + private async Task DoDelete(OfferRowModel rec2del) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler eliminare la riga corrente?
Codice: {rec2del.OfferRowUID} | {rec2del.Note} | importo tot: {rec2del.TotalPrice}")) + return; + + await DLService.OffertRowDelete(rec2del); + // elimino cache img + await ICService.DeleteSvgAsync(rec2del.OfferRowUID, rec2del.Envir); + await ReloadData(); + UpdateTable(); + } + + /// + /// Va in edit della riga richiesta + /// + /// + private void DoEdit(OfferRowModel curRec) + { + // imposto edit record + EditRecord = curRec; + /// modalita edit: gestione valori campi record + CurrEditMode = EditMode.RecData; + isLoading = false; + } + + /// + /// Edit del file: + /// - abilitazione fileUpload + /// - anteprima grande (live) + /// + /// + private void DoEditFile(OfferRowModel curRec) + { + EditRecord = curRec; + /// modalit�edit: gestione JWD + CurrEditMode = EditMode.File; + } + + /// + /// Apre editor finestre del record richiesto + /// + /// + private void DoEditJwd(OfferRowModel curRec) + { + EditRecord = curRec; + /// modalit�edit: gestione JWD + CurrEditMode = EditMode.SerStruc; + // preparazione dati da record corrente + PrepareWindowData(EditRecord.SerStruct); + // reset prev + prevJwd = ""; + } + private async Task DoRecalcOffer(bool forceResetCalc) { isLoading = true; @@ -1135,6 +875,63 @@ namespace Lux.UI.Components.Compo await EC_Updated.InvokeAsync(true); } + /// + /// Salvataggio edit record + reload + /// + /// + /// + private async Task DoSave(OfferRowModel curRec) + { + isLoading = true; + // salvo record modificato... + await DLService.OffertRowUpsert(curRec); + // reset + CurrEditMode = EditMode.None; + EditRecord = null; + await DLService.FlushCacheOffersAsync(); + await ReloadData(); + UpdateTable(); + isLoading = false; + } + + /// + /// Seleziono riga senza cambiare modalit� editing + /// + /// + private void DoSelect(OfferRowModel curRec) + { + // imposto edit record + EditRecord = curRec; + /// modalit�edit: gestione valori campi record + CurrEditMode = EditMode.None; + } + + private async Task DoSelectItem() + { + addFromTemplate = true; + ListCataloghi = ListAllCatalog.Where(x => x.Envir == CurrRecord.Envir).ToList(); + } + + /// + /// Imposta modalita edit ciclo di lavoro + /// + /// + private void DoSwapJobCycle(OfferRowModel currRow) + { + CurrEditMode = EditMode.JobCycle; + selectBom(currRow); + } + + /// + /// Imposta modalita ad edit BOM + /// + /// + private void DoSwapMat(OfferRowModel currRow) + { + CurrEditMode = EditMode.BOM; + selectBom(currRow); + } + /// /// Prepara URL x download file JWD /// @@ -1213,6 +1010,151 @@ namespace Lux.UI.Components.Compo isLoading = false; } + /// + /// Display fileSize scalato + /// + /// + /// + private string fSize(long size) + { + return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1); + } + + /// + /// Formattazione testo come html x display + /// + private MarkupString HtmlConv(string rawData) + { + return (MarkupString)rawData.Replace(Environment.NewLine, "
").Replace("\n", "
");//.Replace(" ", " "); + } + + /// + /// Calcolo URL immagine + /// + /// + /// + /// + /// + private string imgUrl(EgwCoreLib.Lux.Core.Enums.ImageType tipoImg, string imgUid, string env) + { + string answ = ""; + switch (tipoImg) + { + case EgwCoreLib.Lux.Core.Enums.ImageType.Calculated: + // cast string su env.. + EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + Enum.TryParse(env, out envir); + answ = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); + break; + + case EgwCoreLib.Lux.Core.Enums.ImageType.ND: + case EgwCoreLib.Lux.Core.Enums.ImageType.Fixed: + answ = $"{apiUrl}/{imgBasePath}/static/{imgUid}"; + break; + + default: + break; + } + + return answ; + } + + /// + /// Forza parametri generali selezionati nell'offerta + /// + /// + private async Task OfferForceParameters() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler impostare i parametri selezionati per l'offerta?")) + return; + // recupero obj dizionario x i parametri compresi... + ParamDict CurrSel = new ParamDict(CurrRecord.DictPresel); + // metto a waiting tutte le righe con bom... + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + await DLService.OffertRowUpdateAwaitStateAsync(item.OfferRowID, true, true); + // poich� non � gestito evento ritorno update window interno si "scassa" --> try catch/ if FALSE + try + { + string rColor = CurrSel.GetVal("Color"); + string rGlass = CurrSel.GetVal("Glass"); + 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.OffertRowUpdateSerStruct(item.OfferRowID, newSerStruct); + } + catch + { } + } + await InvokeAsync(StateHasChanged); + + // verifica preliminare UID + await DLService.OffertRowFixUid(OfferID); + await DLService.OffertRowFixImgType(OfferID); + + // ricalcolo di tutte le BOM e relativi prezzi... + foreach (var item in listCalc) + { + // chiedo BOM e immagine + await callBomUpdate(item); + } + + //await DoRecalcTemplate(); + } + + /// + /// Aggiornamento costing completo: + /// - verifica UID + /// - ricalcolo BOM + /// - update prezzi + /// + /// + private async Task OfferUpdateAllCosting() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare/validare in toto l'offerta?")) + return; + + // metto a waiting tutte le righe con bom... + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + await DLService.OffertRowUpdateAwaitStateAsync(item.OfferRowID, true, true); + } + await InvokeAsync(StateHasChanged); + + // verifica preliminare UID + await DLService.OffertRowFixUid(OfferID); + await DLService.OffertRowFixImgType(OfferID); + + // fixme todo da riverificare con calcolo BOM funzionante +#if false + // rileggo i record... + await ReloadData(); +#endif + // ricalcolo di tutte le BOM e relativi prezzi... + foreach (var item in listCalc) + { + // chiedo BOM e immagine + await callBomUpdate(item); + } +#if false + await DoRecalcOffer(); +#endif + } + + /// + /// Verifica e ricalcolo dei prezzi degli items nell'offerta + /// + /// + private async Task OfferUpdatePrices() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare a costi correnti offerta?")) + return; + + await DoRecalcOffer(true); + } + /// /// Ricevuto HwOpt, processo /// @@ -1516,7 +1458,7 @@ namespace Lux.UI.Components.Compo .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) .ToList(); AllConfWood = await DLService.ConfWoodGetAllAsync(); - AllColors = await DLService.GenValGetFiltAsync("WoodCol"); + AllColors = await GVService.GetFiltAsync("WoodCol"); // conversione tipi AvailGlassList = AllConfGlass .Select(x => x.Description) @@ -1551,6 +1493,83 @@ namespace Lux.UI.Components.Compo } } + /// + /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) + /// + /// + private async Task RequestBom(OfferRowModel currRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) + return; + + await callBomUpdate(currRec); + } + + /// + /// Css di verifica riga selezionata + /// + /// + /// + private string RowClass(OfferRowModel selRow) + { + return EditRecord != null && EditRecord.OfferRowID == selRow.OfferRowID ? "table-info" : ""; + } + +#if false + /// + /// Aggiunge una nuova riga ordine in coda... + /// + /// + protected async Task DoAddOrderRowFromSellItem(int sellItemID) + { + int numRow = AllRecords.Count + 1; + if (EditRecord != null) + { + numRow = EditRecord.RowNum + 1; + } + OfferRowModel newSOR = new OfferRowModel() + { + AwaitBom = true, + AwaitPrice = true, + OfferID = CurrRecord.OfferID, + Envir = CurrRecord.Envir, + Inserted = DateTime.Now, + RowNum = numRow, + OfferRowUID = "", + Qty = 1, + SellingItemID = sellItemID, + BomCost = 0, + BomPrice = 0, + StepCost = 0, + StepPrice = 0 + }; + // se è window aggiungo "{}" come serStruct sennò non la prende bene... + if (CurrRecord.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW) + { + newSOR.SerStruct = "{}"; + } + addFromTemplate = false; + await DLService.OffertRowUpsert(newSOR); + await ReloadData(); + UpdateTable(); + } +#endif +#if false + /// + /// Calcolo URL immagine + /// + /// + /// + /// + protected string imgUrl(string imgUid, string env) + { + // cast string su env.. + EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + Enum.TryParse(env, out envir); + return ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); + } +#endif + /// /// Salvataggio dei dati del file caricato /// diff --git a/Lux.UI/Components/Compo/OrderRowMan.razor.cs b/Lux.UI/Components/Compo/OrderRowMan.razor.cs index dc95e146..0eb8b1ca 100644 --- a/Lux.UI/Components/Compo/OrderRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OrderRowMan.razor.cs @@ -7,6 +7,7 @@ using EgwCoreLib.Lux.Data.DbModel.Production; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.JSInterop; @@ -114,79 +115,8 @@ namespace Lux.UI.Components.Compo #endregion Public Classes - #region Protected Fields - - /// - /// Predisposizione valori live SVG/JWD - /// - protected LivePayload CurrData = new LivePayload(); - - /// - /// Configurazione elenchi anagrafiche - /// - protected BaseListPayload SetupList = new BaseListPayload(); - - #endregion Protected Fields - #region Protected Properties - [Inject] - protected ConfigDataService CDService { get; set; } = null!; - - [Inject] - protected IConfiguration Config { get; set; } = null!; - - [Inject] - protected CalcRuidService CRService { get; set; } = null!; - - [Inject] - protected CalcRequestService CService { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - /// - /// Costo totale calcolato x offerta - /// - protected double GrandTotCost - { - get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalCost) : 0; - } - - /// - /// Margine medio calcolato x offerta - /// - protected double GrandTotMargin - { - get - { - double answ = 0; - if (AllRecords != null && AllRecords.Count > 0) - { - double totPrice = AllRecords.Sum(x => x.TotalPrice); - double totCost = AllRecords.Sum(x => x.TotalCost); - if (totPrice > 0) - { - answ = (totPrice - totCost) / totPrice; - } - } - return answ; - } - } - - protected decimal GrandTotMaxTime - { - get - { - decimal answ = 0; - if (ListRecords != null && ListRecords.Count > 0) - { - answ = ListRecords.Sum(x => x.WorkLoad?.TotMaxTime ?? 0); - } - return answ; - } - } - /// /// Importo totale calcolato x offerta /// @@ -203,453 +133,10 @@ namespace Lux.UI.Components.Compo } } - protected int GrandTotNumKo - { - get - { - int answ = 0; - if (ListRecords != null && ListRecords.Count > 0) - { - answ = ListRecords.Sum(x => x.WorkLoad?.NumKo ?? 0); - } - return answ; - } - } - - protected int GrandTotNumOk - { - get - { - int answ = 0; - if (ListRecords != null && ListRecords.Count > 0) - { - answ = ListRecords.Sum(x => x.WorkLoad?.NumOk ?? 0); - } - return answ; - } - } - - protected int GrandTotNumOkVin - { - get - { - int answ = 0; - if (ListRecords != null && ListRecords.Count > 0) - { - answ = ListRecords.Sum(x => x.WorkLoad?.NumOkVin ?? 0); - } - return answ; - } - } - - /// - /// Importo totale calcolato x offerta - /// - protected double GrandTotPrice - { - get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalPrice) : 0; - } - - /// - /// Num totale obj calcolato x offerta - /// - protected double GrandTotQty - { - get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.Qty) : 0; - } - - [Inject] - protected IWebHostEnvironment HostEnv { get; set; } = null!; - - [Inject] - protected ImageCacheService ICService { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - /// - /// ID Offerta corrente - /// - protected int OrderID - { - get => CurrRecord.OrderID; - } - - [Inject] - protected ProdService PService { get; set; } = null!; - #endregion Protected Properties #region Protected Methods - protected void ClosePopup() - { - CurrEditMode = EditMode.None; - EditRecord = null; - } - - /// - /// Aggiunge una nuova riga vuota come nota sotto il record selezionato oppure in coda... - /// - /// - protected async Task DoAddNote() - { -#if false - int numRow = AllRecords.Count + 1; - if (EditRecord != null) - { - numRow = EditRecord.RowNum + 1; - } - OrderRowModel newNote = new OrderRowModel() - { - OrderID = CurrRecord.OrderID, - Envir = CurrRecord.Envir, - RowNum = numRow, - OrderRowUID = "", - Qty = 0, - BomCost = 0, - BomPrice = 0, - StepCost = 0, - StepPrice = 0 - }; - await DLService.OffertRowUpsert(newNote); -#endif - await ReloadData(); - UpdateTable(); - } - - /// - /// Annullamento modifica - /// - /// - /// - protected async Task DoCancel() - { - isLoading = true; - CurrEditMode = EditMode.None; - EditRecord = null; - await Task.Delay(20); - await DLService.FlushCacheOffersAsync(); - await Task.Delay(20); - await ReloadData(); - UpdateTable(); - isLoading = false; - } - - /// - /// Clona riga richiesta - /// - /// - protected async Task DoClone(OrderRowModel rec2clone) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler duplicare la riga corrente?")) - return; - - // calcolo indice riga... - int numRow = totalCount + 1; - OrderRowModel newRec = new OrderRowModel() - { - AwaitBom = true, - AwaitPrice = true, - Envir = rec2clone.Envir, - FileName = rec2clone.FileName, - FileResource = rec2clone.FileResource, - FileSize = rec2clone.FileSize, - Inserted = DateTime.Now, - ItemBOM = rec2clone.ItemBOM, - ItemSteps = rec2clone.ItemSteps, - Modified = DateTime.Now, - Note = rec2clone.Note, - OrderID = OrderID, - OrderRowUID = "", - Qty = rec2clone.Qty, - RowNum = numRow, - SellingItemID = rec2clone.SellingItemID, - SerStruct = rec2clone.SerStruct, - StepCost = rec2clone.StepCost, - StepPrice = rec2clone.StepPrice, - }; - // salvo sul DB - await DLService.OrderRowUpsert(newRec); - // chiamo update record che non hanno UID x questo ordine - var list2fix = await DLService.OrderRowFixUid(OrderID); - if (list2fix != null && list2fix.Count > 0) - { - // rileggo i miei record... - await ReloadData(); - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - // se UID fosse tra quelli da ricalcolare... - if (list2fix.Contains(item.OrderRowUID)) - { - // chiedo BOM e immagine - await reqBomUpdate(item); - } - } - } - await ReloadData(); - UpdateTable(); - } - - /// - /// Eliminazione riga Ordine - /// - /// - /// - protected async Task DoDelete(OrderRowModel rec2del) - { - 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); - // elimino cache img - await ICService.DeleteSvgAsync(rec2del.OrderRowUID, rec2del.Envir); - await ReloadData(); - UpdateTable(); - } - - /// - /// Va in edit della riga richiesta - /// - /// - protected void DoEdit(OrderRowModel curRec) - { - // imposto edit record - EditRecord = curRec; - /// modalita edit: gestione valori campi record - CurrEditMode = EditMode.RecData; - isLoading = false; - } - - /// - /// Edit del file: - /// - abilitazione fileUpload - /// - anteprima grande (live) - /// - /// - protected void DoEditFile(OrderRowModel curRec) - { - EditRecord = curRec; - /// modalit�edit: gestione JWD - CurrEditMode = EditMode.File; -#if false - // preparazione dati da record corrente - PrepareWindowData(EditRecord.SerStruct); - // reset prev - prevJwd = ""; -#endif - } - - /// - /// Apre editor finestre del record richiesto - /// - /// - protected void DoEditJwd(OrderRowModel curRec) - { - EditRecord = curRec; - /// modalit�edit: gestione JWD - CurrEditMode = EditMode.SerStruc; - // preparazione dati da record corrente - PrepareWindowData(EditRecord.SerStruct); - // reset prev - prevJwd = ""; - } - - /// - /// Salvataggio edit record + reload - /// - /// - /// - protected async Task DoSave(OrderRowModel curRec) - { - isLoading = true; - // salvo record modificato... - await DLService.OrderRowUpsert(curRec); - // reset - CurrEditMode = EditMode.None; - EditRecord = null; - await DLService.FlushCacheOrdersAsync(); - await ReloadData(); - UpdateTable(); - isLoading = false; - } - - /// - /// Seleziono riga senza cambiare modalita editing - /// - /// - protected void DoSelect(OrderRowModel curRec) - { - // imposto edit record - EditRecord = curRec; - /// modalit�edit: gestione valori campi record - CurrEditMode = EditMode.None; - } - - /// - /// Imposta modalita edit ciclo di lavoro - /// - /// - protected void DoSwapJobCycle(OrderRowModel currRow) - { - CurrEditMode = EditMode.JobCycle; - selectBom(currRow); - } - - /// - /// Imposta modalita ad edit BOM - /// - /// - protected void DoSwapMat(OrderRowModel currRow) - { - CurrEditMode = EditMode.BOM; - selectBom(currRow); - } - - /// - /// Formattazione durata - /// - /// - /// - protected string FormatDatetime(decimal durationSec) - { - TimeSpan tsWorkTime = TimeSpan.FromSeconds((double)durationSec); - return DtUtils.FormatDateTime(tsWorkTime); - } - - /// - /// Display fileSize scalato - /// - /// - /// - protected string fSize(long size) - { - return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1); - } - - /// - /// Formattazione testo come html x display - /// - protected MarkupString HtmlConv(string rawData) - { - return (MarkupString)rawData.Replace(Environment.NewLine, "
").Replace("\n", "
");//.Replace(" ", " "); - } - - /// - /// Calcolo URL immagine - /// - /// - /// - /// - protected string imgUrl(string imgUid, string env) - { - // cast string su env.. - EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - Enum.TryParse(env, out envir); - return ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); - } - - /// - /// Conversione record originali/merged - /// - /// - /// - protected List MergeRecord(List origList) - { - var mergedList = AllRecords - .Select(item => new MergedOrderRow - { - Original = item, - WorkLoad = !string.IsNullOrEmpty(item.ProdEstimate) ? WorkLoadDetail(item.OrderRowUID, item.ProdEstimate) : null - }) - .ToList(); - return mergedList; - } - - /// - /// Forza parametri generali selezionati nell'offerta - /// - /// - protected async Task OfferForceParameters() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler impostare i parametri selezionati per l'Ordine?")) - return; - // recupero obj dizionario x i parametri compresi... - ParamDict CurrSel = new ParamDict(CurrRecord.DictPresel); - // metto a waiting tutte le righe con bom... - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - await DLService.OrderRowUpdateAwaitState(item.OrderRowID, true, true); - // poich� non � gestito evento ritorno update window interno si "scassa" --> try catch/ if FALSE - try - { - string rColor = CurrSel.GetVal("Color"); - string rGlass = CurrSel.GetVal("Glass"); - 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); - } - catch - { } - } - await InvokeAsync(StateHasChanged); - - // verifica preliminare UID - await DLService.OrderRowFixUid(OrderID); - - // ricalcolo di tutte le BOM e relativi prezzi... - foreach (var item in listCalc) - { - // chiedo BOM e immagine - await reqBomUpdate(item); - } - - //await DoRecalcOrder(); - } - - /// - /// Aggiornamento costing completo: - /// - verifica UID - /// - ricalcolo BOM - /// - update prezzi - /// - /// - protected async Task OfferUpdateAllCosting() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare/validare in toto l'offerta?")) - return; - - // metto a waiting tutte le righe con bom... - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - await DLService.OrderRowUpdateAwaitState(item.OrderRowID, true, true); - } - await InvokeAsync(StateHasChanged); - - // verifica preliminare UID - await DLService.OffertRowFixUid(OrderID); - await DLService.OffertRowFixImgType(OrderID); - - // fixme todo da riverificare con calcolo BOM funzionante -#if false - // rileggo i record... - await ReloadData(); -#endif - // ricalcolo di tutte le BOM e relativi prezzi... - foreach (var item in listCalc) - { - // chiedo BOM e immagine - await reqBomUpdate(item); - } -#if false - await DoRecalcOrder(); -#endif - } - /// /// Verifica after render x stato interattivo pagina /// @@ -685,182 +172,6 @@ namespace Lux.UI.Components.Compo UpdateTable(); } - /// - /// Verifica e ricalcolo dei prezzi degli items nell'Ordine - /// - /// - protected async Task OrderUpdatePrices() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare Ordine a costi correnti?")) - return; - - await DoRecalcOrder(true); - } - - /// - /// Invio richiesta balance ordine - /// - /// - /// - protected async Task ReqBalance(BalanceReqDto balData) - { - if (WorkLoadRecord != null && balData != null && balData.TagList.Count > 0) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi richiesta bilanciamento carico per {balData.TagList.Count} articoli?")) - return; - - // preparo oggetto richiesta - - // verifico parametri da conf envir... - var envRec = AllConfEnvir.FirstOrDefault(x => x.EnvirID == CurrRecord.Envir); - Egw.Window.Data.Enums.QuestionModes cMode = Egw.Window.Data.Enums.QuestionModes.ORDER; - Egw.Window.Data.Enums.QuestionOrderSubModes cSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.BALANCE; - string reqKey = ""; - // preparo la richiesta di bilanciamento - CalcRequestDTO calcReq = new CalcRequestDTO(); - // elenco tags ricevuto... - List TagList = balData.TagList; - string serTagList = string.Join(",", TagList); - - // preparo richiesta serializzata e la accodo (viene inviata richiesta calcolo) - Dictionary dictArgs = new Dictionary(); - // creo registrazione richiesta... - var ruid = await CRService.AddRequestAsync($"{CurrRecord.Envir}", $"{(int)cMode}-{(int)cSubMode}", WorkLoadRecord.UID); - dictArgs.Add("UID", WorkLoadRecord.UID); - dictArgs.Add("Group", $"99"); - // aggiungo RUID effettivo - dictArgs.Add("RUID", ruid); - dictArgs.Add("OrderUID", CurrRecord.OrderCode); - dictArgs.Add("Mode", $"{(int)cMode}"); - dictArgs.Add("SubMode", $"{(int)cSubMode}"); - dictArgs.Add("TagList", serTagList); - // serializzo la richiesta di bilanciamento... - string reqBalance = JsonConvert.SerializeObject(balData.MachineBalance); - dictArgs.Add("ReqBalance", reqBalance); - dictArgs.Add("BarLenght", $"{balData.BarLenght}"); - calcReq = new CalcRequestDTO() - { - DictExec = dictArgs, - EnvType = CurrRecord.Envir - }; - // chiave: composta da cMode, submode, UID riga... - reqKey = $"{cMode}:{cSubMode}:{WorkLoadRecord.UID}"; - // invio richiesta - await PService.EnqueueRequest("Balance", reqKey, calcReq); - // parto dalla history attuale - var currHist = CurrRecord.LogHistory; - // aggiungo evento... - currHist.Add(new TaskHistDTO() - { - DtEvent = DateTime.Now, - UserName = "Default User", - Message = $"{reqKey}", - IconCss = "fa-solid fa-hourglass-start" - }); - CurrRecord.LogHistory = currHist; - await DLService.OrderUpsert(CurrRecord); - } - } - - /// - /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) - /// - /// - protected async Task RequestBom(OrderRowModel currRec) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) - return; - - await reqBomUpdate(currRec); - } - - /// - /// Rimette da coda running in waiting il Job del WLD corrente - /// - /// - protected async Task ReRunJob() - { - if (WorkLoadRecord != null && SelRecord != null) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler rimettere in coda il calcolo?")) - return; - - string JobCode = $"ORDER:ESTIMATE:{WorkLoadRecord.UID}"; - await PService.ReRunJob(SelRecord.Envir, JobCode); - } - } - - /// - /// Css di verifica riga selezionata - /// - /// - /// - protected string RowClass(OrderRowModel selRow) - { - return EditRecord != null && EditRecord.OrderRowID == selRow.OrderRowID ? "table-info" : ""; - } - -#if false - /// - /// salva dettaglio workload x mostrare elenco valori KO - /// - /// - protected void ShowDetailKo(WorkLoadDetailDTO detailRec) - { - CurrEditMode = EditMode.DetailKO; - EditRecord = null; - WorkLoadRecord = detailRec; - } - - /// - /// salva dettaglio workload x mostrare elenco valori OK - /// - /// - protected void ShowDetailOk(WorkLoadDetailDTO detailRec) - { - CurrEditMode = EditMode.DetailOK; - EditRecord = null; - WorkLoadRecord = detailRec; - } -#endif - - /// - /// salva dettaglio workload x mostrare tipo pezzi richiesti - /// - /// - protected async Task ShowWLD(MergedOrderRow mergeRec, EditMode reqMode) - { - CurrEditMode = reqMode; - EditRecord = null; - SelRecord = mergeRec.Original; - WorkLoadRecord = mergeRec.WorkLoad; - // recupero i prodassign data... - List? curList = await DLService.ProdGroupByOrderRow(SelRecord.OrderRowID); -#if false - // se non avessi tutte le macchine configurate --> chiamo fix! - if (curList == null || curList.Count == 0 || curList.Count < AllProdPlant.Count()) - { - //var currMachLilst = WorkLoadRecord?.ListMachines ?? AllProdPlant.Select(x => x.ProdPlantCod).ToList(); - // metto tutte le macchine configurate, DA DISCUTERE... - var currMachLilst = AllProdPlant.Select(x => x.ProdPlantCod).ToList(); - curList = await DLService.ProdAssignCheckExist(SelRecord.OrderRowID, currMachLilst); - } -#endif - ListProdAssign = curList; - } - - /// - /// Restituisce struttura dettaglio WorkLoad x item - /// - /// - /// - /// - protected WorkLoadDetailDTO WorkLoadDetail(string UID, string rawData) - { - var currWLD = new WorkLoadDetailDTO(UID, rawData); - return currWLD; - } - #endregion Protected Methods #region Private Fields @@ -870,16 +181,27 @@ namespace Lux.UI.Components.Compo private List AllColors = new(); private List AllConfEnvir = new(); + private List AllConfGlass = new(); + private List AllConfHardware = new(); + private List AllConfWood = new(); + private List AllProdPlant = new(); + private List AllRecords = new List(); + private string apiUrl = ""; + private List AvailColorMaterialList = new List(); + private List AvailFamilyHardwareList = new List(); + private List AvailGlassList = new List(); + private List AvailHardwareList = new(); + private List AvailMaterialList = new List(); /// @@ -898,6 +220,7 @@ namespace Lux.UI.Components.Compo private string basePath = "unsafe_uploads"; private string calcTag = "calc"; + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; /// @@ -927,15 +250,24 @@ namespace Lux.UI.Components.Compo private List? CurrBomList = null; + /// + /// Predisposizione valori live SVG/JWD + /// + private LivePayload CurrData = new LivePayload(); + /// /// Modalit� editint attiva /// private EditMode CurrEditMode = EditMode.None; private Dictionary currGroupShape = new Dictionary(); + private Dictionary currHwOption = new Dictionary(); + private int currPage = 1; + private string currPng = ""; + private string currSvg = ""; /// @@ -949,6 +281,7 @@ namespace Lux.UI.Components.Compo private bool enableMassEdit = false; private string genericBasePath = ""; + private string imgBasePath = ""; /// @@ -957,8 +290,11 @@ namespace Lux.UI.Components.Compo private bool isInteractive = false; private bool isLoading = false; + private List? ListProdAssign = null; + private List ListRecords = new List(); + private int numRecord = 10; /// @@ -977,7 +313,14 @@ namespace Lux.UI.Components.Compo private Dictionary reqDict = new Dictionary(); private OrderRowModel? SelRecord = null; + + /// + /// Configurazione elenchi anagrafiche + /// + private BaseListPayload SetupList = new BaseListPayload(); + private int totalCount = 0; + private WorkLoadDetailDTO? WorkLoadRecord = null; #endregion Private Fields @@ -994,6 +337,141 @@ namespace Lux.UI.Components.Compo #endif }; + [Inject] + private ConfigDataService CDService { get; set; } = null!; + + [Inject] + private IConfiguration Config { get; set; } = null!; + + [Inject] + private CalcRuidService CRService { get; set; } = null!; + + [Inject] + private CalcRequestService CService { get; set; } = null!; + + [Inject] + private DataLayerServices DLService { get; set; } = null!; + + /// + /// Costo totale calcolato x offerta + /// + private double GrandTotCost + { + get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalCost) : 0; + } + + /// + /// Margine medio calcolato x offerta + /// + private double GrandTotMargin + { + get + { + double answ = 0; + if (AllRecords != null && AllRecords.Count > 0) + { + double totPrice = AllRecords.Sum(x => x.TotalPrice); + double totCost = AllRecords.Sum(x => x.TotalCost); + if (totPrice > 0) + { + answ = (totPrice - totCost) / totPrice; + } + } + return answ; + } + } + + private decimal GrandTotMaxTime + { + get + { + decimal answ = 0; + if (ListRecords != null && ListRecords.Count > 0) + { + answ = ListRecords.Sum(x => x.WorkLoad?.TotMaxTime ?? 0); + } + return answ; + } + } + + private int GrandTotNumKo + { + get + { + int answ = 0; + if (ListRecords != null && ListRecords.Count > 0) + { + answ = ListRecords.Sum(x => x.WorkLoad?.NumKo ?? 0); + } + return answ; + } + } + + private int GrandTotNumOk + { + get + { + int answ = 0; + if (ListRecords != null && ListRecords.Count > 0) + { + answ = ListRecords.Sum(x => x.WorkLoad?.NumOk ?? 0); + } + return answ; + } + } + + private int GrandTotNumOkVin + { + get + { + int answ = 0; + if (ListRecords != null && ListRecords.Count > 0) + { + answ = ListRecords.Sum(x => x.WorkLoad?.NumOkVin ?? 0); + } + return answ; + } + } + + /// + /// Importo totale calcolato x offerta + /// + private double GrandTotPrice + { + get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalPrice) : 0; + } + + /// + /// Num totale obj calcolato x offerta + /// + private double GrandTotQty + { + get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.Qty) : 0; + } + + [Inject] + private IGenValService GVService { get; set; } = default!; + + [Inject] + private IWebHostEnvironment HostEnv { get; set; } = null!; + + [Inject] + private ImageCacheService ICService { get; set; } = null!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + /// + /// ID Offerta corrente + /// + private int OrderID + { + get => CurrRecord.OrderID; + } + + [Inject] + private ProdService PService { get; set; } = null!; + #endregion Private Properties #region Private Methods @@ -1091,6 +569,12 @@ namespace Lux.UI.Components.Compo return CloseEdit(infoSave.ForceSave); } + private void ClosePopup() + { + CurrEditMode = EditMode.None; + EditRecord = null; + } + private void ConfInit() { basePath = Config.GetValue("ServerConf:FileSharePath") ?? "unsafe_uploads"; @@ -1145,6 +629,174 @@ namespace Lux.UI.Components.Compo } } + /// + /// Aggiunge una nuova riga vuota come nota sotto il record selezionato oppure in coda... + /// + /// + private async Task DoAddNote() + { +#if false + int numRow = AllRecords.Count + 1; + if (EditRecord != null) + { + numRow = EditRecord.RowNum + 1; + } + OrderRowModel newNote = new OrderRowModel() + { + OrderID = CurrRecord.OrderID, + Envir = CurrRecord.Envir, + RowNum = numRow, + OrderRowUID = "", + Qty = 0, + BomCost = 0, + BomPrice = 0, + StepCost = 0, + StepPrice = 0 + }; + await DLService.OffertRowUpsert(newNote); +#endif + await ReloadData(); + UpdateTable(); + } + + /// + /// Annullamento modifica + /// + /// + /// + private async Task DoCancel() + { + isLoading = true; + CurrEditMode = EditMode.None; + EditRecord = null; + await Task.Delay(20); + await DLService.FlushCacheOffersAsync(); + await Task.Delay(20); + await ReloadData(); + UpdateTable(); + isLoading = false; + } + + /// + /// Clona riga richiesta + /// + /// + private async Task DoClone(OrderRowModel rec2clone) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler duplicare la riga corrente?")) + return; + + // calcolo indice riga... + int numRow = totalCount + 1; + OrderRowModel newRec = new OrderRowModel() + { + AwaitBom = true, + AwaitPrice = true, + Envir = rec2clone.Envir, + FileName = rec2clone.FileName, + FileResource = rec2clone.FileResource, + FileSize = rec2clone.FileSize, + Inserted = DateTime.Now, + ItemBOM = rec2clone.ItemBOM, + ItemSteps = rec2clone.ItemSteps, + Modified = DateTime.Now, + Note = rec2clone.Note, + OrderID = OrderID, + OrderRowUID = "", + Qty = rec2clone.Qty, + RowNum = numRow, + SellingItemID = rec2clone.SellingItemID, + SerStruct = rec2clone.SerStruct, + StepCost = rec2clone.StepCost, + StepPrice = rec2clone.StepPrice, + }; + // salvo sul DB + await DLService.OrderRowUpsert(newRec); + // chiamo update record che non hanno UID x questo ordine + var list2fix = await DLService.OrderRowFixUid(OrderID); + if (list2fix != null && list2fix.Count > 0) + { + // rileggo i miei record... + await ReloadData(); + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + // se UID fosse tra quelli da ricalcolare... + if (list2fix.Contains(item.OrderRowUID)) + { + // chiedo BOM e immagine + await reqBomUpdate(item); + } + } + } + await ReloadData(); + UpdateTable(); + } + + /// + /// Eliminazione riga Ordine + /// + /// + /// + private async Task DoDelete(OrderRowModel rec2del) + { + 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); + // elimino cache img + await ICService.DeleteSvgAsync(rec2del.OrderRowUID, rec2del.Envir); + await ReloadData(); + UpdateTable(); + } + + /// + /// Va in edit della riga richiesta + /// + /// + private void DoEdit(OrderRowModel curRec) + { + // imposto edit record + EditRecord = curRec; + /// modalita edit: gestione valori campi record + CurrEditMode = EditMode.RecData; + isLoading = false; + } + + /// + /// Edit del file: + /// - abilitazione fileUpload + /// - anteprima grande (live) + /// + /// + private void DoEditFile(OrderRowModel curRec) + { + EditRecord = curRec; + /// modalit�edit: gestione JWD + CurrEditMode = EditMode.File; +#if false + // preparazione dati da record corrente + PrepareWindowData(EditRecord.SerStruct); + // reset prev + prevJwd = ""; +#endif + } + + /// + /// Apre editor finestre del record richiesto + /// + /// + private void DoEditJwd(OrderRowModel curRec) + { + EditRecord = curRec; + /// modalit�edit: gestione JWD + CurrEditMode = EditMode.SerStruc; + // preparazione dati da record corrente + PrepareWindowData(EditRecord.SerStruct); + // reset prev + prevJwd = ""; + } + private async Task DoRecalcOrder(bool forceResetCalc) { isLoading = true; @@ -1169,6 +821,57 @@ namespace Lux.UI.Components.Compo await EC_Updated.InvokeAsync(true); } + /// + /// Salvataggio edit record + reload + /// + /// + /// + private async Task DoSave(OrderRowModel curRec) + { + isLoading = true; + // salvo record modificato... + await DLService.OrderRowUpsert(curRec); + // reset + CurrEditMode = EditMode.None; + EditRecord = null; + await DLService.FlushCacheOrdersAsync(); + await ReloadData(); + UpdateTable(); + isLoading = false; + } + + /// + /// Seleziono riga senza cambiare modalita editing + /// + /// + private void DoSelect(OrderRowModel curRec) + { + // imposto edit record + EditRecord = curRec; + /// modalit�edit: gestione valori campi record + CurrEditMode = EditMode.None; + } + + /// + /// Imposta modalita edit ciclo di lavoro + /// + /// + private void DoSwapJobCycle(OrderRowModel currRow) + { + CurrEditMode = EditMode.JobCycle; + selectBom(currRow); + } + + /// + /// Imposta modalita ad edit BOM + /// + /// + private void DoSwapMat(OrderRowModel currRow) + { + CurrEditMode = EditMode.BOM; + selectBom(currRow); + } + /// /// Salvataggio del JWD aggiornato nella mia riga di offerta /// @@ -1250,6 +953,49 @@ namespace Lux.UI.Components.Compo isLoading = false; } + /// + /// Formattazione durata + /// + /// + /// + private string FormatDatetime(decimal durationSec) + { + TimeSpan tsWorkTime = TimeSpan.FromSeconds((double)durationSec); + return DtUtils.FormatDateTime(tsWorkTime); + } + + /// + /// Display fileSize scalato + /// + /// + /// + private string fSize(long size) + { + return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1); + } + + /// + /// Formattazione testo come html x display + /// + private MarkupString HtmlConv(string rawData) + { + return (MarkupString)rawData.Replace(Environment.NewLine, "
").Replace("\n", "
");//.Replace(" ", " "); + } + + /// + /// Calcolo URL immagine + /// + /// + /// + /// + private string imgUrl(string imgUid, string env) + { + // cast string su env.. + EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + Enum.TryParse(env, out envir); + return ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); + } + /// /// Restituisce il contenuto del file salvato /// @@ -1278,6 +1024,118 @@ namespace Lux.UI.Components.Compo return answ; } + /// + /// Conversione record originali/merged + /// + /// + /// + private List MergeRecord(List origList) + { + var mergedList = AllRecords + .Select(item => new MergedOrderRow + { + Original = item, + WorkLoad = !string.IsNullOrEmpty(item.ProdEstimate) ? WorkLoadDetail(item.OrderRowUID, item.ProdEstimate) : null + }) + .ToList(); + return mergedList; + } + + /// + /// Forza parametri generali selezionati nell'offerta + /// + /// + private async Task OfferForceParameters() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler impostare i parametri selezionati per l'Ordine?")) + return; + // recupero obj dizionario x i parametri compresi... + ParamDict CurrSel = new ParamDict(CurrRecord.DictPresel); + // metto a waiting tutte le righe con bom... + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + await DLService.OrderRowUpdateAwaitState(item.OrderRowID, true, true); + // poich� non � gestito evento ritorno update window interno si "scassa" --> try catch/ if FALSE + try + { + string rColor = CurrSel.GetVal("Color"); + string rGlass = CurrSel.GetVal("Glass"); + 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); + } + catch + { } + } + await InvokeAsync(StateHasChanged); + + // verifica preliminare UID + await DLService.OrderRowFixUid(OrderID); + + // ricalcolo di tutte le BOM e relativi prezzi... + foreach (var item in listCalc) + { + // chiedo BOM e immagine + await reqBomUpdate(item); + } + + //await DoRecalcOrder(); + } + + /// + /// Aggiornamento costing completo: + /// - verifica UID + /// - ricalcolo BOM + /// - update prezzi + /// + /// + private async Task OfferUpdateAllCosting() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare/validare in toto l'offerta?")) + return; + + // metto a waiting tutte le righe con bom... + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + await DLService.OrderRowUpdateAwaitState(item.OrderRowID, true, true); + } + await InvokeAsync(StateHasChanged); + + // verifica preliminare UID + await DLService.OffertRowFixUid(OrderID); + await DLService.OffertRowFixImgType(OrderID); + + // fixme todo da riverificare con calcolo BOM funzionante +#if false + // rileggo i record... + await ReloadData(); +#endif + // ricalcolo di tutte le BOM e relativi prezzi... + foreach (var item in listCalc) + { + // chiedo BOM e immagine + await reqBomUpdate(item); + } +#if false + await DoRecalcOrder(); +#endif + } + + /// + /// Verifica e ricalcolo dei prezzi degli items nell'Ordine + /// + /// + private async Task OrderUpdatePrices() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare Ordine a costi correnti?")) + return; + + await DoRecalcOrder(true); + } + /// /// Ricevuto HwOpt, processo /// @@ -1538,7 +1396,7 @@ namespace Lux.UI.Components.Compo .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) .ToList(); AllConfWood = await DLService.ConfWoodGetAllAsync(); - AllColors = await DLService.GenValGetFiltAsync("WoodCol"); + AllColors = await GVService.GetFiltAsync("WoodCol"); // conversione tipi AvailGlassList = AllConfGlass .Select(x => x.Description) @@ -1596,6 +1454,71 @@ namespace Lux.UI.Components.Compo return answ; } + /// + /// Invio richiesta balance ordine + /// + /// + /// + private async Task ReqBalance(BalanceReqDto balData) + { + if (WorkLoadRecord != null && balData != null && balData.TagList.Count > 0) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi richiesta bilanciamento carico per {balData.TagList.Count} articoli?")) + return; + + // preparo oggetto richiesta + + // verifico parametri da conf envir... + var envRec = AllConfEnvir.FirstOrDefault(x => x.EnvirID == CurrRecord.Envir); + Egw.Window.Data.Enums.QuestionModes cMode = Egw.Window.Data.Enums.QuestionModes.ORDER; + Egw.Window.Data.Enums.QuestionOrderSubModes cSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.BALANCE; + string reqKey = ""; + // preparo la richiesta di bilanciamento + CalcRequestDTO calcReq = new CalcRequestDTO(); + // elenco tags ricevuto... + List TagList = balData.TagList; + string serTagList = string.Join(",", TagList); + + // preparo richiesta serializzata e la accodo (viene inviata richiesta calcolo) + Dictionary dictArgs = new Dictionary(); + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{CurrRecord.Envir}", $"{(int)cMode}-{(int)cSubMode}", WorkLoadRecord.UID); + dictArgs.Add("UID", WorkLoadRecord.UID); + dictArgs.Add("Group", $"99"); + // aggiungo RUID effettivo + dictArgs.Add("RUID", ruid); + dictArgs.Add("OrderUID", CurrRecord.OrderCode); + dictArgs.Add("Mode", $"{(int)cMode}"); + dictArgs.Add("SubMode", $"{(int)cSubMode}"); + dictArgs.Add("TagList", serTagList); + // serializzo la richiesta di bilanciamento... + string reqBalance = JsonConvert.SerializeObject(balData.MachineBalance); + dictArgs.Add("ReqBalance", reqBalance); + dictArgs.Add("BarLenght", $"{balData.BarLenght}"); + calcReq = new CalcRequestDTO() + { + DictExec = dictArgs, + EnvType = CurrRecord.Envir + }; + // chiave: composta da cMode, submode, UID riga... + reqKey = $"{cMode}:{cSubMode}:{WorkLoadRecord.UID}"; + // invio richiesta + await PService.EnqueueRequest("Balance", reqKey, calcReq); + // parto dalla history attuale + var currHist = CurrRecord.LogHistory; + // aggiungo evento... + currHist.Add(new TaskHistDTO() + { + DtEvent = DateTime.Now, + UserName = "Default User", + Message = $"{reqKey}", + IconCss = "fa-solid fa-hourglass-start" + }); + CurrRecord.LogHistory = currHist; + await DLService.OrderUpsert(CurrRecord); + } + } + /// /// Effettua vera richiesta della BOM /// @@ -1651,6 +1574,34 @@ namespace Lux.UI.Components.Compo await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{currRec.OrderRowUID}", req); } + /// + /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) + /// + /// + private async Task RequestBom(OrderRowModel currRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) + return; + + await reqBomUpdate(currRec); + } + + /// + /// Rimette da coda running in waiting il Job del WLD corrente + /// + /// + private async Task ReRunJob() + { + if (WorkLoadRecord != null && SelRecord != null) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler rimettere in coda il calcolo?")) + return; + + string JobCode = $"ORDER:ESTIMATE:{WorkLoadRecord.UID}"; + await PService.ReRunJob(SelRecord.Envir, JobCode); + } + } + /// /// Esegue reset assegnazioni /// @@ -1662,6 +1613,16 @@ namespace Lux.UI.Components.Compo await ForceOrderReload(OrderRowID); } + /// + /// Css di verifica riga selezionata + /// + /// + /// + private string RowClass(OrderRowModel selRow) + { + return EditRecord != null && EditRecord.OrderRowID == selRow.OrderRowID ? "table-info" : ""; + } + /// /// Salvataggio dei dati del file caricato /// @@ -1784,6 +1745,31 @@ namespace Lux.UI.Components.Compo return answ; } + /// + /// salva dettaglio workload x mostrare tipo pezzi richiesti + /// + /// + private async Task ShowWLD(MergedOrderRow mergeRec, EditMode reqMode) + { + CurrEditMode = reqMode; + EditRecord = null; + SelRecord = mergeRec.Original; + WorkLoadRecord = mergeRec.WorkLoad; + // recupero i prodassign data... + List? curList = await DLService.ProdGroupByOrderRow(SelRecord.OrderRowID); +#if false + // se non avessi tutte le macchine configurate --> chiamo fix! + if (curList == null || curList.Count == 0 || curList.Count < AllProdPlant.Count()) + { + //var currMachLilst = WorkLoadRecord?.ListMachines ?? AllProdPlant.Select(x => x.ProdPlantCod).ToList(); + // metto tutte le macchine configurate, DA DISCUTERE... + var currMachLilst = AllProdPlant.Select(x => x.ProdPlantCod).ToList(); + curList = await DLService.ProdAssignCheckExist(SelRecord.OrderRowID, currMachLilst); + } +#endif + ListProdAssign = curList; + } + /// /// Elenco SalesOfferRows calcolabili: /// - contengono serializzazione come JWD @@ -1848,12 +1834,6 @@ namespace Lux.UI.Components.Compo isLoading = false; } - /// - /// Esegue lettura file + invio richiesta specifica - /// - /// - /// - private async Task UploadFile(InputFileChangeEventArgs e) { // Proseguo solo se sono in interattivo (NO prerender pagina) @@ -1905,6 +1885,24 @@ namespace Lux.UI.Components.Compo } } + /// + /// Restituisce struttura dettaglio WorkLoad x item + /// + /// + /// + /// + private WorkLoadDetailDTO WorkLoadDetail(string UID, string rawData) + { + var currWLD = new WorkLoadDetailDTO(UID, rawData); + return currWLD; + } + #endregion Private Methods + + /// + /// Esegue lettura file + invio richiesta specifica + /// + /// + /// } } \ No newline at end of file diff --git a/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs b/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs index 5045d6e9..c13c51f4 100644 --- a/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs +++ b/Lux.UI/Components/Compo/Templates/TemplateRowList.razor.cs @@ -5,6 +5,7 @@ using EgwCoreLib.Lux.Data.DbModel.Items; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.JSInterop; @@ -36,6 +37,9 @@ namespace Lux.UI.Components.Compo.Templates [Parameter] public DisplayMode DisplayMode { get; set; } = DisplayMode.Standard; + [Parameter] + public EventCallback EC_ReqFullPage { get; set; } + /// /// Callback invocato al select /// @@ -45,9 +49,6 @@ namespace Lux.UI.Components.Compo.Templates [Parameter] public EventCallback EC_Updated { get; set; } - [Parameter] - public EventCallback EC_ReqFullPage { get; set; } - #endregion Public Properties #region Public Methods @@ -70,67 +71,6 @@ namespace Lux.UI.Components.Compo.Templates #region Protected Methods - /// - /// Display fileSize scalato - /// - /// - /// - protected string fSize(long size) - { - return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1); - } - - /// - /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) - /// - /// - protected async Task RequestBom(TemplateRowModel currRec) - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) - return; - - await reqBomUpdate(currRec); - } - - /// - /// Aggiornamento costing completo: - /// - verifica UID - /// - ricalcolo BOM - /// - update prezzi - /// - /// - protected async Task OfferUpdateAllCosting() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare/validare in toto i Template del gruppo?")) - return; - - // metto a waiting tutte le righe con bom... - var listCalc = SorListCalc(); - foreach (var item in listCalc) - { - await DLService.TemplateRowUpdateAwaitStateAsync(item.TemplateRowID, true, true); - } - await InvokeAsync(StateHasChanged); - - // verifica preliminare UID - await DLService.TemplateRowFixUid(TemplateID); - - // fixme todo da riverificare con calcolo BOM funzionante -#if false - // rileggo i record... - await ReloadData(); -#endif - // ricalcolo di tutte le BOM e relativi prezzi... - foreach (var item in listCalc) - { - // chiedo BOM e immagine - await reqBomUpdate(item); - } -#if false - await DoRecalcOffer(); -#endif - } - /// /// Verifica after render x stato interattivo pagina /// @@ -334,6 +274,9 @@ namespace Lux.UI.Components.Compo.Templates [Inject] private DataLayerServices DLService { get; set; } = null!; + [Inject] + private IGenValService GVService { get; set; } = default!; + [Inject] private ImageCacheService ICService { get; set; } = null!; @@ -746,21 +689,15 @@ namespace Lux.UI.Components.Compo.Templates return $"TP-{objID:X8}"; } -#if false /// - /// Calcolo URL immagine + /// Display fileSize scalato /// - /// - /// + /// /// - private string imgUrl(string imgUid, string env) + private string fSize(long size) { - // cast string su env.. - EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; - Enum.TryParse(env, out envir); - return ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); + return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1); } -#endif /// /// Calcolo URL immagine @@ -780,10 +717,12 @@ namespace Lux.UI.Components.Compo.Templates Enum.TryParse(env, out envir); answ = ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); break; + case Enums.ImageType.ND: case Enums.ImageType.Fixed: answ = $"{apiUrl}/{imgBasePath}/static/{imgUid}"; break; + default: break; } @@ -819,6 +758,45 @@ namespace Lux.UI.Components.Compo.Templates return answ; } + /// + /// Aggiornamento costing completo: + /// - verifica UID + /// - ricalcolo BOM + /// - update prezzi + /// + /// + private async Task OfferUpdateAllCosting() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare/validare in toto i Template del gruppo?")) + return; + + // metto a waiting tutte le righe con bom... + var listCalc = SorListCalc(); + foreach (var item in listCalc) + { + await DLService.TemplateRowUpdateAwaitStateAsync(item.TemplateRowID, true, true); + } + await InvokeAsync(StateHasChanged); + + // verifica preliminare UID + await DLService.TemplateRowFixUid(TemplateID); + + // fixme todo da riverificare con calcolo BOM funzionante +#if false + // rileggo i record... + await ReloadData(); +#endif + // ricalcolo di tutte le BOM e relativi prezzi... + foreach (var item in listCalc) + { + // chiedo BOM e immagine + await reqBomUpdate(item); + } +#if false + await DoRecalcOffer(); +#endif + } + /// /// Ricevuto HwOpt, processo /// @@ -1073,18 +1051,13 @@ namespace Lux.UI.Components.Compo.Templates } AvailProfileListOld = rawProfiles; -#if false - // dizionario dei profili soglia - AvailThresholdDict = CDService.ProfileThreshDict(cEnvir); -#endif - var rawHw = CDService.HwModelList(cEnvir, "HW.AGB"); // hw filtro solo validi... AllConfHardware = rawHw .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) .ToList(); AllConfWood = await DLService.ConfWoodGetAllAsync(); - AllColors = await DLService.GenValGetFiltAsync("WoodCol"); + AllColors = await GVService.GetFiltAsync("WoodCol"); // conversione tipi AvailGlassList = AllConfGlass .Select(x => x.Description) @@ -1236,6 +1209,34 @@ namespace Lux.UI.Components.Compo.Templates } } + /// + /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) + /// + /// + private async Task RequestBom(TemplateRowModel currRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) + return; + + await reqBomUpdate(currRec); + } + +#if false + /// + /// Calcolo URL immagine + /// + /// + /// + /// + private string imgUrl(string imgUid, string env) + { + // cast string su env.. + EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS envir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + Enum.TryParse(env, out envir); + return ICService.ImageUrl($"{apiUrl}/{imgBasePath}", false, imgUid, envir); + } +#endif + /// /// Salvataggio dei dati del file caricato /// diff --git a/Lux.UI/Components/Pages/Offers.razor.cs b/Lux.UI/Components/Pages/Offers.razor.cs index 51bbcba3..53606a2d 100644 --- a/Lux.UI/Components/Pages/Offers.razor.cs +++ b/Lux.UI/Components/Pages/Offers.razor.cs @@ -439,7 +439,7 @@ namespace Lux.UI.Components.Pages private async Task ReloadData() { await DLService.OffersCheckExpired(); - //AllRecordsRedis = await DLService.OfferGetAll(); + //AllRecordsRedis = await GVService.OfferGetAll(); AllRecords = await DLService.OfferGetFilt(PeriodoSel.Inizio, PeriodoSel.Fine); DoFilter(); } diff --git a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs index 29c06748..bf6ba4b0 100644 --- a/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs +++ b/Lux.UI/Components/Pages/WorkLoadBalance.razor.cs @@ -4,14 +4,10 @@ using EgwCoreLib.Lux.Data.DbModel.Production; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwCoreLib.Lux.Data.Services; +using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Cors.Infrastructure; -using Microsoft.AspNetCore.DataProtection; -using Microsoft.AspNetCore.Http.HttpResults; using Microsoft.JSInterop; using Newtonsoft.Json; -using System.Diagnostics.Eventing.Reader; -using System.Threading.Tasks; using static EgwCoreLib.Lux.Core.Enums; using static Lux.UI.Components.Compo.Planner.BalanceProgGroup; @@ -31,25 +27,6 @@ namespace Lux.UI.Components.Pages #endregion Public Methods - #region Protected Properties - - [Inject] - protected CalcRuidService CRService { get; set; } = null!; - - [Inject] - protected CalcRequestService CService { get; set; } = null!; - - [Inject] - protected DataLayerServices DLService { get; set; } = null!; - - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - - [Inject] - protected ProdService PService { get; set; } = null!; - - #endregion Protected Properties - #region Protected Methods protected override void OnInitialized() @@ -64,16 +41,20 @@ namespace Lux.UI.Components.Pages #region Private Fields private List? currBomList = null; + private List? currDefaultSet = null; + private Dictionary>? currDictItem = null; + /// /// Oggetto ODL con assegnazione item x richiesta prod /// private OdlAssignDto? currOdlAssign = null; - private Dictionary>? currDictItem = null; private List? ListBalancedRecords = null; + private List? ListEstimRecords = null; + private List? ListOdl = null; /// @@ -85,6 +66,28 @@ namespace Lux.UI.Components.Pages #endregion Private Fields + #region Private Properties + + [Inject] + private CalcRuidService CRService { get; set; } = null!; + + [Inject] + private CalcRequestService CService { get; set; } = null!; + + [Inject] + private DataLayerServices DLService { get; set; } = null!; + + [Inject] + private IGenValService GVService { get; set; } = default!; + + [Inject] + private IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + private ProdService PService { get; set; } = null!; + + #endregion Private Properties + #region Private Methods private async Task DoBalance(int OrderRowID) @@ -352,7 +355,7 @@ namespace Lux.UI.Components.Pages } } // sistemo i valori di default, qui un pò "cablati"... - currDefaultSet = await DLService.GenValGetFiltAsync("DefaultLenghtBW"); + currDefaultSet = await GVService.GetFiltAsync("DefaultLenghtBW"); // salvo info Dizionario + odlRec così da mostrare finestra modale selezione barre... currOdlAssign = odlRec; } diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index c597497b..9a790ff3 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 - 1.1.2603.1412 + 1.1.2603.1416 diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs index e1bd9e43..c75b59fa 100644 --- a/Lux.UI/Program.cs +++ b/Lux.UI/Program.cs @@ -200,9 +200,11 @@ builder.Services.AddScoped(); // Repository con interfaccia builder.Services.AddScoped(); +builder.Services.AddScoped(); // Servizi dati con interfaccia builder.Services.AddScoped(); +builder.Services.AddScoped(); // Da rivedere!!! #if false diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index fb1defdc..f18c2f65 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2603.1412

+

Versione: 1.1.2603.1416


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 519d5386..2014d644 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2603.1412 +1.1.2603.1416 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 94596b73..dc4346dd 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2603.1412 + 1.1.2603.1416 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false