Files
mapo-core/MP-TAB3/Pages/ProdPlan.razor.cs
T
Samuele Locatelli c8bb1065c7 Fix naming (maybe)
2023-12-18 11:40:46 +01:00

72 lines
1.9 KiB
C#

using global::Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Data.Services;
using NLog;
namespace MP_TAB3.Pages
{
public partial class ProdPlan
{
#region Protected Properties
protected MappaStatoExpl? CurrMSE { get; set; } = null;
protected string IdxMacc { get; set; } = "";
[Inject]
protected MessageService MsgServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task RefreshData(List<MappaStatoExpl> newList)
{
var ListMSE = newList;
if (!string.IsNullOrEmpty(IdxMacc))
{
var rawData = ListMSE.Find(x => x.IdxMacchina == IdxMacc);
if (rawData != null)
{
CurrMSE = rawData;
}
else
{
await ReloadData();
}
}
await InvokeAsync(StateHasChanged);
}
#endregion Protected Methods
#region Private Methods
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private async Task ReloadData()
{
try
{
if (string.IsNullOrEmpty(IdxMacc))
{
IdxMacc = await MsgServ.IdxMaccGet();
// recupero MSE macchina....
if (!string.IsNullOrEmpty(IdxMacc))
{
CurrMSE = await MsgServ.GetMachineMse(IdxMacc);
}
}
}
catch (Exception exc)
{
Log.Error($"Eccerione in ReloadData{Environment.NewLine}{exc}");
}
}
#endregion Private Methods
}
}