diff --git a/MP.INVE/Components/MagList.razor.cs b/MP.INVE/Components/MagList.razor.cs
index c16f7b45..439e3ca7 100644
--- a/MP.INVE/Components/MagList.razor.cs
+++ b/MP.INVE/Components/MagList.razor.cs
@@ -57,7 +57,7 @@ namespace MP.INVE.Components
mod = false;
desc = "";
}
- private List? elencoMagazzini;
+ private List? ElencoMagazzini;
private List? SearchRecords;
private AnagMagModel currMag { get; set; } = null!;
private bool mod { get; set; } = false;
@@ -88,11 +88,11 @@ namespace MP.INVE.Components
private async Task reloadData()
{
isLoading = true;
- elencoMagazzini = null;
+ ElencoMagazzini = null;
SearchRecords = null;
SearchRecords = MIDataservice.ElencoMagazzini();
totalCount = SearchRecords.Count;
- elencoMagazzini = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
+ ElencoMagazzini = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await InvokeAsync(() => StateHasChanged());
await Task.Delay(1);
diff --git a/MP.INVE/Components/ProcOperat.razor b/MP.INVE/Components/ProcOperat.razor
index 801609d8..0366a100 100644
--- a/MP.INVE/Components/ProcOperat.razor
+++ b/MP.INVE/Components/ProcOperat.razor
@@ -8,9 +8,9 @@ elenco di buttons che servono a confermare operazione:
mostrare button conferma/annulla
*@
-
-
-
+
+
+
diff --git a/MP.INVE/Components/ProcSuggestion.razor b/MP.INVE/Components/ProcSuggestion.razor
index 1381b0bf..1c3820f8 100644
--- a/MP.INVE/Components/ProcSuggestion.razor
+++ b/MP.INVE/Components/ProcSuggestion.razor
@@ -11,31 +11,51 @@
@if (udc != null)
{
-
-
- @udc.UDC
-
-
- @tipo
-
-
+ @*
+
+
+ @udc.UDC
+
+
+ @tipo
+
+ *@
+
}
else
{
diff --git a/MP.INVE/Components/ProcSuggestion.razor.cs b/MP.INVE/Components/ProcSuggestion.razor.cs
index 90f5cd18..8125c9ea 100644
--- a/MP.INVE/Components/ProcSuggestion.razor.cs
+++ b/MP.INVE/Components/ProcSuggestion.razor.cs
@@ -52,5 +52,15 @@ namespace MP.INVE.Components
}
}
+ protected string reqArtMod = "disabilita";
+ protected string reqQtaMod = "disabilita";
+ protected void cssDisableArt()
+ {
+ reqArtMod = "";
+ }
+ protected void cssDisableQta()
+ {
+ reqQtaMod = "";
+ }
}
}
\ No newline at end of file
diff --git a/MP.INVE/Data/MpDataService.cs b/MP.INVE/Data/MpDataService.cs
deleted file mode 100644
index 4e6329a8..00000000
--- a/MP.INVE/Data/MpDataService.cs
+++ /dev/null
@@ -1,1319 +0,0 @@
-using MP.Data;
-using MP.Data.Conf;
-using MP.Data.DatabaseModels;
-using MP.Data.DTO;
-using Newtonsoft.Json;
-using NLog;
-using StackExchange.Redis;
-using System.Diagnostics;
-
-namespace MP.INVE.Data
-{
- public class MpDataService : IDisposable
- {
- #region Public Constructors
-
- public MpDataService(IConfiguration configuration, ILogger logger)
- {
- _logger = logger;
- _logger.LogInformation("Starting MpDataService INIT");
- _configuration = configuration;
-
- // setup compoenti REDIS
- redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
- redisConnAdmin = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("RedisAdmin"));
- redisDb = redisConn.GetDatabase();
-
- // leggo cache lungo periodo
- int.TryParse(_configuration.GetValue("ServerConf:redisLongTimeCache"), out redisLongTimeCache);
-
- _logger.LogInformation("Redis INIT");
-
- // conf DB
- string connStr = _configuration.GetConnectionString("Mp.Data");
- if (string.IsNullOrEmpty(connStr))
- {
- _logger.LogError("DbController: ConnString empty!");
- }
- else
- {
- dbController = new MP.Data.Controllers.MpSpecController(configuration);
- _logger.LogInformation("DbController OK");
- }
- }
-
- #endregion Public Constructors
-
- #region Public Properties
-
- public static MP.Data.Controllers.MpSpecController dbController { get; set; } = null!;
-
- ///
- /// Dizionario dei tag configurati per IOB
- ///
- public Dictionary> currTagConf { get; set; } = new Dictionary>();
-
- #endregion Public Properties
-
- #region Public Methods
-
- public async Task> AnagStatiComm()
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- List? result = new List();
- // cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisStatoCom);
- if (!string.IsNullOrEmpty($"{rawData}"))
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"AnagStatiComm Read from REDIS: {ts.TotalMilliseconds}ms");
- }
- else
- {
- result = await Task.FromResult(dbController.AnagStatiComm());
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisStatoCom, rawData, getRandTOut(redisLongTimeCache));
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms");
- }
- if (result == null)
- {
- result = new List();
- }
- return result;
- }
-
- public async Task> AnagTipoArtLV()
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string source = "DB";
- List? result = new List();
- // cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisTipoArt);
- if (!string.IsNullOrEmpty($"{rawData}"))
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- source = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.AnagTipoArtLV());
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisTipoArt, rawData, getRandTOut(redisLongTimeCache));
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"AnagTipoArtLV Read from {source}: {ts.TotalMilliseconds}ms");
- if (result == null)
- {
- result = new List();
- }
- return result;
- }
-
- ///
- /// Elenco Codice articolo con dati dossier gestiti
- ///
- ///
- public async Task> ArticleWithDossier()
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = redisArtByDossier;
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.ArticleWithDossier());
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ArticleWithDossier | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Eliminazione record selezionato
- ///
- ///
- ///
- public async Task ArticoliDeleteRecord(AnagArticoli currRec)
- {
- bool fatto = await dbController.ArticoliDeleteRecord(currRec);
- await resetCacheArticoli();
- return fatto;
- }
-
- ///
- /// Restitusice elenco articoli cercati
- ///
- ///
- ///
- ///
- public async Task> ArticoliGetSearch(int numRecord, string azienda, string searchVal)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisArtList}:{azienda}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ArticoliGetSearch | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Aggiornamento record selezionato
- ///
- ///
- ///
- public async Task ArticoliUpdateRecord(AnagArticoli currRec)
- {
- bool fatto = await dbController.ArticoliUpdateRecord(currRec);
- await resetCacheArticoli();
- return fatto;
- }
-
- ///
- /// Verifica se sia possiubile cancellare articolo dato suo CodArt cercando su redis o su
- /// tab veto da DB
- ///
- ///
- ///
- public bool ArticoloDelEnabled(object CodArt)
- {
- bool answ = false;
- string codArticolo = $"{CodArt}";
- int cacheCheckArtUsato = 1;
- int.TryParse(_configuration.GetValue("ServerConf:cacheCheckArtUsato"), out cacheCheckArtUsato);
- TimeSpan TTLCache = getRandTOut(cacheCheckArtUsato);
- // cerco in cache redis...
- string redKeyArtUsed = $"{Utils.redKeyArtUsed}:{codArticolo}";
- string redKeyTabCheckArt = Utils.redKeyTabCheckArt;
- string rawData = redisDb.StringGet(redKeyArtUsed);
- if (!string.IsNullOrEmpty(rawData))
- {
- bool.TryParse(rawData, out answ);
- }
- else
- {
- // controllo non sia stato mai prodotto sennò non posso cancellare...
- try
- {
- // cerco in cache se ci sia la tabella con gli articoli impiegati...
- string rawTable = redisDb.StringGet(redKeyTabCheckArt);
- List? artList = new List();
- if (!string.IsNullOrEmpty(rawTable))
- {
- artList = JsonConvert.DeserializeObject>(rawTable);
- }
- // rileggo...
- if (artList == null || artList.Count == 0)
- {
- artList = new List();
- var tabArticoli = dbController.ArticoliGetUsed();
- var codList = tabArticoli.Select(x => x.CodArticolo);
- foreach (string cod in codList)
- {
- artList.Add(cod);
- }
- // SE fosse vuoto aggiungo comunque il cado "ND"...
- if (artList.Count == 0)
- {
- artList.Add("ND");
- }
- // salvo
- rawTable = JsonConvert.SerializeObject(artList);
- redisDb.StringSet(redKeyTabCheckArt, rawTable, TTLCache);
- }
- // cerco nella tabella: se ci fosse --> disabilitato delete
- bool usato = false;
- if (artList != null && artList.Count > 0)
- {
- usato = artList.Contains(codArticolo);
- }
- answ = !usato;
- redisDb.StringSet(redKeyArtUsed, $"{answ}", TTLCache);
- }
- catch
- { }
- }
- return answ;
- }
-
- public async Task> ConfigGetAll()
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- List? result = new List();
- // cerco in redis...
- RedisValue rawData = await redisDb.StringGetAsync(redisConfKey);
- if (!string.IsNullOrEmpty($"{rawData}"))
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ConfigGetAll Read from REDIS: {ts.TotalMilliseconds}ms");
- }
- else
- {
- result = await Task.FromResult(dbController.ConfigGetAll());
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- await redisDb.StringSetAsync(redisConfKey, rawData, getRandTOut(redisLongTimeCache));
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ConfigGetAll Read from DB: {ts.TotalMilliseconds}ms");
- }
- if (result == null)
- {
- result = new List();
- }
- return result;
- }
-
- ///
- /// Restituisce valore della stringa (SE disponibile)
- ///
- ///
- ///
- public async Task tryGetConfig(string keyName)
- {
- string answ = "";
- // preselezione valori
- var configData = await ConfigGetAll();
- var currRec = configData.FirstOrDefault(x => x.Chiave == keyName);
- if (currRec != null)
- {
- answ = currRec.Valore;
- }
-
- return answ;
- }
-
-
-
- ///
- /// Reset dati cache config
- ///
- ///
- public async Task ConfigResetCache()
- {
- await redisDb.StringSetAsync(redisConfKey, "");
- }
-
- ///
- /// Update chiave config
- ///
- ///
- public async Task ConfigUpdate(ConfigModel updRec)
- {
- return await Task.FromResult(dbController.ConfigUpdate(updRec));
- }
-
- public void Dispose()
- {
- // Clear database controller
- dbController.Dispose();
- redisConn.Dispose();
- }
-
- ///
- /// Eliminazione di un dossier
- ///
- /// record dossier da eliminare
- ///
- public async Task DossiersDeleteRecord(DossierModel selRecord)
- {
- bool result = false;
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- result = await dbController.DossiersDeleteRecord(selRecord);
- // elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisDossByMac}:*");
- bool answ = await ExecFlushRedisPattern(pattern);
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DossiersDeleteRecord | IdxMacchina {selRecord.IdxMacchina} | DtRif {selRecord.DtRif} | IdxODL {selRecord.IdxODL} | {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato
- /// macchina (ordinato x data registrazione)
- ///
- /// * = tutte, altrimenti solo x una data macchina
- /// Data minima per estrazione records
- /// Data Massima per estrazione records
- ///
- public async Task> DossiersGetLastFilt(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisDossByMac}:{IdxMacchina}:{CodArticolo}:{DtStart:yyyyMMddHHmm}:{DtEnd:yyyyMMddHHmm}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.DossiersGetLastFilt(IdxMacchina, CodArticolo, DtStart, DtEnd));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"DossiersGetLastFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Inserimento nuovo record dossier
- ///
- ///
- ///
- public async Task DossiersInsert(DossierModel currDoss)
- {
- // aggiorno record sul DB
- bool answ = await dbController.DossiersInsert(currDoss);
-
- return answ;
- }
-
- ///
- /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
- ///
- /// macchina
- /// NUm massimo secondi per recuperare dati correnti
- /// DataOra riferimento x cui prendere valori antecedenti
- ///
- public async Task DossiersTakeParamsSnapshot(string IdxMacchina, int MaxSec, DateTime DtRif)
- {
- bool answ = false;
- await Task.Delay(1);
- // chiamo stored x salvare parametri
- dbController.DossiersTakeParamsSnapshot(IdxMacchina, MaxSec, DtRif);
- // elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisDossByMac}:*");
- answ = await ExecFlushRedisPattern(pattern);
- Log.Info($"Svuotata cache dossier | {pattern}");
- return answ;
- }
-
- ///
- /// Effettua salvataggio snapshot parametri (con stored) + svuota eventuale cache redis
- ///
- /// macchina
- /// NUm massimo secondi per recuperare dati correnti
- /// DataOra riferimento x cui prendere valori antecedenti
- ///
- public async Task DossiersTakeParamsSnapshotLast(string IdxMacchina, DateTime dtMin, DateTime dtMax)
- {
- bool answ = false;
- await Task.Delay(1);
- Log.Info($"Richiesta snapshot per macchina {IdxMacchina} | periodo {dtMin} --> {dtMax}");
- // chiamo stored x salvare parametri
- dbController.DossiersTakeParamsSnapshotLast(IdxMacchina, dtMin, dtMax);
- // elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisDossByMac}:*");
- answ = await ExecFlushRedisPattern(pattern);
- Log.Info($"Svuotata cache dossier | {pattern}");
- return answ;
- }
-
- ///
- /// Update valore dossier
- ///
- ///
- ///
- public async Task DossiersUpdateValore(DossierModel currDoss)
- {
- // aggiorno record sul DB
- bool answ = await dbController.DossiersUpdateValore(currDoss);
-
- return answ;
- }
-
- ///
- /// Restitusice elenco aziende
- ///
- ///
- public Task> ElencoAziende()
- {
- return Task.FromResult(dbController.AnagGruppiAziende());
- }
-
- ///
- /// Restitusice elenco fasi
- ///
- ///
- public Task> ElencoGruppiFase()
- {
-#if false
- return Task.FromResult(dbController.AnagGruppiFase());
-#endif
- List result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisAnagGruppi}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = dbController.AnagGruppiFase();
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ElencoGruppiFase | Read from {readType}: {ts.TotalMilliseconds}ms");
- return Task.FromResult(result);
- }
-
- public Task> ElencoLink()
- {
- return Task.FromResult(dbController.ElencoLink());
- }
-
- ///
- /// Aggiunta record EventList
- ///
- ///
- ///
- public async Task EvListInsert(EventListModel newRec)
- {
- return await dbController.EvListInsert(newRec);
- }
-
- public async Task FlushRedisCache()
- {
- await Task.Delay(1);
- RedisValue pattern = new RedisValue($"{redisBaseAddr}*");
- bool answ = await ExecFlushRedisPattern(pattern);
- // rileggo vocabolario.,..
- ObjVocabolario = VocabolarioGetAll();
- return answ;
- }
-
-
- ///
- /// Elenco ultimi n record flux log dato macchina e flusso (ordinato x data registrazione)
- ///
- /// Data massima x eventi
- /// Data minima x eventi
- /// * = tutte, altrimenti solo x una data macchina
- /// *=tutti, altrimenti solo selezionato
- /// numero massimo record da restituire
- ///
- public async Task> FluxLogGetLastFilt(DateTime DtMax, DateTime DtMin, string IdxMacchina, string CodFlux, int MaxRec, int redisCacheSec)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisFluxLogFilt}:{IdxMacchina}:{CodFlux}:{MaxRec}:{DtMax:yyyyMMddHHmm}:{DtMin:yyyyMMddHHmm}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.FluxLogGetLastFilt(DtMax, DtMin, IdxMacchina, CodFlux, MaxRec));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisCacheSec / 2));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"FluxLogGetLastFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Elenco setup dei tag conf correnti
- ///
- ///
- public Task>> getAllTags()
- {
- return Task.FromResult(currTagConf);
- }
-
- public List getFluxLog(string Valore)
- {
- List answ = new List();
- DossierFluxLogDTO? result = JsonConvert.DeserializeObject(Valore);
- if (result != null)
- {
- if (result.ODL != null)
- {
- answ = result
- .ODL
- .OrderBy(x => x.CodFlux)
- .ToList();
- // inizializzo SE necessario
- foreach (var item in answ)
- {
- item.ValoreEdit = String.IsNullOrEmpty(item.ValoreEdit) ? item.Valore : item.ValoreEdit;
- }
- }
- }
- return answ;
- }
-
- ///
- /// restituisce il valore da REDIS associato al tag richeisto
- ///
- /// Chiave in cui cercare il valore
- ///
- public string getTagConf(string redKey)
- {
- string outVal = "";
- // cerco in REDIS la conf x l'IOB
- var rawData = redisDb.StringGet(redKey);
- if (!string.IsNullOrEmpty(rawData))
- {
- outVal = $"{rawData}";
- }
- return outVal;
- }
-
- ///
- /// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato)
- ///
- /// Stato ODL: true=in corso/completato
- /// Cod articolo
- /// KeyRich (parziale) da cercare (es cod stato x yacht)
- /// Reparto selezionato
- /// Macchina selezionata
- /// Data inizio
- /// Data fine
- ///
- public async Task> ListODLFilt(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisOdlList}:{inCorso}:{codArt}:{keyRichPart}:{Reparto}:{IdxMacchina}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ListODLFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
-
-
- //return await Task.FromResult(dbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
- }
-
- ///
- /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato)
- ///
- /// Cod articolo
- /// KeyRich (parziale) da cercare (es cod stato x yacht)
- ///
- public async Task> ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisPOdlList}:{lanciato}:{keyRichPart}:{idxMacchina}:{codGruppo}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ListPODLFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
-
- ///
- /// Elenco PODL avviati filtrati x articolo, KeyRich (che contiene stato)
- ///
- /// Cod articolo
- /// KeyRich (parziale) da cercare (es cod stato x yacht)
- ///
- public async Task> ListPODLFiltNOOdl(string codArt, string keyRichPart)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisPOdlListNOOdl}:{codArt}:{keyRichPart}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.ListPODLFiltNOOdl(codArt, keyRichPart));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(3));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ListPODLFiltNOOdl | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Elenco di tutte le macchine gestite
- ///
- ///
- public async Task> MacchineGetAll()
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = redisMacList;
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.MacchineGetAll());
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"MacchineGetAll | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Elenco id Macchine che abbiano dati FLuxLog, nel periodo indicato
- ///
- ///
- ///
- ///
- public async Task> MacchineWithFlux(DateTime dtStart, DateTime dtEnd)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisMacByFlux}:{dtStart:yyyyMMddHHmm}:{dtEnd:yyyyMMddHHmm}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await dbController.MacchineWithFlux(dtStart, dtEnd);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"MacchineWithFlux | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Effettua chiusura dell'ODL indicato, andand
- ///
- /// idx odl da chiudere
- /// idx macchina
- /// matricola operatore
- /// indica se confermare i pezzi priam di chiudere ODL
- public async Task ODLClose(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi)
- {
- bool fatto = false;
- await Task.Delay(1);
- // recupero dati x conf modalità conferma
- var configData = await ConfigGetAll();
- if (configData != null)
- {
- bool confRett = false;
- var currRec = configData.FirstOrDefault(x => x.Chiave == "confRett");
- if (currRec != null)
- {
- bool.TryParse(currRec.Valore, out confRett);
- }
- int modoConfProd = 0;
- currRec = configData.FirstOrDefault(x => x.Chiave == "modoConfProd");
- if (currRec != null)
- {
- int.TryParse(currRec.Valore, out modoConfProd);
- }
- // chiamo metodo conferma!
- fatto = await dbController.ODLClose(idxOdl, idxMacchina, matrOpr, confPezzi, confRett, modoConfProd);
- }
-
- return fatto;
- }
-
- ///
- /// Record ODL da chaive
- ///
- ///
- public async Task OdlGetByKey(int IdxOdl)
- {
- await Task.Delay(1);
- var dbResult = dbController.OdlGetByKey(IdxOdl);
- return dbResult;
- }
-
- ///
- /// ODL correnti (tutti)
- ///
- ///
- ///
- public List OdlGetCurrent()
- {
- List? dbResult = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisOdlCurrByMac}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- try
- {
- dbResult = JsonConvert.DeserializeObject>($"{rawData}");
- }
- catch
- { }
- readType = "REDIS";
- }
- else
- {
- dbResult = dbController.OdlGetCurrent().Select(x => x.IdxMacchina).Distinct().ToList();
- rawData = JsonConvert.SerializeObject(dbResult);
- redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(3));
- }
- if (dbResult == null)
- {
- dbResult = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"OdlGetCurrent | Read from {readType}: {ts.TotalMilliseconds}ms");
-
- return dbResult;
- }
-
- ///
- /// Elenco di tutti i parametri filtrati x macchina
- ///
- /// * = tutte, altrimenti solo x una data macchina
- ///
- public async Task> ParametriGetFilt(string IdxMacchina)
- {
- List? result = new List();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisFluxByMac}:{IdxMacchina}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await Task.FromResult(dbController.ParametriGetFilt(IdxMacchina));
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new List();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"ParametriGetFilt | Read from {readType}: {ts.TotalMilliseconds}ms");
- return result;
- }
-
- ///
- /// Recupero PODL da chiave
- ///
- ///
- ///
- public async Task PODL_getByKey(int idxPODL)
- {
- PODLModel result = new PODLModel();
- if (idxPODL != 0)
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisPOdlByPOdl}:{idxPODL}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = await dbController.PODL_getByKey(idxPODL);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new PODLModel();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Trace($"PODL_getByKey | Read from {readType}: {ts.TotalMilliseconds}ms");
- }
- else
- {
- Log.Debug("Errore IdxPODL = 0");
- }
- return result;
- }
-
- ///
- /// Recupero PODL da IdxODL
- ///
- ///
- ///
- public PODLModel PODL_getByOdl(int idxODL)
- {
- PODLModel result = new PODLModel();
- if (idxODL != 0)
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- string readType = "DB";
- string currKey = $"{redisPOdlByOdl}:{idxODL}";
- // cerco in redis dato valore sel macchina...
- RedisValue rawData = redisDb.StringGet(currKey);
- if (rawData.HasValue)
- {
- result = JsonConvert.DeserializeObject($"{rawData}");
- readType = "REDIS";
- }
- else
- {
- result = dbController.PODL_getByOdl(idxODL);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (result == null)
- {
- result = new PODLModel();
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Trace($"PODL_getByOdl | Read from {readType}: {ts.TotalMilliseconds}ms");
- }
- else
- {
- Log.Debug("Errore IdxODL = 0");
- }
- return result;
- }
-
- ///
- /// Eliminazione record selezionato
- ///
- ///
- ///
- public async Task PODLDeleteRecord(PODLExpModel currRec)
- {
- return await dbController.PODLDeleteRecord(currRec);
- }
-
- ///
- /// Avvio fase setup per il record selezionato
- ///
- ///
- ///
- public async Task POdlDoSetup(PODLExpModel currRec)
- {
- return await dbController.PODL_startSetup(currRec, 0, 1, 1, "");
- }
-
- ///
- /// Aggiornamento record selezionato
- ///
- ///
- ///
- public async Task POdlUpdateRecord(PODLExpModel currRec)
- {
- var dbResult = await dbController.PODLUpdateRecord(currRec);
- // elimino cache redis...
- RedisValue pattern = new RedisValue($"{redisPOdlList}:*");
- bool answ = await ExecFlushRedisPattern(pattern);
-
- return dbResult;
- }
-
- ///
- /// Statistiche ODL calcolate (da stored stp_STAT_ODL)
- ///
- ///
- public Task> StatOdl(int IdxOdl)
- {
- return dbController.OdlStart(IdxOdl);
- }
-
- ///
- /// Esegue traduzione dato vocabolario da Lingua + Lemma
- ///
- ///
- ///
- ///
- public string Traduci(string lemma, string lingua)
- {
- string answ = $"[{lemma}]";
- // verifico se ho qualcosa nell'obj vocabolario...
- if (ObjVocabolario == null || ObjVocabolario.Count == 0)
- {
- // inizializzo il vocabolario...
- ObjVocabolario = VocabolarioGetAll();
- }
- var record = ObjVocabolario.Where(x => x.Lingua == lingua && x.Lemma == lemma).FirstOrDefault();
- if (record != null)
- {
- answ = record.Traduzione;
- }
- return answ;
- }
-
- public async Task updateDossierValue(DossierModel currDoss, FluxLogDTO editFL)
- {
- bool answ = false;
- // recupero intero set valori dossier deserializzando...
- var fluxLogList = getFluxLog(currDoss.Valore);
- await Task.Delay(1);
-
- // se tutto ok
- if (fluxLogList != null)
- {
- // da provare...!!!!
-
- // elimino vecchio record
- var currRec = fluxLogList.FirstOrDefault(x => x.CodFlux == editFL.CodFlux && x.dtEvento == editFL.dtEvento);
- if (currRec != null)
- {
- fluxLogList.Remove(currRec);
- // aggiungo nuovo
- fluxLogList.Add(editFL);
- }
-
- // serializzo nuovamente valore
- DossierFluxLogDTO? result = new DossierFluxLogDTO();
- var ODLflux = result.ODL.ToList();
- foreach (var item in fluxLogList)
- {
- ODLflux.Add(item);
- }
-
- DossierFluxLogDTO updatedResult = new DossierFluxLogDTO() { ODL = ODLflux };
-
- string rawVal = JsonConvert.SerializeObject(updatedResult);
- currDoss.Valore = rawVal;
- // aggiorno record sul DB
- await dbController.DossiersUpdateValore(currDoss);
- }
-
- return answ;
- }
-
- ///
- /// Elenco completo tabella Vocabolario
- ///
- ///
- public List VocabolarioGetAll()
- {
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- List? result = new List();
- string source = "REDIS";
- // cerco in redis...
- RedisValue rawData = redisDb.StringGet(redisVocabolario);
- if (!string.IsNullOrEmpty($"{rawData}"))
- {
- result = JsonConvert.DeserializeObject>($"{rawData}");
- }
- else
- {
- result = dbController.VocabolarioGetAll();
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(result);
- redisDb.StringSet(redisVocabolario, rawData, getRandTOut(redisLongTimeCache / 5));
- source = "DB";
- }
- stopWatch.Stop();
- TimeSpan ts = stopWatch.Elapsed;
- Log.Debug($"VocabolarioGetAll Read from {source}: {ts.TotalMilliseconds}ms");
- if (result == null)
- {
- result = new List();
- }
- return result;
- }
-
- #endregion Public Methods
-
- #region Protected Fields
-
- protected Random rand = new Random();
-
- #endregion Protected Fields
-
- #region Protected Methods
-
- ///
- /// Restituisce un timeout dai minuti richiesti + tempo random 1..60 sec
- ///
- ///
- ///
- protected TimeSpan getRandTOut(int stdMinutes)
- {
- double rndValue = (double)stdMinutes + (double)rand.Next(1, 60) / 60;
- return TimeSpan.FromMinutes(rndValue);
- }
-
- #endregion Protected Methods
-
- #region Private Fields
-
- private const string redisAnagGruppi = redisBaseAddr + "SPEC:Cache:AnagGruppi";
-
- private const string redisArtByDossier = redisBaseAddr + "SPEC:Cache:ArtByDossier";
-
- private const string redisArtList = redisBaseAddr + "SPEC:Cache:ArtList";
-
- private const string redisBaseAddr = "MP:";
-
- private const string redisConfKey = redisBaseAddr + "SPEC:Cache:Config";
-
- private const string redisDossByMac = redisBaseAddr + "SPEC:Cache:DossByMac";
-
- private const string redisFluxByMac = redisBaseAddr + "SPEC:Cache:FluxByMac";
-
- private const string redisFluxLogFilt = redisBaseAddr + "SPEC:Cache:FluxLogFilt";
-
- private const string redisMacByFlux = redisBaseAddr + "SPEC:Cache:MacByFlux";
-
- private const string redisMacList = redisBaseAddr + "SPEC:Cache:MacList";
-
- private const string redisOdlCurrByMac = redisBaseAddr + "SPEC:Cache:OdlByMac";
- private const string redisOdlList = redisBaseAddr + "SPEC:Cache:OdlList";
-
- private const string redisPOdlByOdl = redisBaseAddr + "SPEC:Cache:POdlByOdl";
- private const string redisPOdlByPOdl = redisBaseAddr + "SPEC:Cache:POdlByPOdl";
- private const string redisPOdlList = redisBaseAddr + "SPEC:Cache:POdlList";
- private const string redisPOdlListNOOdl = redisBaseAddr + "SPEC:Cache:POdlListNOOdl";
- private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom";
-
- private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt";
-
- private const string redisVocabolario = redisBaseAddr + "SPEC:Cache:Vocabolario";
-
- private static IConfiguration _configuration = null!;
-
- private static ILogger _logger = null!;
-
- private static Logger Log = LogManager.GetCurrentClassLogger();
-
- ///
- /// Oggetto vocabolario x uso continuo traduzione
- ///
- private List ObjVocabolario = new List();
-
- ///
- /// Oggetto per connessione a REDIS
- ///
- private ConnectionMultiplexer redisConn = null!;
-
- ///
- /// Oggetto per connessione a REDIS modalità admin (ex flux dati)
- ///
- private ConnectionMultiplexer redisConnAdmin = null!;
-
- ///
- /// Oggetto DB redis da impiegare x chiamate R/W
- ///
- private IDatabase redisDb = null!;
-
- private int redisLongTimeCache = 5;
- private int redisShortTimeCache = 4;
-
- #endregion Private Fields
-
- #region Private Methods
-
- ///
- /// Esegue flush memoria redis dato pattern
- ///
- ///
- ///
- private async Task ExecFlushRedisPattern(RedisValue pattern)
- {
- bool answ = false;
- var listEndpoints = redisConnAdmin.GetEndPoints();
- foreach (var endPoint in listEndpoints)
- {
- //var server = redisConnAdmin.GetServer(listEndpoints[0]);
- var server = redisConnAdmin.GetServer(endPoint);
- if (server != null)
- {
- var keyList = server.Keys(redisDb.Database, pattern);
- foreach (var item in keyList)
- {
- await redisDb.KeyDeleteAsync(item);
- }
- // brutalmente rimuovo intero contenuto DB... DANGER
- //await server.FlushDatabaseAsync();
- answ = true;
- }
- }
-
- return answ;
- }
-
- private async Task resetCacheArticoli()
- {
- RedisValue pattern = new RedisValue($"{redisArtByDossier}:*");
- await ExecFlushRedisPattern(pattern);
- pattern = new RedisValue($"{redisArtList}:*");
- await ExecFlushRedisPattern(pattern);
- }
-
- #endregion Private Methods
- }
-}
\ No newline at end of file
diff --git a/MP.INVE/MP.INVE.csproj b/MP.INVE/MP.INVE.csproj
index 71ae1822..2988c20a 100644
--- a/MP.INVE/MP.INVE.csproj
+++ b/MP.INVE/MP.INVE.csproj
@@ -5,7 +5,7 @@
enable
enable
MP.INVE
- 6.16.2211.2513
+ 6.16.2211.2916
diff --git a/MP.INVE/Pages/Acquisizione.razor b/MP.INVE/Pages/Acquisizione.razor
index 672f34fa..7d5ced7c 100644
--- a/MP.INVE/Pages/Acquisizione.razor
+++ b/MP.INVE/Pages/Acquisizione.razor
@@ -2,27 +2,9 @@
-
-
-
-
+
+ Acquisizione
+
+
+
diff --git a/MP.INVE/Pages/InveSession.razor b/MP.INVE/Pages/InveSession.razor
index 88176182..6be0de66 100644
--- a/MP.INVE/Pages/InveSession.razor
+++ b/MP.INVE/Pages/InveSession.razor
@@ -53,9 +53,9 @@
Magazzino
|