diff --git a/MP-TAB3/Components/CmpTop.razor.cs b/MP-TAB3/Components/CmpTop.razor.cs index 384c5dc8..b1291083 100644 --- a/MP-TAB3/Components/CmpTop.razor.cs +++ b/MP-TAB3/Components/CmpTop.razor.cs @@ -93,6 +93,7 @@ namespace MP_TAB3.Components await MsgServ.ClearLocalStor(); await MsgServ.ClearSessionStor(); await MDataService.FlushCache(); + await TDService.FlushCache(); // salvo di nuovo opr + GUID await MsgServ.SetCurrDevGuidLSAsync(devGuid); await MsgServ.SetLastMatrOprAsync(lastOpr); diff --git a/MP-TAB3/MP-TAB3.csproj b/MP-TAB3/MP-TAB3.csproj index 316e2f39..f496340b 100644 --- a/MP-TAB3/MP-TAB3.csproj +++ b/MP-TAB3/MP-TAB3.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2404.3016 + 6.16.2405.810 enable MP_TAB3 diff --git a/MP-TAB3/Pages/StatusMap.razor.cs b/MP-TAB3/Pages/StatusMap.razor.cs index 9085e713..7941bad5 100644 --- a/MP-TAB3/Pages/StatusMap.razor.cs +++ b/MP-TAB3/Pages/StatusMap.razor.cs @@ -118,13 +118,34 @@ namespace MP_TAB3.Pages Width = dimension.Width; } + /// + /// Verifica se la macchina sia abilitata per l'operatore + /// + /// + /// + protected bool MachineIsOprEnab(string idxMacc) + { + bool answ = false; + if (ListMachineEnabled != null && !string.IsNullOrEmpty(idxMacc)) + { + var macRec = ListMachineEnabled + .Where(x => x.IdxMacchina == idxMacc) + .FirstOrDefault(); + answ = macRec != null && macRec.IdxMacchina == idxMacc; + } + return answ; + } + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { await getWDim(); isCalcSize = false; - ListMSE = await MDataService.MseGetAll(true); + + //ListMSE = await MDataService.MseGetAll(true); + AllDataMSE = await MDataService.MseGetAll(true); + FiltOprMse(); await InvokeAsync(StateHasChanged); } if (ListMSE != null) @@ -136,6 +157,7 @@ namespace MP_TAB3.Pages protected override async Task OnInitializedAsync() { + // ora resetto il resto ListMSE = null; setDefaults(); TDFeeder.dataPipe.EA_NewMessage += DataPipe_EA_NewMessage; @@ -155,9 +177,21 @@ namespace MP_TAB3.Pages } } - protected void SaveData(List newList) + protected override async Task OnParametersSetAsync() { - ListMSE = newList; + // x prima cosa elenco macchine operatore... + ListMachineEnabled = await TabDServ.MacchineByMatrOper(MatrOpr); + } + + protected async Task SaveData(List newList) + { + // rileggo elenco macchine operatore... + ListMachineEnabled = await TabDServ.MacchineByMatrOper(MatrOpr); + // salvo valori ricevuti + //ListMSE = newList; + AllDataMSE = newList; + // filtro! + FiltOprMse(); } #endregion Protected Methods @@ -165,16 +199,26 @@ namespace MP_TAB3.Pages #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); + private bool doBlink = false; #endregion Private Fields #region Private Properties + private List? AllDataMSE { get; set; } = null; + private string baseLang { get; set; } = ""; + private List? ListMachineEnabled { get; set; } = null; + private List? ListMSE { get; set; } = null; + private int MatrOpr + { + get => MsgServ.MatrOpr; + } + private string tcMode { get; set; } = ""; #endregion Private Properties @@ -238,6 +282,25 @@ namespace MP_TAB3.Pages }); } + /// + /// Filtro dati operatore tra macchine visualizzabili e elenco MSE ricevuto + /// + /// + private void FiltOprMse() + { + ListMSE = new List(); + if (AllDataMSE != null) + { + foreach (var item in AllDataMSE) + { + if (MachineIsOprEnab(item.IdxMacchina)) + { + ListMSE.Add(item); + } + } + } + } + private void setDefaults() { string df = MsgServ.UserPrefSetup("DefCardMode", "full"); diff --git a/MP-TAB3/Resources/ChangeLog.html b/MP-TAB3/Resources/ChangeLog.html index e18988bd..38048261 100644 --- a/MP-TAB3/Resources/ChangeLog.html +++ b/MP-TAB3/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2404.3016

+

Versione: 6.16.2405.810


Note di rilascio:
  • diff --git a/MP-TAB3/Resources/VersNum.txt b/MP-TAB3/Resources/VersNum.txt index 2ac7ed17..04599c20 100644 --- a/MP-TAB3/Resources/VersNum.txt +++ b/MP-TAB3/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2404.3016 +6.16.2405.810 diff --git a/MP-TAB3/Resources/manifest.xml b/MP-TAB3/Resources/manifest.xml index 4a60f6b5..ef21272e 100644 --- a/MP-TAB3/Resources/manifest.xml +++ b/MP-TAB3/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2404.3016 + 6.16.2405.810 https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html false diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 6651eb16..724fc4fa 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -711,6 +711,56 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco Macchine dato operatore secondo gruppi (macchine/operatore) + /// + /// + /// + public List MacchineByMatrOper(int MatrOpr) + { + List dbResult = new List(); + try + { + using (var dbCtx = new MoonProContext(_configuration)) + { + if (MatrOpr == 0) + { + dbResult = dbCtx + .DbSetMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + else + { + dbResult = dbCtx + .DbSetGrp2Oper + .Where(g => g.MatrOpr == MatrOpr) + .Join(dbCtx.DbSetGrp2Macc, + g => g.CodGruppo, + m => m.CodGruppo, + (g, m) => m + ) + .Distinct() + .Join(dbCtx.DbSetMacchine, + g => g.IdxMacchina, + m => m.IdxMacchina, + (g, m) => m + ) + .Distinct() + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToList(); + } + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in MacchineByMatrOper{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// MicroStato macchina (da key) /// @@ -1625,30 +1675,6 @@ namespace MP.Data.Controllers } return answ; } - /// - /// Aggiorna un record scarti KIT ( SE ESISTE...) - /// - /// - /// - public bool RegScartiKitUpdateQty(RegistroScartiKitModel currRec) - { - bool answ = false; - using (var dbCtx = new MoonProContext(_configuration)) - { - var IdxMacc = new SqlParameter("@IdxMacchina", currRec.IdxMacchina); - var DtRif = new SqlParameter("@DataOra", currRec.DataOra); - var Causale = new SqlParameter("@Causale", currRec.Causale); - var CodArticolo = new SqlParameter("@CodArticolo", currRec.CodArticolo); - var Qty = new SqlParameter("@Qty", currRec.Qta); - - var dbResult = dbCtx - .Database - .ExecuteSqlRaw("EXEC stp_RSK_UpdateQty @IdxMacchina, @DataOra, @Causale, @CodArticolo, @Qty", IdxMacc, DtRif, Causale, CodArticolo, Qty); - - answ = dbResult != 0; - } - return answ; - } /// /// Elenco scarti KIT dato record parent @@ -1701,6 +1727,31 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Aggiorna un record scarti KIT ( SE ESISTE...) + /// + /// + /// + public bool RegScartiKitUpdateQty(RegistroScartiKitModel currRec) + { + bool answ = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", currRec.IdxMacchina); + var DtRif = new SqlParameter("@DataOra", currRec.DataOra); + var Causale = new SqlParameter("@Causale", currRec.Causale); + var CodArticolo = new SqlParameter("@CodArticolo", currRec.CodArticolo); + var Qty = new SqlParameter("@Qty", currRec.Qta); + + var dbResult = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_RSK_UpdateQty @IdxMacchina, @DataOra, @Causale, @CodArticolo, @Qty", IdxMacc, DtRif, Causale, CodArticolo, Qty); + + answ = dbResult != 0; + } + return answ; + } + /// /// Effettua ricalcolo MSE x macchina indicata /// diff --git a/MP.Data/Services/TabDataFeeder.cs b/MP.Data/Services/TabDataFeeder.cs index 3a06692a..417b2d59 100644 --- a/MP.Data/Services/TabDataFeeder.cs +++ b/MP.Data/Services/TabDataFeeder.cs @@ -13,7 +13,6 @@ namespace MP.Data.Services public TabDataFeeder(IConfiguration configuration) : base(configuration) { - // setup canali pub/sub dataPipe = new MessagePipe(redisConn, Constants.TAB_ACT_MSE_DATA_KEY, false); blinkPipe = new MessagePipe(redisConn, Constants.TAB_ACT_BLINK_KEY, false); @@ -77,10 +76,8 @@ namespace MP.Data.Services private static Logger Log = LogManager.GetCurrentClassLogger(); - private int fastRefreshMs = 1000; - #endregion Private Fields #region Private Methods diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index fa2e878d..8b59a2bf 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -22,25 +22,6 @@ namespace MP.Data.Services { public class TabDataService : BaseServ, IDisposable { - /// - /// Evento richiesta rilettura dati pagina (x refresh pagine aperte) - /// - public event EventHandler ReloadRequest = delegate { }; - - /// - /// Invio notifica rilettura (con parametro) - /// - /// - public void NotifyReloadRequest(string message) - { - if (ReloadRequest != null) - { - // messaggio - ReloadEventArgs rea = new ReloadEventArgs(message); - ReloadRequest.Invoke(this, rea); - } - } - #region Public Constructors /// @@ -95,6 +76,15 @@ namespace MP.Data.Services #endregion Public Constructors + #region Public Events + + /// + /// Evento richiesta rilettura dati pagina (x refresh pagine aperte) + /// + public event EventHandler ReloadRequest = delegate { }; + + #endregion Public Events + #region Public Properties /// @@ -877,7 +867,21 @@ namespace MP.Data.Services await FlushCache("PODL"); await FlushCache("VSODL"); await FlushCache("StatoMacc"); - await FlushCache("MSFD"); + await FlushCache("MSFD"); + } + + public TimeSpan GetKeyTTL(string redKey) + { + TimeSpan answ = TimeSpan.FromMinutes(-1); + try + { + answ = redisDb.KeyTimeToLive(redKey) ?? new TimeSpan(); + } + catch (Exception exc) + { + Log.Info($"Errore GetKeyTTL | currKey: {redKey}{Environment.NewLine}{exc}"); + } + return answ; } /// @@ -1035,6 +1039,43 @@ namespace MP.Data.Services return result; } + /// + /// Elenco Macchine dato operatore secondo gruppi (macchine/operatore) + /// + /// + /// + public async Task> MacchineByMatrOper(int MatrOpr) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:MachByMatOp:{MatrOpr}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + //if (!string.IsNullOrEmpty($"{rawData}")) + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.MacchineByMatrOper(MatrOpr); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"MacchineByMatrOper | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Lista parametri correnti (ObjItemDTO) della macchina /// @@ -1221,6 +1262,20 @@ namespace MP.Data.Services return result; } + /// + /// Invio notifica rilettura (con parametro) + /// + /// + public void NotifyReloadRequest(string message) + { + if (ReloadRequest != null) + { + // messaggio + ReloadEventArgs rea = new ReloadEventArgs(message); + ReloadRequest.Invoke(this, rea); + } + } + /// /// ODL da key /// @@ -1649,21 +1704,6 @@ namespace MP.Data.Services return answ; } - public TimeSpan GetKeyTTL(string redKey) - { - TimeSpan answ = TimeSpan.FromMinutes(-1); - try - { - answ = redisDb.KeyTimeToLive(redKey) ?? new TimeSpan(); - } - catch (Exception exc) - { - Log.Info($"Errore GetKeyTTL | currKey: {redKey}{Environment.NewLine}{exc}"); - } - return answ; - } - - /// /// Legge l'oggetto operatore+device loggato e restituisce la sua TTL /// @@ -3223,16 +3263,11 @@ namespace MP.Data.Services private string CodModulo = ""; private string CodModuloParam = ""; - private string MpIoNS = ""; - private string ConnStr = ""; - private Dictionary connStrParams = new Dictionary(); - private string DataBase = ""; - private string DataSource = ""; - + private string MpIoNS = ""; private string redisBaseKey = "MP:TAB:Cache"; private string redisUserDataKey = "MP:TAB:Users"; @@ -3324,20 +3359,6 @@ namespace MP.Data.Services return result; } - private string redHashParam(string keyName) - { - string result = keyName; - try - { - result = $"{CodModuloParam}:{DataSource}:{DataBase}:{keyName}".Replace("\\", "_"); - } - catch (Exception exc) - { - Log.Error($"Errore in redHashParam{Environment.NewLine}{exc}"); - } - - return result; - } private string redHashMpIO(string keyName) { @@ -3354,7 +3375,20 @@ namespace MP.Data.Services return result; } + private string redHashParam(string keyName) + { + string result = keyName; + try + { + result = $"{CodModuloParam}:{DataSource}:{DataBase}:{keyName}".Replace("\\", "_"); + } + catch (Exception exc) + { + Log.Error($"Errore in redHashParam{Environment.NewLine}{exc}"); + } + return result; + } /// /// Recupero HashSet redis come Dictionary @@ -3469,5 +3503,4 @@ namespace MP.Data.Services #endregion Private Methods } - } \ No newline at end of file