4fda312aac
- altri metodi tracciati - modifica json x prod - aggiunta Async vari
91 lines
2.2 KiB
C#
91 lines
2.2 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.Extensions.Configuration;
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace GWMS.UI.Components
|
|
{
|
|
public partial class CmpFooter : IDisposable
|
|
{
|
|
#region Public Methods
|
|
|
|
public void Dispose()
|
|
{
|
|
if (aTimer != null)
|
|
{
|
|
aTimer.Elapsed -= ElapsedTimer;
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
}
|
|
|
|
public void ElapsedTimer(Object source, System.Timers.ElapsedEventArgs e)
|
|
{
|
|
var pUpd = Task.Run(async () =>
|
|
{
|
|
adesso = DateTime.Now;
|
|
await InvokeAsync(StateHasChanged);
|
|
});
|
|
pUpd.Wait();
|
|
}
|
|
|
|
public void StartTimer()
|
|
{
|
|
if (aTimer != null)
|
|
{
|
|
aTimer.Stop();
|
|
aTimer.Dispose();
|
|
}
|
|
int tOutPeriod = 1000;
|
|
aTimer = new System.Timers.Timer(tOutPeriod);
|
|
aTimer.Elapsed += ElapsedTimer;
|
|
aTimer.Enabled = true;
|
|
aTimer.Start();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Fields
|
|
|
|
protected DateTime adesso = DateTime.Now;
|
|
|
|
private string nodeId = Environment.MachineName;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
var rawVers = typeof(Program).Assembly.GetName().Version;
|
|
version = rawVers != null ? rawVers : new Version("0.0.0.0");
|
|
nodeId = Environment.MachineName;
|
|
#if DEBUG
|
|
// nome completo...
|
|
#else
|
|
//Se non fosse develop --> prende gli ultimi 2 caratteri(es. "01")
|
|
if (nodeId.Length > 2)
|
|
{
|
|
nodeId = nodeId.Substring(nodeId.Length - 2);
|
|
}
|
|
#endif
|
|
StartTimer();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private System.Timers.Timer aTimer = null!;
|
|
private Version? version = null!;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IConfiguration Configuration { get; set; }
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |