From 4916dd42ff624fa39be07b986d82bfa363d0db15 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 21 Mar 2026 11:33:49 +0100 Subject: [PATCH] Migrazione controller stats e CalcRuid (complessa...) --- .../Controllers/LuxController.cs | 5 +- .../DataServiceCollectionExtensions.cs | 10 ++ .../EgwCoreLib.Lux.Data.csproj | 2 - .../Repository/Stats/IStatsAggrRepository.cs | 2 +- .../Stats/IStatsDetailRepository.cs | 2 +- .../Repository/Stats/StatsAggrRepository.cs | 2 +- .../Repository/Stats/StatsDetailRepository.cs | 2 +- .../Services/CalcRuidService.cs | 35 +++-- .../Services/Stats/IStatsAggrService.cs | 2 +- .../Services/Stats/IStatsDetailService.cs | 2 +- .../Services/Stats/StatsAggrService.cs | 4 +- .../Services/Stats/StatsDetailService.cs | 132 ++++-------------- .../Services/StatsCollectService.cs | 79 +++++++---- Lux.API/Lux.API.csproj | 2 +- Lux.API/Program.cs | 16 +-- Lux.UI/Lux.UI.csproj | 2 +- Lux.UI/Program.cs | 33 ++--- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 20 files changed, 146 insertions(+), 192 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index e3ead987..39bf865a 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -1,5 +1,4 @@ using EgwCoreLib.Lux.Data.DbModel.Production; -using EgwCoreLib.Lux.Data.DbModel.Stats; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using NLog; @@ -99,7 +98,7 @@ namespace EgwCoreLib.Lux.Data.Controllers } #endif -#if true +#if false /// /// Elenco da DB delle stats aggregate dato periodo inizio/fine /// @@ -186,7 +185,7 @@ namespace EgwCoreLib.Lux.Data.Controllers return answ; } #endif -#if true +#if false /// /// Recupera dati stats di dettaglio dato filtro envir/tipo (opzionali) e periodo diff --git a/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs b/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs index 57532484..8722207c 100644 --- a/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs +++ b/EgwCoreLib.Lux.Data/DataServiceCollectionExtensions.cs @@ -4,6 +4,7 @@ using EgwCoreLib.Lux.Data.Repository.Items; using EgwCoreLib.Lux.Data.Repository.Job; using EgwCoreLib.Lux.Data.Repository.Production; using EgwCoreLib.Lux.Data.Repository.Sales; +using EgwCoreLib.Lux.Data.Repository.Stats; using EgwCoreLib.Lux.Data.Repository.Utils; using EgwCoreLib.Lux.Data.Services; using EgwCoreLib.Lux.Data.Services.Config; @@ -12,6 +13,7 @@ using EgwCoreLib.Lux.Data.Services.Items; using EgwCoreLib.Lux.Data.Services.Job; using EgwCoreLib.Lux.Data.Services.Production; using EgwCoreLib.Lux.Data.Services.Sales; +using EgwCoreLib.Lux.Data.Services.Stats; using EgwCoreLib.Lux.Data.Services.Utils; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; @@ -52,6 +54,8 @@ namespace EgwCoreLib.Lux.Data services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); @@ -82,6 +86,8 @@ namespace EgwCoreLib.Lux.Data services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); @@ -91,6 +97,10 @@ namespace EgwCoreLib.Lux.Data services.TryAddScoped(); //services.TryAddScoped(); + // aggiunta servizi finali Singleton... + //services.TryAddSingleton(); + + return services; } } diff --git a/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj b/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj index 6d5e1dd7..fed9128f 100644 --- a/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj +++ b/EgwCoreLib.Lux.Data/EgwCoreLib.Lux.Data.csproj @@ -22,8 +22,6 @@ - - diff --git a/EgwCoreLib.Lux.Data/Repository/Stats/IStatsAggrRepository.cs b/EgwCoreLib.Lux.Data/Repository/Stats/IStatsAggrRepository.cs index 3107632e..4503b7f0 100644 --- a/EgwCoreLib.Lux.Data/Repository/Stats/IStatsAggrRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Stats/IStatsAggrRepository.cs @@ -11,7 +11,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Stats Task GetRangeAsync(); - Task UpsertManyAsync(List listRecords, bool removeOld); + Task UpsertManyAsync(List listRecords, bool removeOld); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Repository/Stats/IStatsDetailRepository.cs b/EgwCoreLib.Lux.Data/Repository/Stats/IStatsDetailRepository.cs index c311469c..fbb97dcd 100644 --- a/EgwCoreLib.Lux.Data/Repository/Stats/IStatsDetailRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Stats/IStatsDetailRepository.cs @@ -11,7 +11,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Stats Task GetRangeAsync(string sEnvir, string sType); - Task UpsertAsync(List listRecords, bool removeOld); + Task UpsertManyAsync(List listRecords, bool removeOld); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Repository/Stats/StatsAggrRepository.cs b/EgwCoreLib.Lux.Data/Repository/Stats/StatsAggrRepository.cs index f980efe4..2baec0ad 100644 --- a/EgwCoreLib.Lux.Data/Repository/Stats/StatsAggrRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Stats/StatsAggrRepository.cs @@ -56,7 +56,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Stats /// Elenco dei record da inserire /// Se true preventivamente elimina record nel periodo richiesto /// - public async Task UpsertManyAsync(List listRecords, bool removeOld) + public async Task UpsertManyAsync(List listRecords, bool removeOld) { int answ = 0; await using var dbCtx = await CreateContextAsync(); diff --git a/EgwCoreLib.Lux.Data/Repository/Stats/StatsDetailRepository.cs b/EgwCoreLib.Lux.Data/Repository/Stats/StatsDetailRepository.cs index 10d1a8db..4a16a0a1 100644 --- a/EgwCoreLib.Lux.Data/Repository/Stats/StatsDetailRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Stats/StatsDetailRepository.cs @@ -81,7 +81,7 @@ namespace EgwCoreLib.Lux.Data.Repository.Stats /// Elenco dei record da inserire /// Se true preventivamente elimina record nel periodo richiesto /// - public async Task UpsertAsync(List listRecords, bool removeOld) + public async Task UpsertManyAsync(List listRecords, bool removeOld) { int answ = 0; await using var dbCtx = await CreateContextAsync(); diff --git a/EgwCoreLib.Lux.Data/Services/CalcRuidService.cs b/EgwCoreLib.Lux.Data/Services/CalcRuidService.cs index 388cb503..7bbb3df3 100644 --- a/EgwCoreLib.Lux.Data/Services/CalcRuidService.cs +++ b/EgwCoreLib.Lux.Data/Services/CalcRuidService.cs @@ -1,8 +1,10 @@ using EgwCoreLib.Lux.Core.Stats; using EgwCoreLib.Lux.Data.Controllers; using EgwCoreLib.Lux.Data.DbModel.Stats; +using EgwCoreLib.Lux.Data.Services.Stats; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using NLog; using StackExchange.Redis; using System.Text; @@ -17,12 +19,26 @@ namespace EgwCoreLib.Lux.Data.Services { #region Public Constructors - public CalcRuidService(IConfiguration configuration, IConnectionMultiplexer redisConn, string redisBaseKey, TimeSpan retention, TimeSpan archivePeriod) : base(configuration, redisConn) + public CalcRuidService( + IConfiguration configuration, + IConnectionMultiplexer redisConn, + IServiceProvider serviceProvider) : base(configuration, redisConn) + //public CalcRuidService(IConfiguration configuration, IConnectionMultiplexer redisConn, string redisBaseKey, TimeSpan retention, TimeSpan archivePeriod) : base(configuration, redisConn) { + // leggo conf retention/archive da config... + string cleanupDayTTL = configuration.GetValue("ServerConf:CleanupDayTTL") ?? "360"; + string rBaseKey = configuration.GetValue("ServerConf:RedisBaseKey") ?? "Lux"; + int dayTTL = 360; + int archTTL = 2; + int.TryParse(cleanupDayTTL, out dayTTL); + + // imposto + _serviceProvider = serviceProvider; _db = redisConn.GetDatabase(); - _base = redisBaseKey.TrimEnd(':'); - _retention = retention; - _archivePeriod = archivePeriod; + _base = rBaseKey.TrimEnd(':'); + _retention = TimeSpan.FromDays(dayTTL); + _archivePeriod = TimeSpan.FromDays(archTTL); + // conf DB string connStr = _config.GetConnectionString("Lux.All") ?? ""; if (string.IsNullOrEmpty(connStr)) @@ -41,6 +57,9 @@ namespace EgwCoreLib.Lux.Data.Services #endregion Public Constructors + public IStatsAggrService StAggServ => _serviceProvider.GetRequiredService(); + public IStatsDetailService StDetServ => _serviceProvider.GetRequiredService(); + private readonly IServiceProvider _serviceProvider; #region Public Enums /// @@ -503,8 +522,8 @@ namespace EgwCoreLib.Lux.Data.Services } // Scrittura su DB - long aggrResult = await dbController.StatsAggrUpsertAsync(aggregatedData, true); - long detailResult = await dbController.StatsDetailModelUpsertAsync(detailData, true); + long aggrResult = await StAggServ.UpsertManyAsync(aggregatedData, true); + long detailResult = await StDetServ.UpsertManyAsync(detailData, true); // Se entrambe hanno successo, eseguo batch di cancellazione if (clearRedisAfterExport && aggrResult > 0 && detailResult > 0 && keysToDelete.Any()) @@ -782,7 +801,7 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> StatsAggrListAsync(DateTime from, DateTime to) { List answDto = new List(); - answDto = await dbController.StatsAggrGetAsync(from, to); + answDto = await StAggServ.GetFiltAsync(from, to); return answDto; } @@ -792,7 +811,7 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task StatsAggrRangeAsync() { - var answDto = await dbController.StatsAggrRangeAsync(); + var answDto = await StAggServ.GetRangeAsync(); return answDto; } diff --git a/EgwCoreLib.Lux.Data/Services/Stats/IStatsAggrService.cs b/EgwCoreLib.Lux.Data/Services/Stats/IStatsAggrService.cs index dad0ab78..205ccf66 100644 --- a/EgwCoreLib.Lux.Data/Services/Stats/IStatsAggrService.cs +++ b/EgwCoreLib.Lux.Data/Services/Stats/IStatsAggrService.cs @@ -11,7 +11,7 @@ namespace EgwCoreLib.Lux.Data.Services.Stats Task GetRangeAsync(); - Task UpsertManyAsync(List listRecords, bool removeOld); + Task UpsertManyAsync(List listRecords, bool removeOld); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Services/Stats/IStatsDetailService.cs b/EgwCoreLib.Lux.Data/Services/Stats/IStatsDetailService.cs index ee99f7a1..45e60ff8 100644 --- a/EgwCoreLib.Lux.Data/Services/Stats/IStatsDetailService.cs +++ b/EgwCoreLib.Lux.Data/Services/Stats/IStatsDetailService.cs @@ -11,7 +11,7 @@ namespace EgwCoreLib.Lux.Data.Services.Stats Task GetRangeAsync(string sEnvir, string sType); - Task UpsertAsync(List listRecords, bool removeOld); + Task UpsertManyAsync(List listRecords, bool removeOld); #endregion Public Methods } diff --git a/EgwCoreLib.Lux.Data/Services/Stats/StatsAggrService.cs b/EgwCoreLib.Lux.Data/Services/Stats/StatsAggrService.cs index f153105a..f47b272a 100644 --- a/EgwCoreLib.Lux.Data/Services/Stats/StatsAggrService.cs +++ b/EgwCoreLib.Lux.Data/Services/Stats/StatsAggrService.cs @@ -24,7 +24,7 @@ namespace EgwCoreLib.Lux.Data.Services.Stats #region Public Methods /// - /// Elenco da DB delel stats aggregate dato periodo inizio/fine + /// Elenco da DB delle stats aggregate dato periodo inizio/fine /// /// /// @@ -63,7 +63,7 @@ namespace EgwCoreLib.Lux.Data.Services.Stats /// Elenco dei record da inserire /// Se true preventivamente elimina record nel periodo richiesto /// - public async Task UpsertManyAsync(List listRecords, bool removeOld) + public async Task UpsertManyAsync(List listRecords, bool removeOld) { return await TraceAsync($"{_className}.UpsertMany", async (activity) => { diff --git a/EgwCoreLib.Lux.Data/Services/Stats/StatsDetailService.cs b/EgwCoreLib.Lux.Data/Services/Stats/StatsDetailService.cs index 77c3f470..baf3e0dd 100644 --- a/EgwCoreLib.Lux.Data/Services/Stats/StatsDetailService.cs +++ b/EgwCoreLib.Lux.Data/Services/Stats/StatsDetailService.cs @@ -1,15 +1,8 @@ -using EgwCoreLib.Lux.Data.DbModel.Config; -using EgwCoreLib.Lux.Data.DbModel.Stats; -using EgwCoreLib.Lux.Data.Repository.Config; +using EgwCoreLib.Lux.Data.DbModel.Stats; using EgwCoreLib.Lux.Data.Repository.Stats; -using EgwCoreLib.Lux.Data.Services.Config; +using EgwCoreLib.Utils; using Microsoft.Extensions.Configuration; using StackExchange.Redis; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace EgwCoreLib.Lux.Data.Services.Stats { @@ -30,22 +23,6 @@ namespace EgwCoreLib.Lux.Data.Services.Stats #region Public Methods - /// - /// Elenco completo StatsDetail da DB - /// - /// - public async Task> GetAllAsync() - { - return await TraceAsync($"{_className}.GetAll", async (activity) => - { - return await GetOrSetCacheAsync( - $"{_redisBaseKey}:{_className}:ALL", - async () => await _repo.GetAllAsync(), - UltraLongCache - ); - }); - } - /// /// Recupera dati stats di dettaglio dato filtro envir/tipo (opzionali) e periodo /// @@ -56,27 +33,14 @@ namespace EgwCoreLib.Lux.Data.Services.Stats /// public async Task> GetFiltAsync(DateTime dtStart, DateTime dtEnd, string sEnvir = "", string sType = "") { - await using var dbCtx = await CreateContextAsync(); - List answ = new List(); - - // recupero ed ordino per data-ora - var query = dbCtx.DbSetStatsDet - .Where(x => x.Hour >= dtStart && x.Hour <= dtEnd); - - if (!string.IsNullOrEmpty(sEnvir)) - query = query.Where(x => x.Environment == sEnvir); - - if (!string.IsNullOrEmpty(sType)) - query = query.Where(x => x.Type == sType); - - answ = await query - .AsNoTracking() - .OrderBy(x => x.Hour) - .ThenBy(x => x.Environment) - .ThenBy(x => x.Type) - .ToListAsync(); - - return answ; + return await TraceAsync($"{_className}.GetFilt", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:{_className}:DT:{dtStart:yyyyMMdd}:{dtEnd:yyyyMMdd}", + async () => await _repo.GetFiltAsync(dtStart, dtEnd), + UltraLongCache + ); + }); } /// @@ -87,22 +51,14 @@ namespace EgwCoreLib.Lux.Data.Services.Stats /// public async Task GetRangeAsync(string sEnvir, string sType) { - await using var dbCtx = await CreateContextAsync(); - DtUtils.Periodo answ = new DtUtils.Periodo(DtUtils.PeriodSet.Today); - - var query = dbCtx.DbSetStatsDet.AsQueryable(); - - if (!string.IsNullOrEmpty(sEnvir)) - query = query.Where(x => x.Environment == sEnvir); - - if (!string.IsNullOrEmpty(sType)) - query = query.Where(x => x.Type == sType); - - var minHour = await query.MinAsync(x => x.Hour); - var maxHour = await query.MaxAsync(x => x.Hour); - answ.Inizio = minHour; - answ.Fine = maxHour; - return answ; + return await TraceAsync($"{_className}.GetRange", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:{_className}:Range:{sEnvir}:{sType}", + async () => await _repo.GetRangeAsync(sEnvir, sType), + UltraFastCache + ); + }); } /// @@ -111,50 +67,22 @@ namespace EgwCoreLib.Lux.Data.Services.Stats /// Elenco dei record da inserire /// Se true preventivamente elimina record nel periodo richiesto /// - public async Task UpsertAsync(List listRecords, bool removeOld) + public async Task UpsertManyAsync(List listRecords, bool removeOld) { - int answ = 0; - await using var dbCtx = await CreateContextAsync(); - await using var tx = dbCtx.Database.BeginTransaction(); - try + return await TraceAsync($"{_className}.UpsertMany", async (activity) => { - // in primis se richiesto calcolo range periodo e svuoto... - if (removeOld) - { - var firstRec = listRecords.OrderBy(x => x.Hour).FirstOrDefault(); - var lastRec = listRecords.OrderByDescending(x => x.Hour).FirstOrDefault(); + string operation = "UpsertMany"; + var success = await _repo.UpsertManyAsync(listRecords, removeOld); - if (firstRec != null && lastRec != null) - { - DateTime startDate = firstRec.Hour; - DateTime endDate = lastRec.Hour; - // uso direttamente ExecuteDelete - await dbCtx - .DbSetStatsDet - .Where(x => x.Hour >= startDate && x.Hour <= endDate) - .ExecuteDeleteAsync(); - } + activity?.SetTag("db.operation", operation); + + if (success > 0) + { + await ClearCacheAsync($"{_redisBaseKey}:{_className}:*"); } - // ora preparo inserimento massivo - await dbCtx - .DbSetStatsDet - .AddRangeAsync(listRecords); - - // salvo! - answ = await dbCtx.SaveChangesAsync(); - // commit transazione - tx.Commit(); - - // libero memoria del changeTracker - dbCtx.ChangeTracker.Clear(); - return answ; - } - catch - { - tx.Rollback(); - throw; - } + return success; + }); } #endregion Public Methods @@ -166,4 +94,4 @@ namespace EgwCoreLib.Lux.Data.Services.Stats #endregion Private Fields } -} +} \ No newline at end of file diff --git a/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs b/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs index d761a14f..5ee95471 100644 --- a/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs +++ b/EgwCoreLib.Lux.Data/Services/StatsCollectService.cs @@ -1,9 +1,7 @@ -using EgwCoreLib.Lux.Data.Services; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -using System; -using System.Threading; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace EgwCoreLib.Lux.Data.Services { @@ -11,49 +9,74 @@ namespace EgwCoreLib.Lux.Data.Services { #region Public Constructors - /// - /// Init classe con il servizio di gestione RUID - /// - /// - public StatsCollectService(IConfiguration config, CalcRuidService crService) + public StatsCollectService( + IConfiguration config, + IServiceScopeFactory scopeFactory, + ILogger logger) { _config = config; - try - { - clearProcessed = _config.GetValue("ServerConf:CleanupProcessed"); - refreshPeriod = _config.GetValue("ServerConf:RefreshPeriodMinutes"); - } - catch - { - refreshPeriod = 60; - } - _calcRuidService = crService; + _scopeFactory = scopeFactory; + _logger = logger; + + _clearProcessed = _config.GetValue("ServerConf:CleanupProcessed", false); + _refreshPeriodMinutes = _config.GetValue("ServerConf:RefreshPeriodMinutes", 60); } #endregion Public Constructors - private bool clearProcessed = false; - #region Protected Methods protected override async Task ExecuteAsync(CancellationToken stoppingToken) { + _logger.LogInformation("StatsCollectService started. RefreshPeriod={Minutes} clearProcessed={Clear}", + _refreshPeriodMinutes, _clearProcessed); + while (!stoppingToken.IsCancellationRequested) { - await _calcRuidService.ExportStatsToDbAsync(clearProcessed); + try + { + // crea uno scope per risolvere servizi scoped (CalcRuidService incluso) + await using var scope = _scopeFactory.CreateAsyncScope(); + var calcRuid = scope.ServiceProvider.GetRequiredService(); - // attesa tra le esecuzioni - await Task.Delay(TimeSpan.FromMinutes(refreshPeriod), stoppingToken); + // esegui l'operazione; passa lo stoppingToken se il metodo lo supporta + await calcRuid.ExportStatsToDbAsync(_clearProcessed); + } + catch (OperationCanceledException) when (stoppingToken.IsCancellationRequested) + { + // shutdown in corso: esci pulitamente + _logger.LogInformation("StatsCollectService cancellation requested."); + break; + } + catch (Exception ex) + { + // logga l'errore ma non lasciare che l'host si fermi + _logger.LogError(ex, "Errore durante ExportStatsToDbAsync. Il servizio continuerà a riprovare."); + } + + try + { + await Task.Delay(TimeSpan.FromMinutes(_refreshPeriodMinutes), stoppingToken); + } + catch (OperationCanceledException) + { + // shutdown: esci + break; + } } + + _logger.LogInformation("StatsCollectService stopping."); } #endregion Protected Methods #region Private Fields - private readonly CalcRuidService _calcRuidService; - private IConfiguration _config; - private int refreshPeriod = 10; + private readonly bool _clearProcessed; + private readonly IConfiguration _config; + private readonly ILogger _logger; + private readonly int _refreshPeriodMinutes; + private readonly IServiceScopeFactory _scopeFactory; #endregion Private Fields } diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 1c257d37..286d0a1f 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2603.2019 + 1.1.2603.2111 diff --git a/Lux.API/Program.cs b/Lux.API/Program.cs index 3888bb29..27f74534 100644 --- a/Lux.API/Program.cs +++ b/Lux.API/Program.cs @@ -139,8 +139,6 @@ builder.Services.AddSingleton(redisConn); builder.Services.AddSingleton(); builder.Services.AddSingleton(); - - var connectionString = builder.Configuration.GetConnectionString("Lux.All") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); // DataLayerContext (manca!) builder.Services.AddDbContextFactory(options => @@ -170,18 +168,8 @@ builder.Services.AddScoped(); builder.Services.AddHostedService(); // init servizio gestone ReqIndex -string cleanupDayTTL = configuration.GetValue("ServerConf:CleanupDayTTL") ?? "360"; -string rBaseKey = configuration.GetValue("ServerConf:RedisBaseKey") ?? "Lux"; -int dayTTL = 360; -int archTTL = 2; -int.TryParse(cleanupDayTTL, out dayTTL); -builder.Services.AddSingleton(new CalcRuidService( - configuration, - redisConn, - redisBaseKey: rBaseKey, - retention: TimeSpan.FromDays(dayTTL), - archivePeriod: TimeSpan.FromDays(archTTL) -)); +builder.Services.AddScoped(); +//builder.Services.AddSingleton(new CalcRuidService(configuration, redisConn)); builder.Services.AddHostedService(); diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index b83502f6..b938fdf5 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.2019 + 1.1.2603.2111 diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs index f355edf7..8f53699a 100644 --- a/Lux.UI/Program.cs +++ b/Lux.UI/Program.cs @@ -140,6 +140,12 @@ builder.Services.AddAuthentication(options => }) .AddIdentityCookies(); +// registro connMultiplexer REDIS +builder.Services.AddSingleton(redisConn); +// registro wrapper servizi REDIS +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + var conn = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found."); // ApplicationDbContext (già presente) @@ -168,6 +174,9 @@ builder.Services.AddDbContextFactory(options => builder.Services.AddDatabaseDeveloperPageExceptionFilter(); +// registrazione in blocco servizi con metodo extension custom +builder.Services.AddLuxData(conn); + builder.Services.AddIdentityCore(options => options.SignIn.RequireConfirmedAccount = true) .AddEntityFrameworkStores() .AddSignInManager() @@ -175,12 +184,6 @@ builder.Services.AddIdentityCore(options => options.SignIn.Requ builder.Services.AddSingleton, IdentityNoOpEmailSender>(); - -// registro connMultiplexer REDIS -builder.Services.AddSingleton(redisConn); -// registro wrapper servizi REDIS -builder.Services.AddSingleton(); -builder.Services.AddSingleton(); // Aggiunta servizi specifici builder.Services.AddSingleton(); builder.Services.AddSingleton(); @@ -188,23 +191,9 @@ builder.Services.AddSingleton(); builder.Services.AddSingleton(); builder.Services.AddSingleton(); - -// registrazione in blocco servizi con metodo extension custom -builder.Services.AddLuxData(conn); - // init servizio gestone ReqIndex -string cleanupDayTTL = configuration.GetValue("ServerConf:CleanupDayTTL") ?? "360"; -string rBaseKey = configuration.GetValue("ServerConf:RedisBaseKey") ?? "Lux"; -int dayTTL = 360; -int archTTL = 2; -int.TryParse(cleanupDayTTL, out dayTTL); -builder.Services.AddSingleton(new CalcRuidService( - configuration, - redisConn, - redisBaseKey: rBaseKey, - retention: TimeSpan.FromDays(dayTTL), - archivePeriod: TimeSpan.FromDays(archTTL) -)); +builder.Services.AddScoped(); +//builder.Services.AddSingleton(new CalcRuidService(configuration, redisConn)); // lo gestisco solo via API... #if false diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 93fe476a..06fa929d 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2603.2019

+

Versione: 1.1.2603.2111


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index fdaf61d6..17f8de52 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2603.2019 +1.1.2603.2111 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 8ace2160..ba23e1d7 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2603.2019 + 1.1.2603.2111 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false