Completo spostamento Utils.GenClass eUtils. GenVal da oggetti generici a repository/servizi specializzati e separati

This commit is contained in:
Samuele Locatelli
2026-03-14 16:09:11 +01:00
parent 0ec8015d68
commit ae634079f9
18 changed files with 1667 additions and 1640 deletions
@@ -601,7 +601,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
return answ;
}
#endif
/// <summary>
/// Esegue eliminazione
@@ -768,6 +767,8 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
return answ;
}
#endif
/// <summary>
/// Eliminazione record item
@@ -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
@@ -579,7 +579,6 @@ namespace EgwCoreLib.Lux.Data.Services
LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
#endif
/// <summary>
/// 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
/// <summary>
/// Eliminazione record item
@@ -82,7 +82,7 @@ namespace EgwCoreLib.Lux.Data.Services.Utils
public async Task<bool> 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);
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2603.1412</Version>
<Version>1.1.2603.1416</Version>
</PropertyGroup>
<ItemGroup>
+4 -4
View File
@@ -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);
}
+21 -26
View File
@@ -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
}
/// <summary>
@@ -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);
}
/// <summary>
/// Esegue spostamento
/// </summary>
/// <param name="curRec"></param>
/// <param name="moveUp"></param>
/// <returns></returns>
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;
}
/// <summary>
/// Esegue spostamento
/// </summary>
/// <param name="curRec"></param>
/// <param name="moveUp"></param>
/// <returns></returns>
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();
}
/// <summary>
+68 -60
View File
@@ -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!;
/// <summary>
/// Gestione selezione Colore
/// </summary>
protected string SelColor
{
get => CurrSel.GetVal("Color");
set => CurrSel.SetVal("Color", value);
}
/// <summary>
/// Gestione selezione Glass
/// </summary>
protected string SelGlass
{
get => CurrSel.GetVal("Glass");
set => CurrSel.SetVal("Glass", value);
}
/// <summary>
/// Gestione selezione Profile
/// </summary>
protected string SelProfile
{
get => CurrSel.GetVal("Profile");
set => CurrSel.SetVal("Profile", value);
}
/// <summary>
/// Gestione selezione Wood
/// </summary>
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<string> ListColors = new List<string>();
@@ -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!;
/// <summary>
/// Gestione selezione Colore
/// </summary>
private string SelColor
{
get => CurrSel.GetVal("Color");
set => CurrSel.SetVal("Color", value);
}
/// <summary>
/// Gestione selezione Glass
/// </summary>
private string SelGlass
{
get => CurrSel.GetVal("Glass");
set => CurrSel.SetVal("Glass", value);
}
/// <summary>
/// Gestione selezione Profile
/// </summary>
private string SelProfile
{
get => CurrSel.GetVal("Profile");
set => CurrSel.SetVal("Profile", value);
}
/// <summary>
/// Gestione selezione Wood
/// </summary>
private string SelWood
{
get => CurrSel.GetVal("Wood");
set => CurrSel.SetVal("Wood", value);
}
#endregion Private Properties
#region Private Methods
/// <summary>
@@ -173,17 +181,17 @@ namespace Lux.UI.Components.Compo
calcTag = Config.GetValue<string>("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
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -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<bool> EC_ReqFullPage { get; set; }
/// <summary>
/// Callback invocato al select
/// </summary>
@@ -45,9 +49,6 @@ namespace Lux.UI.Components.Compo.Templates
[Parameter]
public EventCallback<bool> EC_Updated { get; set; }
[Parameter]
public EventCallback<bool> EC_ReqFullPage { get; set; }
#endregion Public Properties
#region Public Methods
@@ -70,67 +71,6 @@ namespace Lux.UI.Components.Compo.Templates
#region Protected Methods
/// <summary>
/// Display fileSize scalato
/// </summary>
/// <param name="size"></param>
/// <returns></returns>
protected string fSize(long size)
{
return EgwCoreLib.Utils.FileHelpers.SizeSuffix(size, 1);
}
/// <summary>
/// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente)
/// </summary>
/// <returns></returns>
protected async Task RequestBom(TemplateRowModel currRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler ricalcolare la BOM?"))
return;
await reqBomUpdate(currRec);
}
/// <summary>
/// Aggiornamento costing completo:
/// - verifica UID
/// - ricalcolo BOM
/// - update prezzi
/// </summary>
/// <returns></returns>
protected async Task OfferUpdateAllCosting()
{
if (!await JSRuntime.InvokeAsync<bool>("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
}
/// <summary>
/// Verifica after render x stato interattivo pagina
/// </summary>
@@ -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
/// <summary>
/// Calcolo URL immagine
/// Display fileSize scalato
/// </summary>
/// <param name="imgUid"></param>
/// <param name="env"></param>
/// <param name="size"></param>
/// <returns></returns>
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
/// <summary>
/// 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;
}
/// <summary>
/// Aggiornamento costing completo:
/// - verifica UID
/// - ricalcolo BOM
/// - update prezzi
/// </summary>
/// <returns></returns>
private async Task OfferUpdateAllCosting()
{
if (!await JSRuntime.InvokeAsync<bool>("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
}
/// <summary>
/// Ricevuto HwOpt, processo
/// </summary>
@@ -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
}
}
/// <summary>
/// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente)
/// </summary>
/// <returns></returns>
private async Task RequestBom(TemplateRowModel currRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di voler ricalcolare la BOM?"))
return;
await reqBomUpdate(currRec);
}
#if false
/// <summary>
/// Calcolo URL immagine
/// </summary>
/// <param name="imgUid"></param>
/// <param name="env"></param>
/// <returns></returns>
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
/// <summary>
/// Salvataggio dei dati del file caricato
/// </summary>
+1 -1
View File
@@ -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();
}
@@ -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<BomItemDTO>? currBomList = null;
private List<GenValueModel>? currDefaultSet = null;
private Dictionary<string, List<ItemRawDTO>>? currDictItem = null;
/// <summary>
/// Oggetto ODL con assegnazione item x richiesta prod
/// </summary>
private OdlAssignDto? currOdlAssign = null;
private Dictionary<string, List<ItemRawDTO>>? currDictItem = null;
private List<ProductionGroupModel>? ListBalancedRecords = null;
private List<OrderRowModel>? ListEstimRecords = null;
private List<OdlAssignDto>? ListOdl = null;
/// <summary>
@@ -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;
}
+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.1412</Version>
<Version>1.1.2603.1416</Version>
</PropertyGroup>
<ItemGroup>
+2
View File
@@ -200,9 +200,11 @@ builder.Services.AddScoped<DataLayerServices>();
// Repository con interfaccia
builder.Services.AddScoped<IGenClassRepository, GenClassRepository>();
builder.Services.AddScoped<IGenValRepository, GenValRepository>();
// Servizi dati con interfaccia
builder.Services.AddScoped<IGenClassService, GenClassService>();
builder.Services.AddScoped<IGenValService, GenValService>();
// Da rivedere!!!
#if false
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2603.1412</h4>
<h4>Versione: 1.1.2603.1416</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2603.1412
1.1.2603.1416
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2603.1412</version>
<version>1.1.2603.1416</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>