Refresh + fix gestione reparti-operatori

This commit is contained in:
Samuele Locatelli
2026-05-29 19:41:00 +02:00
parent 7de0f88b9e
commit 6af40d9cae
38 changed files with 98 additions and 176 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP_TAB3</RootNamespace>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+30 -37
View File
@@ -270,38 +270,34 @@ namespace MP.Data.Controllers
/// Elenco Gruppi tipo REPARTO (x associazione Macchine-Operatori) in formato DTO con conteggi del numero record trovati
/// </summary>
/// <returns></returns>
public List<RepartiDTO> AnagGruppiRepartoDTO()
public async Task<List<RepartiDTO>> AnagGruppiRepartoDtoAsync()
{
List<RepartiDTO> dbResult = new List<RepartiDTO>();
using (var dbCtx = new MoonProContext(options))
{
// in primis recupero i reparti...
var listReparti = AnagGruppiGetTipo("REPARTO");
using var dbCtx = new MoonProContext(options);
// in primis recupero i reparti...
var listReparti = AnagGruppiGetTipo("REPARTO");
// recupero TUTTE le macchine da DbSetGrp2Macc
var listMacc = dbCtx
// recupero TUTTE le macchine da DbSetGrp2Macc
var listMacc = await dbCtx
.DbSetGrp2Macc
.AsNoTracking()
.ToList();
// recupero TUTTI gli operatori da DbSetGrp2Oper
var listOpr = dbCtx
.ToListAsync();
// recupero TUTTI gli operatori da DbSetGrp2Oper
var listOpr = await dbCtx
.DbSetGrp2Oper
.AsNoTracking()
.ToList();
.ToListAsync();
dbResult = listReparti
.Select(x => new RepartiDTO()
{
CodGruppo = x.CodGruppo,
TipoGruppo = x.TipoGruppo,
DescrGruppo = x.DescrGruppo,
SelEnabled = x.SelEnabled,
CountMacc = listMacc.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.IdxMacchina).Distinct().Count(),
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.MatrOpr).Distinct().Count()
})
.ToList();
}
return dbResult;
return listReparti
.Select(x => new RepartiDTO()
{
CodGruppo = x.CodGruppo,
TipoGruppo = x.TipoGruppo,
DescrGruppo = x.DescrGruppo,
SelEnabled = x.SelEnabled,
CountMacc = listMacc.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.IdxMacchina).Distinct().Count(),
CountOpr = listOpr.Where(y => y.CodGruppo == x.CodGruppo).Select(x => x.MatrOpr).Distinct().Count()
})
.ToList();
}
/// <summary>
@@ -1319,20 +1315,17 @@ namespace MP.Data.Controllers
/// </summary>
/// <param name="CodArtParent">Articolo KIT (fittizio)</param>
/// <param name="KeyFilt">Chiave x filtro conf su tab WKS</param>
public bool IstKitInsertByWKS(string CodArtParent, string KeyFilt)
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
{
bool answ = false;
using (var dbCtx = new MoonProContext(options))
{
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
using var dbCtx = new MoonProContext(options);
var dbResult = dbCtx
.Database
.ExecuteSqlRaw("EXEC dbo.stp_IstKit_insertByWKS @CodArtParent,@KeyFilt", pCodArtParent, pKeyFilt);
answ = true;
}
return answ;
var pCodArtParent = new SqlParameter("@CodArtParent", CodArtParent);
var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt);
var dbResult = await dbCtx
.Database
.ExecuteSqlRawAsync("EXEC dbo.stp_IstKit_insertByWKS @CodArtParent,@KeyFilt", pCodArtParent, pKeyFilt);
return dbResult > 0;
}
/// <summary>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.INVE</RootNamespace>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOINVE </i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-IOC </i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MP.Land</RootNamespace>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
<Configurations>Debug;Release;Debug_LiManDebug</Configurations>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<RunAnalyzersDuringBuild>True</RunAnalyzersDuringBuild>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo Tablet MAPO - DotNet6</i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.MON</RootNamespace>
<AssemblyName>$(AssemblyName.Replace(' ', '_'))</AssemblyName>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+1 -1
View File
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MP.Prog</RootNamespace>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo gestione Programmi MAPO</i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.RIOC</RootNamespace>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-RIOC </i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
@@ -99,7 +99,7 @@ namespace MP.SPEC.Components.ProdKit
return;
// eseguo stored...
bool fatto = MDService.IstKitInsertByWKS(currRec.CodArtParent, KeyFilt);
bool fatto = await MDService.IstKitInsertByWKSAsync(currRec.CodArtParent, KeyFilt);
if (fatto)
{
// segnalo update
+14 -95
View File
@@ -693,39 +693,15 @@ namespace MP.SPEC.Data
/// Restitusice elenco Reparti
/// </summary>
/// <returns></returns>
public List<RepartiDTO> ElencoRepartiDTO()
public async Task<List<RepartiDTO>> ElencoRepartiDtoAsync()
{
using var activity = ActivitySource.StartActivity("ElencoRepartiDTO");
List<RepartiDTO> result = new List<RepartiDTO>();
string source = "DB";
string currKey = $"{Utils.redisAnagGruppi}:REPARTO";
// cerco in redis dato valore sel idxMaccSel...
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
var rawResult = JsonConvert.DeserializeObject<List<RepartiDTO>>($"{rawData}");
if (rawResult != null)
{
result = rawResult;
}
source = "REDIS";
}
else
{
result = dbController.AnagGruppiRepartoDTO();
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
result = new List<RepartiDTO>();
}
activity?.SetTag("data.source", source);
activity?.SetTag("result.count", result.Count);
activity?.Stop();
LogTrace($"ElencoRepartiDTO | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return result;
return await GetOrFetchAsync(
operationName: "ElencoRepartiDtoAsync",
cacheKey: $"{Utils.redisAnagGruppi}:REPARTO",
expiration: getRandTOut(redisLongTimeCache),
fetchFunc: async () => await dbController.AnagGruppiRepartoDtoAsync() ?? new(),
tagList: [Utils.redisAnagGruppi]
);
}
/// <summary>
@@ -1213,22 +1189,18 @@ namespace MP.SPEC.Data
/// </summary>
/// <param name="CodArtParent">Articolo KIT (fittizio)</param>
/// <param name="KeyFilt">Chiave x filtro conf su tab WKS</param>
public bool IstKitInsertByWKS(string CodArtParent, string KeyFilt)
public async Task<bool> IstKitInsertByWKSAsync(string CodArtParent, string KeyFilt)
{
bool fatto = false;
using var activity = ActivitySource.StartActivity("IstKitInsertByWKS");
string source = "DB+REDIS";
using var activity = ActivitySource.StartActivity("IstKitInsertByWKSAsync");
string source = "DB";
// salvo
fatto = dbController.IstKitInsertByWKS(CodArtParent, KeyFilt);
fatto = await dbController.IstKitInsertByWKSAsync(CodArtParent, KeyFilt);
// svuoto cache
ExecFlushRedisPattern($"{Utils.redisKit}:*");
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitInst}:*");
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitScore}:*");
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitTempl}:*");
//ExecFlushRedisPattern((RedisValue)$"{Utils.redisKitWip}:*");
await FlushCacheByTagAsync(Utils.redisPOdlList);
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"IstKitInsertByWKS | {source} | {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"IstKitInsertByWKSAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -1554,22 +1526,6 @@ namespace MP.SPEC.Data
return fatto;
}
#if false
/// <summary>
/// Record ODL da chaive
/// </summary>
/// <returns></returns>
public async Task<ODLModel> OdlGetByKey(int IdxOdl)
{
using var activity = ActivitySource.StartActivity("OdlGetByKey");
string source = "DB";
var dbResult = await dbController.OdlGetByKey(IdxOdl);
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"OdlGetByKey | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
return dbResult;
}
#endif
/// <summary>
/// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato)
@@ -2260,9 +2216,6 @@ namespace MP.SPEC.Data
fatto = await dbController.WipKitDeleteAsync(currRecord);
// svuoto cache
await FlushCacheByTagAsync(Utils.redisKitWip);
#if false
EmptyWipCache();
#endif
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"WipKitDeleteAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -2282,9 +2235,6 @@ namespace MP.SPEC.Data
fatto = await dbController.WipKitDeleteOlderAsync(DateLimit);
// svuoto cache KitWip
await FlushCacheByTagAsync(Utils.redisKitWip);
#if false
EmptyWipCache();
#endif
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"WipKitDeleteOlderAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
@@ -2321,9 +2271,6 @@ namespace MP.SPEC.Data
fatto = await dbController.WipKitUpsertAsync(currRecord);
// svuoto cache KitWip
await FlushCacheByTagAsync(Utils.redisKitWip);
#if false
EmptyWipCache();
#endif
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"WipKitUpsertAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
@@ -2481,19 +2428,6 @@ namespace MP.SPEC.Data
#region Private Methods
#if false
/// <summary>
/// Svuota cache creazione KIT
/// </summary>
private void EmptyWipCache()
{
string pattern = $"{Utils.redisKitWip}:*";
if (!string.IsNullOrEmpty(pattern))
{
ExecFlushRedisPattern(pattern);
}
}
#endif
/// <summary>
/// Verifica caricamento dizionario ConfigData
@@ -2510,21 +2444,6 @@ namespace MP.SPEC.Data
.ToDictionary(g => g.Key, g => g.First().Valore);
}
}
/// <summary>
/// Verifica caricamento Vocabolario
/// </summary>
/// <returns></returns>
private async Task EnsureVocabolarioLoadedAsync()
{
if (_configData.Count == 0)
{
var list = await ConfigGetAllAsync();
_configData = list
.GroupBy(x => x.Chiave)
.ToDictionary(g => g.Key, g => g.First().Valore);
}
}
/// <summary>
/// Implementa gestione recupero cache da memoria o da obj esterno + cache memoria + tracking attività
@@ -41,7 +41,7 @@
</div>
@if (ShowDetail)
{
<div class="col-5">
<div class="col-4">
<MP.SPEC.Components.Reparti.ListMacchine CodGruppoCurr="@CodGruppo" AllRecords="ListMacchineAll" CurrRecords="ListMacchine" EC_RecChange="ForceReload"></MP.SPEC.Components.Reparti.ListMacchine>
</div>
<div class="col-4">
@@ -5,7 +5,7 @@ using MP.SPEC.Data;
namespace MP.SPEC.Pages
{
public partial class GroupMacOprMan
public partial class RepOper
{
#region Protected Fields
@@ -64,7 +64,7 @@ namespace MP.SPEC.Pages
private string CssMain
{
get => ShowDetail ? "col-3" : "col-12";
get => ShowDetail ? "col-4" : "col-12";
}
private bool ShowDetail
@@ -96,14 +96,18 @@ namespace MP.SPEC.Pages
{
isLoading = true;
ListMacchine?.Clear();
var rawList = MDService.ElencoRepartiDTO();
if (string.IsNullOrEmpty(SearchVal))
ListReparti?.Clear();
if (string.IsNullOrEmpty(CodGruppo))
{
ListReparti = rawList;
}
else
{
ListReparti = rawList.Where(x => x.CodGruppo.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || x.DescrGruppo.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)).ToList();
var rawList = await MDService.ElencoRepartiDtoAsync();
if (string.IsNullOrEmpty(SearchVal))
{
ListReparti = rawList;
}
else
{
ListReparti = rawList.Where(x => x.CodGruppo.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase) || x.DescrGruppo.Contains(SearchVal, StringComparison.InvariantCultureIgnoreCase)).ToList();
}
}
if (!string.IsNullOrEmpty(CodGruppo))
{
@@ -122,9 +126,10 @@ namespace MP.SPEC.Pages
}
}
private void ResetSearch()
private async Task ResetSearch()
{
SearchVal = "";
await ReloadDataAsync();
}
private async Task SetCodGruppo(string CodGruppoSel)
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>MP.Stats</RootNamespace>
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
<Version>8.16.2605.2911</Version>
<Version>8.16.2605.2912</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo statistiche MAPO</i>
<h4>Versione: 8.16.2605.2911</h4>
<h4>Versione: 8.16.2605.2912</h4>
<br />
Note di rilascio:
<ul>
+1 -1
View File
@@ -1 +1 @@
8.16.2605.2911
8.16.2605.2912
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2605.2911</version>
<version>8.16.2605.2912</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>
+5
View File
@@ -55,6 +55,10 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
- `WipKitFiltAsync`
- `MseGetAllAsync` (Migrato e rinominato)
- `OdlByKeyAsync` (Migrato e rinominato)
- `TemplateKitDeleteAsync` (Migrato con tag invalidazione)
- `TemplateKitUpsertAsync` (Migrato con tag invalidazione)
- `WipKitDeleteAsync` (Migrato con tag invalidazione)
- `WipKitUpsertAsync` (Migrato con tag invalidazione)
#### 🛠️ Metodi da Migrare (Usano ancora Redis/DB manuale)
- [ ] Migrazione di `ActionGetReq` (linea 110: usa `redisDb.StringGetAsync`).
@@ -82,3 +86,4 @@ Migrare la logica di caching manuale (Redis + DB) verso l'utilizzo di `IFusionCa
- **Rischio**: Errori di serializzazione.
- *Mitigazione*: `FusionCache` gestisce la serializzazione, ma è necessario assicurarsi che i tipi di ritorno siano compatibili con le aspettative dei chiamanti.