cbd4a90d01
- Correzione MSE i MSEModel x naming - fix e test vari su app CORE (IOC/SPEC/TAB3/MON)
132 lines
4.1 KiB
C#
132 lines
4.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Data.DbModels;
|
|
using MP.Data.Services;
|
|
using MP_TAB3.Shared;
|
|
|
|
namespace MP_TAB3.Components
|
|
{
|
|
public partial class CheckControls
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public MappaStatoExplModel? RecMSE { get; set; } = null;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Determina se dato lo stato dell'impianto si debba mostrare btn fermata perch�
|
|
/// - fermo > xx min (da web.config, es 20')
|
|
/// - impianto fermo (controllando idxStato: priorit� > 1)
|
|
/// </summary>
|
|
protected bool CheckShowInsFermata
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
int idxStato = 0;
|
|
double durata = 0;
|
|
int durMinWarning = SMServ.GetConfInt("durMinWarning");
|
|
if (RecMSE != null)
|
|
{
|
|
idxStato = RecMSE.IdxStato ?? 0;
|
|
durata = RecMSE.Durata ?? 0;
|
|
if (durata >= durMinWarning)
|
|
{
|
|
try
|
|
{
|
|
// in questo caso controllo idxStato... e recupero priorita se > 1 -->
|
|
// richiesta qualifica
|
|
answ = SMServ.GetStateRow(idxStato).Priorita > 1;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected MessageService MServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected NavigationManager NavMan { get; set; } = null!;
|
|
|
|
protected bool ShowInsFermata { get; set; } = false;
|
|
|
|
protected bool ShowReqControls { get; set; } = false;
|
|
|
|
[Inject]
|
|
protected SharedMemService SMServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected TabDataService TabDServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Verifica necessit� visualizzare il check controlli
|
|
/// </summary>
|
|
protected async Task<bool> CheckShowReqControls()
|
|
{
|
|
bool answ = false;
|
|
if (RecMSE != null)
|
|
{
|
|
// SE abilitata gestione controlli...
|
|
bool enableCtrl = SMServ.GetConfBool("enableControlli");
|
|
if (enableCtrl)
|
|
{
|
|
int intervalloControlli = SMServ.GetConfInt("intervalloControlli");
|
|
// cerco ultimo controllo fatto
|
|
DateTime lastControl = DateTime.Now.AddYears(-1);
|
|
try
|
|
{
|
|
var tabCtrls = await TabDServ.RegControlliLast(RecMSE.IdxMacchina);
|
|
if (tabCtrls != null && tabCtrls.Count > 0)
|
|
{
|
|
var thisRec = tabCtrls.FirstOrDefault();
|
|
if (thisRec != null)
|
|
{
|
|
lastControl = thisRec.DataOra;
|
|
if (Math.Abs(DateTime.Now.Subtract(lastControl).TotalMinutes) >= intervalloControlli)
|
|
{
|
|
answ = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
protected void GoToControls()
|
|
{
|
|
NavMan.NavigateTo("controls");
|
|
}
|
|
|
|
protected void GoToFermate()
|
|
{
|
|
NavMan.NavigateTo("prod-stop");
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
if (RecMSE != null)
|
|
{
|
|
ShowInsFermata = CheckShowInsFermata;
|
|
ShowReqControls = await CheckShowReqControls();
|
|
MServ.LastIdxMacchina = RecMSE.IdxMacchina;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |