117 lines
3.1 KiB
C#
117 lines
3.1 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.Data.Services;
|
|
using NLog;
|
|
|
|
namespace MP_TAB3.Components
|
|
{
|
|
public partial class CmpFooter : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
if (aTimer != null)
|
|
{
|
|
aTimer.Elapsed -= ElapsedTimer;
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
}
|
|
|
|
public double CurrExpVal { get; set; } = 50;
|
|
public double MaxExpVal { get; set; } = 100;
|
|
public double yLimit { get; set; } = 30;
|
|
public double rLimit { get; set; } = 10;
|
|
|
|
public string timeUm
|
|
{
|
|
get
|
|
{
|
|
string answ = "m";
|
|
if (CurrExpVal > 60)
|
|
{
|
|
answ = "h";
|
|
}
|
|
else if (CurrExpVal > 1440)
|
|
{
|
|
answ = "gg";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
if (typeScadLogin > 0)
|
|
{
|
|
var diffOfTime = DateTime.Now.Subtract(MsgServ.dtLastAction);
|
|
CurrExpVal = MaxExpVal - diffOfTime.TotalMinutes;
|
|
|
|
}
|
|
await InvokeAsync(() => StateHasChanged());
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
|
|
public void StartTimer()
|
|
{
|
|
int tOutPeriod = 1000;
|
|
aTimer = new System.Timers.Timer(tOutPeriod);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
protected int dtScadLogin { get; set; } = 0;
|
|
|
|
[Inject]
|
|
protected MessageService MsgServ { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected NavigationManager NavMan { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected SharedMemService SMServ { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected int typeScadLogin { get; set; } = 0;
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await Task.Delay(1);
|
|
var rawVers = typeof(Program).Assembly.GetName().Version;
|
|
version = rawVers != null ? rawVers : new Version("0.0.0.0");
|
|
typeScadLogin = SMServ.GetConfInt("TAB_TypeScadLogin");
|
|
dtScadLogin = SMServ.GetConfInt("TAB_dtTimerScadLogin");
|
|
MaxExpVal = dtScadLogin;
|
|
yLimit = MaxExpVal * 0.3;
|
|
rLimit = MaxExpVal * 0.1;
|
|
StartTimer();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
private System.Timers.Timer aTimer = null!;
|
|
private Version version = null!;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private int dtTimerScadenzaLogin { get; set; } = 0;
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |