Analisi progetto IOC e documentazione pre modifiche struttura DAL
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<Version>8.16.2606.414</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP_TAB3</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<h4>Versione: 8.16.2606.414</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.410
|
||||
8.16.2606.414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.410</version>
|
||||
<version>8.16.2606.414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.INVE</RootNamespace>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<Version>8.16.2606.414</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOINVE </i>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<h4>Versione: 8.16.2606.414</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.410
|
||||
8.16.2606.414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.410</version>
|
||||
<version>8.16.2606.414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/MP.INVE.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-INVE/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -13,10 +13,9 @@ namespace MP.IOC.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public BenchController(IConfiguration configuration, MpDataService DataService)
|
||||
public BenchController(MpDataService DataService)
|
||||
{
|
||||
Log.Info("Starting BenchController");
|
||||
_configuration = configuration;
|
||||
DService = DataService;
|
||||
Log.Info("Avviata BenchController");
|
||||
}
|
||||
@@ -378,8 +377,6 @@ namespace MP.IOC.Controllers
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace MP.IOC.Controllers
|
||||
|
||||
public IOBController(IConfiguration configuration, MpDataService DataService, IIocService IService)
|
||||
{
|
||||
_configuration = configuration;
|
||||
DService = DataService;
|
||||
IOCService = IService;
|
||||
}
|
||||
@@ -1451,8 +1450,6 @@ namespace MP.IOC.Controllers
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private IIocService IOCService;
|
||||
|
||||
|
||||
@@ -10,10 +10,9 @@ namespace MP.IOC.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public RecipeArchiveController(IConfiguration configuration, MpDataService DataService)
|
||||
public RecipeArchiveController(MpDataService DataService)
|
||||
{
|
||||
Log.Info("Starting RecipeArchiveController");
|
||||
_configuration = configuration;
|
||||
DService = DataService;
|
||||
Log.Info("Avviata classe RecipeArchiveController");
|
||||
}
|
||||
@@ -121,8 +120,6 @@ namespace MP.IOC.Controllers
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -12,10 +12,9 @@ namespace MP.IOC.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 RecipeController");
|
||||
}
|
||||
@@ -64,8 +63,6 @@ namespace MP.IOC.Controllers
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<Version>8.16.2606.414</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
+68
-4
@@ -1,10 +1,74 @@
|
||||
# MP.IOC
|
||||
|
||||
MAPO IOC: WebApi rest per la gestione delel chaimate dagli applicativi remoti sul campo (IOB-PI su raspberry pi e IOB-WIN su PC Windows) che si occupano di comunicare con le varie macchine di processo i dati da trasmettere al MES.
|
||||
E' la nuova implementazioen del modulo IO (il precedente era fatto in dotNet framework 4.7.2) su cui si sta dirigendo lo sviluppo della soluzione MES MAPO
|
||||
MAPO IOC: WebApi rest per la gestione delle chiamate dagli applicativi remoti sul campo (IOB-PI su Raspberry Pi e IOB-WIN su PC Windows) che si occupano di comunicare con le varie macchine di processo i dati da trasmettere al MES.
|
||||
|
||||
Integra raccolta di informazioni riguardo ai compiti svolti e uesti sono ottimizzati per l'impiego di cache e ottimizzazioni varie su ogni strato del progetto.
|
||||
È la nuova implementazione del modulo IO (il precedente era fatto in .NET Framework 4.7.2) su cui si sta dirigendo lo sviluppo della soluzione MES MAPO.
|
||||
|
||||
Integra raccolta di informazioni riguardo ai compiti svolti e questi sono ottimizzati per l'impiego di cache e ottimizzazioni varie su ogni strato del progetto.
|
||||
|
||||
## Sezioni Principali
|
||||
|
||||
Il metodo principale è una webApi che risponde all'indirizzo api/IOB, è presente una documentazione swagger (in develop)
|
||||
- Api IOB (`api/IOB`) — endpoint principale per comunicazioni da campo (52 metodi)
|
||||
- Benchmark Redis (`api/Bench`) — tool di test per debugging Redis
|
||||
- Api Ricette (`api/Recipe`) — recupero ricette per PODL
|
||||
- Dashboard Blazor — interfaccia web interattiva
|
||||
|
||||
## Architettura
|
||||
|
||||
### Livello Controller (MP.IOC/Controllers/)
|
||||
|
||||
| Controller | Routing | Methods | Descrizione |
|
||||
|------------|---------|---------|-------------|
|
||||
| `IOBController` | `api/IOB` | 52 | Endpoint principale per IOB-PI/IOB-WIN |
|
||||
| `BenchController` | `api/Bench` | 10 | Test/benchmark Redis |
|
||||
| `RecipeController` | `api/Recipe` | 2 | API ricette (JSON) |
|
||||
| `RecipeArchiveController` | `api/RecipeArchive` | 2 | API archive ricette (file) |
|
||||
|
||||
### Livello Dati
|
||||
|
||||
| Componente | Tipologia | Descrizione |
|
||||
|------------|-----------|-------------|
|
||||
| `MpDataService` | Singleton | Service di accesso dati principale (~3475 righe) |
|
||||
| `MpIocController` | Singleton | 82 metodi EFCore nel progetto MP.Data |
|
||||
| `Redis` | 2 connessioni | `redisConn`, `redisConnAdmin` per dati IOB |
|
||||
| `MongoDB` | Via `MpMongoController` | Storage ricette |
|
||||
|
||||
### Livello DbContext
|
||||
|
||||
| DbContext | ConnStr | Uso |
|
||||
|-----------|---------|-----|
|
||||
| `MoonProContext` | `MP.Data` | Tabelle anagrafiche, ODL, produzione, macchine |
|
||||
| `MoonPro_UtilsContext` | `MP.Utils` | Tabelle utility (VMSFD, MicroStati) |
|
||||
| `MoonPro_FluxContext` | `MP.Flux` | FluxLog, configurazioni flusso |
|
||||
|
||||
### Livello DI
|
||||
|
||||
Registrato via `AddIocDataLayer()` in `MP.Data/DataServiceCollectionExtensions.cs`:
|
||||
|
||||
```
|
||||
Singleton: IMtcSetupRepository, IMtcSetupService, ProductionRepository, MpIocController, MpDataService, IFusionCacheSerializer
|
||||
Scoped: IIocRepository, IStatsAggrRepository, IStatsDetailRepository, IIocService, IStatsAggrService, IStatsDetailService
|
||||
```
|
||||
|
||||
### Livello Infrastruttura
|
||||
|
||||
- **FusionCache** — L1 Memory only (1min default), NO Redis backplane
|
||||
- **MessagePipe** — Broadcasting real-time tra servizi
|
||||
- **OpenTelemetry** — Tracing configurabile (non abilitato in MP.IOC)
|
||||
- **Swagger** — Documentazione API in svilup
|
||||
|
||||
## Refactoring Completati
|
||||
|
||||
**Nessuno ancora.** Il progetto è pronto per il refactoring. Vedi `refactor_plan.md` per il piano dettagliato.
|
||||
|
||||
## Refactoring in Corso (Riferimento)
|
||||
|
||||
### Piano Generale (Vedi refactor_plan.md)
|
||||
|
||||
1. **Fase 1 — Anti-Pattern** (Quota completata): Rimuovere `static IConfiguration` dai 4 controller
|
||||
2. **Fase 2 — FusionCache**: Abilitare L2/L3 con Redis backplane e migrare i ~100 metodi di caching manuale
|
||||
3. **Fase 3 — Repository IoC**: Scomporre MpIocController (82 metodi) in 5-7 repository focalizzati
|
||||
4. **Fase 4 — Scomposizione MpDataService**: Il monolite da 3475 righe suddiviso in servizi tematici
|
||||
5. **Fase 5 — Build & Verifica**: Validazione finale su tutte le soluzioni
|
||||
|
||||
**Stato attuale:** In attesa di inizio Fase 1.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<h4>Versione: 8.16.2606.414</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.410
|
||||
8.16.2606.414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.410</version>
|
||||
<version>8.16.2606.414</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>
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
# Piano di Refactoring: MP.IOC
|
||||
|
||||
## Obiettivo
|
||||
|
||||
Modernizzare il progetto MP.IOC allineandolo agli standard architettonici definiti in MP.SPEC:
|
||||
1. Rimuovere l'uso di `MpIocController` come servizio di accesso dati diretto
|
||||
2. Migrare la logica di `MpDataService` ai repository esistenti (`IIocRepository`, `IStatsAggrRepository`, etc.)
|
||||
3. Standardizzare il caching manuale Redis → FusionCache `GetOrFetchAsync`
|
||||
4. Correggere tutti gli anti-pattern statici e DI
|
||||
|
||||
## Stato Attuale
|
||||
|
||||
| File | Riga | Tipo | Descrizione |
|
||||
|------|------|------|-------------|
|
||||
| `IOBController.cs` | 1675 | ✅ Controller ASP.NET | 52 endpoints REST (api/IOB) |
|
||||
| `BenchController.cs` | 387 | ✅ Controller ASP.NET | Test/bench Redis |
|
||||
| `RecipeController.cs` | 73 | ✅ Controller ASP.NET | API ricette (2 metodi) |
|
||||
| `RecipeArchiveController.cs` | 130 | ✅ Controller ASP.NET | API ricette file (2 metodi) |
|
||||
| `MpDataService.cs` | 3475 | ❌ Data Hub | Singleton, ~100 metodi, bypassa repository |
|
||||
| `MpIocController.cs` | 1480 | ⚠️ Wrong location | 82 metodi EFCore in MP.Data, usato come servizio |
|
||||
|
||||
### Struttura DI Attuale
|
||||
|
||||
```
|
||||
Program.cs
|
||||
├── AddIocDataLayer() da MP.Data
|
||||
│ ├── MpIocController ── Singleton ← usato direttamente da MpDataService
|
||||
│ ├── IIocRepository ── Scoped ← mai usato da MpDataService
|
||||
│ ├── IStatsAggrRepository ── Scoped ← mai usato
|
||||
│ └── IStatsDetailRepository ── Scoped ← mai usato
|
||||
├── MpDataService ── Singleton ← chiama IocDbController (statico)
|
||||
└── IFusionCache ── L1 Memory only, NO Redis backplane
|
||||
```
|
||||
|
||||
### Problemi Chiave
|
||||
|
||||
1. **MpIocController come servizio** — 82 metodi EFCore classificati ingannevolmente come "Controller" ma in realtà sono un servizio di accesso dati, registrato come Singleton con DbContext che non è thread-safe
|
||||
2. **MpDataService bypassa repository** — ~80% dei metodi chiama `IocDbController.XXX()` direttamente invece di usare `IIocRepository`
|
||||
3. **Nessun FusionCache** — MpDataService usa manual `redisDb.StringGetAsync`/`StringSetAsync` (~80% del codice) invece di `IFusionCache.GetOrFetchAsync`
|
||||
4. **Singleton lifetime mismatch** — MpDataService è Singleton, registra campi statici per IoC Controller e Mongo Controller che vengono sovrascritti
|
||||
|
||||
## Piano di Refactoring
|
||||
|
||||
### Fase 1: Pulizia Anti-Pattern (Quick Wins)
|
||||
|
||||
Obiettivo: risolvere gli Static fields e i problemi DI più evidenti senza cambiare architettura.
|
||||
|
||||
#### 1.1 Rimuovere `static IConfiguration` dai 4 controller
|
||||
|
||||
| File | Fix |
|
||||
|------|-----|
|
||||
| `IOBController.cs:23` | `readonly IConfiguration _configuration` (usato solo nel ctor, rimosso se dead) |
|
||||
| `BenchController.cs:19` | Rimuovere campo statico (non usato dopo ctor) |
|
||||
| `RecipeController.cs:18` | Rimuovere campo statico (non usato dopo ctor) |
|
||||
| `RecipeArchiveController.cs:18` | Rimuovere campo statico (non usato dopo ctor) |
|
||||
|
||||
**File da modificare:**
|
||||
- `C:\Users\samuele.steamw\source\MAPO-CORE\MP.IOC\Controllers\IOBController.cs`
|
||||
- `C:\Users\samuele.steamw\source\MAPO-CORE\MP.IOC\Controllers\BenchController.cs`
|
||||
- `C:\Users\samuele.steamw\source\MAPO-CORE\MP.IOC\Controllers\RecipeController.cs`
|
||||
- `C:\Users\samuele.steamw\source\MAPO-CORE\MP.IOC\Controllers\RecipeArchiveController.cs`
|
||||
|
||||
#### 1.2 Correggere `MpIocController` singleton
|
||||
|
||||
`MpIocController` usa `IDbContextFactory` correttamente, ma è registrato come Singleton in `AddIocDataLayer()`. I DbContext Factory sono thread-safe ma il pattern Singleton è inutile e potenzialmente pericoloso.
|
||||
|
||||
Fix: registrare come **Scoped** in `DataServiceCollectionExtensions.cs`:
|
||||
```csharp
|
||||
services.TryAddScoped<IMpIocService, MpIocController>(); // rinominare in servizio
|
||||
// oppure creare interfaccia IMpIocRepository
|
||||
```
|
||||
|
||||
#### 1.3 Rimuovere campi statici in `MpDataService`
|
||||
|
||||
| Campo | Righe | Fix |
|
||||
|-------|-------|-----|
|
||||
| `public static MpMongoController mongoController` | 94 | Rimuovere campo statico → iniettare via contructor o renderlo readonly |
|
||||
| `public static MpIocController IocDbController` | 95 | **Bloccante** — usato da ~45+ metodi. Richiede Fase 3 completa |
|
||||
|
||||
### Fase 2: Abilitare FusionCache per MP.IOC
|
||||
|
||||
Attualmente MP.IOC ha FusionCache disabilitato (L1 solo, Redis non connesso).
|
||||
|
||||
#### 2.1 Configurazione Redis + FusionCache in Program.cs
|
||||
|
||||
```csharp
|
||||
// Attuale (solo L1 Memory)
|
||||
builder.Services.AddFusionCache()
|
||||
.WithDefaultEntryOptions(options => { options.Duration = TimeSpan.FromMinutes(1); });
|
||||
|
||||
// Nuovo (L1 Memory + L2 Redis + L3 DB)
|
||||
var redisMux = ConnectionMultiplexer.Connect(confRedis);
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMux);
|
||||
|
||||
builder.Services.AddFusionCache()
|
||||
.WithDistributedCache(sp => sp.GetRequiredService<IDistributedCache>())
|
||||
.WithSerializer(new FusionCacheNewtonsoftJsonSerializer())
|
||||
.WithBackplane(new RedisBackplane(new RedisBackplaneOptions {
|
||||
ConnectionMultiplexerFactory = () => Task.FromResult(redisMux)
|
||||
}));
|
||||
```
|
||||
|
||||
#### 2.2 Migrazione metodi MpDataService a GetOrFetchAsync
|
||||
|
||||
**Metodi da migrare (identificazione preliminare):**
|
||||
|
||||
| Categoria | Metodi | Stima righe |
|
||||
|-----------|---------|-------------|
|
||||
| Anagrafica | `AnagStatiGetAllAsync`, `ArticoliGetLastByMaccAsync`, `ConfigGetAllAsync`, `DecNumArtGetFiltAsync` | ~120 |
|
||||
| Produzione | `OdlCurrByMaccAsync`, `OdlLastByMaccAsync`, `POdlGetByMaccArtAsync`, `PezziProdMacchinaAsync`, `StatoProdMacchinaAsync` | ~200 |
|
||||
| FluxLog | `ConfFluxFiltAsync`, `FluxLogFirstByMaccAsync`, `FluxLogGetLastFiltAsync`, `FluxLogTakeSnapshotLastAsync` | ~100 |
|
||||
| Dossier | `DossGetLastByMaccAsync` | ~50 |
|
||||
| Machine | `DatiMacchineGetAllAsync`, `MseGetAllAsync`, `Macchine2SlaveAsync`, `MacchineGetByIdxAsync` | ~150 |
|
||||
| MicroStato | `EvListMicroStatoInsertAsync`, `MicroStatoMacchinaUpsertAsync`, `MicroStatoMacchinaGetByIdxMaccAsync` | ~80 |
|
||||
| VMSFD | `VMSFDGetByMaccAsync`, `VMSFDGetMultiByMaccAsync`, `StateMachIngressiAsync` | ~80 |
|
||||
| Misc | `Alarms`, `RegScarti`, `RegControlli`, `RemRebootLog`, `SignalLog`, `KeepAlive` | ~150 |
|
||||
|
||||
**Totale stimato:** ~930 righe di codice caching da migrare a pattern `GetOrFetchAsync`.
|
||||
|
||||
### Fase 3: Decomposizione MpIocController in Repository (Core)
|
||||
|
||||
`MpIocController` (1480 righe, 82 metodi) va scomposto in repository specialistici, come fatto per MP.SPEC:
|
||||
|
||||
#### 3.1 Mappatura attuali → Nuovi Repository
|
||||
|
||||
| Attuale (82 metodi) | Nuovo Repository | Ambito |
|
||||
|----------------------|-------------------|--------|
|
||||
| `AnagStatiGetAllAsync`, `ArticoliGetLastByMaccAsync`, `ConfigGetAllAsync`, `ConfigUpdateAsync`, `DecNumArtGetFiltAsync`, `ListValuesFiltAsync`, `ListLinkFiltAsync`, `EvListInsert` | `IAnagRepository` | **Usato da SPEC** — già migrato! |
|
||||
| `AutoStartOdlAsync`, `ConfirmaProdMacchinaAsync/Full`, `OdlCurrByMaccAsync`, `OdlLastByMaccAsync`, `OdlListByMaccPeriodoAsync`, `PezziProdMacchinaAsync`, `StatoProdMacchinaAsync` | `IProduzioneRepository` (nuovo) | Produzione IOB-specifica |
|
||||
| `OdlAutoDayGenAsync/Full`, `POdlGetByMaccArtAsync`, `OdlFixMachineSlave` | `IProduzioneRepository` (nuovo) | Pianificazione produzione |
|
||||
| `FluxLogInsertAsync`, `FluxLogGetLastFiltAsync`, `FluxLogFirstByMaccAsync`, `FluxLogTakeSnapshotLastAsync`, `ConfFluxFiltAsync` | `IFluxLogRepository` | **Usato da SPEC** — già migrato! |
|
||||
| `DossGetLastByMaccAsync`, `SignalLogInsertAsync` | `IDossierRepository` | **Usato da SPEC** — già migrato! |
|
||||
| `DatiMacchineGetAllAsync`, `MacchineGetByIdxAsync`, `MacchineUpsertAsync`, `MacchineGetFiltAsync`, `MacchineGetAllAsync`, `Macchine2Slave` | `IMacchineRepository` (nuovo) | Gestione macchine |
|
||||
| `EvListMicroStatoInsertAsync`, `MicroStatoMacchinaUpsertAsync`, `MicroStatoMacchinaGetByIdxMaccAsync`, `MicroStatoMacchinaGetByIdxMaccAsync` | `IMicroStatoRepository` (nuovo) | Micro-stati macchine |
|
||||
| `MSE_getUserForcedAsync`, `SMES_getHwTransitionsAsync`, `DDB_InsStatoBatchAsync`, `CheckCambiaStatoBatchAsync`, `RecalcMseAsync` | `IMseRepository` (nuovo) | Mappa stati macchin |
|
||||
| `StateMachineIngressiAsync`, `VMSFDGetByMaccAsync`, `VMSFDGetMultiByMaccAsync`, `VMSFDGetAllAsync` | `IStateMachineRepository` (nuovo) | State machine |
|
||||
| `KeepAliveUpsertAsync` | `IMacchineRepository` (nuovo) | Keep-alive |
|
||||
| `AlarmLogInsertAsync`, `RegScartiInsertAsync`, `RegControlliInsertAsync`, `RegDichiarInsertAsync` | `IRegistroRepository` (nuovo) | Registri qualità |
|
||||
| `RemRebootLog*` methods (6) | `IRemRebootRepository` (nuovo) | Reboot remote logging |
|
||||
|
||||
#### 3.2 Interfacce Nuove (da creare in MP.Data/Repository/)
|
||||
|
||||
```
|
||||
MP.Data/Repository/Iob/
|
||||
├── IProduzioneRepository.cs
|
||||
├── ProduzioneRepository.cs
|
||||
├── IMacchineRepository.cs
|
||||
├── MacchineRepository.cs
|
||||
├── IMicroStatoRepository.cs
|
||||
├── MicroStatoRepository.cs
|
||||
├── IMseRepository.cs
|
||||
├── MseRepository.cs
|
||||
├── IStateMachineRepository.cs
|
||||
├── StateMachineRepository.cs
|
||||
├── IRegistroRepository.cs
|
||||
├── RegistroRepository.cs
|
||||
└── IRemRebootRepository.cs
|
||||
└── RemRebootRepository.cs
|
||||
```
|
||||
|
||||
#### 3.3 Migrazione Dipendenze
|
||||
|
||||
Dopo aver creato i repository, ogni metodo in `MpDataService.cs` che chiama `IocDbController.XXX()` va aggiornato per chiamare il repository invece.
|
||||
|
||||
**Esempio:**
|
||||
```csharp
|
||||
// PRIMA
|
||||
var result = await IocDbController.AnagStatiGetAllAsync();
|
||||
|
||||
// DOPO
|
||||
var result = await _anagRepository.AnagStatiGetAllAsync();
|
||||
```
|
||||
|
||||
#### 3.4 Rimozione MpIocController
|
||||
|
||||
Dopo la migrazione completa:
|
||||
1. Rimuovere `MpIocController` da `DataServiceCollectionExtensions.cs`
|
||||
2. Rimuovere il parametro dal costruttore di `MpDataService`
|
||||
3. Spostare i metodi ancora non migrati a `#if false` come fallback documentato
|
||||
|
||||
### Fase 4: Scomposizione MpDataService
|
||||
|
||||
`MpDataService.cs` (3475 righe) è troppo grande per essere un unico servizio. Proposta di scomposizione:
|
||||
|
||||
| Servizio | Responsabilità | Metodi |
|
||||
|----------|---------------|--------|
|
||||
| `MpDataService` (core) | Gateway, orchestrazione | ~50 |
|
||||
| `IodlManagementService` | ODL lifecycle (apri, chiudi, split, conferma) | ~15 |
|
||||
| `FluxLogProcessingService` | Processing flux log, snapshot, pareto | ~10 |
|
||||
| `MachineCommunicationService` | Keep-alive, dati macchin, micro-stati, state machine | ~20 |
|
||||
| `ProductionTrackingService` | Conferma produzione, pezzi prodotti, stato produzione | ~8 |
|
||||
| `RedisCacheService` | Wrapper methods per Redis operations (Hash, String, Set) | ~15 |
|
||||
|
||||
**Nota:** La scomposizione va fatta **dopo** la migrazione a repository (Fase 3) per non dover modificare ogni singola chiamata.
|
||||
|
||||
### Fase 5: Build & Verifica
|
||||
|
||||
Dopo ogni fase completa:
|
||||
1. `dotnet build MP-IOC.sln`
|
||||
2. `dotnet build MP-SPEC.sln` (non deve rompersi)
|
||||
3. `dotnet build MP-LAND.sln`
|
||||
4. `dotnet build MP-MON.sln`
|
||||
5. Verificare che MP.IOC parta correttamente
|
||||
|
||||
## Riepilogo Costi Stimati
|
||||
|
||||
| Fase | File Modificati | Righe Modificate | Rischio | Stato |
|
||||
|------|-----------------|-------------------|---------|-------|
|
||||
| ~~F1: Anti-Pattern 4 controller~~ | ~~4~~ | ~~20~~ | ~~Basso~~ | ✅ **Completato** |
|
||||
| F2: FusionCache config + metodi | 2 + 1 | ~1200 | Medio | ⏳ Da fare |
|
||||
| F3: Repository IoC | 7+ nuovi + 5 esistenti | ~2000 | Alto | ⏳ Da fare |
|
||||
| F4: Scomposizione MpDataService | 5 nuovi + 1 esistente | ~3475 | Alto | ⏳ Da fare |
|
||||
| F5: Build & Verifica | — | — | Basso | ✅ OK (0 errori, 12 warnings) |
|
||||
|
||||
## Stato Completato
|
||||
|
||||
### ✅ Fase 1: Anti-Pattern Controller — COMPLETATA
|
||||
|
||||
Rimosso `static IConfiguration _configuration` da tutti i 4 controller e rimossa la dead assignment dai costruttori:
|
||||
|
||||
| Controller | Prima | Dopo |
|
||||
|------------|-------|------|
|
||||
| `IOBController` | `IConfiguration + static field` | Nessun param (dead code), field rimosso |
|
||||
| `BenchController` | `IConfiguration + static field` | Solo `MpDataService`, field rimosso |
|
||||
| `RecipeController` | `IConfiguration + static field` | Solo `MpDataService`, field rimosso |
|
||||
| `RecipeArchiveController` | `IConfiguration + static field` | Solo `MpDataService`, field rimosso |
|
||||
|
||||
**Build risultato:** ✅ 0 errori, 12 warnings (solo nullable reference, nessun warning statico residuo nei controller)
|
||||
|
||||
### 📋 Fase 2+: In Attesa
|
||||
|
||||
Prossimo step: abilitare FusionCache con Redis backplane (Fase 2) — richiede approvazione architetturale.
|
||||
|
||||
## Priorità Operativa
|
||||
|
||||
1. **F1 immediata** — zero rischio, fix 4 controller statici
|
||||
2. **F2 parallela** — abilitare FusionCache con Redis backplane (config) + migrare i metodi più usati
|
||||
3. **F3 dopo F2** — decomporre MpIocController una volta che il caching è standardizzato
|
||||
4. **F4 opzionale** — scomporare MpDataService quando il resto è stabile
|
||||
|
||||
## Note
|
||||
|
||||
- MpIocController usa già `IDbContextFactory` correttamente — il problema è che è un Singleton e lo si chiama da un altro Singleton (MpDataService)
|
||||
- IIocRepository (già esistente) ha solo 16 metodi ed è mai usato da MpDataService
|
||||
- I repository SPEC (Anag, Dossier, FluxLog, Production) sono già usati da alcuni metodi — sfruttare questi dove possibile
|
||||
- La struttura MP.Data/Controllers/ è ingannevole: MpIocController è un servizio, non un controller Web API
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>MP.Land</RootNamespace>
|
||||
<Version>8.16.2606.0410</Version>
|
||||
<Version>8.16.2606.0414</Version>
|
||||
<Configurations>Debug;Release;Debug_LiManDebug</Configurations>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
<RunAnalyzersDuringBuild>True</RunAnalyzersDuringBuild>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo Tablet MAPO - DotNet6</i>
|
||||
<h4>Versione: 8.16.2606.0410</h4>
|
||||
<h4>Versione: 8.16.2606.0414</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.0410
|
||||
8.16.2606.0414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.0410</version>
|
||||
<version>8.16.2606.0414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.MON</RootNamespace>
|
||||
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<Version>8.16.2606.414</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<h4>Versione: 8.16.2606.414</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.410
|
||||
8.16.2606.414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.410</version>
|
||||
<version>8.16.2606.414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/MP.MON.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-MON/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>MP.Prog</RootNamespace>
|
||||
<Version>8.16.2606.0410</Version>
|
||||
<Version>8.16.2606.0414</Version>
|
||||
<GenerateDocumentationFile>True</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo gestione Programmi MAPO</i>
|
||||
<h4>Versione: 8.16.2606.0410</h4>
|
||||
<h4>Versione: 8.16.2606.0414</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.0410
|
||||
8.16.2606.0414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.0410</version>
|
||||
<version>8.16.2606.0414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/MP.Prog.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-PROG/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.RIOC</RootNamespace>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<Version>8.16.2606.414</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-RIOC </i>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<h4>Versione: 8.16.2606.414</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.410
|
||||
8.16.2606.414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.410</version>
|
||||
<version>8.16.2606.414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/MP.RIOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-RIOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>8.16.2606.410</Version>
|
||||
<Version>8.16.2606.414</Version>
|
||||
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2606.410</h4>
|
||||
<h4>Versione: 8.16.2606.414</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.410
|
||||
8.16.2606.414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.410</version>
|
||||
<version>8.16.2606.414</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>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>8.16.2606.0410</Version>
|
||||
<Version>8.16.2606.0414</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 8.16.2606.0410</h4>
|
||||
<h4>Versione: 8.16.2606.0414</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2606.0410
|
||||
8.16.2606.0414
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2606.0410</version>
|
||||
<version>8.16.2606.0414</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user