diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index 6a409cbe..01666d64 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -2194,6 +2194,55 @@ namespace EgwCoreLib.Lux.Data.Controllers } return answ; } + /// + /// Aggiornamento valore ImgType da tipo Prodotto sellingItem ancestor + /// + /// + /// + internal async Task OffertRowFixImgTypeAsync(int offertID) + { + bool answ = false; + //using (DataLayerContext dbCtx = new DataLayerContext(_config)) + using (DataLayerContext dbCtx = new DataLayerContext()) + { +#if false + try + { +#endif + var currList = await dbCtx + .DbSetOfferRow + .Where(x => x.OfferID == offertID) + .Include(s => s.SellingItemNav) + .ToListAsync(); + // se trovato --> verifico valori differenti, aggiorno e restituisco da calcolare + if (currList != null) + { + var list2fix = currList.Where(x => x.ImgType == ImageType.ND).ToList(); + if (list2fix != null && list2fix.Count > 0) + { + // sistemo ImgType + foreach (var item in list2fix) + { + // se รจ calcolato il selling item --> img calcolata + if (item.SellingItemNav != null && (item.SellingItemNav.SourceType == ItemSourceType.Jwd || item.SellingItemNav.SourceType == ItemSourceType.FileBTL)) + item.ImgType = ImageType.Calculated; + dbCtx.Entry(item).State = EntityState.Modified; + } + // salvo... + var result = await dbCtx.SaveChangesAsync(); + answ = result > 0; + } + } +#if false + } + catch (Exception exc) + { + Log.Error($"Eccezione durante OffertRowFixUid{Environment.NewLine}{exc}"); + } +#endif + } + return answ; + } /// /// Effettua update stato await BOM/PRICE per l'offerta indicata diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index 29e5e0a9..8d13f81c 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -1258,6 +1258,42 @@ namespace EgwCoreLib.Lux.Data.Services return answ; } + /// + /// Aggiornamento valore UID non calcolato + ritorno elenco UID da aggiornare + /// + /// + /// + public async Task OffertRowFixImgType(int OffertID) + { + using var activity = StartActivity(); + string source = "DB+REDIS"; + bool answ = false; + try + { + // calcolo + answ = await dbController.OffertRowFixImgTypeAsync(OffertID); + // svuoto cache... + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); + } + catch (Exception exc) + { + string exMsg = $"Eccezione durante OffertRowFixImgType"; + LogTrace($"{exMsg}{Environment.NewLine}{exc}", LogLevel.Error); + // traccio errore + activity?.SetStatus(ActivityStatusCode.Error, exc.Message); + activity?.AddEvent(new ActivityEvent("exception", tags: new ActivityTagsCollection { + { "exception.type", exc.GetType().Name }, + { "exception.message", exc.Message }, + { "exception.stacktrace", exc.StackTrace } + })); + } + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + return answ; + } + + /// /// Effettua update stato await BOM/PRICE per l'offerta indicata /// @@ -1376,6 +1412,7 @@ namespace EgwCoreLib.Lux.Data.Services { // sistemo UID... await OffertRowFixUid(updRec.OfferID); + await OffertRowFixImgType(updRec.OfferID); dbResult = await dbController.OfferRowGetByIdAsync(updRec.OfferRowID); } else diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor b/Lux.UI/Components/Compo/OfferRowMan.razor index 94d0a7b0..95e867d3 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor +++ b/Lux.UI/Components/Compo/OfferRowMan.razor @@ -35,18 +35,17 @@ else
- +
-
+ @*
-
-
-
- Dettaglio Offerta +
*@
+ @*
+
*@
@if (DisplayMode == DisplayMode.Edit) { @@ -155,20 +154,20 @@ else @if (DisplayMode == DisplayMode.Edit) { - @* rifare gestione switch tipo obj!!!! *@ @if (isBuy) { - + @* *@ + } else { @if (item.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW) { - + } else { - + } } diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index 97b7ff53..903ccc4b 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -55,12 +55,12 @@ namespace Lux.UI.Components.Compo /// /// Predisposizione valori live SVG/JWD /// - protected LivePayload CurrData = new LivePayload(); + private LivePayload CurrData = new LivePayload(); /// /// Configurazione elenchi anagrafiche /// - protected BaseListPayload SetupList = new BaseListPayload(); + private BaseListPayload SetupList = new BaseListPayload(); #endregion Protected Fields @@ -69,7 +69,7 @@ namespace Lux.UI.Components.Compo /// /// Margine medio calcolato x offerta /// - protected double GrandTotMargin + private double GrandTotMargin { get { @@ -90,7 +90,7 @@ namespace Lux.UI.Components.Compo /// /// Importo totale calcolato x offerta /// - protected double GrandTotNumItems + private double GrandTotNumItems { get { @@ -106,7 +106,7 @@ namespace Lux.UI.Components.Compo /// /// Importo totale calcolato x offerta /// - protected double GrandTotPrice + private double GrandTotPrice { get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.TotalPrice) : 0; } @@ -114,19 +114,19 @@ namespace Lux.UI.Components.Compo /// /// Num totale obj calcolato x offerta /// - protected double GrandTotQty + private double GrandTotQty { get => AllRecords != null && AllRecords.Count > 0 ? AllRecords.Sum(x => x.Qty) : 0; } [Inject] - protected IWebHostEnvironment HostEnv { get; set; } = null!; + private IWebHostEnvironment HostEnv { get; set; } = null!; #endregion Protected Properties #region Protected Methods - protected void ClosePopup() + private void ClosePopup() { CurrEditMode = EditMode.None; EditRecord = null; @@ -311,6 +311,7 @@ namespace Lux.UI.Components.Compo // 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) { @@ -464,6 +465,7 @@ namespace Lux.UI.Components.Compo return (MarkupString)rawData.Replace(Environment.NewLine, "
").Replace("\n", "
");//.Replace(" ", " "); } +#if false /// /// Calcolo URL immagine /// @@ -476,6 +478,36 @@ namespace Lux.UI.Components.Compo 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; } /// @@ -510,6 +542,7 @@ namespace Lux.UI.Components.Compo // verifica preliminare UID await DLService.OffertRowFixUid(OfferID); + await DLService.OffertRowFixImgType(OfferID); // ricalcolo di tutte le BOM e relativi prezzi... foreach (var item in listCalc) @@ -543,6 +576,7 @@ namespace Lux.UI.Components.Compo // verifica preliminare UID await DLService.OffertRowFixUid(OfferID); + await DLService.OffertRowFixImgType(OfferID); // fixme todo da riverificare con calcolo BOM funzionante #if false @@ -604,6 +638,7 @@ namespace Lux.UI.Components.Compo protected override async Task OnParametersSetAsync() { + await DLService.OffertRowFixImgType(OfferID); await ReloadData(); UpdateTable(); } diff --git a/Lux.UI/Components/Compo/OrderRowMan.razor.cs b/Lux.UI/Components/Compo/OrderRowMan.razor.cs index 1bd1eeee..dc95e146 100644 --- a/Lux.UI/Components/Compo/OrderRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OrderRowMan.razor.cs @@ -632,6 +632,7 @@ namespace Lux.UI.Components.Compo // verifica preliminare UID await DLService.OffertRowFixUid(OrderID); + await DLService.OffertRowFixImgType(OrderID); // fixme todo da riverificare con calcolo BOM funzionante #if false