diff --git a/MP-TAB3/Components/MachSel.razor.cs b/MP-TAB3/Components/MachSel.razor.cs index f494da1e..32af8c0d 100644 --- a/MP-TAB3/Components/MachSel.razor.cs +++ b/MP-TAB3/Components/MachSel.razor.cs @@ -2,6 +2,7 @@ using global::Microsoft.AspNetCore.Components; using MP.Data.DbModels; using MP.Data.Services; using MP_TAB3.Shared; +using NLog; using System; using System.Reflection.Metadata; @@ -61,47 +62,56 @@ namespace MP_TAB3.Components return answ; } } + private static Logger Log = LogManager.GetCurrentClassLogger(); protected override async Task OnParametersSetAsync() { - // inizilamente riporto machcina corrente da MSE - if (RecMSE == null) + try { - IdxMaccSel = ""; - } - else - { - if (string.IsNullOrEmpty(idxMaccSel)) + // inizilamente riporto macchina corrente da MSE + if (RecMSE == null) { - // verifico se la macchina sia configurata tra le MSFD... - if (SMServ.DictMacchMulti.ContainsKey(RecMSE.IdxMacchina)) + IdxMaccSel = ""; + Log.Error("Impossibile selezionare: recMSE è nullo"); + } + else + { + if (string.IsNullOrEmpty(idxMaccSel)) { - isMulti = SMServ.DictMacchMulti[RecMSE.IdxMacchina] == 1; - } - if (isMulti) - { - - var listMulti = await TDataService.VMSFDGetAll(); - ListMacchine = listMulti - .Where(x => x.IdxMacchina.Contains($"{RecMSE.IdxMacchina}#")) - .ToDictionary(x => x.IdxMacchina, x => x.CodMaccArticolo); - - if (ListMacchine.Count > 0) + // verifico se la macchina sia configurata tra le MSFD... + if (SMServ.DictMacchMulti.ContainsKey(RecMSE.IdxMacchina)) { - // cerco se ho in storage la macchina selezionata... - var idxMSel = MsgServ.UserPrefGet(idxMaccCurr); - if (!string.IsNullOrEmpty(idxMSel)) + isMulti = SMServ.DictMacchMulti[RecMSE.IdxMacchina] == 1; + } + if (isMulti) + { + + var listMulti = await TDataService.VMSFDGetAll(); + ListMacchine = listMulti + .Where(x => x.IdxMacchina.Contains($"{RecMSE.IdxMacchina}#")) + .ToDictionary(x => x.IdxMacchina, x => x.CodMaccArticolo); + + if (ListMacchine.Count > 0) { - IdxMaccSel = idxMSel; - } - else - { - IdxMaccSel = ListMacchine.FirstOrDefault().Key; + // cerco se ho in storage la macchina selezionata... + var idxMSel = MsgServ.UserPrefGet(idxMaccCurr); + if (!string.IsNullOrEmpty(idxMSel)) + { + IdxMaccSel = idxMSel; + } + else + { + IdxMaccSel = ListMacchine.FirstOrDefault().Key; + } } } } } } + catch (Exception exc) + { + Log.Error($"Errore in MachSel.OnParametersSetAsync{Environment.NewLine}{exc}"); + } await Task.Delay(1); } diff --git a/MP-TAB3/Components/MachineBlock.razor b/MP-TAB3/Components/MachineBlock.razor index 8011134e..5044d5ae 100644 --- a/MP-TAB3/Components/MachineBlock.razor +++ b/MP-TAB3/Components/MachineBlock.razor @@ -160,14 +160,16 @@ else