82 lines
2.4 KiB
C#
82 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using MP.Mon;
|
|
using MP.Mon.Shared;
|
|
using MP.Mon.Components;
|
|
using MP.Data.DatabaseModels;
|
|
|
|
namespace MP.Mon.Components
|
|
{
|
|
public partial class DetailMSE
|
|
{
|
|
|
|
protected string baseCss = "";
|
|
|
|
[Parameter]
|
|
public bool doAnimate { get; set; } = true;
|
|
|
|
[Parameter]
|
|
public int keepAliveMin { get; set; } = 5;
|
|
[Parameter]
|
|
public MappaStatoExpl? CurrRecord { get; set; } = null;
|
|
|
|
private string cssStatus(string codSemaforo)
|
|
{
|
|
return $"{baseCss}{codSemaforo.Substring(1, 2)}";
|
|
}
|
|
|
|
private string cssComStatus(string semaforo, DateTime? lastUpdateN)
|
|
{
|
|
DateTime lastUpdate = lastUpdateN.HasValue ? (DateTime)lastUpdateN : DateTime.Now.AddHours(-1);
|
|
string answ = cssStatus(semaforo);
|
|
if (DateTime.Now.Subtract(lastUpdate).TotalSeconds > (keepAliveMin * 60 / 2))
|
|
{
|
|
answ = $"{baseCss}Ro";
|
|
}
|
|
return answ;
|
|
}
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
setupConf();
|
|
}
|
|
private void setupConf()
|
|
{
|
|
baseCss = doAnimate ? "semBlink" : "sem";
|
|
}
|
|
private bool showComErr(DateTime? lastUpdateN)
|
|
{
|
|
DateTime lastUpdate = lastUpdateN.HasValue ? (DateTime)lastUpdateN : DateTime.Now.AddHours(-1);
|
|
bool answ = false;
|
|
if (DateTime.Now.Subtract(lastUpdate).TotalSeconds > (keepAliveMin * 60 / 2))
|
|
{
|
|
answ = true;
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private string getMinSec(decimal? currTimeMin)
|
|
{
|
|
string answ = "nd";
|
|
TimeSpan tSpan = new TimeSpan(0);
|
|
try
|
|
{
|
|
tSpan = TimeSpan.FromMinutes((double)currTimeMin);
|
|
answ = tSpan.ToString("mm:ss");
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
} |