diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
index 40a7036..ef91f0c 100644
--- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
+++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
@@ -1,12 +1,10 @@
using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Core.RestPayload;
-using EgwCoreLib.Lux.Data.DbModel.Config;
using EgwCoreLib.Lux.Data.DbModel.Items;
using EgwCoreLib.Lux.Data.DbModel.Job;
using EgwCoreLib.Lux.Data.DbModel.Production;
using EgwCoreLib.Lux.Data.DbModel.Stats;
using EgwCoreLib.Lux.Data.Domains;
-using EgwMultiEngineManager.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
@@ -605,6 +603,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
#endif
+#if false
///
/// Esegue merge dei dati nella tab profili del DB con le info accessorie...
///
@@ -648,8 +647,10 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
}
return answ;
- }
+ }
+#endif
+#if false
///
/// Salvataggio info serializzate x soglie e dati opzionali sul DB
///
@@ -698,7 +699,8 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
}
return answ;
- }
+ }
+#endif
///
/// Elenco da DB delel stats aggregate dato periodo inizio/fine
diff --git a/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs
index 3952903..57938b9 100644
--- a/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs
+++ b/EgwCoreLib.Lux.Data/Repository/Config/ConfProfileRepository.cs
@@ -22,6 +22,13 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
return await dbCtx.SaveChangesAsync() > 0;
}
+ public async Task AddRangeAsync(List entityList)
+ {
+ await using var dbCtx = await CreateContextAsync();
+ await dbCtx.DbSetConfProfile.AddRangeAsync(entityList);
+ return await dbCtx.SaveChangesAsync() > 0;
+ }
+
public async Task DeleteAsync(ProfileModel entity)
{
await using var dbCtx = await CreateContextAsync();
@@ -38,8 +45,15 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
{
await using var dbCtx = await CreateContextAsync();
return await dbCtx.DbSetConfProfile
- .Where(x => x.ProfileID == recId)
- .FirstOrDefaultAsync();
+ .FirstOrDefaultAsync(x => x.ProfileID == recId);
+ //.Where(x => x.ProfileID == recId)
+ }
+ public async Task GetByUidAsync(string uID)
+ {
+ await using var dbCtx = await CreateContextAsync();
+ return await dbCtx.DbSetConfProfile
+ .FirstOrDefaultAsync(x => x.Code == uID);
+ //.FirstOrDefaultAsync();
}
diff --git a/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs b/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs
index 5419d02..1381070 100644
--- a/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs
+++ b/EgwCoreLib.Lux.Data/Repository/Config/IConfProfileRepository.cs
@@ -6,6 +6,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
{
Task AddAsync(ProfileModel entity);
+ Task AddRangeAsync(List entityList);
Task DeleteAsync(ProfileModel entity);
@@ -13,6 +14,8 @@ namespace EgwCoreLib.Lux.Data.Repository.Config
Task GetByIdAsync(int recId);
+ Task GetByUidAsync(string uID);
+
Task UpdateAsync(ProfileModel entity);
}
}
diff --git a/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs b/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs
index 22ef55b..50e5388 100644
--- a/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs
+++ b/EgwCoreLib.Lux.Data/Services/Config/ConfProfileService.cs
@@ -1,6 +1,8 @@
using EgwCoreLib.Lux.Data.DbModel.Config;
using EgwCoreLib.Lux.Data.Repository.Config;
+using EgwMultiEngineManager.Data;
using Microsoft.Extensions.Configuration;
+using Newtonsoft.Json;
using StackExchange.Redis;
namespace EgwCoreLib.Lux.Data.Services.Config
@@ -64,6 +66,100 @@ namespace EgwCoreLib.Lux.Data.Services.Config
});
}
+ ///
+ /// Esegue merge dei dati nella tab profili del DB con le info accessorie...
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
+ {
+ return await TraceAsync($"{_className}.SaveProfileList", async (activity) =>
+ {
+ string operation = "SaveProfileList";
+ bool success = false;
+
+ if (string.IsNullOrWhiteSpace(rawContent))
+ return false;
+
+
+ // in primis recupero profili attuali
+ var dbList = await _repo.GetAllAsync();
+
+ // ciclo sul contenuto ricevuto, se mancasse aggiungo!
+ List list2check = JsonConvert.DeserializeObject>(rawContent) ?? new List();
+ List rec2ins = new List();
+ 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)
+ {
+ success = await _repo.AddRangeAsync(rec2ins);
+ }
+
+ activity?.SetTag("db.operation", operation);
+ if (success)
+ {
+ await ClearCacheAsync($"{_redisBaseKey}:{_className}");
+ }
+
+ return success;
+ });
+ }
+
+ ///
+ /// Salvataggio info serializzate x soglie e dati opzionali sul DB
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task SaveProfileThreshAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawThreshold, string rawData)
+ {
+ return await TraceAsync($"{_className}.SaveProfileThresh", async (activity) =>
+ {
+ var currRec = await _repo.GetByUidAsync(uID);
+
+ string operation = "UPDATE";
+ bool success = false;
+ if (currRec != null)
+ {
+ currRec.ProfDataRaw = rawData;
+ currRec.ThreshDataRaw = rawThreshold;
+ success = await _repo.UpdateAsync(currRec);
+ }
+ else
+ {
+ operation = "INSERT";
+ var upsRec = new ProfileModel()
+ {
+ Code = uID,
+ Description = $"{uID} - NEW PROFILE",
+ ProfDataRaw = rawData,
+ ThreshDataRaw = rawThreshold
+ };
+ success = await _repo.AddAsync(upsRec);
+ }
+
+ activity?.SetTag("db.operation", operation);
+
+ if (success)
+ {
+ await ClearCacheAsync($"{_redisBaseKey}:{_className}");
+ }
+
+ return success;
+ });
+ }
+
///
/// Upsert record Profile (aggiorna o inserisce)
///
diff --git a/EgwCoreLib.Lux.Data/Services/Config/IConfProfileService.cs b/EgwCoreLib.Lux.Data/Services/Config/IConfProfileService.cs
index 8d2e9e4..52eb8f7 100644
--- a/EgwCoreLib.Lux.Data/Services/Config/IConfProfileService.cs
+++ b/EgwCoreLib.Lux.Data/Services/Config/IConfProfileService.cs
@@ -1,4 +1,5 @@
using EgwCoreLib.Lux.Data.DbModel.Config;
+using EgwMultiEngineManager.Data;
namespace EgwCoreLib.Lux.Data.Services.Config
{
@@ -10,6 +11,10 @@ namespace EgwCoreLib.Lux.Data.Services.Config
Task> GetAllAsync();
+ Task SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent);
+
+ Task SaveProfileThreshAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawThreshold, string rawData);
+
Task UpsertAsync(ProfileModel upsRec);
#endregion Public Methods
diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
index 0f88888..46ce82e 100644
--- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
+++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
@@ -4,6 +4,7 @@ using EgwCoreLib.Lux.Data.Controllers;
using EgwCoreLib.Lux.Data.DbModel.Job;
using EgwCoreLib.Lux.Data.DbModel.Production;
using EgwCoreLib.Lux.Data.DbModel.Sales;
+using EgwCoreLib.Lux.Data.Services.Config;
using EgwCoreLib.Lux.Data.Services.Production;
using EgwCoreLib.Lux.Data.Services.Sales;
using EgwMultiEngineManager.Data;
@@ -52,6 +53,7 @@ namespace EgwCoreLib.Lux.Data.Services
#region Public Properties
+ public IConfProfileService ConfProfServ => _serviceProvider.GetRequiredService();
public IOfferRowService OfferRowServ => _serviceProvider.GetRequiredService();
public IOrderRowService OrderRowServ => _serviceProvider.GetRequiredService();
public IProductionOdlService PrOdlServ => _serviceProvider.GetRequiredService();
@@ -401,18 +403,6 @@ namespace EgwCoreLib.Lux.Data.Services
{
var result = await OrderRowServ.SaveProdEstAsync(uID, prodEstim);
return result;
-#if false
- using var activity = StartActivity();
- string source = "DB";
- // salvo sul DB il risultato della BOM
- if (!string.IsNullOrEmpty(prodEstim))
- {
- // salvo info balance nel record del DB relativo all'oggetto richiesto
- await dbController.OrderRowUpsertProdEst(uID, prodEstim);
- }
- activity?.SetTag("data.source", source);
- LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
-#endif
}
///
@@ -422,33 +412,10 @@ namespace EgwCoreLib.Lux.Data.Services
/// Environment dell'item
/// ProfileList serializzata
///
- public async Task SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
+ public async Task SaveProfileListAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawContent)
{
- using var activity = StartActivity();
- string source = "DB";
- // salvo sul DB il risultato della BOM
- if (!string.IsNullOrEmpty(rawContent))
- {
- try
- {
- // faccio ANCHE merge sui dati del DB x avere key corrette...
- await dbController.SaveProfileListAsync(uID, execEnvironment, rawContent);
- }
- catch (Exception exc)
- {
- string exMsg = $"Eccezione durante SaveProfileListAsync | 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 }
- }));
- }
- activity?.SetTag("data.source", source);
- LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
- }
+ var result = await ConfProfServ.SaveProfileListAsync(uID, execEnvironment, rawContent);
+ return result;
}
///
@@ -459,32 +426,10 @@ namespace EgwCoreLib.Lux.Data.Services
/// ThresholdList serializzata
/// Info profile data serializzati
///
- public async Task SaveProfileThreshAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawThreshold, string rawData)
+ public async Task SaveProfileThreshAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string rawThreshold, string rawData)
{
- using var activity = StartActivity();
- string source = "DB";
- // salvo sul DB il risultato della BOM
- if (!string.IsNullOrEmpty(rawThreshold))
- {
- try
- {
- await dbController.SaveProfileThreshAsync(uID, execEnvironment, rawThreshold, rawData);
- }
- catch (Exception exc)
- {
- string exMsg = $"Eccezione durante SaveProfileThreshAsync | 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 }
- }));
- }
- activity?.SetTag("data.source", source);
- LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
- }
+ var result = await ConfProfServ.SaveProfileThreshAsync(uID, execEnvironment, rawThreshold, rawData);
+ return result;
}
#endregion Public Methods
diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj
index bf09cc3..3d3542d 100644
--- a/Lux.API/Lux.API.csproj
+++ b/Lux.API/Lux.API.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 1.1.2603.1916
+ 1.1.2603.2008
diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj
index 3f40ca8..ab94178 100644
--- a/Lux.UI/Lux.UI.csproj
+++ b/Lux.UI/Lux.UI.csproj
@@ -5,7 +5,7 @@
enable
enable
aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50
- 1.1.2603.1916
+ 1.1.2603.2008
diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index 441b41b..4f491d8 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
LUX - Web Windows MES
- Versione: 1.1.2603.1916
+ Versione: 1.1.2603.2008
Note di rilascio:
-
diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt
index c56f4e9..e6b25d0 100644
--- a/Resources/VersNum.txt
+++ b/Resources/VersNum.txt
@@ -1 +1 @@
-1.1.2603.1916
+1.1.2603.2008
diff --git a/Resources/manifest.xml b/Resources/manifest.xml
index de3ee92..97f31f9 100644
--- a/Resources/manifest.xml
+++ b/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 1.1.2603.1916
+ 1.1.2603.2008
http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip
http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html
false