diff --git a/MP.Land/Data/LicenseService.cs b/MP.Land/Data/LicenseService.cs index f802a34b..56da8707 100644 --- a/MP.Land/Data/LicenseService.cs +++ b/MP.Land/Data/LicenseService.cs @@ -120,10 +120,26 @@ namespace MP.Land.Data public DateTime infoExpiry { get; set; } = DateTime.Today.AddDays(1); + /// + /// Codice cliente/installazione + /// public string Installazione { get; set; } = ""; + /// + /// Master key licenza principale + /// public string MasterKey { get; set; } = ""; + /// + /// Numero licenze da DB + /// + public int NumLicDb { get; set; } = -1; + + /// + /// Numero licenze da auth remota + /// + public int NumLicRemote { get; set; } = -1; + public bool ValidData { get @@ -184,6 +200,25 @@ namespace MP.Land.Data #region Protected Methods + /// + /// Cerca di recuperare valore INT da elenco AKV + /// + /// Chiave AKV richiesta + /// + protected int getAVKInt(string varReq) + { + int answ = -9999; + if (AKVList != null && AKVList.Count > 0) + { + var currRec = AKVList.Where(x => x.NomeVar == varReq).FirstOrDefault(); + if (currRec != null) + { + answ = currRec.ValInt ?? 0; + } + } + return answ; + } + /// /// Cerca di recuperare valore string da elenco AKV /// @@ -285,6 +320,54 @@ namespace MP.Land.Data return await Task.FromResult(dbResult); } + /// + /// Verifica attivazione licenza + /// + /// + /// + public bool checkLicenseActive(string authKey) + { + bool answ = false; + //cerco anche nelle info AKV + if (AKVList != null) + { + var recLic = AKVList.Where(x => x.ValString == authKey).FirstOrDefault(); + int numLic = 0; + //cerco in record + if (recLic != null) + { + numLic = (int)recLic.ValInt; + // verifico scadenza licenza! + DateTime scadenza = licenseManGLS.expiryDateByAuthKey(Installazione, recLic.NomeVar, numLic, authKey); + answ = scadenza > DateTime.Today; + } + else + { + _logger.LogInformation($"Record non trovato per {authKey}"); + } + } + return answ; + } + + /// + /// Stato server gestione licenze + /// + public async Task checkLimanServer() + { + string answ = "ND"; + // cerco online + RestClient client = new RestClient(apiUrl); + var request = new RestRequest($"/api/health", Method.Get); + var response = await client.GetAsync(request); + // controllo risposta + if (response.StatusCode == System.Net.HttpStatusCode.OK) + { + // verifico risposta + answ = response.Content.Replace("\"", ""); + } + return await Task.FromResult(answ); + } + /// /// Init della classe con variabili di base da Redis/DB /// @@ -294,6 +377,7 @@ namespace MP.Land.Data Applicazione = "MAPO"; Installazione = getAVKStr("Installazione"); MasterKey = getAVKStr(Applicazione); + NumLicDb = getAVKInt(Applicazione); fatto = !string.IsNullOrEmpty($"{Installazione}{MasterKey}"); return fatto; } @@ -334,35 +418,6 @@ namespace MP.Land.Data return fatto; } - /// - /// Verifica attivazione licenza - /// - /// - /// - public bool checkLicenseActive(string authKey) - { - bool answ = false; - //cerco anche nelle info AKV - if (AKVList != null) - { - var recLic = AKVList.Where(x => x.ValString == authKey).FirstOrDefault(); - int numLic = 0; - //cerco in record - if (recLic != null) - { - numLic = (int)recLic.ValInt; - // verifico scadenza licenza! - DateTime scadenza = licenseManGLS.expiryDateByAuthKey(Installazione, recLic.NomeVar, numLic, authKey); - answ = scadenza > DateTime.Today; - } - else - { - _logger.LogInformation($"Record non trovato per {authKey}"); - } - } - return answ; - } - #endregion Public Methods } -} +} \ No newline at end of file diff --git a/MP.Land/MP.Land.csproj b/MP.Land/MP.Land.csproj index 880365c6..1723f2d9 100644 --- a/MP.Land/MP.Land.csproj +++ b/MP.Land/MP.Land.csproj @@ -3,7 +3,7 @@ net6.0 MP.Land - 6.15.2204.1216 + 6.15.2204.2309 diff --git a/MP.Land/Pages/About.razor b/MP.Land/Pages/About.razor index 893dd040..bb0f5664 100644 --- a/MP.Land/Pages/About.razor +++ b/MP.Land/Pages/About.razor @@ -2,6 +2,7 @@ @using MP.Land.Data @inject MessageService AppMService +@inject LicenseService LicServ @@ -28,28 +29,71 @@ - + @Messaggio + MoonPro / MAPO sono una suite di applicazioni e dispositivi hw dedicati per l'IOT,l'industry 4.0 e la gestione automatizzata dei processi produttivi. + Per maggiori informazioni visita il link sul nostro sito. + + + Info installazione + + + + Remote Server: + + + @ServerStatus + + + + + Cliente: + + + @Installazione + + + + + App: + + + @Applicazione + + + + + Licenze: + + + @Licenze + + + + + Scadenza: + + + @($"{Scadenza:yyyy/MM/dd}") + + + + + Key + + + @MastKey + + + + -@code { - protected string Titolo = ""; - protected string Messaggio = ""; - - protected override void OnInitialized() - { - Titolo = "MES | SCADA | IOT"; - Messaggio = "Soluzione integrata per la gestione della produzione"; - AppMService.ShowSearch = false; - AppMService.PageName = "About"; - AppMService.PageIcon = "fas fa-info-circle pr-2"; - } -} \ No newline at end of file diff --git a/MP.Land/Pages/About.razor.cs b/MP.Land/Pages/About.razor.cs new file mode 100644 index 00000000..e4168f46 --- /dev/null +++ b/MP.Land/Pages/About.razor.cs @@ -0,0 +1,72 @@ +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.Land; +using MP.Land.Shared; +using MP.Land.Data; + +namespace MP.Land.Pages +{ + public partial class About + { + protected string Titolo = ""; + protected string Messaggio = ""; + + protected string ServerStatus = "SrvState"; + protected string Installazione = "Inst"; + protected string Applicazione = "App"; + protected string Licenze = "#"; + protected DateTime Scadenza = DateTime.Today; + protected string MastKey = "########################"; + + protected string mainCss = "alert alert-info"; + protected string remSrvCss = "bg-danger text-warning"; + protected string expDateCss = "bg-danger text-warning"; + + protected override async Task OnInitializedAsync() + { + updatePageHead(); + + await reloadLicenseData(); + } + + private async Task reloadLicenseData() + { + // recupero dati + LicServ.InitAkv(); + Installazione = LicServ.Installazione; + Applicazione = LicServ.Applicazione; + Licenze=$"{LicServ.NumLicDb}/??"; + MastKey = LicServ.MasterKey; + // verifico stati + ServerStatus = await LicServ.checkLimanServer(); + bool okRemoteSrv = ServerStatus == "OK"; + bool okScadenza = LicServ.checkLicenseActive(LicServ.MasterKey); + bool okNumLic = true; //((licenzeGPW.licenzeAttive <= licenzeGPW.licenzeDb) && (licenzeGPW.licenzeDb <= licenzeGPW.licenzeOnline)); + + // aggiornamento css secondo status colore da check + mainCss = okNumLic ? "alert alert-success shadowBox" : "alert alert-warning shadowBox"; + expDateCss = okScadenza ? "d-flex justify-content-between" : "d-flex justify-content-between bg-danger text-warning"; + remSrvCss = okRemoteSrv ? "d-flex justify-content-between" : "d-flex justify-content-between bg-danger text-warning"; + } + + 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 pr-2"; + } + } +} \ No newline at end of file diff --git a/MP.Land/Resources/ChangeLog.html b/MP.Land/Resources/ChangeLog.html index dd422355..2adb7933 100644 --- a/MP.Land/Resources/ChangeLog.html +++ b/MP.Land/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo gestione Programmi MAPO - Versione: 6.15.2204.1216 + Versione: 6.15.2204.2309 Note di rilascio: diff --git a/MP.Land/Resources/VersNum.txt b/MP.Land/Resources/VersNum.txt index f474a27a..38bc608a 100644 --- a/MP.Land/Resources/VersNum.txt +++ b/MP.Land/Resources/VersNum.txt @@ -1 +1 @@ -6.15.2204.1216 +6.15.2204.2309 diff --git a/MP.Land/Resources/manifest.xml b/MP.Land/Resources/manifest.xml index b50456ee..7462ed24 100644 --- a/MP.Land/Resources/manifest.xml +++ b/MP.Land/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.15.2204.1216 + 6.15.2204.2309 https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/MP.Land.zip https://nexus.steamware.net/repository/SWS/MP-LAND/stable/LAST/ChangeLog.html false
MoonPro / MAPO sono una suite di applicazioni e dispositivi hw dedicati per l'IOT,l'industry 4.0 e la gestione automatizzata dei processi produttivi.
Per maggiori informazioni visita il link sul nostro sito.