using Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; using MP.Data.Services; using NLog; namespace MP_TAB3.Pages { public partial class MachineDetail { #region Protected Properties protected MappaStatoExpl? CurrMSE { get; set; } = null; protected string IdxMacc { get; set; } = ""; [Inject] protected MessageService MsgServ { get; set; } = null!; [Inject] protected SharedMemService MStor { get; set; } = null!; [Inject] protected TabDataService TabServ { get; set; } = null!; #endregion Protected Properties #region Protected Methods protected override async Task OnInitializedAsync() { await ReloadData(); if (enableSchedaTecnica) { checkLottiOdl(); } } protected async Task RefreshData(List newList) { var ListMSE = newList; if (!string.IsNullOrEmpty(IdxMacc)) { var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc); if (rawData != null) { CurrMSE = rawData; } else { await RefreshMBlock(); } } //await InvokeAsync(StateHasChanged); } protected async Task RefreshMBlock() { // recupero MSE macchina.... if (!string.IsNullOrEmpty(IdxMacc)) { CurrMSE = await MsgServ.GetMachineMse(IdxMacc); } } protected void SetMacc(string selIdxMacc) { IdxMaccSubSel = selIdxMacc; } #endregion Protected Methods #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); private bool enableMagLotti = false; private bool enableSchedaTecnica = false; private string IdxMaccSubSel = ""; #endregion Private Fields #region Private Methods private void checkLottiOdl() { #if false // controlla se abilitato check LOTTI MAG if (enableMagLotti) { if (idxOdl > 0) { // controlla se ci sia lotto x ODL if (DataLayerObj.taMagELotti.getByODL(idxOdl).Rows.Count == 0) { try { // se non c'� chiama stored x rigenerare DataLayerObj.taMagELotti.UpsertByOdl(idxOdl, true); } catch { } } } } #endif } private async Task ReloadData() { if (string.IsNullOrEmpty(IdxMacc)) { try { IdxMacc = await MsgServ.IdxMaccGet(); // recupero MSE macchina.... if (!string.IsNullOrEmpty(IdxMacc)) { CurrMSE = await MsgServ.GetMachineMse(IdxMacc); } } catch (Exception exc) { Log.Error($"Eccezione in ReloadData{Environment.NewLine}{exc}"); } } // recupero parametri configurazione... await setupConf(); } private async Task setupConf() { enableSchedaTecnica = MStor.GetConfBool("enableSchedaTecnica"); enableMagLotti = MStor.GetConfBool("enableMagLotti"); await Task.Delay(1); } #endregion Private Methods } }