Modifica gestore DB x salvataggio info BOM restituite

This commit is contained in:
Samuele Locatelli
2025-08-07 17:23:58 +02:00
parent 293bec8f52
commit 8d7569baa7
13 changed files with 78 additions and 40 deletions
+19 -19
View File
@@ -50,10 +50,10 @@ namespace EgwCoreLib.Lux.Data
// inizializzazione dei valori di default x gruppi item
modelBuilder.Entity<ItemGroupModel>().HasData(
new ItemGroupModel { CodGroup = "BARRA", Description = "Barre legno per lavorazione" },
new ItemGroupModel { CodGroup = "VETRO", Description = "Vetri serramento" },
new ItemGroupModel { CodGroup = "VERNICE", Description = "Vernici per legno" },
new ItemGroupModel { CodGroup = "FERRAMENTA", Description = "Ferramenta serramento" }
new ItemGroupModel { CodGroup = "WindowTrunk", Description = "Barre legno per lavorazione" },
new ItemGroupModel { CodGroup = "WindowGlass", Description = "Vetri serramento" },
new ItemGroupModel { CodGroup = "WindowVarnish", Description = "Vernici per legno" },
new ItemGroupModel { CodGroup = "WindowHardware", Description = "Ferramenta serramento" }
);
// inizializzazione tipo mov mag
@@ -69,24 +69,24 @@ namespace EgwCoreLib.Lux.Data
// inizializzazione dei valori di default x Item di magazzino
modelBuilder.Entity<ItemModel>().HasData(
// barre grezzo
new ItemModel { ItemID = 1, CodGroup = "BARRA", IsService = false, ItemCode = 1001, Description = "BARRA-60x80 generica", SupplCode = "BARR.001", Cost = 20, Margin = 0.3, UM = "#" },
new ItemModel { ItemID = 2, CodGroup = "BARRA", IsService = false, ItemCode = 1002, ExtItemCode = "BARRA-60x80x12000", SupplCode = "ABC.00123.12000", Description = "Barra 60x80, lunghezza 12m", Cost = 16.5, Margin = 0.21, UM = "#" },
new ItemModel { ItemID = 3, CodGroup = "BARRA", IsService = false, ItemCode = 1003, ExtItemCode = "BARRA-60x80x8000", SupplCode = "ABC.00123.8000", Description = "Barra 60x80, lunghezza 8m", Cost = 17.5, Margin = 0.22, UM = "#" },
new ItemModel { ItemID = 4, CodGroup = "BARRA", IsService = false, ItemCode = 1004, ExtItemCode = "BARRA-60x80x16000", SupplCode = "ABC.00123.16000", Description = "Barra 60x80, lunghezza 16m", Cost = 15.5, Margin = 0.2, UM = "#" },
new ItemModel { ItemID = 1, CodGroup = "WindowTrunk", IsService = false, ItemCode = 1001, Description = "BARRA-60x80 generica", SupplCode = "BARR.001", Cost = 20, Margin = 0.3, UM = "#" },
new ItemModel { ItemID = 2, CodGroup = "WindowTrunk", IsService = false, ItemCode = 1002, ExtItemCode = "BARRA-60x80x12000", SupplCode = "ABC.00123.12000", Description = "Barra 60x80, lunghezza 12m", Cost = 16.5, Margin = 0.21, UM = "#" },
new ItemModel { ItemID = 3, CodGroup = "WindowTrunk", IsService = false, ItemCode = 1003, ExtItemCode = "BARRA-60x80x8000", SupplCode = "ABC.00123.8000", Description = "Barra 60x80, lunghezza 8m", Cost = 17.5, Margin = 0.22, UM = "#" },
new ItemModel { ItemID = 4, CodGroup = "WindowTrunk", IsService = false, ItemCode = 1004, ExtItemCode = "BARRA-60x80x16000", SupplCode = "ABC.00123.16000", Description = "Barra 60x80, lunghezza 16m", Cost = 15.5, Margin = 0.2, UM = "#" },
// vetri
new ItemModel { ItemID = 5, CodGroup = "VETRO", IsService = false, ItemCode = 2001, ExtItemCode = "VETRO-3L-THERMO-800x1000", SupplCode = "V3T.800.1000", Description = "Vetro triplo, basso indice termico, 800x1000", Cost = 300, Margin = 0.20, UM = "m2" },
new ItemModel { ItemID = 6, CodGroup = "VETRO", IsService = false, ItemCode = 2002, ExtItemCode = "VETRO-2L-800x1000", SupplCode = "V2.800.1000", Description = "Vetro doppio, 800x1000", Cost = 200, Margin = 0.15, UM = "m2" },
new ItemModel { ItemID = 7, CodGroup = "VETRO", IsService = false, ItemCode = 2003, ExtItemCode = "VETRO-3L-800x1000", SupplCode = "V3.800.1000", Description = "Vetro triplo, 800x1000", Cost = 250, Margin = 0.18, UM = "m2" },
new ItemModel { ItemID = 5, CodGroup = "WindowGlass", IsService = false, ItemCode = 2001, ExtItemCode = "VETRO-3L-THERMO-800x1000", SupplCode = "V3T.800.1000", Description = "Vetro triplo, basso indice termico, 800x1000", Cost = 300, Margin = 0.20, UM = "m2" },
new ItemModel { ItemID = 6, CodGroup = "WindowGlass", IsService = false, ItemCode = 2002, ExtItemCode = "VETRO-2L-800x1000", SupplCode = "V2.800.1000", Description = "Vetro doppio, 800x1000", Cost = 200, Margin = 0.15, UM = "m2" },
new ItemModel { ItemID = 7, CodGroup = "WindowGlass", IsService = false, ItemCode = 2003, ExtItemCode = "VETRO-3L-800x1000", SupplCode = "V3.800.1000", Description = "Vetro triplo, 800x1000", Cost = 250, Margin = 0.18, UM = "m2" },
// vernici
new ItemModel { ItemID = 8, CodGroup = "VERNICE", IsService = false, ItemCode = 3001, ExtItemCode = "VERN-TRASP", SupplCode = "VT.STD", Description = "Vernice trasparente", Cost = 20, Margin = 0.20, UM = "l" },
new ItemModel { ItemID = 8, CodGroup = "WindowVarnish", IsService = false, ItemCode = 3001, ExtItemCode = "VERN-TRASP", SupplCode = "VT.STD", Description = "Vernice trasparente", Cost = 20, Margin = 0.20, UM = "l" },
// ferramenta
new ItemModel { ItemID = 9, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5001, ExtItemCode = "KIT-001", SupplCode = "AGB-KIT-001", Description = "Kit standard completo AGB tipo 001", Cost = 65, Margin = 0.20, UM = "#" },
new ItemModel { ItemID = 10, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5002, ExtItemCode = "CERN-001", SupplCode = "AGB-CERN-001", Description = "Cerniera AGB tipo 001", Cost = 10, Margin = 0.20, UM = "#" },
new ItemModel { ItemID = 11, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5003, ExtItemCode = "SERR-001", SupplCode = "AGB-SERR-001", Description = "Serratura AGB tipo 001", Cost = 15, Margin = 0.20, UM = "#" },
new ItemModel { ItemID = 12, CodGroup = "FERRAMENTA", IsService = false, ItemCode = 5004, ExtItemCode = "MAN-001", SupplCode = "AGB-MAN-001", Description = "Maniglia AGB tipo 001", Cost = 25, Margin = 0.20, UM = "#" }
new ItemModel { ItemID = 9, CodGroup = "WindowHardware", IsService = false, ItemCode = 5001, ExtItemCode = "KIT-001", SupplCode = "AGB-KIT-001", Description = "Kit standard completo AGB tipo 001", Cost = 65, Margin = 0.20, UM = "#" },
new ItemModel { ItemID = 10, CodGroup = "WindowHardware", IsService = false, ItemCode = 5002, ExtItemCode = "CERN-001", SupplCode = "AGB-CERN-001", Description = "Cerniera AGB tipo 001", Cost = 10, Margin = 0.20, UM = "#" },
new ItemModel { ItemID = 11, CodGroup = "WindowHardware", IsService = false, ItemCode = 5003, ExtItemCode = "SERR-001", SupplCode = "AGB-SERR-001", Description = "Serratura AGB tipo 001", Cost = 15, Margin = 0.20, UM = "#" },
new ItemModel { ItemID = 12, CodGroup = "WindowHardware", IsService = false, ItemCode = 5004, ExtItemCode = "MAN-001", SupplCode = "AGB-MAN-001", Description = "Maniglia AGB tipo 001", Cost = 25, Margin = 0.20, UM = "#" }
);
// inizializzazione dei valori di default x Item di giacenza
@@ -203,9 +203,9 @@ namespace EgwCoreLib.Lux.Data
// inizializzazione dei valori di default x OfferRow
modelBuilder.Entity<OfferRowModel>().HasData(
new OfferRowModel { OfferRowID = 1, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 950, SellingItemID = 1, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Finestra anta singola 2025", ItemSPP = "{}" },
new OfferRowModel { OfferRowID = 2, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 160, SellingItemID = 2, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Persiana per Finestra anta singola 2025", ItemSPP = "{}" },
new OfferRowModel { OfferRowID = 3, OfferID = 1, Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 200, SellingItemID = 3, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Installazione serramento", ItemSPP = "{}" }
new OfferRowModel { OfferRowID = 1, OfferID = 1, OfferRowUID= "OFF0000000001", Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 950, SellingItemID = 1, Qty = 3, RowNum = 1, SerStruct = "{}", Note = "Finestra anta singola 2025", ItemSPP = "{}" },
new OfferRowModel { OfferRowID = 2, OfferID = 1, OfferRowUID = "OFF0000000002", Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 160, SellingItemID = 2, Qty = 3, RowNum = 2, SerStruct = "{}", Note = "Persiana per Finestra anta singola 2025", ItemSPP = "{}" },
new OfferRowModel { OfferRowID = 3, OfferID = 1, OfferRowUID = "OFF0000000003", Inserted = DateTime.Now, Modified = DateTime.Now, Cost = 200, SellingItemID = 3, Qty = 3, RowNum = 3, SerStruct = "{}", Note = "Installazione serramento", ItemSPP = "{}" }
);
}
@@ -1,5 +1,7 @@
using EgwCoreLib.Lux.Data.Controllers;
using EgwCoreLib.Lux.Core.RestPayload;
using EgwCoreLib.Lux.Data.Controllers;
using EgwCoreLib.Lux.Data.DbModel;
using EgwMultiEngineManager.Data;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NLog;
@@ -340,6 +342,34 @@ namespace EgwCoreLib.Lux.Data.Services
return answ;
}
/// <summary>
/// Esegue salvataggio BOM sul DB
/// </summary>
/// <param name="uID"></param>
/// <param name="execEnvironment"></param>
/// <param name="bomContent"></param>
/// <returns></returns>
public async Task SaveBomAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string bomContent)
{
// salvo sul DB il risultato della BOM
if (!string.IsNullOrEmpty(bomContent))
{
try
{
// deserializzo la Bom...
var bomList = JsonConvert.DeserializeObject<List<BomItemDTO>>(bomContent);
if (bomList != null)
{
// verifico 1:1 gli item sul DB x eventuale insert
dbController.ItemUpsertFromBom(bomList);
// salvo la BOM nel record del DB
}
}
catch { }
}
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using EgwCoreLib.Lux.Core.RestPayload;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NLog;
using RestSharp;
@@ -97,7 +98,7 @@ namespace EgwCoreLib.Lux.Data.Services
response = await client.ExecutePostAsync(request);
}
return response;
}
}
/// <summary>
/// Calcola URL immagine dato
@@ -163,15 +164,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <summary>
/// Salva e invia su channel img redis SVG per il doc richiesto
/// </summary>
/// <param name="imgId"></param>
/// <param name="uid"></param>
/// <param name="bomContent"></param>
public async Task<bool> SaveBomAsync(string imgId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string bomContent)
public async Task<bool> SaveBomAsync(string uid, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS env, string bomContent)
{
// salvo img in cache
string currKey = $"{redisBaseKey}:{env}:BOM:{imgId.Replace("/", ":")}";
string currKey = $"{redisBaseKey}:{env}:BOM:{uid.Replace("/", ":")}";
var done = await _redisService.SetAsync(currKey, bomContent);
// invio notifica nuova svg generata sul canale... viene inviato solo svg con ID nel canale
string notifyChannel = $"{bomChannel}:{imgId}";
string notifyChannel = $"{bomChannel}:{uid}";
long numSent = await _redisService.PublishAsync(notifyChannel, bomContent);
return done;
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2508.0618</Version>
<Version>0.9.2508.0717</Version>
</PropertyGroup>
<ItemGroup>
+1
View File
@@ -45,6 +45,7 @@ builder.Services.AddSingleton<IRedisService, RedisService>();
builder.Services.AddSingleton<RedisSubscriptionManager>();
// altri servizi!
builder.Services.AddSingleton<ImageCacheService>();
builder.Services.AddSingleton<DataLayerServices>();
builder.Services.AddSingleton<ExternalMessageProcessor>();
builder.Services.AddHostedService<RedisSubscriberService>();
+13 -5
View File
@@ -12,9 +12,15 @@ namespace Lux.API.Services
{
#region Public Constructors
public ExternalMessageProcessor(ImageCacheService imgService)
/// <summary>
/// Init classe message processor con accesso REDIS e DB
/// </summary>
/// <param name="imgService"></param>
/// <param name="dlService"></param>
public ExternalMessageProcessor(ImageCacheService imgService, DataLayerServices dlService)
{
_cacheService = imgService;
cacheService = imgService;
dbService = dlService;
}
#endregion Public Constructors
@@ -43,14 +49,15 @@ namespace Lux.API.Services
// salvo SVG
string newSvg = retData.Args["Svg"];
string UID = retData.Args["UID"];
await _cacheService.SaveSvgAsync(UID, retData.ExecEnvironment, newSvg);
await cacheService.SaveSvgAsync(UID, retData.ExecEnvironment, newSvg);
}
if(retData.Args.ContainsKey("BOM"))
{
// salvo BOM ricevuta
string newBom = retData.Args["BOM"];
string UID = retData.Args["UID"];
await _cacheService.SaveBomAsync(UID, retData.ExecEnvironment, newBom);
await cacheService.SaveBomAsync(UID, retData.ExecEnvironment, newBom);
await dbService.SaveBomAsync(UID, retData.ExecEnvironment, newBom);
}
}
}
@@ -74,7 +81,8 @@ namespace Lux.API.Services
#region Private Fields
private readonly ImageCacheService _cacheService;
private readonly ImageCacheService cacheService;
private readonly DataLayerServices dbService;
private static Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
-1
View File
@@ -52,7 +52,6 @@
"ConnectionStrings": {
//"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50;Trusted_Connection=True;MultipleActiveResultSets=true",
"DefaultConnection": "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;",
"Lux.All": "Server=SQL2016DEV;Database=MoonPro_STATS; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.Land;",
"Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true"
},
+2 -2
View File
@@ -1,6 +1,6 @@
@if (EditRecord != null)
{
<h3>@EditRecord.OfferRowCode</h3>
<h3>@EditRecord.OfferRowUID</h3>
}
else
{
@@ -60,7 +60,7 @@ else
<img class="img-fluid" src="images/logoegw.png" width="48" />
</td>
}
<td>@item.OfferRowCode</td>
<td>@item.OfferRowUID</td>
<td>@item.Note</td>
<td class="text-end">@item.Qty</td>
<td class="text-end">@($"{item.Cost:C2}")</td>
+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>0.9.2508.0712</Version>
<Version>0.9.2508.0717</Version>
</PropertyGroup>
<ItemGroup>
-1
View File
@@ -53,7 +53,6 @@
"ConnectionStrings": {
//"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50;Trusted_Connection=True;MultipleActiveResultSets=true",
"DefaultConnection": "Server=mdb.ufficio;port=3306;database=Lux_000;uid=lux_user;pwd=Egal_pwd!;sslmode=None;",
"Lux.All": "Server=SQL2016DEV;Database=MoonPro_STATS; User ID=sa;Password=keyhammer16; integrated security=False; MultipleActiveResultSets=True; App=MP.Land;",
"Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true"
},
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2508.0712</h4>
<h4>Versione: 0.9.2508.0717</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2508.0712
0.9.2508.0717
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2508.0712</version>
<version>0.9.2508.0717</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>