From 217836099ccea0d1f525e9caba6ed55111fc018f Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 3 Jun 2026 18:32:51 +0200 Subject: [PATCH] LAND: - fix program.cs startup - fix calcolo dim DB - fix IOB count --- MP.Data/DataServiceCollectionExtensions.cs | 1 + MP.Data/Repository/MpLand/MpLandRepository.cs | 8 ++++- MP.Data/Services/LandDataService.cs | 16 ++++----- MP.Land/Components/DbInfoMan.razor.cs | 10 +++--- MP.Land/MP.Land.csproj | 2 +- MP.Land/Pages/IobList.razor.cs | 6 ++-- MP.Land/Resources/ChangeLog.html | 2 +- MP.Land/Resources/VersNum.txt | 2 +- MP.Land/Resources/manifest.xml | 2 +- MP.Land/Startup.cs | 33 +++++++++++++++++-- 10 files changed, 60 insertions(+), 22 deletions(-) diff --git a/MP.Data/DataServiceCollectionExtensions.cs b/MP.Data/DataServiceCollectionExtensions.cs index 8ed9107a..826ce9f2 100644 --- a/MP.Data/DataServiceCollectionExtensions.cs +++ b/MP.Data/DataServiceCollectionExtensions.cs @@ -67,6 +67,7 @@ namespace MP.Data // Servizi LAND services.TryAddSingleton(); + services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/MP.Data/Repository/MpLand/MpLandRepository.cs b/MP.Data/Repository/MpLand/MpLandRepository.cs index 83b60fff..3eb4f9d8 100644 --- a/MP.Data/Repository/MpLand/MpLandRepository.cs +++ b/MP.Data/Repository/MpLand/MpLandRepository.cs @@ -20,10 +20,16 @@ namespace MP.Data.Repository.MpLand #region Public Constructors - public MpLandRepository(IConfiguration configuration, IDbContextFactory ctxFactory) + public MpLandRepository( + IConfiguration configuration, + IDbContextFactory ctxFactory, + IDbContextFactory ctxFactoryFL, + IDbContextFactory ctxFactorySta) { _configuration = configuration; _ctxFactory = ctxFactory; + _ctxFactoryFluxLog = ctxFactoryFL; + _ctxFactoryStats= ctxFactorySta; } #endregion diff --git a/MP.Data/Services/LandDataService.cs b/MP.Data/Services/LandDataService.cs index 1770d3eb..8351a4b8 100644 --- a/MP.Data/Services/LandDataService.cs +++ b/MP.Data/Services/LandDataService.cs @@ -88,15 +88,15 @@ namespace MP.Data.Services /// /// /// - public List IobListAll() + public async Task> IobListAllAsync() { string source = "DB"; List? dbResult = new List(); string currKey = $"{redisBaseKey}:IobList"; Stopwatch sw = new Stopwatch(); sw.Start(); - string? rawData = _redisDb.StringGet(currKey); - if (!string.IsNullOrEmpty(rawData) && rawData.Length > 2) + var rawData = await _redisDb.StringGetAsync(currKey); + if (rawData.HasValue) { source = "REDIS"; var tempResult = JsonConvert.DeserializeObject>(rawData); @@ -105,10 +105,10 @@ namespace MP.Data.Services else { // recupero RRL missing - var listRRl = _mpLandRepository.RemRebootLogGetLastAsync().GetAwaiter().GetResult(); - var listRRlAdd = _mpLandRepository.RemRebootLogGetLastNoMaccAsync().GetAwaiter().GetResult(); + var listRRl = await _mpLandRepository.RemRebootLogGetLastAsync(); + var listRRlAdd = await _mpLandRepository.RemRebootLogGetLastNoMaccAsync(); // recupero lista macchine - var ListMacch = _mpLandRepository.MacchineGetAllAsync().GetAwaiter().GetResult(); + var ListMacch = await _mpLandRepository.MacchineGetAllAsync(); // ...converto in DTO dbResult = ListMacch .Select(x => new IobDTO(x, IobInfo(x.IdxMacchina), MachIobConf(x.IdxMacchina))) @@ -125,14 +125,14 @@ namespace MP.Data.Services // serializzo in cache _redisConn rawData = JsonConvert.SerializeObject(dbResult, JSSettings); - _redisDb.StringSet(currKey, rawData, UltraLongCache); + await _redisDb.StringSetAsync(currKey, rawData, UltraLongCache); } if (dbResult == null) { dbResult = new List(); } sw.Stop(); - Log.Debug($"IobListAll | {source} | {sw.ElapsedMilliseconds} ms"); + Log.Debug($"IobListAllAsync | {source} | {sw.ElapsedMilliseconds} ms"); return dbResult; } diff --git a/MP.Land/Components/DbInfoMan.razor.cs b/MP.Land/Components/DbInfoMan.razor.cs index aae03d69..6b434c3a 100644 --- a/MP.Land/Components/DbInfoMan.razor.cs +++ b/MP.Land/Components/DbInfoMan.razor.cs @@ -5,6 +5,7 @@ using MP.Data.Services; using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; namespace MP.Land.Components { @@ -21,9 +22,10 @@ namespace MP.Land.Components #region Protected Methods - protected override void OnParametersSet() + + protected override async Task OnParametersSetAsync() { - ReloadData(); + await ReloadDataAsync(); } protected void SortRequested(Sorter.SortCallBack e) @@ -117,9 +119,9 @@ namespace MP.Land.Components } } - private void ReloadData() + private async Task ReloadDataAsync() { - ListRecord = LDService.AllDbInfo(); + ListRecord = await LDService.AllDbInfoAsync(); } #endregion Private Methods diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 508b0702..d7bc72a6 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net8.0 MP.Land - 8.16.2606.0312 + 8.16.2606.0318 Debug;Release;Debug_LiManDebug en True diff --git a/MP.Land/Pages/IobList.razor.cs b/MP.Land/Pages/IobList.razor.cs index 90157bb1..8984045a 100644 --- a/MP.Land/Pages/IobList.razor.cs +++ b/MP.Land/Pages/IobList.razor.cs @@ -173,11 +173,11 @@ namespace MP.Land.Pages return answ; } - protected void DataInit() + protected async Task DataInitAsync() { isLoading = true; // recupero TUTTI i dati IobList già completi anche on i RemoteRebootLog - AllRecords = LDService.IobListAll(); + AllRecords = await LDService.IobListAllAsync(); #if false @@ -216,7 +216,7 @@ namespace MP.Land.Pages AppMService.PageName = "IobList"; AppMService.PageIcon = "fas fa-computer pe-2"; await SetupRight(); - DataInit(); + await DataInitAsync(); } protected void ResetSearch() diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index a19361ad..5cc46a2e 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo Tablet MAPO - DotNet6 -

Versione: 8.16.2606.0312

+

Versione: 8.16.2606.0318


Note di rilascio:
    diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index b505b6b3..c21e857b 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2606.0312 +8.16.2606.0318 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index c16761d9..d2e91e50 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2606.0312 + 8.16.2606.0318 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false diff --git a/MP.Land/Startup.cs b/MP.Land/Startup.cs index b8b345a7..d318e61b 100644 --- a/MP.Land/Startup.cs +++ b/MP.Land/Startup.cs @@ -1,4 +1,4 @@ -using Blazored.LocalStorage; +using Blazored.LocalStorage; using Blazored.SessionStorage; using Microsoft.AspNetCore.Authentication.Negotiate; using Microsoft.AspNetCore.Builder; @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.Localization; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.Extensions.Caching.Distributed; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; @@ -17,6 +18,10 @@ using MP.TaskMan.Services; using StackExchange.Redis; using System; using System.Globalization; +using System.Threading.Tasks; +using ZiggyCreatures.Caching.Fusion; +using ZiggyCreatures.Caching.Fusion.Backplane.StackExchangeRedis; +using ZiggyCreatures.Caching.Fusion.Serialization.NewtonsoftJson; namespace MP.Land { @@ -121,12 +126,22 @@ namespace MP.Land options.FallbackPolicy = options.DefaultPolicy; }); + + // REDIS setup string connStringRedis = Configuration.GetConnectionString("Redis"); string redisSrvAddr = connStringRedis.Substring(0, connStringRedis.IndexOf(":")); // avvio oggetto shared x redis... - var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis); + IConnectionMultiplexer redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis); + // ✅ FusionCache + services.AddFusionCache() + .WithDistributedCache(sp => sp.GetRequiredService()) + .WithSerializer(new FusionCacheNewtonsoftJsonSerializer()) + .WithBackplane(new RedisBackplane(new RedisBackplaneOptions + { + ConnectionMultiplexerFactory = () => Task.FromResult(redisMultiplexer) + })); services.AddLocalization(); @@ -143,6 +158,20 @@ namespace MP.Land .EnableSensitiveDataLogging(false) // true solo in Sviluppo .ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning))); + var connStrFlux = Configuration.GetConnectionString("MP.Flux") + ?? throw new InvalidOperationException("ConnString 'MP.Flux' mancante."); + services.AddDbContextFactory(options => + options.UseSqlServer(connStrFlux) + .EnableSensitiveDataLogging(false) // true solo in Sviluppo + .ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning))); + + var connStrStats = Configuration.GetConnectionString("MP.Stats") + ?? throw new InvalidOperationException("ConnString 'MP.Stats' mancante."); + services.AddDbContextFactory(options => + options.UseSqlServer(connStrStats) + .EnableSensitiveDataLogging(false) // true solo in Sviluppo + .ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning))); + //init servizi specifici LAND //services.AddAuthLandDataLayer(); services.AddLandDataLayer();