- completata review program.cs
- fix temporaneo init servizi data interni (da rivedere con FusionCache ...)
This commit is contained in:
Samuele Locatelli
2026-06-03 18:23:12 +02:00
parent fab32124d8
commit febe1d0132
7 changed files with 32 additions and 13 deletions
@@ -34,6 +34,7 @@ namespace MP.Data
{
// Repository Singleton
services.TryAddSingleton<IMtcSetupRepository, MtcSetupRepository>();
services.TryAddSingleton<IProductionRepository, ProductionRepository>();
// Repository Scoped
services.TryAddScoped<IIocRepository, IocRepository>();
+15 -5
View File
@@ -7,6 +7,7 @@ using MP.Data.Controllers;
using MP.Data.DbModels;
using MP.Data.DbModels.Anag;
using MP.Data.MgModels;
using MP.Data.Repository.Production;
using MP.Data.Services.IOC;
using MP.Data.Services.Mtc;
using Newtonsoft.Json;
@@ -22,17 +23,22 @@ namespace MP.IOC.Data
public class MpDataService
{
#region Public Constructors
private readonly IProductionRepository _productionRepository;
public MpDataService(
IConfiguration configuration,
ILogger<MpDataService> logger,
IServiceScopeFactory scopeFactory,
IProductionRepository productionRepository,
MpIocController mpIocCtr,
IMtcSetupService mtcServ)
{
_logger = logger;
_logger.LogInformation("Starting MpDataService INIT");
_configuration = configuration;
_scopeFactory = scopeFactory;
_productionRepository = productionRepository;
IocDbController = mpIocCtr;
// setup compoenti REDIS
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
@@ -58,8 +64,10 @@ namespace MP.IOC.Data
}
else
{
SpecDbController = new MpSpecController(configuration);
#if false
SpecDbController = new MpSpecController(configuration);
IocDbController = new MpIocController(configuration);
#endif
Log.Info("DbControllers INIT OK");
}
@@ -83,9 +91,11 @@ namespace MP.IOC.Data
#region Public Properties
public static MpIocController IocDbController { get; set; } = null!;
public static MpMongoController mongoController { get; set; } = null!;
public static MpSpecController SpecDbController { get; set; } = null!;
public static MpIocController IocDbController { get; set; } = null!;
#if false
public static MpSpecController SpecDbController { get; set; } = null!;
#endif
public MessagePipe BroadastMsgPipe { get; set; } = null!;
/// <summary>
@@ -1209,7 +1219,7 @@ namespace MP.IOC.Data
}
else
{
result = await SpecDbController.MacchineGetFiltAsync(codGruppo);
result = await _productionRepository.MacchineGetFiltAsync(codGruppo);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
@@ -1622,7 +1632,7 @@ namespace MP.IOC.Data
}
else
{
result = await SpecDbController.PODL_getByKeyAsync(idxPODL);
result = await _productionRepository.PODL_getByKeyAsync(idxPODL);
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>8.16.2606.311</Version>
<Version>8.16.2606.318</Version>
</PropertyGroup>
<ItemGroup>
+12 -4
View File
@@ -42,18 +42,26 @@ 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<MoonProContext>(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;";
string connStrUtils = builder.Configuration.GetConnectionString("MP.Utils")
?? throw new InvalidOperationException("ConnString 'MP.Utils' mancante.");
//?? "Server=localhost;Database=MoonPro_Utils; integrated security=True; MultipleActiveResultSets=True; App=MP.IOC;";
builder.Services.AddDbContextFactory<MoonPro_UtilsContext>(options =>
options.UseSqlServer(utilsConnString));
options.UseSqlServer(connStrUtils).EnableSensitiveDataLogging(false)
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
var connStrFL = builder.Configuration.GetConnectionString("MP.Flux")
?? throw new InvalidOperationException("ConnString 'MP.Flux' mancante.");
builder.Services.AddDbContextFactory<MoonPro_FluxContext>(options =>
options.UseSqlServer(connStrFL)
.EnableSensitiveDataLogging(false) // true solo in Sviluppo
.ConfigureWarnings(w => w.Ignore(CoreEventId.ManyServiceProvidersCreatedWarning)));
// MP.Data Services Utils - Statistiche DB
builder.Services.AddIocDataLayer();
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-IOC </i>
<h4>Versione: 8.16.2606.311</h4>
<h4>Versione: 8.16.2606.318</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.311
8.16.2606.318
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.311</version>
<version>8.16.2606.318</version>
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>