Files
2025-06-28 09:24:16 +02:00

97 lines
3.3 KiB
C#

using Microsoft.AspNetCore.Components;
using MP.Land.Data;
using NLog;
using System;
using System.Net.NetworkInformation;
using System.Threading.Tasks;
namespace MP.Land.Pages
{
public partial class About
{
[Inject]
protected LMessageService AppMService { get; set; } = null!;
[Inject]
protected LicenseService LicServ{get;set;}=null!;
#region Protected Methods
protected override async Task OnInitializedAsync()
{
updatePageHead();
await reloadLicenseData();
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private string Applicazione = "App";
private string expDateCss = "bg-warning text-secondary";
private string Installazione = "Inst";
private string licenseCss = "bg-warning text-secondary";
private string Licenze = "#";
private string mainCss = "alert alert-info";
private string MastKey = "########################";
private string Messaggio = "";
private string remSrvCss = "bg-warning text-secondary";
private DateTime Scadenza = DateTime.Today;
private string ServerStatus = "SrvState";
private string Titolo = "";
#endregion Private Fields
#region Private Methods
private async Task reloadLicenseData()
{
int cDelay = 10;
// recupero dati
await Task.Delay(cDelay);
try
{
LicServ.InitAkv();
// verifico stati
ServerStatus = await LicServ.checkLimanServer();
Installazione = LicServ.Installazione;
Applicazione = LicServ.Applicazione;
MastKey = LicServ.MasterKey;
Scadenza = LicServ.getLicenseExpiry(LicServ.MasterKey);
await Task.Delay(cDelay);
var fatto = await LicServ.RefreshLicense();
await Task.Delay(cDelay);
Licenze = $"{LicServ.NumLicDb}/{LicServ.NumLicRemote}";
licenseCss = "";
}
catch (Exception exc)
{
licenseCss = "bg-dark text-warning";
Log.Error($"Eccezione in reloadLicenseData:{Environment.NewLine}{exc}");
}
bool okRemoteSrv = ServerStatus == "OK";
bool okScadenza = LicServ.checkLicenseActive(LicServ.MasterKey);
bool okNumLic = (LicServ.NumLicDb <= LicServ.NumLicRemote);
// aggiornamento css secondo status colore da check
mainCss = okNumLic ? "alert alert-success shadowBox" : "alert alert-warning shadowBox";
expDateCss = okScadenza ? "" : "bg-danger text-warning";
remSrvCss = okRemoteSrv ? "" : "bg-danger text-warning";
await Task.Delay(cDelay);
}
private void updatePageHead()
{
Titolo = "MES | SCADA | IOT";
Messaggio = "Soluzione integrata per la gestione della produzione";
AppMService.ShowSearch = false;
AppMService.PageName = "About";
AppMService.PageIcon = "fas fa-info-circle pe-2";
}
#endregion Private Methods
}
}