Ancora update x fix imgType
This commit is contained in:
@@ -2194,6 +2194,55 @@ namespace EgwCoreLib.Lux.Data.Controllers
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Aggiornamento valore ImgType da tipo Prodotto sellingItem ancestor
|
||||
/// </summary>
|
||||
/// <param name="offertID"></param>
|
||||
/// <returns></returns>
|
||||
internal async Task<bool> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Effettua update stato await BOM/PRICE per l'offerta indicata
|
||||
|
||||
@@ -1258,6 +1258,42 @@ namespace EgwCoreLib.Lux.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Aggiornamento valore UID non calcolato + ritorno elenco UID da aggiornare
|
||||
/// </summary>
|
||||
/// <param name="offertID"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> 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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Effettua update stato await BOM/PRICE per l'offerta indicata
|
||||
/// </summary>
|
||||
@@ -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
|
||||
|
||||
@@ -35,18 +35,17 @@ else
|
||||
<div class="card-header bg-success bg-opacity-50 bg-gradient d-flex justify-content-between">
|
||||
<div class="px-0 d-flex">
|
||||
<div class="px-1">
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoSelectItem()">Prodotto <i class="fa-solid fa-plus"></i></button>
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoSelectItem()">Prodotto a Catalogo <i class="fa-solid fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="px-1">
|
||||
<button class="btn btn-sm btn-success" @onclick="() => DoAddNote()">Nota <i class="fa-solid fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="px-1">
|
||||
@* <div class="px-1">
|
||||
<button class="btn btn-sm btn-success" @onclick="() => ForceReloadData()">Articolo (buy) <i class="fa-solid fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-0 text-center fs-4">
|
||||
Dettaglio Offerta
|
||||
</div> *@
|
||||
</div>
|
||||
@* <div class="px-0 text-center fs-4">
|
||||
</div> *@
|
||||
<div class="px-0 d-flex justify-content-end">
|
||||
@if (DisplayMode == DisplayMode.Edit)
|
||||
{
|
||||
@@ -155,20 +154,20 @@ else
|
||||
@if (DisplayMode == DisplayMode.Edit)
|
||||
{
|
||||
<td>
|
||||
@* <i>rifare gestione switch tipo obj!!!!</i> *@
|
||||
@if (isBuy)
|
||||
{
|
||||
<img class="img-fluid image-hover-pop p-1" src="@($"images/SellingItemID_{item.SellingItemID:00}.png")" width="64" />
|
||||
@* <img class="img-fluid image-hover-pop p-1" src="@($"images/SellingItemID_{item.SellingItemID:00}.png")" width="64" /> *@
|
||||
<img class="img-fluid image-hover-pop p-1" src="@(imgUrl(item.ImgType, item.ImgUID, $"{item.Envir}"))" width="64" @onclick="() => DoEditJwd(item)" title="Edit Item" />
|
||||
}
|
||||
else
|
||||
{
|
||||
@if (item.Envir == EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW)
|
||||
{
|
||||
<img class="img-fluid image-hover-pop p-1" src="@(imgUrl(item.OfferRowUID, $"{item.Envir}"))" width="64" @onclick="() => DoEditJwd(item)" title="Edit Item" />
|
||||
<img class="img-fluid image-hover-pop p-1" src="@(imgUrl(item.ImgType, item.ImgUID, $"{item.Envir}"))" width="64" @onclick="() => DoEditJwd(item)" title="Edit Item" />
|
||||
}
|
||||
else
|
||||
{
|
||||
<img class="img-fluid image-hover-pop" src="@(imgUrl(item.OfferRowUID, $"{item.Envir}"))" width="150" @onclick="() => DoEditFile(item)" title="Edit Item" />
|
||||
<img class="img-fluid image-hover-pop" src="@(imgUrl(item.ImgType, item.ImgUID, $"{item.Envir}"))" width="150" @onclick="() => DoEditFile(item)" title="Edit Item" />
|
||||
}
|
||||
}
|
||||
</td>
|
||||
|
||||
@@ -55,12 +55,12 @@ namespace Lux.UI.Components.Compo
|
||||
/// <summary>
|
||||
/// Predisposizione valori live SVG/JWD
|
||||
/// </summary>
|
||||
protected LivePayload CurrData = new LivePayload();
|
||||
private LivePayload CurrData = new LivePayload();
|
||||
|
||||
/// <summary>
|
||||
/// Configurazione elenchi anagrafiche
|
||||
/// </summary>
|
||||
protected BaseListPayload SetupList = new BaseListPayload();
|
||||
private BaseListPayload SetupList = new BaseListPayload();
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Lux.UI.Components.Compo
|
||||
/// <summary>
|
||||
/// Margine medio calcolato x offerta
|
||||
/// </summary>
|
||||
protected double GrandTotMargin
|
||||
private double GrandTotMargin
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -90,7 +90,7 @@ namespace Lux.UI.Components.Compo
|
||||
/// <summary>
|
||||
/// Importo totale calcolato x offerta
|
||||
/// </summary>
|
||||
protected double GrandTotNumItems
|
||||
private double GrandTotNumItems
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace Lux.UI.Components.Compo
|
||||
/// <summary>
|
||||
/// Importo totale calcolato x offerta
|
||||
/// </summary>
|
||||
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
|
||||
/// <summary>
|
||||
/// Num totale obj calcolato x offerta
|
||||
/// </summary>
|
||||
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, "<br />").Replace("\n", "<br />");//.Replace(" ", " ");
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Calcolo URL immagine
|
||||
/// </summary>
|
||||
@@ -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
|
||||
|
||||
/// <summary>
|
||||
/// Calcolo URL immagine
|
||||
/// </summary>
|
||||
/// <param name="tipoImg"></param>
|
||||
/// <param name="imgUid"></param>
|
||||
/// <param name="env"></param>
|
||||
/// <returns></returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user