Update componente window x display corretto

This commit is contained in:
Samuele Locatelli
2026-03-20 10:41:52 +01:00
parent 252f07cb29
commit 669b5b36f1
14 changed files with 137 additions and 367 deletions
+2 -2
View File
@@ -8,8 +8,8 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageVersion>
<PackageVersion Include="Egw.Lux.WebWindow.Base" Version="3.1.3.1610" />
<PackageVersion Include="Egw.Lux.WebWindowComplex" Version="3.1.3.1610" />
<PackageVersion Include="Egw.Lux.WebWindow.Base" Version="3.1.3.2010" />
<PackageVersion Include="Egw.Lux.WebWindowComplex" Version="3.1.3.2010" />
<PackageVersion Include="Egw.Window.Data" Version="2.8.1.2611" />
<PackageVersion Include="EgwCoreLib.Razor" Version="1.5.2511.312" />
<PackageVersion Include="EgwCoreLib.Utils" Version="1.5.2511.312" />
@@ -1,5 +1,4 @@
using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Core.RestPayload;
using EgwCoreLib.Lux.Core.RestPayload;
using EgwCoreLib.Lux.Data.DbModel.Items;
using EgwCoreLib.Lux.Data.DbModel.Job;
using EgwCoreLib.Lux.Data.DbModel.Production;
@@ -220,204 +219,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
#endif
/// <summary>
/// Add record del solo ProdEstimate
/// </summary>
/// <param name="uID"></param>
/// <param name="prodEstim"></param>
#if false
internal async Task<bool> OrderRowUpsertProdEst(string uID, string prodEstim)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
{
// recupero offerta...
var currRec = dbCtx
.DbSetOrderRow
.Where(x => x.OrderRowUID == uID)
.FirstOrDefault();
// se trovo aggiorno
if (currRec != null)
{
// genero WLD x controllo
var currWLD = new WorkLoadDetailDTO(currRec.OrderRowUID, currRec.ProdEstimate);
// faccio update in cascata dei record collegati x macchine e items
var listMachDb = dbCtx
.DbSetProdPlant
.Select(x => x.ProdPlantCod)
.ToList();
List<string> listMaccCurr = currWLD.MachineCalcResults.Select(x => x.Name).OrderBy(x => x).ToList() ?? new List<string>();
if (listMaccCurr != null && listMaccCurr.Any())
{
var listDiff = listMaccCurr.Except(listMachDb).ToList();
if (listDiff.Any())
{
foreach (var macch in listDiff)
{
dbCtx
.DbSetProdPlant
.Add(new ProductionPlantModel() { ProdPlantCod = macch, ProdPlantDescript = macch });
}
}
}
// resetta assegnazioni prodgroup agli items...
List<ProductionItemModel> listItem2upd = await dbCtx
.DbSetProdItem
.Where(x => x.OrderRowID == currRec.OrderRowID && x.ProdGroupID != null)
.ToListAsync();
if (listItem2upd != null && listItem2upd.Count > 0)
{
// li aggiorna tutti resettando ProdGroupID
listItem2upd.ForEach(x => x.ProdGroupID = null);
}
// elimina eventuali oggetti ProductionGroup precedenti
List<ProductionGroupModel> listProdGroup2Rem = await dbCtx
.DbSetProdGroup
.Where(x => x.OrderRowID == currRec.OrderRowID)
.ToListAsync();
// rimuovo...
if (listProdGroup2Rem != null && listProdGroup2Rem.Count > 0)
{
dbCtx.DbSetProdGroup.RemoveRange(listProdGroup2Rem);
}
/*----------------------------------
* Generazione ProdGroup
* FixMe ToDo !!!
*
* rifare considerando le REALI combinazioni scaturite x questo specifico caso e
* - ENUMERARE le combinazioni
* - ogni combinazione sarà un caso specifico tra 0...N dove N è il totale delle macchine gestite
* - i successivi calcoli di balance/stima saranno fatti x questo SPECIFICO ID GROUP così da fare prima... a sto punto GroupIP potrebbe essere un int 0...n oppure l'id del record... forse meglio il counter 0..n
*
* */
int grpIdx = 1;
// preparo x add nuovi ProductionGroup da analisi ritorno stime
List<ProductionGroupModel> listProdGroup2Add = new List<ProductionGroupModel>();
// 1: non lavorabili...
if (currWLD.ListUnWorkable.Count > 0)
{
// calcolo il dizionario degli elementi...
Dictionary<string, ProdMachineDetailDto> newWorkGroupList = new();
ProdMachineDetailDto detProd = new ProdMachineDetailDto()
{
TagList = currWLD.ListUnWorkable
};
newWorkGroupList.Add("", detProd);
string rawWGL = JsonConvert.SerializeObject(newWorkGroupList);
ProductionGroupModel newRec = new ProductionGroupModel()
{
OrderRowID = currRec.OrderRowID,
GrpIdx = grpIdx++,
WorkGroupListRaw = rawWGL
};
listProdGroup2Add.Add(newRec);
}
// dizionario x macchina delle parts LAVORABILI su impianto..
var machineTags = currWLD.MachineCalcResults
.ToDictionary(
m => m.Name,
m => m.PartList
.Where(p => p.CalcResult == EgwCoreLib.Lux.Core.Enums.PartVerificationResult.MACHINABLE)
.ToList()
);
// ciclo x tutte le combinazioni di gruppi lavorabilità...
foreach (var item in currWLD.LoadDetail)
{
// calcolo il dizionario degli elementi...
Dictionary<string, ProdMachineDetailDto> newWorkGroupList = new();
foreach (var machineName in item.Machines)
{
decimal effectiveTime = 0;
// Recuperiamo i dati della macchina dal dizionario
if (machineTags.TryGetValue(machineName, out var machineParts))
{
// Creiamo un set dei tag del gruppo per una ricerca veloce O(1)
var groupTagsSet = item.Tags.ToHashSet();
// Sommiamo il tempo solo per i pezzi che appartengono a questo gruppo
effectiveTime = machineParts
.Where(p => groupTagsSet.Contains(p.Tag))
.Sum(p => p.Time);
}
ProdMachineDetailDto detProd = new ProdMachineDetailDto()
{
TagList = item.Tags,
Time = effectiveTime // Tempo reale specifico per questa macchina/gruppo
};
newWorkGroupList.Add(machineName, detProd);
}
string rawWGL = JsonConvert.SerializeObject(newWorkGroupList);
ProductionGroupModel newRec = new ProductionGroupModel()
{
OrderRowID = currRec.OrderRowID,
GrpIdx = grpIdx++,
WorkGroupListRaw = rawWGL
};
listProdGroup2Add.Add(newRec);
}
// aggiungo i record...
dbCtx.DbSetProdGroup.AddRange(listProdGroup2Add);
// aggiorno info Estimation, tempi e stato
currRec.ProdEstimate = prodEstim;
if (!string.IsNullOrEmpty(prodEstim))
{
currRec.OrderRowState = OrderStates.Estimated;
}
var totEstim = listProdGroup2Add.Sum(x => x.TotalEstimTime);
currRec.ProdEstimTime = totEstim;
dbCtx.Entry(currRec).State = EntityState.Modified;
}
// salvo TUTTI i cambiamenti...
var result = await dbCtx.SaveChangesAsync();
answ = result > 0;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante OrderRowUpsertProdEst{Environment.NewLine}{exc}");
}
}
return answ;
}
/// <summary>
/// Validazione record:
/// - controllo state vs estimate
/// - segnala il numero dei record aggiornati
/// </summary>
/// <param name="list2chk">Elenco record da verificare</param>
internal async Task<int> OrderRowListValidate(List<OrderRowModel> list2chk)
{
int numDone = 0;
// verifica preliminare: serve SSE stato e estimate non corrispondono...
var list2fix = list2chk
.Where(x => x.OrderRowState == OrderStates.Created && !string.IsNullOrEmpty(x.ProdEstimate))
.ToList();
if (list2fix.Any())
{
// per ogni record processo intera validazione
foreach (var item in list2fix)
{
bool fatto = await OrderRowUpsertProdEst(item.OrderRowUID, item.ProdEstimate);
numDone += fatto ? 1 : 0;
}
}
return numDone;
}
#endif
/// <summary>
/// Elenco record Fasi da DB
/// </summary>
@@ -442,6 +243,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
#if false
/// <summary>
/// Add record di un singolo ProdGroup da fase Balance
/// </summary>
@@ -515,7 +317,8 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
}
return answ;
}
}
#endif
#if true
/// <summary>
@@ -602,106 +405,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
#endif
#if false
/// <summary>
/// Esegue merge dei dati nella tab profili del DB con le info accessorie...
/// </summary>
/// <param name="uID"></param>
/// <param name="execEnvironment"></param>
/// <param name="rawContent"></param>
/// <returns></returns>
internal async Task<bool> SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
// solo se ho qualcosa da controllare...
if (!string.IsNullOrEmpty(rawContent))
{
// in primis recupero profili attuali
var dbList = await dbCtx
.DbSetConfProfile
.ToListAsync();
// ciclo sul contenuto ricevuto, se mancasse aggiungo!
List<string> list2check = JsonConvert.DeserializeObject<List<string>>(rawContent) ?? new List<string>();
List<ProfileModel> rec2ins = new List<ProfileModel>();
foreach (var item in list2check)
{
if (!dbList.Any(x => x.Code == item))
{
rec2ins.Add(new ProfileModel() { Code = item, Description = $"{item} - NEW" });
}
}
// se ho dati li inserisco...
if (rec2ins.Count > 0)
{
dbCtx.DbSetConfProfile.AddRange(rec2ins);
// salvo...
int numDone = await dbCtx.SaveChangesAsync();
answ = numDone > 0;
}
}
}
return answ;
}
#endif
#if false
/// <summary>
/// Salvataggio info serializzate x soglie e dati opzionali sul DB
/// </summary>
/// <param name="uID"></param>
/// <param name="execEnvironment"></param>
/// <param name="rawThreshold"></param>
/// <param name="rawData"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
internal async Task<bool> SaveProfileThreshAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawThreshold, string rawData)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
// solo se ho qualcosa da controllare...
if (!string.IsNullOrEmpty(rawThreshold) || !string.IsNullOrEmpty(rawData))
{
// in primis recupero profilo da aggiornare
var dbRec = await dbCtx
.DbSetConfProfile
.Where(x => x.Code == uID)
.FirstOrDefaultAsync();
// se ho record aggiorno...
if (dbRec != null)
{
dbRec.ProfDataRaw = rawData;
dbRec.ThreshDataRaw = rawThreshold;
dbCtx.Entry(dbRec).State = EntityState.Modified;
}
// alrimenti creo + aggiorno
else
{
dbCtx.DbSetConfProfile.Add(new ProfileModel()
{
Code = uID,
Description = $"{uID} - NEW PROFILE",
ProfDataRaw = rawData,
ThreshDataRaw = rawThreshold
});
}
// salvo...
int numDone = await dbCtx.SaveChangesAsync();
answ = numDone > 0;
}
}
return answ;
}
#endif
/// <summary>
/// Elenco da DB delel stats aggregate dato periodo inizio/fine
/// </summary>
@@ -9,5 +9,6 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
Task<List<ProductionGroupModel>> GetByOrderStateAsync(OrderStates reqState);
Task<bool> UpsertBalanceAsync(string uID, string rGroup, string rawBalance);
}
}
@@ -1,5 +1,7 @@
using EgwCoreLib.Lux.Data.DbModel.Production;
using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Data.DbModel.Production;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using static EgwCoreLib.Lux.Core.Enums;
namespace EgwCoreLib.Lux.Data.Repository.Production
@@ -45,6 +47,87 @@ namespace EgwCoreLib.Lux.Data.Repository.Production
.ToListAsync();
}
/// <summary>
/// Add record di un singolo ProdGroup da fase Balance
/// </summary>
/// <param name="uID">UID dell'item offerta di cui si è ricevuto l'oggetto Balance'</param>
/// <param name="rGroup">Prod Group di riferimento</param>
/// <param name="rawBalance"></param>
public async Task<bool> UpsertBalanceAsync(string uID, string rGroup, string rawBalance)
{
bool answ = false;
// Add validation for null or empty list
if (string.IsNullOrWhiteSpace(uID) ||
string.IsNullOrWhiteSpace(rGroup) ||
string.IsNullOrWhiteSpace(rawBalance))
{
return answ;
}
await using var dbCtx = await CreateContextAsync();
await using var tx = dbCtx.Database.BeginTransaction();
try
{
// Tentativo di deserializzazione
var data = JsonConvert.DeserializeObject<Dictionary<string, ProdMachineDetailDto>>(rawBalance);
// proseguo solo se è valida la deserializzazione...
if (data != null)
{
// Togliamo la 'G' e convertiamo in int (gestisce automaticamente "01" -> 1)
int grpIdx = int.Parse(rGroup.TrimStart('G'));
// recupero ord row (parent)...
var ordRowRec = dbCtx
.DbSetOrderRow
.Where(x => x.OrderRowUID == uID)
.FirstOrDefault();
if (ordRowRec != null)
{
// recupero record specifico
var currRec = dbCtx
.DbSetProdGroup
.Where(x => x.OrderRowID == ordRowRec.OrderRowID && x.GrpIdx == grpIdx)
.FirstOrDefault();
// se trovato aggiorno
if (currRec != null)
{
currRec.WorkGroupListRaw = rawBalance;
dbCtx.Entry(currRec).State = EntityState.Modified;
}
// altrimenti aggiungo
else
{
ProductionGroupModel newRec = new ProductionGroupModel()
{
OrderRowID = ordRowRec.OrderRowID,
GrpIdx = grpIdx,
WorkGroupListRaw = rawBalance
};
dbCtx
.DbSetProdGroup
.Add(newRec);
}
// segno ordine come Assigned se non lo fosse...
if (ordRowRec.OrderRowState != OrderStates.Assigned)
{
ordRowRec.OrderRowState = OrderStates.Assigned;
dbCtx.Entry(ordRowRec).State = EntityState.Modified;
}
// salvo TUTTI i cambiamenti...
answ = await dbCtx.SaveChangesAsync() > 0;
}
}
return answ;
}
catch
{
tx.Rollback();
throw;
}
}
#endregion Public Methods
}
}
@@ -56,6 +56,7 @@ namespace EgwCoreLib.Lux.Data.Services
public IConfProfileService ConfProfServ => _serviceProvider.GetRequiredService<IConfProfileService>();
public IOfferRowService OfferRowServ => _serviceProvider.GetRequiredService<IOfferRowService>();
public IOrderRowService OrderRowServ => _serviceProvider.GetRequiredService<IOrderRowService>();
public IProductionGroupService PrGrpServ => _serviceProvider.GetRequiredService<IProductionGroupService>();
public IProductionOdlService PrOdlServ => _serviceProvider.GetRequiredService<IProductionOdlService>();
#endregion Public Properties
@@ -343,29 +344,10 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task SaveHmlAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
{
// non effettuo salvataggio sul DB perché master del dato è esterno e lo lasceremo solo in cache REDIS
await Task.Delay(1);
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(rawContent))
{
try
{
// non effettuo salvataggio sul DB perché master del dato è esterno e lo lasceremo solo in cache REDIS
await Task.Delay(1);
}
catch (Exception exc)
{
string exMsg = $"Eccezione durante SaveHmlAsync | uID: {uID} | envir: {execEnvironment}";
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 }
}));
}
}
string source = "NONE";
activity?.SetTag("data.source", source);
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
}
@@ -378,18 +360,10 @@ namespace EgwCoreLib.Lux.Data.Services
/// <param name="execEnvironment">Environment dell'item</param>
/// <param name="balance">Stima Balance serializzata</param>
/// <returns></returns>
public async Task SaveProdBalanceAsync(string uID, string rGroup, Constants.EXECENVIRONMENTS execEnvironment, string balance)
public async Task<bool> SaveProdBalanceAsync(string uID, string rGroup, Constants.EXECENVIRONMENTS execEnvironment, string balance)
{
using var activity = StartActivity();
string source = "DB";
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(balance))
{
// salvo info balance nel record del DB relativo all'oggetto richiesto
await dbController.ProdGroupUpsertBalance(uID, rGroup, balance);
}
activity?.SetTag("data.source", source);
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
var result = await PrGrpServ.UpsertBalanceAsync(uID, rGroup, balance);
return result;
}
/// <summary>
@@ -638,29 +612,6 @@ namespace EgwCoreLib.Lux.Data.Services
private new static Logger Log = LogManager.GetCurrentClassLogger();
private readonly IServiceProvider _serviceProvider;
#if false
/// <summary>
/// Validazione record:
/// - controllo state vs estimate
/// - segnala il numero dei record aggiornati
/// </summary>
/// <param name="list2chk">Elenco record da verificare</param>
public async Task<int> OrderRowListValidate(List<OrderRowModel> list2chk)
{
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
int numDone = await dbController.OrderRowListValidate(list2chk);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*");
activity?.SetTag("data.source", source);
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return numDone;
}
#endif
private string redisBaseKey = "Lux:Cache";
#endregion Private Fields
@@ -8,5 +8,7 @@ namespace EgwCoreLib.Lux.Data.Services.Production
Task<List<ProductionGroupModel>> GetByOrderRowAsync(int orderRowID);
Task<List<ProductionGroupModel>> GetByOrderStateAsync(OrderStates reqState);
Task<bool> UpsertBalanceAsync(string uID, string rGroup, string rawBalance);
}
}
@@ -47,6 +47,36 @@ namespace EgwCoreLib.Lux.Data.Services.Production
});
}
/// <summary>
/// Esegue salvataggio ProdBalance (di un gruppo lavorazioni per riga ordine) sul DB
/// </summary>
/// <param name="uID">UID dell'item offerta di cui si è ricevuto l'oggetto Balance'</param>
/// <param name="rGroup">Prod Group di riferimento</param>
/// <param name="execEnvironment">Environment dell'item</param>
/// <param name="balance">Stima Balance serializzata</param>
/// <returns></returns>
public async Task<bool> UpsertBalanceAsync(string uID, string rGroup, string rawBalance)
{
return await TraceAsync($"{_className}.UpsertBalance", async (activity) =>
{
string operation = "UpsertBalance";
bool success = false;
if (string.IsNullOrWhiteSpace(uID) || string.IsNullOrWhiteSpace(rGroup) || string.IsNullOrWhiteSpace(rawBalance))
return false;
success = await _repo.UpsertBalanceAsync(uID, rGroup, rawBalance);
activity?.SetTag("db.operation", operation);
if (success)
{
await ClearCacheAsync($"{_redisBaseKey}:{_className}");
}
return success;
});
}
#endregion Public Methods
#region Private Fields
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2603.2008</Version>
<Version>1.1.2603.2010</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1461,7 +1461,7 @@ namespace Lux.UI.Components.Compo
CurrData = new LivePayload()
{
CurrJwd = currJwd,
SvgPreview = currSvg
SvgPreview = "" //currSvg
};
}
@@ -1042,7 +1042,7 @@ namespace Lux.UI.Components.Compo.Templates
CurrData = new LivePayload()
{
CurrJwd = currJwd,
SvgPreview = currSvg
SvgPreview = "" //currSvg
};
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>1.1.2603.2008</Version>
<Version>1.1.2603.2010</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2603.2008</h4>
<h4>Versione: 1.1.2603.2010</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2603.2008
1.1.2603.2010
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2603.2008</version>
<version>1.1.2603.2010</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>