diff --git a/MP-RIOC/MP.RIOC.csproj b/MP-RIOC/MP.RIOC.csproj index e2cd4295..5ee72a40 100644 --- a/MP-RIOC/MP.RIOC.csproj +++ b/MP-RIOC/MP.RIOC.csproj @@ -5,7 +5,7 @@ enable enable MP.RIOC - 8.16.2605.808 + 8.16.2605.809 @@ -28,6 +28,15 @@ + + + Always + + + Always + + + diff --git a/MP-RIOC/Program.cs b/MP-RIOC/Program.cs index c532a415..31e3342f 100644 --- a/MP-RIOC/Program.cs +++ b/MP-RIOC/Program.cs @@ -1,4 +1,7 @@ -using MP.RIOC.Services; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using MP.Core.Conf; +using MP.Data; using MP.RIOC.Services; using NLog; using NLog.Web; @@ -23,10 +26,33 @@ logger.Info($"Current ASPNETCORE_ENVIRONMENT: {env.EnvironmentName}"); ConfigurationManager configuration = builder.Configuration; // REDIS setup logger.Info("Config OK"); -string confRedis = configuration.GetConnectionString("Redis"); +string confRedis = configuration.GetConnectionString("Redis") ?? "localhost:6379"; string redisSrvAddr = confRedis.Substring(0, confRedis.IndexOf(":")); logger.Info("Setup REDIS OK"); +builder.Services.Configure( + builder.Configuration.GetSection("RedisScripts")); +logger.Info("RedisScript Provider configured"); + +// Metodi principali x accesso dati +var connStr = builder.Configuration.GetConnectionString("MP.Data") + ?? throw new InvalidOperationException("ConnString 'MP.Data' mancante."); + +//builder.Services.AddMemoryCache(); + +builder.Services.AddDbContextFactory(options => + options.UseSqlServer(connStr) + .EnableSensitiveDataLogging(false) // true solo in Sviluppo + .ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning))); + +// MP.Data DbContext for Stats repositories +string utilsConnString = builder.Configuration.GetConnectionString("MP.Utils") ?? "Server=localhost;Database=MoonPro_Utils; integrated security=True; MultipleActiveResultSets=True; App=MP.IOC;"; +builder.Services.AddDbContextFactory(options => + options.UseSqlServer(utilsConnString)); + +// MP.Data Services Utils - Statistiche DB +builder.Services.AddIocDataLayer(); + // 1. Configurazione dell'invoker personalizzato (Risolve i tuoi errori) var httpClientInvoker = new HttpMessageInvoker(new SocketsHttpHandler { @@ -36,7 +62,7 @@ var httpClientInvoker = new HttpMessageInvoker(new SocketsHttpHandler UseCookies = false, // Correzione per il tracing: usa il propagatore corrente di sistema ActivityHeadersPropagator = DistributedContextPropagator.Current, - ConnectTimeout = TimeSpan.FromSeconds(15), + ConnectTimeout = TimeSpan.FromSeconds(30), // Gestione certificato (ignora errori per localhost/test) SslOptions = new System.Net.Security.SslClientAuthenticationOptions @@ -82,6 +108,22 @@ builder.Services.AddRazorPages(); var app = builder.Build(); +// Blocco per la migrazione automatica del DB Utils... +using (var scope = app.Services.CreateScope()) +{ + var services = scope.ServiceProvider; + try + { + var context = services.GetRequiredService(); + context.Database.Migrate(); + } + catch (Exception ex) + { + var migrateLogger = services.GetRequiredService>(); + migrateLogger.LogError(ex, "Si � verificato un errore durante l'aggiornamento del database."); + } +} + // 1. Configurazione Base Path string baseUrl = configuration.GetValue("ServerConf:BaseUrlIoc") ?? "/MP/RIOC"; app.UsePathBase(baseUrl); diff --git a/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml b/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml index d91b9388..853c1cd4 100644 --- a/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml +++ b/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml @@ -1,25 +1,32 @@  - - MSDeploy - true - Release - Any CPU - https://iis01.egalware.com/MP/RIOC/ - false - b9188473-f4ae-4f9f-be2d-70edaace0db9 - false - https://iis01.egalware.com:8172/MsDeploy.axd - Default Web Site/MP/RIOC - - false - WMSVC - true - true - jenkins - <_SavePWD>true - <_TargetId>IISWebDeploy - net8.0 - + + MSDeploy + true + Release + Any CPU + https://iis01.egalware.com/MP/RIOC/ + false + b9188473-f4ae-4f9f-be2d-70edaace0db9 + false + https://iis01.egalware.com:8172/MsDeploy.axd + Default Web Site/MP/RIOC + + false + logs + WMSVC + true + true + jenkins + <_SavePWD>true + <_TargetId>IISWebDeploy + net8.0 + + + + dirPath + \\logs$ + + \ No newline at end of file diff --git a/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml.user b/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml.user index 00f79f0d..7b6e593f 100644 --- a/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml.user +++ b/MP-RIOC/Properties/PublishProfiles/IIS01.pubxml.user @@ -2,7 +2,7 @@ - False|2026-05-08T07:04:47.5869659Z||;False|2026-05-08T09:01:28.1405561+02:00||;False|2026-05-08T09:00:37.4358771+02:00||;False|2026-05-08T08:58:53.9394322+02:00||;False|2026-05-08T08:57:18.3710854+02:00||;False|2026-05-08T08:56:39.0642155+02:00||;True|2026-05-08T08:36:15.4113336+02:00||;False|2026-05-08T08:35:31.1992313+02:00||;False|2026-05-08T08:34:56.3101908+02:00||;False|2026-05-08T08:34:41.2943768+02:00||;True|2026-05-08T08:28:29.2065443+02:00||; + True|2026-05-08T07:44:50.2145461Z||;False|2026-05-08T09:42:53.1130763+02:00||;True|2026-05-08T09:34:45.8167687+02:00||;False|2026-05-08T09:34:21.4017890+02:00||;True|2026-05-08T09:24:04.8527556+02:00||;False|2026-05-08T09:04:47.5869659+02:00||;False|2026-05-08T09:01:28.1405561+02:00||;False|2026-05-08T09:00:37.4358771+02:00||;False|2026-05-08T08:58:53.9394322+02:00||;False|2026-05-08T08:57:18.3710854+02:00||;False|2026-05-08T08:56:39.0642155+02:00||;True|2026-05-08T08:36:15.4113336+02:00||;False|2026-05-08T08:35:31.1992313+02:00||;False|2026-05-08T08:34:56.3101908+02:00||;False|2026-05-08T08:34:41.2943768+02:00||;True|2026-05-08T08:28:29.2065443+02:00||; AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAlmCNMQ0J1UqPM+RugOqtLgAAAAACAAAAAAAQZgAAAAEAACAAAABmDmKQdTOJuzYQ2FFyU+1htQ8H/TQ+IM9D7RchZs6pvgAAAAAOgAAAAAIAACAAAABeb+XK2KUWpsQ2fiYxFKeezXYyZloQPjo9Qkmjbf+FlyAAAAAR+ckV3KTLXMIMyW4f5PBdp6Uxv5tWJ5LldbO4N+tXYUAAAACJwytTC9fJKy3wyHTlSVYRd/OdBUQ8pCweu3wSK3CGvcpgwT+VFYooELXfzgEV8l6P6FrAdGoF0gt9O3yyn1X4 diff --git a/MP-RIOC/Resources/ChangeLog-original.html b/MP-RIOC/Resources/ChangeLog-original.html new file mode 100644 index 00000000..2ec27a72 --- /dev/null +++ b/MP-RIOC/Resources/ChangeLog-original.html @@ -0,0 +1,31 @@ + + Modulo MP-RIOC +

Versione: {{CURRENT-REL}}

+
Note di rilascio: +
    +
  • + Ultime modifiche: +
      {{LAST-CHANGES}}
    +
  • +
  • + v.8.16.* → +
      +
    • Ottimizzazioni varie x Redis
    • +
    +
  • +
  • + v.8.16.* → +
      +
    • Prima release dotNet 8.0 router
    • +
    +
  • +
+
+
+ +
+ +
+ \ No newline at end of file diff --git a/MP-RIOC/Resources/ChangeLog.html b/MP-RIOC/Resources/ChangeLog.html new file mode 100644 index 00000000..5a58a32f --- /dev/null +++ b/MP-RIOC/Resources/ChangeLog.html @@ -0,0 +1,31 @@ + + Modulo MP-RIOC +

Versione: 8.16.2605.809

+
Note di rilascio: +
    +
  • + Ultime modifiche: +
      {{LAST-CHANGES}}
    +
  • +
  • + v.8.16.* → +
      +
    • Ottimizzazioni varie x Redis
    • +
    +
  • +
  • + v.8.16.* → +
      +
    • Prima release dotNet 8.0 router
    • +
    +
  • +
+
+
+ +
+ +
+ diff --git a/MP-RIOC/Resources/VersNum.txt b/MP-RIOC/Resources/VersNum.txt new file mode 100644 index 00000000..61a5fcb0 --- /dev/null +++ b/MP-RIOC/Resources/VersNum.txt @@ -0,0 +1 @@ +8.16.2605.809 diff --git a/MP-RIOC/Resources/logoSteamware.png b/MP-RIOC/Resources/logoSteamware.png new file mode 100644 index 00000000..0958b50a Binary files /dev/null and b/MP-RIOC/Resources/logoSteamware.png differ diff --git a/MP-RIOC/Resources/manifest-original.xml b/MP-RIOC/Resources/manifest-original.xml new file mode 100644 index 00000000..f95e0763 --- /dev/null +++ b/MP-RIOC/Resources/manifest-original.xml @@ -0,0 +1,7 @@ + + + 1.0.0.0 + https://nexus.steamware.net/repository/SWS/{{DIRNAME}}/{{BRANCHNAME}}/{{PACKNAME}}.zip + https://nexus.steamware.net/repository/SWS/{{DIRNAME}}/{{BRANCHNAME}}/ChangeLog.html + false + diff --git a/MP-RIOC/Resources/manifest.xml b/MP-RIOC/Resources/manifest.xml new file mode 100644 index 00000000..f973210b --- /dev/null +++ b/MP-RIOC/Resources/manifest.xml @@ -0,0 +1,7 @@ + + + 8.16.2605.809 + https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip + https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html + false + diff --git a/MP-RIOC/Services/MetricsCalcService.cs b/MP-RIOC/Services/MetricsCalcService.cs index 1accf3a5..81c164c4 100644 --- a/MP-RIOC/Services/MetricsCalcService.cs +++ b/MP-RIOC/Services/MetricsCalcService.cs @@ -1,5 +1,4 @@ -using MP.RIOC.Services; -using NLog; +using NLog; using StackExchange.Redis; using System.Globalization; @@ -56,7 +55,7 @@ namespace MP.RIOC.Services protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - var interval = _config.GetValue("RouteMan:MetricCalcIntervalSeconds", 20); + var interval = _config.GetValue("RouteMan:MetricCalcIntervalSeconds", 30); while (!stoppingToken.IsCancellationRequested) { diff --git a/MP-RIOC/Services/MetricsDbFlushService.cs b/MP-RIOC/Services/MetricsDbFlushService.cs index dbbc9eb4..1b831f82 100644 --- a/MP-RIOC/Services/MetricsDbFlushService.cs +++ b/MP-RIOC/Services/MetricsDbFlushService.cs @@ -27,7 +27,7 @@ namespace MP.RIOC.Services protected override async Task ExecuteAsync(CancellationToken stoppingToken) { - var interval = _config.GetValue("RouteMan:MetricFlushIntervalSeconds", 300); + var interval = _config.GetValue("RouteMan:MetricFlushIntervalSeconds", 180); while (!stoppingToken.IsCancellationRequested) { diff --git a/MP-RIOC/appsettings.Production.json b/MP-RIOC/appsettings.Production.json new file mode 100644 index 00000000..9d45229b --- /dev/null +++ b/MP-RIOC/appsettings.Production.json @@ -0,0 +1,24 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "CodApp": "MP.RIOC", + "ConnectionStrings": { + "MP.Data": "Server=localhost\\SQLEXPRESS;Database=MoonPro;User ID=steamware;Password=viadante16; integrated security=False; MultipleActiveResultSets=True; App=MP.RIOC;", + "MP.Utils": "Server=localhost\\SQLEXPRESS;Database=MoonPro_Utils; User ID=steamware;Password=viadante16; integrated security=False; App=MP.RIOC;", + "Redis": "localhost:6379,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", + "RedisAdmin": "localhost:6379,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true" + }, + "ServerConf": { + "useFactory": false + }, + "RedisScripts": { + "Scripts": { + "Update": "RedisScript/RedisUpdateScript_v5.lua" + } + } +} diff --git a/MP-RIOC/appsettings.json b/MP-RIOC/appsettings.json index 0f17cadb..67137685 100644 --- a/MP-RIOC/appsettings.json +++ b/MP-RIOC/appsettings.json @@ -22,6 +22,8 @@ "logfile": { "type": "File", "fileName": "${basedir}/logs/${shortdate}.log", + "keepFileOpen": false, + "concurrentWrites": true, "archiveEvery": "Day", "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", "archiveNumbering": "DateAndSequence", @@ -50,7 +52,7 @@ }, "CodApp": "MP.RIOC", "RouteMan": { - "MetricCalcIntervalSeconds": 10, + "MetricCalcIntervalSeconds": 20, "MetricFlushIntervalSeconds": 60, "DefaultWeightOld": 100, "DefaultWeightNew": 0, @@ -71,7 +73,14 @@ "redisShortTimeCache": 30, "useFactory": true }, + "RedisScripts": { + "Scripts": { + "Update": "RedisScript/RedisUpdateScript_v6.lua" + } + }, "ConnectionStrings": { + "MP.Data": "Server=SQL2016DEV;Database=MoonPro; User ID=sa;Password=keyhammer16; integrated security=False; App=MP.IOC;", + "MP.Utils": "Server=SQL2016DEV;Database=MoonPro_Utils; User ID=sa;Password=keyhammer16; integrated security=False; App=MP.RIOC;", "Redis": "redis.ufficio:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false", "RedisAdmin": "redis.ufficio:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true" } diff --git a/MP.Data/DataServiceCollectionExtensions.cs b/MP.Data/DataServiceCollectionExtensions.cs index 78eb73e2..2ff337b3 100644 --- a/MP.Data/DataServiceCollectionExtensions.cs +++ b/MP.Data/DataServiceCollectionExtensions.cs @@ -14,15 +14,6 @@ namespace MP.Data { public static IServiceCollection AddIocDataLayer(this IServiceCollection services) { - //// DbContextFactory: preferibile in Blazor Server e scenari concorrenti - //services.AddDbContextFactory(options => - // options.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString))); - - //// servizi preliminari - ////services.TryAddSingleton(redisConn); - //services.TryAddSingleton(); - //services.TryAddSingleton(); - // Repository Singleton services.TryAddSingleton(); @@ -40,14 +31,6 @@ namespace MP.Data services.TryAddScoped(); services.TryAddScoped(); - //// aggiunta servizi finali Singleton... - //services.TryAddSingleton(); - //services.TryAddSingleton(); - //services.TryAddSingleton(); - //services.TryAddSingleton(); - //services.TryAddSingleton(); - - return services; } } diff --git a/MP.IOC/Resources/ChangeLog-original.html b/MP.IOC/Resources/ChangeLog-original.html index fa79ade6..cf07d7e9 100644 --- a/MP.IOC/Resources/ChangeLog-original.html +++ b/MP.IOC/Resources/ChangeLog-original.html @@ -25,7 +25,7 @@ \ No newline at end of file diff --git a/MP.IOC/appsettings.json b/MP.IOC/appsettings.json index 0600459a..e24667d4 100644 --- a/MP.IOC/appsettings.json +++ b/MP.IOC/appsettings.json @@ -2,7 +2,6 @@ "Logging": { "LogLevel": { "Default": "Information", - "Yarp": "Debug", "Microsoft.AspNetCore": "Warning", "Microsoft.EntityFrameworkCore.Database.Command": "Warning", "Microsoft.EntityFrameworkCore.Infrastructure": "Warning", @@ -27,6 +26,8 @@ "logfile": { "type": "File", "fileName": "${basedir}/logs/${shortdate}.log", + "keepFileOpen": false, + "concurrentWrites": true, "archiveEvery": "Day", "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", "archiveNumbering": "DateAndSequence",