diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 33b5ba9f..d7081f32 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -6,6 +6,7 @@ using NLog; using StackExchange.Redis; using System; using System.Collections.Generic; +using System.Data; using System.Linq; using System.Threading.Tasks; @@ -329,6 +330,55 @@ namespace MP.Data.Controllers return answ; } + /// + /// Elenco giacenze + /// + /// id odl da cercare + /// + public List ListGiacenze(int IdxOdl) + { + List dbResult = new List(); + using (var dbCtx = new MoonPro_InveContext(_configuration)) + { + try + { + dbResult = dbCtx + .DbGiacenzeData + .AsNoTracking() + .Where(x => x.IdxOdl == IdxOdl) + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ListGiacenze{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// + /// Elenco TUTTI GLI ODL + /// + /// + public List ListOdlAll() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + dbResult = dbCtx + .DbSetODL + .AsNoTracking() + .ToList(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ListOdlAll{Environment.NewLine}{exc}"); + } + } + return dbResult; + } + /// /// Elenco ultimi n record DOssiers (che contengono ad esempio "salvataggi" di FLuxLog) dato /// macchina (ordinato x data registrazione) @@ -600,7 +650,7 @@ namespace MP.Data.Controllers /// Macchina /// Gruppo /// - public List ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo) + public List ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate) { List dbResult = new List(); @@ -610,10 +660,12 @@ namespace MP.Data.Controllers var KeyRich = new SqlParameter("@KeyRich", keyRichPart); var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); var CodGrp = new SqlParameter("@CodGruppo", codGruppo); + var DateFrom = new SqlParameter("@DateFrom", startDate); + var DateTo = new SqlParameter("@DateTo", endDate); dbResult = dbCtx .DbSetPODLExp - .FromSqlRaw("EXEC stp_PODL_getByFiltSpec @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina", Lanc, KeyRich, CodGrp, IdxMacc) + .FromSqlRaw("EXEC stp_PODL_getByFiltSpec @Lanciato, @KeyRich, @CodGruppo, @IdxMacchina, @DateFrom, @DateTo", Lanc, KeyRich, CodGrp, IdxMacc, DateFrom, DateTo) .AsNoTracking() //.AsEnumerable() .ToList(); @@ -621,6 +673,7 @@ namespace MP.Data.Controllers return dbResult; } +#if false /// /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) @@ -643,7 +696,8 @@ namespace MP.Data.Controllers .ToList(); } return dbResult; - } + } +#endif /// /// Elenco valori ammessi x tabella/colonna @@ -954,22 +1008,42 @@ namespace MP.Data.Controllers public async Task PODL_startSetup(PODLExpModel editRec, int matrOpr, double tcRich, int pzPallet, string note) { bool answ = false; + + PODLModel recPODL = new PODLModel() + { + IdxPromessa = editRec.IdxPromessa, + KeyRichiesta = editRec.KeyRichiesta, + KeyBCode = editRec.KeyBCode, + IdxOdl = editRec.IdxOdl, + CodArticolo = editRec.CodArticolo, + CodGruppo = editRec.CodGruppo, + IdxMacchina = editRec.IdxMacchina, + NumPezzi = editRec.NumPezzi, + Tcassegnato = editRec.Tcassegnato, + DueDate = editRec.DueDate, + Priorita = editRec.Priorita, + PzPallet = editRec.PzPallet, + Note = editRec.Note, + CodCli = editRec.CodCli, + InsertDate = editRec.InsertDate + }; + using (var dbCtx = new MoonProContext(_configuration)) { try { var currRec = dbCtx - .DbSetPODLExp + .DbSetPODL .AsNoTracking() - .Where(x => x.IdxPromessa == editRec.IdxPromessa) + .Where(x => x.IdxPromessa == recPODL.IdxPromessa) .FirstOrDefault(); if (currRec != null) { // eseguo stored attrezzaggio - var IdxPromessa = new SqlParameter("@idxPromessa", editRec.IdxPromessa); + var IdxPromessa = new SqlParameter("@idxPromessa", recPODL.IdxPromessa); var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); - var IdxMacchina = new SqlParameter("@IdxMacchina", editRec.IdxMacchina); + var IdxMacchina = new SqlParameter("@IdxMacchina", recPODL.IdxMacchina); var TCRichAttr = new SqlParameter("@TCRichAttr", tcRich); var PzPallet = new SqlParameter("@PzPallet", pzPallet); var Note = new SqlParameter("@Note", note); @@ -996,17 +1070,35 @@ namespace MP.Data.Controllers /// public async Task PODLDeleteRecord(PODLExpModel currRec) { + PODLModel recPODL = new PODLModel() + { + IdxPromessa = currRec.IdxPromessa, + KeyRichiesta = currRec.KeyRichiesta, + KeyBCode = currRec.KeyBCode, + IdxOdl = currRec.IdxOdl, + CodArticolo = currRec.CodArticolo, + CodGruppo = currRec.CodGruppo, + IdxMacchina = currRec.IdxMacchina, + NumPezzi = currRec.NumPezzi, + Tcassegnato = currRec.Tcassegnato, + DueDate = currRec.DueDate, + Priorita = currRec.Priorita, + PzPallet = currRec.PzPallet, + Note = currRec.Note, + CodCli = currRec.CodCli, + InsertDate = currRec.InsertDate + }; bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) { try { var currVal = dbCtx - .DbSetPODLExp - .Where(x => x.IdxPromessa == currRec.IdxPromessa) + .DbSetPODL + .Where(x => x.IdxPromessa == recPODL.IdxPromessa) .FirstOrDefault(); dbCtx - .DbSetPODLExp + .DbSetPODL .Remove(currVal); await dbCtx.SaveChangesAsync(); fatto = true; @@ -1024,7 +1116,7 @@ namespace MP.Data.Controllers /// /// /// - public async Task PODLUpdateRecord(PODLExpModel editRec) + public async Task PODLUpdateRecord(PODLModel editRec) { bool fatto = false; using (var dbCtx = new MoonProContext(_configuration)) @@ -1032,7 +1124,7 @@ namespace MP.Data.Controllers try { var currRec = dbCtx - .DbSetPODLExp + .DbSetPODL .Where(x => x.IdxPromessa == editRec.IdxPromessa) .FirstOrDefault(); if (currRec != null) @@ -1051,7 +1143,7 @@ namespace MP.Data.Controllers else { dbCtx - .DbSetPODLExp + .DbSetPODL .Add(editRec); } await dbCtx.SaveChangesAsync(); diff --git a/MP.Data/DatabaseModels/AnagGiacenzeModel.cs b/MP.Data/DatabaseModels/AnagGiacenzeModel.cs new file mode 100644 index 00000000..3b001a78 --- /dev/null +++ b/MP.Data/DatabaseModels/AnagGiacenzeModel.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + [Table("RegGiacenze")] + public class AnagGiacenzeModel + { + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxRG { get; set; } = 0; + public int IdxOdl { get; set; } = 0; + public string IdentRG { get; set; } = ""; + public string Product { get; set; } = ""; + public string Variety { get; set; } = ""; + public string Supplier { get; set; } = ""; + public string ExtDoc { get; set; } = ""; + public DateTime DateRif { get; set; } + public double QtyTot { get; set; } = 0; + public int NumPack { get; set; } = 0; + public string Notes { get; set; } = ""; + } +} diff --git a/MP.Data/MoonPro_InveContext.cs b/MP.Data/MoonPro_InveContext.cs index ec5d15c5..e656d1c9 100644 --- a/MP.Data/MoonPro_InveContext.cs +++ b/MP.Data/MoonPro_InveContext.cs @@ -45,11 +45,20 @@ namespace MP.Data #region Public Properties + #region PER INVE + public virtual DbSet DbAnagMag { get; set; } public virtual DbSet DbInveSess { get; set; } public virtual DbSet DbScanData { get; set; } public virtual DbSet DbUdcData { get; set; } public virtual DbSet DbLottoData { get; set; } + #endregion PER INVE + + #region PER SPEC + + public virtual DbSet DbGiacenzeData { get; set; } + + #endregion PER SPEC #endregion Public Properties diff --git a/MP.Data/Utils.cs b/MP.Data/Utils.cs index f7f548cd..c52fc80b 100644 --- a/MP.Data/Utils.cs +++ b/MP.Data/Utils.cs @@ -1,5 +1,6 @@ using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; using MP.Data.DTO; using System; using System.Collections.Generic; @@ -13,7 +14,7 @@ namespace MP.Data public class Utils { #region Public Properties - + public static string redKeyArtUsed { @@ -109,6 +110,68 @@ namespace MP.Data return answ; } + public class POdlExt + { + /// + /// Clona un POdleExt a POdl + /// + /// + /// + public static PODLModel convertToPOdl(PODLExpModel selRec) + { + // creo record duplicato... + PODLModel newRec = new PODLModel() + { + Attivabile = selRec.Attivabile, + CodArticolo = selRec.CodArticolo, + CodCli = selRec.CodCli, + CodGruppo = selRec.CodGruppo, + DueDate = selRec.DueDate, + IdxMacchina = selRec.IdxMacchina, + IdxOdl = selRec.IdxOdl, + IdxPromessa = 0, + InsertDate = selRec.InsertDate, + KeyBCode = selRec.KeyBCode, + KeyRichiesta = selRec.KeyRichiesta, + Note = selRec.Note, + NumPezzi = selRec.NumPezzi, + Priorita = selRec.Priorita, + PzPallet = selRec.PzPallet, + Tcassegnato = selRec.Tcassegnato + }; + return newRec; + } + /// + /// Clona un POdleExt + /// + /// + /// + public static PODLExpModel clone(PODLExpModel selRec) + { + // creo record duplicato... + PODLExpModel newRec = new PODLExpModel() + { + Attivabile = selRec.Attivabile, + CodArticolo = selRec.CodArticolo, + CodCli = selRec.CodCli, + CodGruppo = selRec.CodGruppo, + DueDate = selRec.DueDate, + IdxMacchina = selRec.IdxMacchina, + IdxOdl = selRec.IdxOdl, + IdxPromessa = 0, + InsertDate = selRec.InsertDate, + KeyBCode = selRec.KeyBCode, + KeyRichiesta = selRec.KeyRichiesta, + Note = $"DUPLICATED - {selRec.Note}", + NumPezzi = selRec.NumPezzi, + Priorita = selRec.Priorita, + PzPallet = selRec.PzPallet, + Tcassegnato = selRec.Tcassegnato + }; + return newRec; + } + } + #endregion Public Methods } } \ No newline at end of file diff --git a/MP.INVE/Components/CmpFooter.razor b/MP.INVE/Components/CmpFooter.razor index e8d26461..ad842ade 100644 --- a/MP.INVE/Components/CmpFooter.razor +++ b/MP.INVE/Components/CmpFooter.razor @@ -1,9 +1,9 @@ 
-
+
Mapo INVE @(DateTime.Today.Year) | v.@version
- @($"{DateTime.Now:HH:mm:ss}") | Egalware + @*@($"{DateTime.Now:HH:mm:ss}")*@ Egalware
diff --git a/MP.INVE/Components/CmpTop.razor b/MP.INVE/Components/CmpTop.razor index 5672c13e..b336adc3 100644 --- a/MP.INVE/Components/CmpTop.razor +++ b/MP.INVE/Components/CmpTop.razor @@ -3,38 +3,21 @@ @using System.Security.Claims @using Microsoft.AspNetCore.Components.Authorization -@inject AuthenticationStateProvider AuthenticationStateProvider -
@if (userName != "0") { } - else - { - - }
- @*
- @TipoSearch -
-
- @if (ShowSearch) - { - - } -
*@
diff --git a/MP.INVE/Components/CmpTop.razor.cs b/MP.INVE/Components/CmpTop.razor.cs index 65f635b7..262b05f0 100644 --- a/MP.INVE/Components/CmpTop.razor.cs +++ b/MP.INVE/Components/CmpTop.razor.cs @@ -34,7 +34,7 @@ namespace MP.INVE.Components [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; [Inject] - protected MiDataService MIDataService{ get; set; } = null!; + protected MiDataService MIDataService { get; set; } = null!; #endregion Protected Properties @@ -44,20 +44,23 @@ namespace MP.INVE.Components { OperatoreDTO answ = new OperatoreDTO(); answ = await localStorage.GetItemAsync("MatrOpr"); - if (answ != null) + if (!NavManager.Uri.Contains("Jumper?")) { - userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})"; - if (NavManager.Uri.Contains("OperatoreLogin")) - { - NavManager.NavigateTo("Starter", true); - } - } - else - { - userName = "0"; - if (!NavManager.Uri.Contains("OperatoreLogin")) + if (answ != null) { - NavManager.NavigateTo("OperatoreLogin", true); + userName = $"{answ.Cognome} {answ.Nome} ({answ.MatrOpr})"; + if (NavManager.Uri.Contains("OperatoreLogin")) + { + NavManager.NavigateTo("Starter", true); + } + } + else + { + userName = "0"; + if (!NavManager.Uri.Contains("OperatoreLogin")) + { + NavManager.NavigateTo("OperatoreLogin", true); + } } } } diff --git a/MP.INVE/Components/CodeScan.razor b/MP.INVE/Components/CodeScan.razor index 5e0b794a..8bb24799 100644 --- a/MP.INVE/Components/CodeScan.razor +++ b/MP.INVE/Components/CodeScan.razor @@ -1,5 +1,6 @@ - - +
+ +
@if (rawScan != null) { diff --git a/MP.INVE/Components/InveSessionList.razor b/MP.INVE/Components/InveSessionList.razor index 9901e34b..b0c46970 100644 --- a/MP.INVE/Components/InveSessionList.razor +++ b/MP.INVE/Components/InveSessionList.razor @@ -21,9 +21,9 @@ Magazzino + @tipo +
+ +
  • + Articolo: +
    + + +
    +
  • Quantità:
    - + +
  • -
    +
    + + } 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

    -
    -
    -
    -
    - -
    -
    -
    - +
    +

    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 - - @if (ListGruppiFase != null) - { - foreach (var item in ListGruppiFase) - { - - } - } - -
    - -
    - -
    - -
    -
    - - -
    -
    -
    - -
    - -
    -
    - - -
    -
    - - - diff --git a/MP.SPEC/Components/SelFilterPODL.razor.cs b/MP.SPEC/Components/SelFilterPODL.razor.cs deleted file mode 100644 index 7ac096f7..00000000 --- a/MP.SPEC/Components/SelFilterPODL.razor.cs +++ /dev/null @@ -1,114 +0,0 @@ -using Blazored.LocalStorage; -using Microsoft.AspNetCore.Components; -using MP.Data.DatabaseModels; -using MP.SPEC.Data; - -namespace MP.SPEC.Components -{ - public partial class SelFilterPODL - { - #region Public Properties - - [Parameter] - public SelectPOdlParams currFilter { get; set; } = new SelectPOdlParams(); - - [Parameter] - public EventCallback FilterChanged { get; set; } - - [Parameter] - public List? ListGruppiFase { get; set; } = null; - - [Parameter] - public List? ListMacchine { get; set; } = null; - - [Parameter] - public List? ListStati { get; set; } = null; - - #endregion Public Properties - - #region Protected Properties - - [Inject] - protected ILocalStorageService localStorage { get; set; } = null!; - protected async Task getReparto() - { - string keyStor = "reparto"; - string localReparto = await localStorage.GetItemAsync(keyStor); - if (!string.IsNullOrEmpty(localReparto)) - { - selReparto = localReparto; - } - else - { - await localStorage.SetItemAsync(keyStor, selReparto); - } - } - protected bool hasOdl - { - get => currFilter.hasOdl; - } - - - #endregion Protected Properties - - #region Private Properties - - private string selMacchina - { - get => currFilter.IdxMacchina; - set - { - if (currFilter.IdxMacchina != value) - { - currFilter.IdxMacchina = value; - Task.Delay(1); - reportChange(); - } - } - } - - private string selReparto - { - get => currFilter.CodReparto; - set - { - if (currFilter.CodReparto != value) - { - currFilter.CodReparto = value; - Task.Delay(1); - reportChange(); - } - } - } - - private string selStato - { - get => currFilter.CodFase; - set - { - if (currFilter.CodFase != value) - { - currFilter.CodFase = value; - Task.Delay(1); - reportChange(); - } - } - } - protected override async Task OnInitializedAsync() - { - await Task.Delay(1); - //selReparto = localStorage.GetItemAsync("reparto").ToString(); - await getReparto(); - } - #endregion Private Properties - - #region Private Methods - - private void reportChange() - { - FilterChanged.InvokeAsync(currFilter); - } - - #endregion Private Methods - } -} \ No newline at end of file diff --git a/MP.SPEC/Components/SelFilterXDL.razor b/MP.SPEC/Components/SelFilterXDL.razor index 891c9f2e..526b89cc 100644 --- a/MP.SPEC/Components/SelFilterXDL.razor +++ b/MP.SPEC/Components/SelFilterXDL.razor @@ -16,7 +16,7 @@
    - + diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index af80d0d3..e694bcb4 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -701,14 +701,16 @@ namespace MP.SPEC.Data /// KeyRich (parziale) da cercare (es cod stato x yacht) /// Macchina /// Gruppo + /// Data inizio + /// Data fine /// - public async Task> ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo) + public async Task> ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate) { List? result = new List(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - string currKey = $"{redisPOdlList}:{lanciato}:{keyRichPart}:{idxMacchina}:{codGruppo}"; + string currKey = $"{redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}"; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) @@ -718,7 +720,7 @@ namespace MP.SPEC.Data } else { - result = await Task.FromResult(dbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo)); + result = await Task.FromResult(dbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo, startDate, endDate)); // serializzo e salvo... rawData = JsonConvert.SerializeObject(result); redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); @@ -733,41 +735,75 @@ namespace MP.SPEC.Data return result; } - /// - /// Elenco PODL avviati filtrati x articolo, KeyRich (che contiene stato) /// - /// Cod articolo - /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// id odl da cercare /// - public async Task> ListPODLFiltNOOdl(string codArt, string keyRichPart) + public async Task> ListGiacenze(int IdxOdl) { - List? result = new List(); + List? result = new List(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - string currKey = $"{redisPOdlListNOOdl}:{codArt}:{keyRichPart}"; + string currKey = $"{redisGiacenzaList}:{IdxOdl}"; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) { - result = JsonConvert.DeserializeObject>($"{rawData}"); + result = JsonConvert.DeserializeObject>($"{rawData}"); readType = "REDIS"; } else { - result = await Task.FromResult(dbController.ListPODLFiltNOOdl(codArt, keyRichPart)); + result = await Task.FromResult(dbController.ListGiacenze(IdxOdl)); // serializzo e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(3)); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); } if (result == null) { - result = new List(); + result = new List(); } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ListPODLFiltNOOdl | Read from {readType}: {ts.TotalMilliseconds}ms"); + Log.Debug($"ListGiacenze | Read from {readType}: {ts.TotalMilliseconds}ms"); + return result; + } + /// + /// elenco TUTTI gli ODL + /// + /// + /// + public List ListOdlAll() + { + List? result = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; +#if false + string currKey = $"{redisGiacenzaList}:{IdxOdl}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + readType = "REDIS"; + } + else + { + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); + } + if (result == null) + { + result = new List(); + } +#endif + result = dbController.ListOdlAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ListOdlAll | Read from {readType}: {ts.TotalMilliseconds}ms"); return result; } @@ -1062,7 +1098,12 @@ namespace MP.SPEC.Data /// public async Task PODLDeleteRecord(PODLExpModel currRec) { - return await dbController.PODLDeleteRecord(currRec); + var dbResult = await dbController.PODLDeleteRecord(currRec); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisXdlData}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; } /// @@ -1072,7 +1113,12 @@ namespace MP.SPEC.Data /// public async Task POdlDoSetup(PODLExpModel currRec) { - return await dbController.PODL_startSetup(currRec, 0, 1, 1, ""); + var dbResult = await dbController.PODL_startSetup(currRec, 0, 1, 1, ""); + // elimino cache redis... + RedisValue pattern = new RedisValue($"{redisXdlData}:*"); + bool answ = await ExecFlushRedisPattern(pattern); + await Task.Delay(1); + return dbResult; } /// @@ -1080,13 +1126,13 @@ namespace MP.SPEC.Data /// /// /// - public async Task POdlUpdateRecord(PODLExpModel currRec) + public async Task POdlUpdateRecord(PODLModel currRec) { var dbResult = await dbController.PODLUpdateRecord(currRec); // elimino cache redis... - RedisValue pattern = new RedisValue($"{redisPOdlList}:*"); + RedisValue pattern = new RedisValue($"{redisXdlData}:*"); bool answ = await ExecFlushRedisPattern(pattern); - + await Task.Delay(1); return dbResult; } @@ -1241,13 +1287,17 @@ namespace MP.SPEC.Data 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 redisXdlData = redisBaseAddr + "SPEC:Cache:XDL"; + + private const string redisOdlCurrByMac = redisXdlData + ":OdlByMac"; + private const string redisOdlList = redisXdlData + ":OdlList"; + + private const string redisPOdlByOdl = redisXdlData + ":POdlByOdl"; + private const string redisPOdlByPOdl = redisXdlData + ":POdlByPOdl"; + private const string redisPOdlList = redisXdlData + ":POdlList"; + private const string redisGiacenzaList = redisBaseAddr + ":GiacenzaList"; + private const string redisPOdlListNOOdl = redisXdlData + ":POdlListNOOdl"; private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom"; private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt"; diff --git a/MP.SPEC/Data/SelectOdlParams.cs b/MP.SPEC/Data/SelectOdlParams.cs deleted file mode 100644 index 522eba5b..00000000 --- a/MP.SPEC/Data/SelectOdlParams.cs +++ /dev/null @@ -1,77 +0,0 @@ -using MP.Data; - -namespace MP.SPEC.Data -{ - public class SelectOdlParams - { - #region Public Constructors - - public SelectOdlParams() - { } - - #endregion Public Constructors - - #region Public Properties - - public bool IsActive { get; set; } = true; - public string CodReparto { get; set; } = "*"; - public string CodStato { get; set; } = "*"; - public string IdxMacchina { get; set; } = "*"; - public int MaxRecord { get; set; } = 100; - public int NumRec { get; set; } = 10; - public DateTime DtStart { get; set; } = Utils.InitDatetime(DateTime.Now, 5).AddDays(-10); - public DateTime DtEnd { get; set; } = Utils.InitDatetime(DateTime.Now, 5); - public int CurrPage { get; set; } = 1; - public string SearchVal { get; set; } = "*"; - public int TotCount { get; set; } = 0; - - #endregion Public Properties - - #region Public Methods - - public override bool Equals(object obj) - { - if (!(obj is SelectOdlParams item)) - return false; - - if (IsActive != item.IsActive) - return false; - - if (CodReparto != item.CodReparto) - return false; - - if (CodStato != item.CodStato) - return false; - - if (IdxMacchina != item.IdxMacchina) - return false; - - if (MaxRecord != item.MaxRecord) - return false; - - if (NumRec != item.NumRec) - return false; - - if (DtStart != item.DtStart) - return false; - - if (DtEnd != item.DtEnd) - return false; - - if (CurrPage != item.CurrPage) - return false; - - if (SearchVal != item.SearchVal) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - #endregion Public Methods - } -} \ No newline at end of file diff --git a/MP.SPEC/Data/SelectPOdlParams.cs b/MP.SPEC/Data/SelectPOdlParams.cs deleted file mode 100644 index 82ae7daf..00000000 --- a/MP.SPEC/Data/SelectPOdlParams.cs +++ /dev/null @@ -1,92 +0,0 @@ -namespace MP.SPEC.Data -{ - public class SelectPOdlParams - { - #region Public Constructors - - public SelectPOdlParams() - { } - - #endregion Public Constructors - - #region Public Properties - - public string CodFase { get; set; } = "*"; - - public string CodReparto { get; set; } = "*"; - public int CurrPage { get; set; } = 1; - public bool hasOdl { get; set; } = false; - public string IdxMacchina { get; set; } = "*"; - - public int MaxRecord { get; set; } = 100; - - public int NumRec { get; set; } = 10; - - public string SearchVal { get; set; } = "*"; - - public int TotCount { get; set; } = 0; - - #endregion Public Properties - - #region Public Methods - - public SelectPOdlParams clone() - { - SelectPOdlParams clonedData = new SelectPOdlParams() - { - CodFase = this.CodFase, - CurrPage = this.CurrPage, - IdxMacchina = this.IdxMacchina, - CodReparto = this.CodReparto, - MaxRecord = this.MaxRecord, - NumRec = this.NumRec, - SearchVal = this.SearchVal, - TotCount = this.TotCount, - hasOdl = this.hasOdl - }; - return clonedData; - } - - public override bool Equals(object obj) - { - if (!(obj is SelectPOdlParams item)) - return false; - - if (CodFase != item.CodFase) - return false; - - if (CodReparto != item.CodReparto) - return false; - - if (MaxRecord != item.MaxRecord) - return false; - - if (NumRec != item.NumRec) - return false; - - if (TotCount != item.TotCount) - return false; - - if (CurrPage != item.CurrPage) - return false; - - if (IdxMacchina != item.IdxMacchina) - return false; - - if (SearchVal != item.SearchVal) - return false; - - if (hasOdl != item.hasOdl) - return false; - - return true; - } - - public override int GetHashCode() - { - return base.GetHashCode(); - } - - #endregion Public Methods - } -} \ No newline at end of file diff --git a/MP.SPEC/Data/SelectXdlParams.cs b/MP.SPEC/Data/SelectXdlParams.cs index e52e1b14..e91ae7c9 100644 --- a/MP.SPEC/Data/SelectXdlParams.cs +++ b/MP.SPEC/Data/SelectXdlParams.cs @@ -17,13 +17,14 @@ namespace MP.SPEC.Data public string CodReparto { get; set; } = "*"; public int CurrPage { get; set; } = 1; public DateTime DtEnd { get; set; } = Utils.InitDatetime(DateTime.Now, 5); - public DateTime DtStart { get; set; } = Utils.InitDatetime(DateTime.Now, 5).AddDays(-10); + public DateTime DtStart { get; set; } = Utils.InitDatetime(DateTime.Now, 5).AddMonths(-2); public bool HasOdl { get; set; } = false; public string IdxMacchina { get; set; } = "*"; public bool IsActive { get; set; } = true; public int MaxRecord { get; set; } = 100; public int NumRec { get; set; } = 10; public string SearchVal { get; set; } = "*"; + public string Header { get; set; } = ""; public int TotCount { get; set; } = 0; #endregion Public Properties @@ -45,6 +46,7 @@ namespace MP.SPEC.Data MaxRecord = this.MaxRecord, NumRec = this.NumRec, SearchVal = this.SearchVal, + Header = this.Header, TotCount = this.TotCount }; return clonedData; @@ -87,6 +89,8 @@ namespace MP.SPEC.Data if (SearchVal != item.SearchVal) return false; + if (Header != item.Header) + return false; if (TotCount != item.TotCount) return false; diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index ad52035d..0be92b1d 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2211.2519 + 6.16.2211.2916 @@ -28,6 +28,7 @@ + diff --git a/MP.SPEC/Pages/Giacenze.razor b/MP.SPEC/Pages/Giacenze.razor new file mode 100644 index 00000000..fc1fdae4 --- /dev/null +++ b/MP.SPEC/Pages/Giacenze.razor @@ -0,0 +1,21 @@ +@page "/Giacenze" + +
    +
    +

    Giacenze

    + @if (odlExp != null) + { + @odlExp.CodArticolo + } +
    +
    + +
    + +
    + + + + + diff --git a/MP.SPEC/Pages/Giacenze.razor.cs b/MP.SPEC/Pages/Giacenze.razor.cs new file mode 100644 index 00000000..a4ec97fb --- /dev/null +++ b/MP.SPEC/Pages/Giacenze.razor.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using MP.SPEC; +using MP.SPEC.Shared; +using MP.SPEC.Components; +using MP.Data.DatabaseModels; +using MP.SPEC.Data; +using Microsoft.AspNetCore.WebUtilities; +using Blazored.SessionStorage; + +namespace MP.SPEC.Pages +{ + public partial class Giacenze + { + [Inject] + MpDataService MDService { get; set; } = null!; + + [Inject] + ISessionStorageService sessionStorage { get; set; } = null!; + + [Inject] + NavigationManager NavManager { get; set; } = null!; + + protected List? elencoOdl; + + protected ODLModel? odlExp; + + protected int IdxOdl { get; set; } = 0; + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + var uri = NavManager.ToAbsoluteUri(NavManager.Uri); + if (QueryHelpers.ParseQuery(uri.Query).TryGetValue("IdxOdl", out var _idxOdl)) + { + IdxOdl = int.Parse(_idxOdl); + } + elencoOdl = MDService.ListOdlAll(); + odlExp = elencoOdl.Where(o => (o.IdxOdl == IdxOdl)).SingleOrDefault(); + } + + } +} \ No newline at end of file diff --git a/MP.SPEC/Pages/ODL.razor b/MP.SPEC/Pages/ODL.razor index 406a3ea0..e1a03bdb 100644 --- a/MP.SPEC/Pages/ODL.razor +++ b/MP.SPEC/Pages/ODL.razor @@ -8,7 +8,7 @@

    ODL

    -
    +
    Completati @@ -19,116 +19,35 @@
    -
    +
    - @if (filtActive) - { -
    - @**@ + @if (filtActive) + { +
    + @**@ + @if (selReparto != "*") + { + + } @if (selMacchina != "*") - { + { - } - @if (selStato != "*") - { + } + @if (selStato != "*") + { - } + } +
    + } + @selDtStart   + @selDtEnd   + - } - -
    - @*
    -
    -

    FILTRI

    - -
    -
    -
    -
    - Seleziona i filtri per: -
    -
    -
    - -
    - -
    -
    - - -
    -
    -
    - -
    - -
    -
    - - -
    -
    -
    - -
    - -
    -
    - - -
    -
    - @if (!isActive) - { -
    - -
    -
    - - -
    -
    - -
    -
    - - -
    - } -
    -
    *@
    diff --git a/MP.SPEC/Pages/ODL.razor.cs b/MP.SPEC/Pages/ODL.razor.cs index 929351a5..fb11ee4f 100644 --- a/MP.SPEC/Pages/ODL.razor.cs +++ b/MP.SPEC/Pages/ODL.razor.cs @@ -136,12 +136,17 @@ namespace MP.SPEC.Pages { selMacchina = "*"; } - + protected void resetReparto() + { + selReparto = "*"; + } protected void setDtMax() { - // copio il filtro - currFilter.DtEnd = RoundDatetime(5); - currFilter.DtStart = RoundDatetime(5).AddDays(-10); + if (currFilter.HasOdl == true) + { + currFilter.DtEnd = RoundDatetime(5); + currFilter.DtStart = RoundDatetime(5).AddDays(-10); + } } protected void UpdateTotCount(int newTotCount) @@ -170,7 +175,7 @@ namespace MP.SPEC.Pages private bool filtActive { - get => selMacchina != "*" || selStato != "*"; + get => selMacchina != "*" || selStato != "*" || selReparto != "*"; } private bool isLoading { get; set; } = false; diff --git a/MP.SPEC/Pages/PODL.razor b/MP.SPEC/Pages/PODL.razor index c9a05e53..7a9d707d 100644 --- a/MP.SPEC/Pages/PODL.razor +++ b/MP.SPEC/Pages/PODL.razor @@ -3,73 +3,65 @@
    -
    -
    -
    -
    -

    Promesse ODL

    -
    -
    -
    -
    - Da Produrre -
    - -
    - Lanciati -
    +
    +
    +

    Promesse ODL

    +
    +
    +
    +
    + Da Produrre +
    +
    - -
    -
    - @if (addEnabled) - { - - } + Lanciati
    + @if (addEnabled) + { + + }
    -
    -
    - @* - *@ - @* - *@ - @**@ - -
    +
    +
    -
    @if (currRecord != null) {
    -
    Modifica PODL
    +
    @header
    @@ -86,7 +78,7 @@