125 lines
3.8 KiB
C#
125 lines
3.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using MP.Core.DTO;
|
|
using MP.Data;
|
|
using MP.Data.DbModels;
|
|
using MP.Data.Services;
|
|
using MP.SPEC.Components.Reparti;
|
|
using MP.SPEC.Data;
|
|
using NLog.LayoutRenderers;
|
|
using static MP.Core.Objects.Enums;
|
|
using static MP.Data.Services.ExecStatsCollector;
|
|
|
|
namespace MP.SPEC.Pages
|
|
{
|
|
public partial class RepStop
|
|
{
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected SharedMemService SMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected TabDataService TabDServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<string> CurrMachSel = new List<string>();
|
|
|
|
private List<MappaStatoExplModel> CurrMSE = new();
|
|
|
|
private bool isLoading = false;
|
|
|
|
private List<vSelEventiBCodeModel> SearchFermate = new();
|
|
|
|
private bool showFermate = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private void CheckSelection(List<string> listSelezione)
|
|
{
|
|
CurrMachSel = listSelezione;
|
|
// se c'è selezione mostro elenco fermate...
|
|
showFermate = listSelezione.Count > 0;
|
|
}
|
|
|
|
private async Task DoReload(bool forceReload)
|
|
{
|
|
CurrMSE = await MDService.MseGetAll(true);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Gestione selezione evento da registrare x le macchine selezionate
|
|
/// </summary>
|
|
/// <param name="selEv"></param>
|
|
/// <returns></returns>
|
|
private async Task EventRecord(SelEventDTO selEv)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Hai {CurrMachSel.Count} impianti selezionati.{Environment.NewLine}Confermi di voler registrare l'evento {selEv.Descript}?"))
|
|
return;
|
|
|
|
isLoading = true;
|
|
await InvokeAsync(StateHasChanged);
|
|
|
|
// recupero evento
|
|
var rigaEvento = SMServ.GetEventRow(selEv.IdxEv);
|
|
if (rigaEvento != null)
|
|
{
|
|
// se conferma ciclo x ogni macchina e registro
|
|
foreach (var idxMacc in CurrMachSel)
|
|
{
|
|
var rigaStato = MDService.StatoMacchina(idxMacc);
|
|
// processo evento...
|
|
|
|
DateTime adesso = DateTime.Now.Floor(TimeSpan.FromSeconds(1));
|
|
EventListModel newRec = new EventListModel()
|
|
{
|
|
IdxMacchina = idxMacc,
|
|
InizioStato = adesso,
|
|
IdxTipo = selEv.IdxEv,
|
|
CodArticolo = rigaStato.CodArticolo,
|
|
Value = "DRT",
|
|
MatrOpr = 1, // rivedere!!!
|
|
pallet = rigaStato.pallet
|
|
};
|
|
// FORZO con metodo TAB
|
|
await TabDServ.EvListInsert(newRec, tipoInputEvento.barcode);
|
|
// resetta il microstato in modo da ricevere successive info HW
|
|
await TabDServ.resetMicrostatoMacchina(idxMacc);
|
|
}
|
|
|
|
var ListMSE = await MDService.MseGetAll(true);
|
|
await Task.Delay(250);
|
|
await ReloadData();
|
|
isLoading = false;
|
|
}
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
CurrMSE = await MDService.MseGetAll(false);
|
|
SearchFermate = MDService.AnagEventiGeneral();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |