Completata review gestione chiave e sua scadenza
This commit is contained in:
@@ -65,6 +65,11 @@ namespace GPW.CORE.Smart.Components.Compo
|
||||
// chiamo refresh licenze da remoto
|
||||
allOk = await LicServ.RefreshLicense();
|
||||
}
|
||||
// se non avesse info applicativo...
|
||||
if(!LicServ.HasAppData)
|
||||
{
|
||||
await LicServ.RefreshApplic();
|
||||
}
|
||||
}
|
||||
|
||||
await Task.Delay(1);
|
||||
@@ -178,10 +183,6 @@ namespace GPW.CORE.Smart.Components.Compo
|
||||
await CDService.FlushRedisCache();
|
||||
// ritorno in home
|
||||
navManager.NavigateTo("Home", true);
|
||||
|
||||
//await Task.Delay(1);
|
||||
//await DoVerifyActiv();
|
||||
//navManager.NavigateTo($"ForceReset?nextPage=Home", true);
|
||||
}
|
||||
|
||||
protected async Task VerifyActiv()
|
||||
|
||||
@@ -24,6 +24,25 @@
|
||||
<img src="images/LogoEgw.png" wi class="img-fluid" />
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12">
|
||||
<h4 class="card-title">Version and license</h4>
|
||||
</div>
|
||||
<div class="col-6 small">
|
||||
<strong>GPW</strong><br />
|
||||
<span class="small">v.@version</span>
|
||||
</div>
|
||||
<div class="col-6 small">
|
||||
<strong>License:</strong><br />
|
||||
<ul>
|
||||
<li>
|
||||
Scad: @licExpiry
|
||||
</li>
|
||||
<li>
|
||||
Num: @licStatus
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<hr />
|
||||
<div class="col-12">
|
||||
<h4 class="card-title">@Messaggio</h4>
|
||||
</div>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using GPW.CORE.Smart.Data;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace GPW.CORE.Smart.Components.Pages
|
||||
@@ -22,19 +23,51 @@ namespace GPW.CORE.Smart.Components.Pages
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnInitialized()
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LicServ.RefreshApplic();
|
||||
Titolo = Configuration.GetValue<string>("Application:Name")!;
|
||||
Messaggio = Configuration.GetValue<string>("Application:ContactText")!;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
private int numLicAvail
|
||||
{
|
||||
get
|
||||
{
|
||||
int answ = 0;
|
||||
if (LicServ.HasActivData)
|
||||
{
|
||||
var licRec = LicServ.AKVList.Where(x => x.NomeVar == LicServ.Installazione).FirstOrDefault();
|
||||
if (licRec != null)
|
||||
{
|
||||
answ = licRec.ValInt ?? 0;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
private string licStatus
|
||||
{
|
||||
get => LicServ.HasActivData ? $"{LicServ.ActivList.Count}/{numLicAvail}" : "N.A.";
|
||||
}
|
||||
private string licExpiry
|
||||
{
|
||||
get => LicServ.HasActivData ? $"{LicServ.AppLicense.Scadenza:yyyy-MM-dd}" : "N.A.";
|
||||
}
|
||||
|
||||
#region Private Properties
|
||||
|
||||
[Inject]
|
||||
private IConfiguration Configuration { get; set; } = null!;
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
[Inject]
|
||||
protected LicenseService LicServ { get; set; } = null!;
|
||||
|
||||
protected Version? version = typeof(Program).Assembly.GetName().Version;
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
@page "/Info"
|
||||
<h3>Info</h3>
|
||||
|
||||
Pagina info generiche come https://iis01.egalware.com/GPW/SMART/Informazioni
|
||||
<br>
|
||||
In particolare
|
||||
<ul>
|
||||
<li>app + versione</li>
|
||||
<li>copyright</li>
|
||||
<li>dati cliente / licenze /scadenza </li>
|
||||
<li> dati contatto e supporto</li>
|
||||
</ul>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -39,6 +39,9 @@ namespace GPW.CORE.Smart.Data
|
||||
|
||||
#region Public Properties
|
||||
|
||||
|
||||
public LiManObj.ApplicativoDTO AppLicense { get; set; } = new LiManObj.ApplicativoDTO();
|
||||
|
||||
public List<LiManObj.AttivazioneDTO> ActivList { get; set; } = new List<LiManObj.AttivazioneDTO>();
|
||||
public List<AnagKeyValueModel> AKVList { get; set; } = new List<AnagKeyValueModel>();
|
||||
public string Applicazione { get; set; } = "";
|
||||
@@ -67,6 +70,25 @@ namespace GPW.CORE.Smart.Data
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasAppData
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = !string.IsNullOrEmpty(AppLicense.CodApp);
|
||||
// se ok controllo che ci siano attivazioni
|
||||
if (!answ)
|
||||
{
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
AppLicense = await AppLicCache();
|
||||
});
|
||||
pUpd.Wait();
|
||||
answ = !string.IsNullOrEmpty(AppLicense.CodApp);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime infoExpiry { get; set; } = DateTime.Today.AddDays(1);
|
||||
public string Installazione { get; set; } = "";
|
||||
public string MasterKey { get; set; } = "";
|
||||
@@ -102,6 +124,23 @@ namespace GPW.CORE.Smart.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<LiManObj.ApplicativoDTO> AppLicCache()
|
||||
{
|
||||
LiManObj.ApplicativoDTO dbResult = new LiManObj.ApplicativoDTO();
|
||||
string cacheKey = $"{rKeyLic}:{MasterKey}";
|
||||
string rawData = await getRSV(cacheKey);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var cacheRes = JsonConvert.DeserializeObject<LiManObj.ApplicativoDTO>(rawData);
|
||||
if (cacheRes != null)
|
||||
{
|
||||
dbResult = cacheRes;
|
||||
}
|
||||
}
|
||||
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init della classe con variabili di base da Redis/DB
|
||||
/// </summary>
|
||||
@@ -114,6 +153,27 @@ namespace GPW.CORE.Smart.Data
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init della classe x licenza applicativo
|
||||
/// </summary>
|
||||
public async Task<bool> RefreshApplic()
|
||||
{
|
||||
bool fatto = false;
|
||||
if (string.IsNullOrEmpty(AppLicense.CodApp))
|
||||
{
|
||||
var onlineLic = await OnlineApplicationData();
|
||||
if (onlineLic != null)
|
||||
{
|
||||
// scadenza info a 15 gg...
|
||||
int numDays = 15;
|
||||
AppLicense = onlineLic;
|
||||
fatto = await setAppLicData(AppLicense, numDays);
|
||||
}
|
||||
}
|
||||
await Task.Delay(1);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init della classe con variabili di base da Redis/DB
|
||||
/// </summary>
|
||||
@@ -150,10 +210,28 @@ namespace GPW.CORE.Smart.Data
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public async Task<bool> setAppLicData(LiManObj.ApplicativoDTO newAppDto, int numDays)
|
||||
{
|
||||
bool fatto = false;
|
||||
string cacheKey = $"{rKeyLic}:{MasterKey}";
|
||||
var rawData = JsonConvert.SerializeObject(newAppDto);
|
||||
await setRSV(cacheKey, rawData, numDays * 24);
|
||||
fatto = true;
|
||||
if (EA_InfoUpdated != null)
|
||||
{
|
||||
EA_InfoUpdated?.Invoke();
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Chiave redis x info licenza
|
||||
/// </summary>
|
||||
protected const string rKeyLic = "LongCache:LicData";
|
||||
/// <summary>
|
||||
/// Chiave redis x attivazioni della licenza
|
||||
/// </summary>
|
||||
@@ -283,6 +361,34 @@ namespace GPW.CORE.Smart.Data
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Dati Applicativo
|
||||
/// </summary>
|
||||
private async Task<LiManObj.ApplicativoDTO?> OnlineApplicationData()
|
||||
{
|
||||
LiManObj.ApplicativoDTO? answ = new LiManObj.ApplicativoDTO();
|
||||
// cerco online
|
||||
RestClient client = new RestClient(apiUrl);
|
||||
//client.Authenticator = new HttpBasicAuthenticator("username", "password");
|
||||
string ValEnc = HttpUtility.UrlEncode(Applicazione);
|
||||
var request = new RestRequest($"/api/applicazione/{Installazione}?CodApp={ValEnc}", Method.Get);
|
||||
var response = await client.GetAsync(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
// salvo in redis contenuto serializzato
|
||||
string rawData = $"{response.Content}";
|
||||
var rawList = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>>(rawData);
|
||||
if (rawList != null)
|
||||
{
|
||||
answ = rawList.FirstOrDefault();
|
||||
}
|
||||
//answ = JsonConvert.DeserializeObject<LiManObj.ApplicativoDTO>(rawData);
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
private void ReportUpdated()
|
||||
{
|
||||
if (EA_InfoUpdated != null)
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>3.0.2408.2217</Version>
|
||||
<Version>3.0.2408.2218</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<PackageProjectUrl>www.egalware.com</PackageProjectUrl>
|
||||
<Description>GPW Smart UI</Description>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>GPW - Gestione Presenze Web</i>
|
||||
<h4>Versione: 3.0.2408.2217</h4>
|
||||
<h4>Versione: 3.0.2408.2218</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
3.0.2408.2217
|
||||
3.0.2408.2218
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>3.0.2408.2217</version>
|
||||
<version>3.0.2408.2218</version>
|
||||
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.Smart.zip</url>
|
||||
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user