diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj
index 2bda010c..1ef197a8 100644
--- a/Lux.API/Lux.API.csproj
+++ b/Lux.API/Lux.API.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 1.1.2603.1410
+ 1.1.2603.1411
diff --git a/Lux.API/Program.cs b/Lux.API/Program.cs
index 2a5b6cb2..736f675f 100644
--- a/Lux.API/Program.cs
+++ b/Lux.API/Program.cs
@@ -155,18 +155,12 @@ builder.Services.AddDbContext(options =>
.LogTo(_ => { }); // disabilita EF logging;
});
-//builder.Services.AddSingleton();
-builder.Services.AddSingleton();
-// altri servizi!
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
-builder.Services.AddHostedService();
-builder.Services.AddSingleton();
-builder.Services.AddSingleton();
+// servizi Scoped (usano DB)
+//builder.Services.AddSingleton();
+builder.Services.AddScoped();
// Repository con interfaccia
builder.Services.AddScoped();
-
// Servizi dati con interfaccia
builder.Services.AddScoped();
@@ -188,6 +182,17 @@ builder.Services.Scan(scan => scan
);
#endif
+// servizi Singleton (no DB)
+builder.Services.AddSingleton();
+builder.Services.AddSingleton();
+builder.Services.AddSingleton();
+
+// servizi con dipendenze" ma Scoped
+builder.Services.AddScoped();
+
+// servizi hosted usano scope factory
+builder.Services.AddHostedService();
+
// init servizio gestone ReqIndex
string cleanupDayTTL = configuration.GetValue("ServerConf:CleanupDayTTL") ?? "360";
string rBaseKey = configuration.GetValue("ServerConf:RedisBaseKey") ?? "Lux";
diff --git a/Lux.API/Services/RedisSubscriberService.cs b/Lux.API/Services/RedisSubscriberService.cs
index ccc845af..eabd94a6 100644
--- a/Lux.API/Services/RedisSubscriberService.cs
+++ b/Lux.API/Services/RedisSubscriberService.cs
@@ -1,12 +1,11 @@
using EgwCoreLib.Lux.Data.Services;
-using EgwCoreLib.Lux.Data;
namespace Lux.API.Services
{
public class RedisSubscriberService : BackgroundService
{
- #region Public Constructors
+#if false
public RedisSubscriberService(IConfiguration config, RedisSubscriptionManager subManager, ExternalMessageProcessor processor)
{
_subManager = subManager;
@@ -15,9 +14,6 @@ namespace Lux.API.Services
chSub = _config.GetValue("ServerConf:ChannelSub") ?? "";
}
- #endregion Public Constructors
-
- #region Protected Methods
protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
@@ -29,15 +25,44 @@ namespace Lux.API.Services
return Task.CompletedTask;
}
- #endregion Protected Methods
-
- #region Private Fields
private readonly IConfiguration _config;
private readonly ExternalMessageProcessor _processor;
private readonly RedisSubscriptionManager _subManager;
private readonly string chSub = "";
+#endif
- #endregion Private Fields
+
+ private readonly IConfiguration _config;
+ private readonly RedisSubscriptionManager _subManager;
+ private readonly IServiceScopeFactory _scopeFactory;
+ private readonly string _channel;
+
+ public RedisSubscriberService(
+ IConfiguration config,
+ RedisSubscriptionManager subManager,
+ IServiceScopeFactory scopeFactory)
+ {
+ _config = config;
+ _subManager = subManager;
+ _scopeFactory = scopeFactory;
+
+ _channel = _config.GetValue("ServerConf:ChannelSub") ?? "";
+ }
+
+ protected override Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ _subManager.Subscribe(_channel, async (ch, msg) =>
+ {
+ // Ogni messaggio → nuovo scope
+ using var scope = _scopeFactory.CreateScope();
+
+ var processor = scope.ServiceProvider.GetRequiredService();
+
+ await processor.HandleResultMessageAsync($"{ch}", $"{msg}");
+ });
+
+ return Task.CompletedTask;
+ }
}
}
\ No newline at end of file
diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj
index c1c0eb3a..e29f7644 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.1410
+ 1.1.2603.1411
diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index 6c8cbf42..952adaad 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
LUX - Web Windows MES
- Versione: 1.1.2603.1410
+ Versione: 1.1.2603.1411
Note di rilascio:
-
diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt
index af59cf79..3b6a9fc0 100644
--- a/Resources/VersNum.txt
+++ b/Resources/VersNum.txt
@@ -1 +1 @@
-1.1.2603.1410
+1.1.2603.1411
diff --git a/Resources/manifest.xml b/Resources/manifest.xml
index b93412ec..00a9d7f8 100644
--- a/Resources/manifest.xml
+++ b/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 1.1.2603.1410
+ 1.1.2603.1411
http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip
http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html
false