From fd40a6906fdb86776ac1cae5f0128d4f463ab8a7 Mon Sep 17 00:00:00 2001
From: Samuele Locatelli
Date: Wed, 18 Mar 2026 19:25:50 +0100
Subject: [PATCH] Move Repo/Serv x TagModel...
---
.../Controllers/LuxController.cs | 25 ----------
.../Repository/Utils/ITagRepository.cs | 9 ++++
.../Repository/Utils/TagRepository.cs | 28 +++++++++++
.../Services/DataLayerServices.cs | 35 --------------
.../Services/Utils/ITagService.cs | 10 ++++
.../Services/Utils/TagService.cs | 46 +++++++++++++++++++
Lux.API/Program.cs | 2 +
Lux.UI/Components/Pages/JobRoute.razor.cs | 6 ++-
Lux.UI/Program.cs | 2 +
Resources/ChangeLog.html | 27 -----------
Resources/VersNum.txt | 1 -
Resources/manifest.xml | 7 ---
12 files changed, 102 insertions(+), 96 deletions(-)
create mode 100644 EgwCoreLib.Lux.Data/Repository/Utils/ITagRepository.cs
create mode 100644 EgwCoreLib.Lux.Data/Repository/Utils/TagRepository.cs
create mode 100644 EgwCoreLib.Lux.Data/Services/Utils/ITagService.cs
create mode 100644 EgwCoreLib.Lux.Data/Services/Utils/TagService.cs
diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
index 6e1127b4..8f2a7b66 100644
--- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
+++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs
@@ -7,7 +7,6 @@ using EgwCoreLib.Lux.Data.DbModel.Job;
using EgwCoreLib.Lux.Data.DbModel.Production;
using EgwCoreLib.Lux.Data.DbModel.Sales;
using EgwCoreLib.Lux.Data.DbModel.Stats;
-using EgwCoreLib.Lux.Data.DbModel.Utils;
using EgwCoreLib.Lux.Data.Domains;
using EgwMultiEngineManager.Data;
using Microsoft.EntityFrameworkCore;
@@ -1179,30 +1178,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
- ///
- /// Elenco completo Tags
- ///
- ///
- internal async Task> TagsGetAllAsync()
- {
- List dbResult = new List();
- //using (DataLayerContext dbCtx = new DataLayerContext(_config))
- using (DataLayerContext dbCtx = new DataLayerContext())
- {
- try
- {
- dbResult = await dbCtx
- .DbSetTags
- .ToListAsync();
- }
- catch (Exception exc)
- {
- Log.Error($"Eccezione durante TagsGetAllAsync{Environment.NewLine}{exc}");
- }
- }
- return dbResult;
- }
-
#if true
internal bool UpdateCodGroup(List bomList)
{
diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/ITagRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/ITagRepository.cs
new file mode 100644
index 00000000..f3b85eb1
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/Repository/Utils/ITagRepository.cs
@@ -0,0 +1,9 @@
+using EgwCoreLib.Lux.Data.DbModel.Utils;
+
+namespace EgwCoreLib.Lux.Data.Repository.Utils
+{
+ public interface ITagRepository
+ {
+ Task> GetAllAsync();
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/Repository/Utils/TagRepository.cs b/EgwCoreLib.Lux.Data/Repository/Utils/TagRepository.cs
new file mode 100644
index 00000000..200e38f1
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/Repository/Utils/TagRepository.cs
@@ -0,0 +1,28 @@
+using EgwCoreLib.Lux.Data.DbModel.Utils;
+using Microsoft.EntityFrameworkCore;
+
+namespace EgwCoreLib.Lux.Data.Repository.Utils
+{
+ public class TagRepository : BaseRepository, ITagRepository
+ {
+ #region Public Constructors
+
+ public TagRepository(IDbContextFactory ctxFactory) : base(ctxFactory)
+ {
+ }
+
+ #endregion Public Constructors
+
+ #region Public Methods
+
+ public async Task> GetAllAsync()
+ {
+ await using var dbCtx = await CreateContextAsync();
+ return await dbCtx.DbSetTags
+ .AsNoTracking()
+ .ToListAsync();
+ }
+
+ #endregion Public Methods
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
index 995bfffb..c305a4fc 100644
--- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
+++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs
@@ -5,7 +5,6 @@ using EgwCoreLib.Lux.Data.DbModel.Cost;
using EgwCoreLib.Lux.Data.DbModel.Job;
using EgwCoreLib.Lux.Data.DbModel.Production;
using EgwCoreLib.Lux.Data.DbModel.Sales;
-using EgwCoreLib.Lux.Data.DbModel.Utils;
using EgwMultiEngineManager.Data;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
@@ -642,40 +641,6 @@ namespace EgwCoreLib.Lux.Data.Services
}
}
- ///
- /// Elenco completo Tags disponibili
- ///
- ///
- public async Task> TagsGetAllAsync()
- {
- using var activity = StartActivity();
- string source = "DB";
- List? result = new List();
- // cerco in redis...
- string currKey = $"{redisBaseKey}:Tags:ALL";
- RedisValue rawData = _redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- source = "REDIS";
- }
- else
- {
- result = await dbController.TagsGetAllAsync();
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- _redisDb.StringSet(currKey, rawData, UltraLongCache);
- }
- if (result == null)
- {
- result = new List();
- }
- // aggiunta tags + log
- activity?.SetTag("data.source", source);
- LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
- return result;
- }
-
#endregion Public Methods
#region Protected Fields
diff --git a/EgwCoreLib.Lux.Data/Services/Utils/ITagService.cs b/EgwCoreLib.Lux.Data/Services/Utils/ITagService.cs
new file mode 100644
index 00000000..71ab84f3
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/Services/Utils/ITagService.cs
@@ -0,0 +1,10 @@
+using EgwCoreLib.Lux.Data.DbModel.Utils;
+
+namespace EgwCoreLib.Lux.Data.Services.Utils
+{
+
+ public interface ITagService
+ {
+ Task> GetAllAsync();
+ }
+}
diff --git a/EgwCoreLib.Lux.Data/Services/Utils/TagService.cs b/EgwCoreLib.Lux.Data/Services/Utils/TagService.cs
new file mode 100644
index 00000000..5c3fb1f6
--- /dev/null
+++ b/EgwCoreLib.Lux.Data/Services/Utils/TagService.cs
@@ -0,0 +1,46 @@
+using EgwCoreLib.Lux.Data.DbModel.Utils;
+using EgwCoreLib.Lux.Data.Repository.Utils;
+using Microsoft.Extensions.Configuration;
+using StackExchange.Redis;
+
+namespace EgwCoreLib.Lux.Data.Services.Utils
+{
+ public class TagService : BaseServ, ITagService
+ {
+ #region Public Constructors
+
+ public TagService(
+ IConfiguration config,
+ IConnectionMultiplexer redis,
+ ITagRepository repo) : base(config, redis)
+ {
+ _className = "Tag";
+ _repo = repo;
+ }
+
+ #endregion Public Constructors
+
+ #region Public Methods
+
+ public async Task> GetAllAsync()
+ {
+ return await TraceAsync($"{_className}.GetAll", async (activity) =>
+ {
+ return await GetOrSetCacheAsync(
+ $"{_redisBaseKey}:{_className}:ALL",
+ async () => await _repo.GetAllAsync(),
+ UltraLongCache
+ );
+ });
+ }
+
+ #endregion Public Methods
+
+ #region Private Fields
+
+ private readonly string _className;
+ private readonly ITagRepository _repo;
+
+ #endregion Private Fields
+ }
+}
diff --git a/Lux.API/Program.cs b/Lux.API/Program.cs
index a7eb7aa0..0f946194 100644
--- a/Lux.API/Program.cs
+++ b/Lux.API/Program.cs
@@ -196,6 +196,7 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
+builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
@@ -221,6 +222,7 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
+builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
diff --git a/Lux.UI/Components/Pages/JobRoute.razor.cs b/Lux.UI/Components/Pages/JobRoute.razor.cs
index 414ac421..2957e8de 100644
--- a/Lux.UI/Components/Pages/JobRoute.razor.cs
+++ b/Lux.UI/Components/Pages/JobRoute.razor.cs
@@ -3,6 +3,7 @@ using EgwCoreLib.Lux.Data.DbModel.Job;
using EgwCoreLib.Lux.Data.Services;
using EgwCoreLib.Lux.Data.Services.Cost;
using EgwCoreLib.Lux.Data.Services.Job;
+using EgwCoreLib.Lux.Data.Services.Utils;
using Microsoft.AspNetCore.Components;
namespace Lux.UI.Components.Pages
@@ -23,6 +24,9 @@ namespace Lux.UI.Components.Pages
[Inject]
protected IResourceService ResService { get; set; } = null!;
+ [Inject]
+ protected ITagService TagService { get; set; } = null!;
+
#endregion Protected Properties
#region Protected Methods
@@ -74,7 +78,7 @@ namespace Lux.UI.Components.Pages
private async Task ReloadData()
{
isLoading = true;
- var rawTags = await DLService.TagsGetAllAsync();
+ var rawTags = await TagService.GetAllAsync();
ListTagsAvailable = rawTags.Select(x => x.CodTag).ToList();
ListCostDrivers = await DLService.CostDriverGetAllAsync();
ListPhases = await DLService.PhasesGetAllAsync();
diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs
index cb09035e..870ca50f 100644
--- a/Lux.UI/Program.cs
+++ b/Lux.UI/Program.cs
@@ -234,6 +234,7 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
+builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
@@ -259,6 +260,7 @@ builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
+builder.Services.AddScoped();
builder.Services.AddScoped();
builder.Services.AddScoped();
diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index 6ad93267..7671c91e 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -25,30 +25,3 @@
- LUX - Web Windows MES
- Versione: 1.1.2603.1819
-
Note di rilascio:
-
- -
- Ultime modifiche:
-
-
- -
- v.0.9.* →
-
- - Versione preliminare
- - Release dotNet8
- - Integrazione EFCore
-
-
-
-
-
-

-
-
-
-