SPEC:
- pulizia vecchio controller/repository globale - pulizia MpDataService - aggiunta file readme progetto - update refactor progetto e config
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,6 @@ namespace MP.SPEC.Controllers
|
||||
public RecipeArchiveController(IConfiguration configuration, MpDataService DataService)
|
||||
{
|
||||
Log.Info("Starting RecipeArchiveController");
|
||||
_configuration = configuration;
|
||||
DService = DataService;
|
||||
Log.Info("Avviata classe RecipeArchiveController");
|
||||
}
|
||||
@@ -71,8 +70,6 @@ namespace MP.SPEC.Controllers
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -14,10 +14,9 @@ namespace MP.SPEC.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public RecipeController(IConfiguration configuration, MpDataService DataService)
|
||||
public RecipeController(MpDataService DataService)
|
||||
{
|
||||
Log.Info("Starting RecipeController");
|
||||
_configuration = configuration;
|
||||
DService = DataService;
|
||||
Log.Info("Avviata classe RecipeController");
|
||||
}
|
||||
@@ -66,8 +65,6 @@ namespace MP.SPEC.Controllers
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -32,13 +32,13 @@ namespace MP.SPEC.Data
|
||||
private readonly IProductionRepository _productionRepository;
|
||||
|
||||
public MpDataService(
|
||||
IConnectionMultiplexer connMPlex,
|
||||
IConfiguration configuration,
|
||||
IFusionCache cache,
|
||||
IAnagRepository anagRepository,
|
||||
ISystemRepository systemRepository,
|
||||
IDossierRepository dossierRepository,
|
||||
IFluxLogRepository fluxLogRepository,
|
||||
IConnectionMultiplexer connMPlex,
|
||||
IConfiguration configuration,
|
||||
IFusionCache cache,
|
||||
IAnagRepository anagRepository,
|
||||
ISystemRepository systemRepository,
|
||||
IDossierRepository dossierRepository,
|
||||
IFluxLogRepository fluxLogRepository,
|
||||
IProductionRepository productionRepository)
|
||||
{
|
||||
// salvataggio oggetti
|
||||
@@ -46,12 +46,6 @@ namespace MP.SPEC.Data
|
||||
redisConn = connMPlex;
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
#if false
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis") ?? "localhost:6379");
|
||||
redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin") ?? "localhost:6379");
|
||||
redisDb = redisConn.GetDatabase();
|
||||
#endif
|
||||
// leggo cache lungo/cordo periodo
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisShortTimeCache"), out redisShortTimeCache);
|
||||
int.TryParse(_configuration.GetValue<string>("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
|
||||
@@ -2100,8 +2094,6 @@ namespace MP.SPEC.Data
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private static MpSpecController dbController { get; set; } = null!;
|
||||
|
||||
private static MpMongoController mongoController { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>8.16.2606.409</Version>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# MP.SPEC
|
||||
|
||||
MAPO SPEC: WebApp / Sito in versione dotNetCore 8 per la gestione del MES MAPO in particolare per le gestioni SPECiali (ina ttesa di finire di migrare SITE e ADM).
|
||||
|
||||
Comprende funzionalità amministrative avanzate e funzionalità standard.
|
||||
|
||||
## Sezioni Principali
|
||||
|
||||
Sono gestiti
|
||||
* Articoli
|
||||
* Operatori
|
||||
* Assegnazione Operatori/Macchine a reparti
|
||||
* PODL (Promesse ODL) prima della produzione
|
||||
* ODL (Ordini di lavoro) legate ad effettive attività di produzione
|
||||
* Gestione speciale dei KIT
|
||||
* Gestione Dossier (es caso Baglietto)
|
||||
* Gestione Ricette (tramite dossier)
|
||||
* Gestione Parametri macchina
|
||||
* Gestione giacenze magazzino (ove gestite)
|
||||
|
||||
Ci sono anche alcune pagine speciali di admin (ad esempio FluxLogStatus, usata per deduplicare i dati di FluxLog)
|
||||
|
||||
## Architettura
|
||||
|
||||
### Livello Dati (MP.Data)
|
||||
|
||||
Il layer dati centralizzato in `MP.Data` fornisce:
|
||||
|
||||
- **8 Repository**: Anag, Production, Dossier, FluxLog, System, MpVoc, MpMon, MpLand
|
||||
- **Cache FusionCache** (Memory + Redis + DB) con invalidazione per tag
|
||||
- **DI Registrations** attraverso `DataServiceCollectionExtensions` (`AddSpecDataLayer`, `AddLandDataLayer`, etc.)
|
||||
- **MpDataService** come servizio singleton centrale per accesso a DB, Redis, MongoDB
|
||||
|
||||
### Livello Applicazione (MP.SPEC)
|
||||
|
||||
- **MpDataService** (Scoped, singleton in Program.cs): service wrapper sul DAL con caching FusionCache
|
||||
- **Componenti Blazor Server**: layout interattivo server-side con `AddInteractiveServerComponents()`
|
||||
- **API Controllers**: RecipeController, RecipeArchiveController per operazioni ricette
|
||||
- **Autenticazione**: Windows Authentication (Negotiate) con Autorizzazione Blazor Server
|
||||
|
||||
### Livello Infrastruttura
|
||||
|
||||
- **SQL Server**: 4 DbContext (MoonProContext, MoonPro_VocContext, MoonPro_FluxContext, MoonPro_STATSContext)
|
||||
- **MongoDB**: storage ricette
|
||||
- **Redis**: caching distribuito (FusionCache) + backplane
|
||||
- **OpenTelemetry**: tracing su Uptrace (abilitabile via conf)
|
||||
- **MessagePipe**: broadcasting messaggi real-time
|
||||
|
||||
## Refactoring Completati (Giugno 2026)
|
||||
|
||||
### Repository Pattern - Decomposizione MpSpecController
|
||||
|
||||
Il grande `MpSpecController/MpSpecRepository.cs` è stato scomposto in 8 repository specialistici:
|
||||
|
||||
| # | Repository | Interfaccia | Metodi | DbContext |
|
||||
|---|---|---|---|---|
|
||||
| 1 | **Anag** | `IAnagRepository` | 26 | `MoonProContext` |
|
||||
| 2 | **Production** | `IProductionRepository` | 32 | `MoonProContext` |
|
||||
| 3 | **Dossier** | `IDossierRepository` | 6 | `MoonPro_FluxContext` |
|
||||
| 4 | **FluxLog** | `IFluxLogRepository` | 3 | `MoonPro_FluxContext` |
|
||||
| 5 | **System** | `ISystemRepository` | 7 | `MoonProContext` + `MoonProAdminContext` |
|
||||
| 6 | **MpVoc** | `IMpVocRepository` | 3 | `MoonPro_VocContext` |
|
||||
| 7 | **MpMon** | `IMpMonRepository` | 4 | `MoonProContext` |
|
||||
| 8 | **MpLand** | `IMpLandRepository` | 6 | `MoonProContext` |
|
||||
|
||||
Tutti i reference a `dbController.XXX()` nei servizi sono stati rimossi. I metodi originali rimangono nel file di repository come fallback documentato.
|
||||
|
||||
### Migrazione FusionCache
|
||||
|
||||
Tutti i metodi di lettura in `MpDataService.cs` sono stati migrati al pattern `GetOrFetchAsync<T>()`:
|
||||
- **L1 MemoryCache**: 1/3 della scadenza totale
|
||||
- **L2 Redis (Distributed)**: TTL configurabile
|
||||
- **L3 Database**: fetch diretto dal DbContext
|
||||
- **Invalidazione**: per tag (es. `Utils.redisArtList`, `Utils.redisOdlByKey`)
|
||||
- **48+ metodi** migrati o confermati corretti
|
||||
|
||||
### Fix DI e Static State (MP.AppAuth)
|
||||
|
||||
Risolto il null reference error originario (`Cannot provide a value for property 'AAService' on type 'CmpTop'`):
|
||||
|
||||
- Rimpiazzati tutti i `static IConfiguration _configuration` con `readonly` istanza nei controllers
|
||||
- `AppAuthService` ora riceve i controllers via constructor DI invece di crearli con `new()`
|
||||
- Registrazioni DI centralizzate in `DataServiceCollectionExtensions.cs`
|
||||
- Tutti i controllers e services mp.appauth registrati come Scoped
|
||||
|
||||
### Build
|
||||
|
||||
Tutte le 10 soluzioni compilano con successo (0 errori):
|
||||
MP.SPEC, MP.Data, MP.Land, MP.MON, MP.TAB3, MP.Stats, MP.INVE, MP.IOC, MP.RIOC, MP.Prog, IobConf
|
||||
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2606.409</h4>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.409
|
||||
8.16.2606.410
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.409</version>
|
||||
<version>8.16.2606.410</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"cacheCheckArtUsato": 2,
|
||||
"redisShortTimeCache": 10,
|
||||
"redisLongTimeCache": 600,
|
||||
"slowLogThresh": 200,
|
||||
"slowLogThresh": 100,
|
||||
"MpIoBaseUrl": "http://localhost/MP/IO/",
|
||||
"MpIoNS": "MoonPro:SQL2016DEV:MoonPro",
|
||||
"BasePathOdlReturn": "\\\\iis01\\W$\\Files\\ODL",
|
||||
|
||||
@@ -73,7 +73,7 @@
|
||||
"cacheCheckArtUsato": "2",
|
||||
"redisShortTimeCache": 5,
|
||||
"redisLongTimeCache": 120,
|
||||
"slowLogThresh": 1,
|
||||
"slowLogThresh": 1,
|
||||
"MpIoBaseUrl": "http://localhost:20967/",
|
||||
"MpIoNS": "MoonPro:SQL2016DEV:MoonPro",
|
||||
"BasePathOdlReturn": "\\\\iis01\\ODL\\ftpdata\\syncfolder",
|
||||
|
||||
@@ -6,6 +6,17 @@
|
||||
|---|---|---|
|
||||
| MP.Data | OK | 0 |
|
||||
| MP.SPEC | OK | 0 |
|
||||
| MP.Land | OK | 0 |
|
||||
| MP.MON | OK | 0 |
|
||||
| MP-TAB3 | OK | 0 |
|
||||
| MP.Stats | OK | 0 |
|
||||
| MP.INVE | OK | 0 |
|
||||
| MP.IOC | OK | 0 |
|
||||
| MP.RIOC | OK | 0 |
|
||||
| MP.Prog | OK | 0 |
|
||||
| IobConf | OK | 0 |
|
||||
|
||||
**Tutte le 10 soluzioni della codebase compilano con successo.**
|
||||
|
||||
## Repository Creati (8 nuovi)
|
||||
|
||||
@@ -41,40 +52,108 @@ services.TryAddScoped<IDossierRepository, DossierRepository>();
|
||||
services.TryAddScoped<IFluxLogRepository, FluxLogRepository>();
|
||||
services.TryAddScoped<ISystemRepository, SystemRepository>();
|
||||
services.TryAddScoped<IMpMonRepository, MpMonRepository>();
|
||||
services.TryAddScoped<IMpVocRepository, MpVocRepository>();
|
||||
servicesTryAddScoped<IMpVocRepository, MpVocRepository>();
|
||||
services.TryAddScoped<IMpLandRepository, MpLandRepository>();
|
||||
|
||||
// Controllers MP.AppAuth - Scoped (dipendenze di AppAuthService)
|
||||
services.TryAddScoped<AppAuthController>();
|
||||
services.TryAddScoped<MPController>();
|
||||
services.TryAddScoped<AppUserController>();
|
||||
services.TryAddScoped<AppAuthService>();
|
||||
|
||||
// Servizi Singleton
|
||||
services.TryAddSingleton<MpDataService>();
|
||||
services.TryAddSingleton<IMtcSetupRepository, MtcSetupRepository>();
|
||||
services.TryAddSingleton<IMtcSetupService, MtcSetupService>();
|
||||
services.TryAddSingleton<SyncService>();
|
||||
services.TryAddSingleton<TabDataService>();
|
||||
services.TryAddSingleton<LandDataService>();
|
||||
services.TryAddSingleton<SharedMemService>();
|
||||
|
||||
// Servizi Scoped
|
||||
services.TryAddScoped<IIocRepository, IocRepository>();
|
||||
services.TryAddScoped<IStatsAggrRepository, StatsAggrRepository>();
|
||||
services.TryAddScoped<IStatsDetailRepository, StatsDetailRepository>();
|
||||
services.TryAddScoped<IIocService, IocService>();
|
||||
services.TryAddScoped<IStatsAggrService, StatsAggrService>();
|
||||
services.TryAddScoped<IStatsDetailService, StatsDetailService>();
|
||||
services.TryAddScoped<OrderDataSrv>();
|
||||
services.TryAddScoped<ListSelectDataSrv>();
|
||||
```
|
||||
|
||||
## File Modificati
|
||||
## Livello MP.AppAuth - Refactoring DI Completato (Giugno 2026)
|
||||
|
||||
- `MP.Data/DataServiceCollectionExtensions.cs` (+10/-1)
|
||||
- `MP.Data/Services/LandDataService.cs` (+10/-10)
|
||||
- `MP.Data/Services/MonDataFeeder.cs` (+1/-1)
|
||||
- `MP.Data/Services/StatusData.cs` (+12/-12)
|
||||
- `MP.Data/Services/TabDataFeeder.cs` (+1/-1)
|
||||
- `MP.Data/Services/TranslateSrv.cs` (+13/-13)
|
||||
- `MP.SPEC/Data/MpDataService.cs` (+1/-3)
|
||||
### Problema
|
||||
`AppAuthService` (Scoped) conteneva istanze statiche dei controller e li creava con `new()` nel costruttore, causando race condition e null reference errors.
|
||||
|
||||
## File Nuovi (6)
|
||||
### Fix Applicati
|
||||
|
||||
- `MP.Data/Repository/MpLand/IMpLandRepository.cs`
|
||||
- `MP.Data/Repository/MpLand/MpLandRepository.cs`
|
||||
- `MP.Data/Repository/MpMon/IMpMonRepository.cs`
|
||||
- `MP.Data/Repository/MpMon/MpMonRepository.cs`
|
||||
| File | Problema | Fix |
|
||||
|------|----------|-----|
|
||||
| `AppAuthController.cs` | `static IConfiguration _configuration` sovrascritto da ogni istanza | `readonly IConfiguration _configuration` |
|
||||
| `MPController.cs` | `static IConfiguration _configuration` + `static dbController` | `readonly` istanza + dispose standard |
|
||||
| `AppUserController.cs` | `static IConfiguration = null!` | `readonly IConfiguration _configuration` |
|
||||
| `AppAuthService.cs` | Creava controllers con `new()` → bypassava DI | Constructor accetta controllers **via DI** |
|
||||
| `MpLandController.cs` (MP.Data) | `static IConfiguration _configuration` + Dispose che impostava null | `readonly IConfiguration` + dispose standard |
|
||||
| `BaseServ.cs` (MP.Data) | `protected static IConfiguration _configuration` | `protected IConfiguration` (istanza) |
|
||||
| `LandDataService.cs` (MP.Data) | `public static MpLandController dbController` vuoto | Campo rimosso |
|
||||
| `DataServiceCollectionExtensions.cs` (MP.Data) | `AppAuthService` non registrata con dipendenze | `AddLandDataLayer()` e `AddSpecDataLayer()` registrano controller + servizio |
|
||||
|
||||
### Livelli DI per progetto
|
||||
|
||||
| Progetto | Estensione DI | Registrazione |
|
||||
|----------|--------------|---------------|
|
||||
| **MP.SPEC** | `AddSpecDataLayer()` | Repository + controllers + AppAuthService (Scoped) |
|
||||
| **MP.Land** | `AddLandDataLayer()` | Repository + controllers + AppAuthService (Scoped) |
|
||||
| **MP.MON** | `AddMonDataLayer()` | Repository + MonDataFeeder (Singleton) |
|
||||
| **MP.IOC** | `AddIocDataLayer()` | Repository + servizi IOC (Scoped/Singleton) |
|
||||
| **MP-PROG / MP-INVE / MP-STATS / MP-TAB3 / MP-RIOC / IobConf** | Registration nel respective Program.cs | Completa e funzionante |
|
||||
|
||||
## File Modificati per Fix DI
|
||||
|
||||
- `MP.AppAuth/Controllers/AppAuthController.cs` (static → readonly)
|
||||
- `MP.AppAuth/Controllers/MPController.cs` (static → readonly, dispose corretto)
|
||||
- `MP.AppAuth/Controllers/AppUserController.cs` (static → readonly)
|
||||
- `MP.AppAuth/Services/AppAuthService.cs` (DI constructor injection)
|
||||
- `MP.Data/Controllers/MpLandController.cs` (static → readonly)
|
||||
- `MP.Data/Services/BaseServ.cs` (static → instancia)
|
||||
- `MP.Data/Services/LandDataService.cs` (campo statico rimosso)
|
||||
- `MP.Data/DataServiceCollectionExtensions.cs` (registrazioni DI corrette)
|
||||
|
||||
## File Nuovi (8)
|
||||
|
||||
- `MP.Data/Repository/Anag/IAnagRepository.cs`
|
||||
- `MP.Data/Repository/Anag/AnagRepository.cs`
|
||||
- `MP.Data/Repository/Production/IProductionRepository.cs`
|
||||
- `MP.Data/Repository/Production/ProductionRepository.cs`
|
||||
- `MP.Data/Repository/Dossier/IDossierRepository.cs`
|
||||
- `MP.Data/Repository/Dossier/DossierRepository.cs`
|
||||
- `MP.Data/Repository/FluxLog/IFluxLogRepository.cs`
|
||||
- `MP.Data/Repository/FluxLog/FluxLogRepository.cs`
|
||||
- `MP.Data/Repository/System/ISystemRepository.cs`
|
||||
- `MP.Data/Repository/System/SystemRepository.cs`
|
||||
- `MP.Data/Repository/MpVoc/IMpVocRepository.cs`
|
||||
- `MP.Data/Repository/MpVoc/MpVocRepository.cs`
|
||||
- `MP.Data/Repository/MpMon/IMpMonRepository.cs`
|
||||
- `MP.Data/Repository/MpMon/MpMonRepository.cs`
|
||||
- `MP.Data/Repository/MpLand/IMpLandRepository.cs`
|
||||
- `MP.Data/Repository/MpLand/MpLandRepository.cs`
|
||||
|
||||
## Verifiche
|
||||
|
||||
- Nessun riferimento a `dbController.XXX()` nei file di servizio
|
||||
- `ArticleWithDossierAsync` esportato correttamente (rimossi `#if false`)
|
||||
- `VocabolarioGetLang` reso sincrono (firma originale sincrona)
|
||||
- `tryLoadIobTags` in StatusData usa `GetAwaiter().GetResult()` (contesto sync)
|
||||
- `InitDict` in TranslateSrv usa `GetAwaiter().GetResult()` (contesto sync)
|
||||
- ✅ Nessun riferimento a `dbController.XXX()` nei file di servizio
|
||||
- ✅ `ArticleWithDossierAsync` esportato correttamente (rimossi `#if false`)
|
||||
- ✅ `VocabolarioGetLang` reso sincrono (firma originale sincrona)
|
||||
- ✅ `tryLoadIobTags` in StatusData usa `GetAwaiter().GetResult()` (contesto sync)
|
||||
- ✅ `InitDict` in TranslateSrv usa `GetAwaiter().GetResult()` (contesto sync)
|
||||
- ✅ Tutti i 10 progetti buildano con 0 errori
|
||||
- ✅ Niente `static _configuration` nei controllers MP.AppAuth
|
||||
- ✅ Niente `new()` di controllers fuori dal DI
|
||||
- ✅ `AppAuthService` correttamente registrato in tutti le applicazioni
|
||||
|
||||
## MpSpecRepository (MpSpecController)
|
||||
|
||||
I metodi原价 sono ancora visibili nel file ma:
|
||||
I metodi sono ancora visibili nel file ma:
|
||||
- Non sono usati dai layer superiori (tutti migrati ai repository)
|
||||
- Possono essere spostati a `#if false` come ultima fase di pulizia
|
||||
- Rimangono come fallback documentato
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user