diff --git a/MP-TAB-SERV/Components/MachineBlock.razor.cs b/MP-TAB-SERV/Components/MachineBlock.razor.cs index 493cf73a..3d673874 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor.cs +++ b/MP-TAB-SERV/Components/MachineBlock.razor.cs @@ -160,9 +160,11 @@ namespace MP_TAB_SERV.Components imgBasePath = $"{Environment.CurrentDirectory}/images/"; } - + } + [Inject] + protected StatusData SDService { get; set; } = null!; /// /// Dati produzioen rilevati @@ -175,7 +177,16 @@ namespace MP_TAB_SERV.Components // controllo SE avessi idxMacchSub --> rileggo! if (RecMSE != null) { - datiProdAct = await TabDServ.StatoProdMacchina(RecMSE.IdxMacchina, adesso); + if (SDService.MachNumPzGet(RecMSE.IdxMacchina) != RecMSE.NumPezzi) + { + datiProdAct = await TabDServ.StatoProdMacchina(RecMSE.IdxMacchina, adesso); + SDService.MachProdStSet(RecMSE.IdxMacchina, datiProdAct); + SDService.MachNumPzSet(RecMSE.IdxMacchina, RecMSE.NumPezzi); + } + else + { + datiProdAct = SDService.MachProdStGet(RecMSE.IdxMacchina); + } } if (!string.IsNullOrEmpty(IdxMacchSub) && RecMSE != null) { diff --git a/MP-TAB-SERV/Components/MseSampler.razor.cs b/MP-TAB-SERV/Components/MseSampler.razor.cs index 085d46e3..788802a9 100644 --- a/MP-TAB-SERV/Components/MseSampler.razor.cs +++ b/MP-TAB-SERV/Components/MseSampler.razor.cs @@ -57,7 +57,7 @@ namespace MP_TAB_SERV.Components } [Inject] - protected StatusData MDataService { get; set; } = null!; + protected StatusData SDService { get; set; } = null!; [Inject] protected MessageService MServ { get; set; } = null!; @@ -113,7 +113,7 @@ namespace MP_TAB_SERV.Components private async Task RefreshData() { - List ListMSE = await MDataService.MseGetAll(); + List ListMSE = await SDService.MseGetAll(); await MServ.SaveMse(ListMSE); await E_Updated.InvokeAsync(ListMSE); } diff --git a/MP.Data/Services/StatusData.cs b/MP.Data/Services/StatusData.cs index 3c1782c9..caed4352 100644 --- a/MP.Data/Services/StatusData.cs +++ b/MP.Data/Services/StatusData.cs @@ -143,6 +143,79 @@ namespace MP.Data.Services return result; } + /// + /// Restituisce numPezzi (ultimo) x macchina + /// + /// + /// + public int MachNumPzGet(string idxMacchina) + { + int answ = 0; + if (MachineNumPz.ContainsKey(idxMacchina)) + { + answ = MachineNumPz[idxMacchina]; + } + return answ; + } + /// + /// Salva numPezzi x macchina + /// + /// + /// + /// + public bool MachNumPzSet(string idxMacchina, int numPz) + { + bool answ = false; + if (MachineNumPz.ContainsKey(idxMacchina)) + { + MachineNumPz[idxMacchina] = numPz; + } + else + { + MachineNumPz.Add(idxMacchina, numPz); + } + answ = true; + return answ; + } + + /// + /// Restituisce numPezzi (ultimo) x macchina + /// + /// + /// + public StatoProdModel MachProdStGet(string idxMacchina) + { + StatoProdModel answ = new StatoProdModel(); + if (MachineProdStatus.ContainsKey(idxMacchina)) + { + answ = MachineProdStatus[idxMacchina]; + } + return answ; + } + /// + /// Salva numPezzi x macchina + /// + /// + /// + /// + public bool MachProdStSet(string idxMacchina, StatoProdModel currStatus) + { + bool answ = false; + if (MachineProdStatus.ContainsKey(idxMacchina)) + { + MachineProdStatus[idxMacchina] = currStatus; + } + else + { + MachineProdStatus.Add(idxMacchina, currStatus); + } + answ = true; + return answ; + } + + private Dictionary MachineNumPz { get; set; } = new Dictionary(); + private Dictionary MachineProdStatus { get; set; } = new Dictionary(); + #endregion Public Methods #region Protected Fields