Iniziata integrazioen licenze con chiamate RestSharp
This commit is contained in:
@@ -7,7 +7,17 @@
|
||||
|
||||
<div class="d-flex justify-content-between text-right table-secondary">
|
||||
<div class="p-2">
|
||||
Licenze: disponibili <b><%: numLicenze %></b> / attivate <b><%: utentiAttivi %></b>
|
||||
<div class="border border-info p-2" runat="server" id="divDB">
|
||||
Licenze locali: disponibili <b><%: numLicenze %></b> / attivate <b><%: utentiAttivi %></b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<div class="border border-success p-2" runat="server" id="divOnline">
|
||||
Licenze online: disponibili <b><%: numLicenzeOnline %></b> / attivate <b><%: attivazioniOnline %></b>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<asp:LinkButton runat="server" ID="lbtRefresh" CssClass="btn btn-success btn-sm" OnClick="lbtRefresh_Click">Re-Validate</asp:LinkButton>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
<asp:CheckBox runat="server" ID="chkshowAll" Text="Mostra tutti" OnCheckedChanged="chkshowAll_CheckedChanged" AutoPostBack="true" ToolTip="Mostra tutti gli utenti (anche cessati/inattivi)" Checked="true" />
|
||||
|
||||
@@ -14,6 +14,11 @@ namespace GPW_Admin.WebUserControls
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public int attivazioniOnline
|
||||
{
|
||||
get => licenzeGPW.attivazioniOnline;
|
||||
}
|
||||
|
||||
public int IdxDipSel
|
||||
{
|
||||
get
|
||||
@@ -33,6 +38,11 @@ namespace GPW_Admin.WebUserControls
|
||||
get => licenzeGPW.licenzeAttive;
|
||||
}
|
||||
|
||||
public int numLicenzeOnline
|
||||
{
|
||||
get => licenzeGPW.licenzeOnline;
|
||||
}
|
||||
|
||||
public bool showAll
|
||||
{
|
||||
get
|
||||
@@ -161,6 +171,12 @@ namespace GPW_Admin.WebUserControls
|
||||
ods.Insert();
|
||||
}
|
||||
|
||||
protected void lbtRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
// eseguo call di recupero da online
|
||||
bool fatto = licenzeGPW.CheckOnline().Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// check licenze in fase di update...
|
||||
/// </summary>
|
||||
|
||||
@@ -14,6 +14,33 @@ namespace GPW_Admin.WebUserControls
|
||||
public partial class mod_adminDipendenti
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// divDB control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divDB;
|
||||
|
||||
/// <summary>
|
||||
/// divOnline control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divOnline;
|
||||
|
||||
/// <summary>
|
||||
/// lbtRefresh control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.LinkButton lbtRefresh;
|
||||
|
||||
/// <summary>
|
||||
/// chkshowAll control.
|
||||
/// </summary>
|
||||
|
||||
@@ -34,11 +34,16 @@ public partial class mod_login : ApplicationUserControl
|
||||
|
||||
protected override void traduciObj()
|
||||
{
|
||||
lblPwd.Text = user_std.UtSn.Traduci("lblPwd");
|
||||
lblUser.Text = user_std.UtSn.Traduci("lblUser");
|
||||
lblDominio.Text = user_std.UtSn.Traduci("lblDominio");
|
||||
lblTitolo.Text = user_std.UtSn.Traduci("ForzaUtente");
|
||||
btnOk.Text = user_std.UtSn.Traduci("btnCommit");
|
||||
try
|
||||
{
|
||||
lblPwd.Text = user_std.UtSn.Traduci("lblPwd");
|
||||
lblUser.Text = user_std.UtSn.Traduci("lblUser");
|
||||
lblDominio.Text = user_std.UtSn.Traduci("lblDominio");
|
||||
lblTitolo.Text = user_std.UtSn.Traduci("ForzaUtente");
|
||||
btnOk.Text = user_std.UtSn.Traduci("btnCommit");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GPW_data
|
||||
{
|
||||
public class LiManObj
|
||||
{
|
||||
#region Public Enums
|
||||
|
||||
public enum TipoLicenza
|
||||
{
|
||||
ND = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Licenza LEgacy Steamware
|
||||
/// </summary>
|
||||
GLS,
|
||||
|
||||
/// <summary>
|
||||
/// Master Key License, che ha una data di scadenza globale ed un token = numero di utenti/token massimi associati
|
||||
/// </summary>
|
||||
MasterKey,
|
||||
|
||||
/// <summary>
|
||||
/// UserKey License (licenza che consuma un token utente della licenza master) - es GPW
|
||||
/// </summary>
|
||||
UserKey,
|
||||
|
||||
/// <summary>
|
||||
/// Chiave tiupo Checksum basata su licenza masster + checksum MD5 di una serie di dati (child licenses)
|
||||
/// </summary>
|
||||
CheckSumKey
|
||||
}
|
||||
|
||||
#endregion Public Enums
|
||||
|
||||
#region Public Classes
|
||||
|
||||
public class ApplicativoDTO
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string Chiave { get; set; } = "";
|
||||
public string CodApp { get; set; } = "";
|
||||
public string CodInst { get; set; } = "";
|
||||
public DateTime DataEnigma { get; set; } = DateTime.Today.AddYears(-1);
|
||||
public string Descrizione { get; set; } = "";
|
||||
public string Enigma { get; set; } = "";
|
||||
public int IdxLic { get; set; } = 0;
|
||||
|
||||
public bool IsActive
|
||||
{
|
||||
get => (Scadenza.Subtract(DateTime.Today).TotalDays > 0);
|
||||
}
|
||||
|
||||
public bool Locked { get; set; } = false;
|
||||
public int NumLicenze { get; set; } = 0;
|
||||
public int NumLicenzeAttive { get; set; } = 0;
|
||||
public string Payload { get; set; } = "";
|
||||
public DateTime Scadenza { get; set; } = DateTime.Today.AddYears(-1);
|
||||
public TipoLicenza Tipo { get; set; } = TipoLicenza.ND;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
public class AttivazioneDTO
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string Chiave { get; set; } = "";
|
||||
public string CodApp { get; set; } = "";
|
||||
public string CodImpiego { get; set; } = "";
|
||||
public string CodInst { get; set; } = "";
|
||||
public string Descrizione { get; set; } = "";
|
||||
public int IdxLic { get; set; } = 0;
|
||||
public int IdxSubLic { get; set; } = 0;
|
||||
public TipoLicenza Tipo { get; set; } = TipoLicenza.UserKey;
|
||||
public DateTime VetoUnlock { get; set; } = DateTime.Today.AddMonths(2);
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
|
||||
#endregion Public Classes
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,22 @@
|
||||
using SteamWare;
|
||||
using System;
|
||||
using RestSharp;
|
||||
using RestSharp.Authenticators;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace GPW_data
|
||||
{
|
||||
public class licenzeGPW
|
||||
{
|
||||
#region Protected Fields
|
||||
|
||||
protected static string appInfoKey = memLayer.ML.redHash($"LiMan:AppInfo");
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -19,6 +31,17 @@ namespace GPW_data
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive da info online
|
||||
/// </summary>
|
||||
public static int attivazioniOnline
|
||||
{
|
||||
get
|
||||
{
|
||||
return InfoApplicativo.NumLicenzeAttive;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// chaive licenza
|
||||
/// </summary>
|
||||
@@ -86,6 +109,38 @@ namespace GPW_data
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Info applicativo corrente (da cache con eventuale recupero online...)
|
||||
/// </summary>
|
||||
public static LiManObj.ApplicativoDTO InfoApplicativo
|
||||
{
|
||||
get
|
||||
{
|
||||
LiManObj.ApplicativoDTO answ = new LiManObj.ApplicativoDTO();
|
||||
// cerco da cache
|
||||
string rawData = memLayer.ML.getRSV(appInfoKey);
|
||||
// se no ci fosse --> refresh online!
|
||||
if (string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var fatto = CheckOnline().Result;
|
||||
if (fatto)
|
||||
{
|
||||
rawData = memLayer.ML.getRSV(appInfoKey);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
// POTREBBE darmi + di 1 risultato, prendo + recente...
|
||||
List<LiManObj.ApplicativoDTO> infoList = JsonConvert.DeserializeObject<List<LiManObj.ApplicativoDTO>>(rawData);
|
||||
if (infoList != null)
|
||||
{
|
||||
answ = infoList.OrderByDescending(x => x.Scadenza).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// nome installazione sw
|
||||
/// </summary>
|
||||
@@ -147,6 +202,17 @@ namespace GPW_data
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze disponibili da info online
|
||||
/// </summary>
|
||||
public static int licenzeOnline
|
||||
{
|
||||
get
|
||||
{
|
||||
return InfoApplicativo.NumLicenze;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modalità applicazione (pagina test.aspx)
|
||||
/// </summary>
|
||||
@@ -192,5 +258,32 @@ namespace GPW_data
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public static async Task<bool> CheckOnline()
|
||||
{
|
||||
bool answ = false;
|
||||
string apiUrl = "https://localhost:44351/";
|
||||
//string apiUrl= "https://iis01.egalware.com/ELM.API/";
|
||||
|
||||
// cerco online
|
||||
RestClient client = new RestClient(apiUrl);
|
||||
//client.Authenticator = new HttpBasicAuthenticator("username", "password");
|
||||
var request = new RestRequest($"/api/applicazione/{installazione}?CodApp={applicazione}", DataFormat.Json);
|
||||
var response = client.Get(request);
|
||||
// controllo risposta
|
||||
if (response.StatusCode == System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
answ = true;
|
||||
// salvo in redis contenuto serializzato
|
||||
string rawData = response.Content;
|
||||
// salvo in redis per 7 gg
|
||||
memLayer.ML.setRSV(appInfoKey, rawData, 60 * 60 * 24 * 7);
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@
|
||||
<package id="NLog" version="4.7.9" targetFramework="net462" />
|
||||
<package id="PDFsharp" version="1.50.5147" targetFramework="net462" />
|
||||
<package id="Pipelines.Sockets.Unofficial" version="2.2.0" targetFramework="net462" />
|
||||
<package id="RestSharp" version="106.13.0" targetFramework="net462" />
|
||||
<package id="SharpCompress" version="0.28.1" targetFramework="net462" />
|
||||
<package id="SharpZipLib" version="1.3.1" targetFramework="net462" />
|
||||
<package id="Snappy.NET" version="1.1.1.8" targetFramework="net462" />
|
||||
|
||||
@@ -85,6 +85,9 @@
|
||||
<HintPath>..\packages\Pipelines.Sockets.Unofficial.2.2.0\lib\net461\Pipelines.Sockets.Unofficial.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp, Version=106.13.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\RestSharp.106.13.0\lib\net452\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpCompress, Version=0.28.1.0, Culture=neutral, PublicKeyToken=afb0a02973931d96, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpCompress.0.28.1\lib\netstandard2.0\SharpCompress.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -207,6 +210,7 @@
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="licenzeGPW.cs" />
|
||||
<Compile Include="Objects.cs" />
|
||||
<Compile Include="ObjLicenze.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
Reference in New Issue
Block a user