diff --git a/GPW_Data/licenzeGPW.cs b/GPW_Data/licenzeGPW.cs index 504ec1a..130f79a 100644 --- a/GPW_Data/licenzeGPW.cs +++ b/GPW_Data/licenzeGPW.cs @@ -1,16 +1,15 @@ -using SteamWare; -using System; +using Newtonsoft.Json; using RestSharp; -using RestSharp.Authenticators; -using System.Threading.Tasks; -using Newtonsoft.Json; +using SteamWare; +using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; using System.Web; using static GPW_data.LiManObj; -using System.Text; -using System.Security.Cryptography; -using System.Diagnostics; namespace GPW_data { @@ -24,20 +23,36 @@ namespace GPW_data //protected static string apiUrl = "https://localhost:44351/"; protected static string apiUrl = "https://liman.egalware.com/ELM.API/"; - /// - /// Durata cache statica locale dati licenza - /// protected static int LicCacheTTL = 60 * 60 * 24 * 7; - /// - protected static int LicCacheTTL = 120; - protected static string rkeyActInfo = memLayer.ML.redHash($"LiMan:ActInfo"); + protected static string rkeyAppInfo = memLayer.ML.redHash($"LiMan:AppInfo"); + protected static string rkeyLicInfo = memLayer.ML.redHash($"LiMan:LicInfo"); + protected static string rkeyPayload = memLayer.ML.redHash($"LiMan:Payload"); + protected static string rkeyVetoRefPayL = memLayer.ML.redHash($"LiMan:VetoRefPayL"); #endregion Protected Fields + #region Protected Properties + + /// + /// Durata cache statica locale dati licenza, random circa 1 h + /// + protected static int LicCacheTTL + { + get + { + Random rndGen = new Random(); + int minVal = 50; + int maxVal = 70; + return rndGen.Next(minVal, maxVal) * 60; + } + } + + #endregion Protected Properties + #region Public Properties /// @@ -132,6 +147,7 @@ namespace GPW_data var okAct = RefreshLicInfo().Result; var okPld = RefreshPayload().Result; + // evito ricalcolo x 5 sec... memLayer.ML.setRSV(rkeyVetoRefPayL, "Veto", 5); sw.Stop(); logger.lg.scriviLog($"Trovato payload non valido, effettuato reset variabili in {sw.ElapsedMilliseconds} ms"); @@ -369,7 +385,7 @@ namespace GPW_data if (string.IsNullOrEmpty(currPayload)) { currPayload = calcPayload(); - memLayer.ML.setRSV(rkeyPayload, currPayload, 3600); + memLayer.ML.setRSV(rkeyPayload, currPayload, LicCacheTTL); } // confronto payload calc con quello della licenza answ = InfoApplicativo.Payload == currPayload; @@ -586,7 +602,7 @@ namespace GPW_data public static async Task RefreshPayload() { bool answ = false; - // svuoto payload calcolato in primis... + // svuoto payload calcolato in primis (ttl a 1 sec)... memLayer.ML.setRSV(rkeyPayload, "", 1); // cerco online