Files
mapo-core/MP-TAB-SERV/Components/MachSel.razor.cs
T
2023-10-05 19:38:01 +02:00

84 lines
2.4 KiB
C#

using global::Microsoft.AspNetCore.Components;
using MP.Data.DatabaseModels;
using MP.Data.Services;
using System;
using System.Reflection.Metadata;
namespace MP_TAB_SERV.Components
{
public partial class MachSel
{
#region Public Properties
[Parameter]
public EventCallback<string> E_MachSel { get; set; }
[Parameter]
public MappaStatoExpl? RecMSE { get; set; } = null;
#endregion Public Properties
#region Protected Properties
protected string IdxMaccSel
{
get => idxMaccSel;
set
{
if (idxMaccSel != value)
{
idxMaccSel = value;
E_MachSel.InvokeAsync(value).ConfigureAwait(false);
}
}
}
private string idxMaccSel { get; set; } = "";
protected Dictionary<string, string>? ListMacchine { get; set; } = null;
[Inject]
protected SharedMemService MServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
// inizilamente riporto machcina corrente da MSE
if (RecMSE != null)
{
// verifico se la macchina sia configurata tra le MSFD...
if (MServ.DictMacchMulti.ContainsKey(RecMSE?.IdxMacchina))
{
isMulti = MServ.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.IdxMacchina.Replace($"{RecMSE?.IdxMacchina}#", "")}");
if (ListMacchine.Count > 0 && string.IsNullOrEmpty(idxMaccSel))
{
IdxMaccSel = ListMacchine.FirstOrDefault().Key;
//await E_MachSel.InvokeAsync(idxMaccSel);
}
}
}
await Task.Delay(1);
}
[Inject]
protected TabDataService TDataService { get; set; } = null!;
#endregion Protected Methods
#region Private Fields
private bool isMulti = false;
#endregion Private Fields
}
}