-
+
@if (RecordEdit == null)
{
-
+ if (CheckFreeEdit(item.IdxDipendente))
+ {
+
+ }
+ else
+ {
+
+ }
}
else
{
diff --git a/GPW.CORE.ADM/Components/Compo/DipendentiMan.razor.cs b/GPW.CORE.ADM/Components/Compo/DipendentiMan.razor.cs
index 4f844af..7f91438 100644
--- a/GPW.CORE.ADM/Components/Compo/DipendentiMan.razor.cs
+++ b/GPW.CORE.ADM/Components/Compo/DipendentiMan.razor.cs
@@ -56,7 +56,12 @@ namespace GPW.CORE.ADM.Components.Compo
protected string modalSize
{
- get => EnableFullEdit ? "modal-xl" : "modal-lg";
+ get => CtrlMode == DipendentiEdit.EditMode.FullEdit ? "modal-xl" : "modal-lg";
+ }
+
+ protected bool NeedAllocation
+ {
+ get => NumLicActOnline == NumLicActLocal && NumLicActOnline != NumLicActLocal;
}
protected string TextQrLinkCore
@@ -89,20 +94,64 @@ namespace GPW.CORE.ADM.Components.Compo
protected void DoEdit(DipendentiModel? selItem)
{
- EnableFullEdit = true;
+ CtrlMode = DipendentiEdit.EditMode.FullEdit;
RecordEdit = selItem;
}
+ protected void RequestReset(DipendentiModel? selItem)
+ {
+ CtrlMode = DipendentiEdit.EditMode.ResetRequest;
+ RecordEdit = selItem;
+ }
+
+ protected async Task DoFixMissing()
+ {
+ // procedo SOLO SE il numero online/offline è differente in primis...
+ if (NeedAllocation)
+ {
+ // ciclo tutti gli utenti attivi
+ // verifico SE sia disponibile licenza...
+ var activationsList = LicServ.ActivList;
+ Dictionary CodList = new Dictionary();
+
+ // ciclo x ogni dip attivo...
+ foreach (var item in ListDipendentiAttiviOrd)
+ {
+ // calcolo codImpiego
+ string currCodImp = LicServ.HashDip(item);
+ // cerco se abbia attivazione
+ var currActiv = activationsList.Where(x => x.CodImpiego == currCodImp).FirstOrDefault();
+ if (currActiv == null || currActiv.CodImpiego != currCodImp)
+ {
+ CodList.Add(currCodImp, item.AuthKey);
+ }
+ }
+ // provo attivazione in blocco
+ await LicServ.TryActivationMult(CodList);
+ // cmq faccio refresh
+ await FullRefresh();
+ }
+
+ await ReloadData();
+ }
+
+ protected async Task DoRefresh()
+ {
+ isLoading = true;
+ await FullRefresh();
+ await ReloadData();
+ isLoading = false;
+ }
protected void DoSelect(DipendentiModel currRec)
{
- EnableFullEdit = false;
+ CtrlMode = DipendentiEdit.EditMode.KeyRegen;
RecordEdit = currRec;
}
protected async Task ForceReload()
{
currPage = 1;
- EnableFullEdit = false;
+ CtrlMode = DipendentiEdit.EditMode.None;
RecordEdit = null;
await ReloadData();
}
@@ -115,65 +164,6 @@ namespace GPW.CORE.ADM.Components.Compo
AppMServ.EA_SearchUpdated += AppMServ_EA_SearchUpdated;
}
- protected async Task DoRefresh()
- {
- await FullRefresh();
- await ReloadData();
- }
- protected async Task DoFixMissing()
- {
- // procedo SOLO SE il numero online/offline è differente in primis...
-#if false
- if (numLicenzeOnline == numLicenze && attivazioniOnline != utentiAttivi)
- {
- // ciclo tutti gli utenti attivi
- var localUserList = licenzeGPW.getDipAttivi();
- // verifico SE sia disponibile licenza...
- var activationsList = licenzeGPW.ListaAttivazioni;
- Dictionary CodList = new Dictionary();
-
- // ciclo x ogni dip attivo...
- foreach (var item in localUserList)
- {
- // calcolo codImpiego
- string currCodImp = DataProxy.DP.hashCodImpiego(item);
- // cerco se abbia attivazione
- var currActiv = activationsList.Where(x => x.CodImpiego == currCodImp).FirstOrDefault();
- if (currActiv == null || currActiv.CodImpiego != currCodImp)
- {
- CodList.Add(currCodImp, item.authKey);
- }
- }
- // provo attivazione in blocco
- licenzeGPW.tryActivationMult(CodList).ConfigureAwait(false);
-
- if (CodList.Count > 0)
- {
- raiseReset();
- }
-
- // cmq faccio refresh
- await FullRefresh();
- }
-#endif
-
- await ReloadData();
- }
-
- private async Task FullRefresh()
- {
- LicServ.ResetLicenseData();
- // eseguo call di recupero da online
- bool refreshApp = await LicServ.RefreshApplic();
- bool refreshAct = await LicServ.RefreshLicense();
- // chiama update di TUTTE le authKey verso il server online
- foreach (var item in ListDipendentiAttiviOrd)
- {
- var CodImpiego = LicServ.HashDip(item);
- bool fatto = await LicServ.TryRefreshActivation(CodImpiego, item.AuthKey);
- }
- }
-
protected async Task SetNumRec(int newNum)
{
numRecord = newNum;
@@ -203,7 +193,7 @@ namespace GPW.CORE.ADM.Components.Compo
private int currPage = 1;
- private bool EnableFullEdit = false;
+ private DipendentiEdit.EditMode CtrlMode = DipendentiEdit.EditMode.None;
private string gridKey = "DipendentiMan";
@@ -250,6 +240,69 @@ namespace GPW.CORE.ADM.Components.Compo
ReloadData().ConfigureAwait(false);
}
+
+ ///
+ /// Verifica licenza (se sia libera x modifica o prima associazione)
+ ///
+ ///
+ ///
+ public bool CheckFreeEdit(int IdxDip)
+ {
+ bool answ = false;
+ if (IdxDip > 0)
+ {
+ // cerco!
+ var currUser = ListDipendentiAttiviOrd.Where(x => x.IdxDipendente == IdxDip).FirstOrDefault();
+ if (currUser != null)
+ {
+ // verifico SE sia disponibile licenza...
+ var activationsList = LicServ.ActivList;
+ var currHash = LicServ.HashDip(currUser);
+ var currAct = activationsList.Where(x => x.CodImpiego == currHash).FirstOrDefault();
+ // se NON c'è licenza è ok (editabile)
+ answ = (currAct == null);
+ // ora verifico: se NON ha licenza OK, altrimenti deve essere scaduta...
+ if (!answ)
+ {
+ answ = currAct.VetoUnlock <= DateTime.Today;
+ }
+ }
+ }
+ return answ;
+ }
+
+ private async Task DoActivate(DipendentiModel CurrRecord)
+ {
+ // verifica SE ci sono licenze disponibili
+ if (NumLicDispOnline > NumLicActOnline)
+ {
+ // attiva utente
+ GDataServ.DipUpdateActive(CurrRecord.IdxDipendente, true);
+
+ string CodImpiego = LicServ.HashDip(CurrRecord);
+
+ // effettua riassegnazione
+ bool fatto = LicServ.TryActivation(CodImpiego, CurrRecord.AuthKey);
+ }
+
+ await ReloadData();
+ }
+
+ private async Task FullRefresh()
+ {
+ LicServ.ResetLicenseData();
+ // eseguo call di recupero da online
+ bool refreshApp = await LicServ.RefreshApplic();
+ bool refreshAct = await LicServ.RefreshLicense();
+ bool refreshPay = LicServ.RefreshPayload();
+ // chiama update di TUTTE le authKey verso il server online
+ foreach (var item in ListDipendentiAttiviOrd)
+ {
+ var CodImpiego = LicServ.HashDip(item);
+ bool fatto = await LicServ.TryRefreshActivation(CodImpiego, item.AuthKey);
+ }
+ }
+
private void RefreshLicData()
{
if (LicServ.HasAppData)
@@ -299,6 +352,9 @@ namespace GPW.CORE.ADM.Components.Compo
isLoading = false;
}
+ ///
+ /// Sorting e paging tabella
+ ///
private void SortTable()
{
if (SearchRecords != null)
diff --git a/GPW.CORE.ADM/GPW.CORE.ADM.csproj b/GPW.CORE.ADM/GPW.CORE.ADM.csproj
index 14e9cb5..ccdce98 100644
--- a/GPW.CORE.ADM/GPW.CORE.ADM.csproj
+++ b/GPW.CORE.ADM/GPW.CORE.ADM.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 4.1.2506.2419
+ 4.1.2506.2518
diff --git a/GPW.CORE.Data/Controllers/GPWController.cs b/GPW.CORE.Data/Controllers/GPWController.cs
index 634dd39..f9bf9ea 100644
--- a/GPW.CORE.Data/Controllers/GPWController.cs
+++ b/GPW.CORE.Data/Controllers/GPWController.cs
@@ -2031,6 +2031,37 @@ namespace GPW.CORE.Data.Controllers
return answ;
}
+ ///
+ /// Ricalcola Tag Mensili dato dipendente, periodo, tag
+ ///
+ /// IdxDipendente
+ /// Stato attivo richiesto
+ ///
+ public bool DipUpdateActive(int idxDipendente, bool attivo)
+ {
+ // init dati necessari
+ bool fatto = false;
+ // cerco su DB recuperando set di dati....
+ using (GPWContext dbCtx = new GPWContext(_configuration))
+ {
+ try
+ {
+ var pAttivo = new SqlParameter("@attivo", attivo);
+ var pIdxDip = new SqlParameter("@Original_idxDipendente", idxDipendente);
+
+ var dbResult = dbCtx
+ .Database
+ .ExecuteSqlRaw("EXEC dbo.stp_AD_updateActive @attivo, @Original_idxDipendente", pAttivo, pIdxDip);
+ fatto = dbResult > 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore in DipUpdateActive:{Environment.NewLine}{exc}");
+ }
+ }
+ return fatto;
+ }
+
public void Dispose()
{
Log.Info("Dispose di GPWController");
@@ -2570,6 +2601,7 @@ namespace GPW.CORE.Data.Controllers
}
return dbResult;
}
+
///
/// Ricalcola Tag Mensili dato dipendente, periodo, tag
///
diff --git a/GPW.CORE.Data/DTO/DatiReqResetDTO.cs b/GPW.CORE.Data/DTO/DatiReqResetDTO.cs
new file mode 100644
index 0000000..817c437
--- /dev/null
+++ b/GPW.CORE.Data/DTO/DatiReqResetDTO.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GPW.CORE.Data.DTO
+{
+ public class DatiReqResetDTO
+ {
+ public string Richiedente { get; set; } = "";
+ public string Email { get; set; } = "";
+ public string Telefono { get; set; } = "";
+ public string Causale { get; set; } = "";
+ }
+}
diff --git a/GPW.CORE.Data/DataValidator.cs b/GPW.CORE.Data/DataValidator.cs
index 6f03fad..d4d926c 100644
--- a/GPW.CORE.Data/DataValidator.cs
+++ b/GPW.CORE.Data/DataValidator.cs
@@ -31,6 +31,28 @@ namespace GPW.CORE.Data
#endregion Public Properties
+ #region Public Methods
+
+ ///
+ /// Calcolo Hash data stringa input
+ ///
+ ///
+ ///
+ public static string CalcHash(string rawData)
+ {
+ string hash = "";
+ // hashing!
+ using (var md5 = MD5.Create())
+ {
+ byte[] InputBytes = Encoding.UTF8.GetBytes(rawData);
+ var byteHash = md5.ComputeHash(InputBytes);
+ hash = BitConverter.ToString(byteHash).Replace("-", "").ToLowerInvariant();
+ }
+ return hash;
+ }
+
+ #endregion Public Methods
+
#region Private Fields
private DipendentiModel? rigaDip = null;
@@ -55,6 +77,8 @@ namespace GPW.CORE.Data
}
if (!string.IsNullOrEmpty(buffData))
{
+ hash = CalcHash(buffData);
+#if false
// hashing!
using (var md5 = MD5.Create())
{
@@ -62,6 +86,7 @@ namespace GPW.CORE.Data
var byteHash = md5.ComputeHash(InputBytes);
hash = BitConverter.ToString(byteHash).Replace("-", "").ToLowerInvariant();
}
+#endif
}
return hash;
}
diff --git a/GPW.CORE.Data/Enum.cs b/GPW.CORE.Data/Enum.cs
index 62747f7..2f1e14f 100644
--- a/GPW.CORE.Data/Enum.cs
+++ b/GPW.CORE.Data/Enum.cs
@@ -11,6 +11,7 @@ namespace GPW.CORE.Data
ND = 0,
Lavoro = 1
}
+
//public enum TestUser
//{
// LocatelliSamuele = 1,
diff --git a/GPW.CORE.Data/LiManObj.cs b/GPW.CORE.Data/LiManObj.cs
index efedf8f..e7734f0 100644
--- a/GPW.CORE.Data/LiManObj.cs
+++ b/GPW.CORE.Data/LiManObj.cs
@@ -48,6 +48,16 @@ namespace GPW.CORE.Data
CheckSumKey
}
+ ///
+ /// Tipologia di ticket
+ ///
+ public enum TipologiaTicket
+ {
+ ND = 0,
+ Licenze,
+ FileUpload
+ }
+
#endregion Public Enums
#region Public Classes
@@ -127,6 +137,7 @@ namespace GPW.CORE.Data
public string MasterKey { get; set; } = "";
public string ReqBody { get; set; } = "";
+ public TipologiaTicket Tipo { get; set; } = TipologiaTicket.ND;
#endregion Public Properties
}
@@ -217,4 +228,4 @@ namespace GPW.CORE.Data
#endregion Public Classes
}
-}
+}
\ No newline at end of file
diff --git a/GPW.CORE.Data/Services/GpwDataService.cs b/GPW.CORE.Data/Services/GpwDataService.cs
index 94ef0c7..aa75e26 100644
--- a/GPW.CORE.Data/Services/GpwDataService.cs
+++ b/GPW.CORE.Data/Services/GpwDataService.cs
@@ -163,6 +163,7 @@ namespace GPW.CORE.Data.Services
Log.Debug($"AnagClientiAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
+
///
/// Recupera l'elenco fasi (tutte)
///
@@ -941,6 +942,7 @@ namespace GPW.CORE.Data.Services
Log.Debug($"AnagProjAll | {source} in: {ts.TotalMilliseconds} ms");
return dbResult;
}
+
///
/// Recupera elenco record da idx cliente
///
@@ -2008,6 +2010,20 @@ namespace GPW.CORE.Data.Services
return dbResult;
}
+ ///
+ /// Ricalcola Tag Mensili dato dipendente, periodo, tag
+ ///
+ /// IdxDipendente
+ /// Stato attivo richiesto
+ ///
+ public bool DipUpdateActive(int idxDipendente, bool attivo)
+ {
+ bool answ = dbController.DipUpdateActive(idxDipendente, attivo);
+ // svuoto cache
+ ExecFlushRedisPattern((RedisValue)$"{rKeyDipendenti}:*");
+ return answ;
+ }
+
public void Dispose()
{
// Clear database controller
diff --git a/GPW.CORE.Data/Services/LicenseService.cs b/GPW.CORE.Data/Services/LicenseService.cs
index b634374..1b78b16 100644
--- a/GPW.CORE.Data/Services/LicenseService.cs
+++ b/GPW.CORE.Data/Services/LicenseService.cs
@@ -7,6 +7,7 @@ using RestSharp;
using StackExchange.Redis;
using System.Web;
using static GPW.CORE.Data.LiManObj;
+using static System.Net.Mime.MediaTypeNames;
namespace GPW.CORE.Data.Services
{
@@ -215,56 +216,6 @@ namespace GPW.CORE.Data.Services
string hash = cDV.HashDip;
return hash;
}
- ///
- /// Tenta refresh licenza dato codice impiego (aggiorna la authKey...)
- ///
- ///
- ///
- public async Task TryRefreshActivation(string CodImpiego, string Chiave)
- {
- bool answ = false;
- // cerco online
- RestClient client = new RestClient(apiUrl);
- //client.Authenticator = new HttpBasicAuthenticator("username", "password");
- string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
- var request = new RestRequest($"/api/attivazioni/refreshKey");
- Dictionary parDict = new Dictionary();
- parDict.Add(CodImpiego, Chiave);
- UserLicenseRequest newBody = new UserLicenseRequest()
- {
- MasterKey = MasterKey,
- ParamDict = parDict
- };
- request.AddJsonBody(newBody);
- var response = client.Post(request);
- // controllo risposta
- if (response.StatusCode == System.Net.HttpStatusCode.OK)
- {
- // verifico risposta
- string rawData = $"{response.Content}";
- try
- {
- if (rawData.StartsWith("["))
- {
- // deserializzo
- List datiAttivazione = JsonConvert.DeserializeObject>(rawData);
- answ = datiAttivazione != null;
- }
- else
- {
- // deserializzo singolo
- AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject(rawData);
- answ = datiAttivazione != null;
- ResetLicenseData();
- await RefreshLicense();
- }
- }
- catch
- { }
- }
- Log.Info($"Richiesta TryRefreshActivation | CodImpiego: {CodImpiego}");
- return answ;
- }
///
/// Init della classe con variabili di base da Redis/DB
@@ -295,7 +246,6 @@ namespace GPW.CORE.Data.Services
fatto = await setAppLicData(AppLicense, numDays);
}
}
- await Task.Delay(1);
return fatto;
}
@@ -317,10 +267,45 @@ namespace GPW.CORE.Data.Services
fatto = await setActivList(onlineAct, numDays);
}
}
- await Task.Delay(1);
return fatto;
}
+ ///
+ /// Effettua refresh Payload su server (Remoto) e recupera info licenza in locale (sovrascrivendo info locali Redis)
+ ///
+ ///
+ public bool RefreshPayload()
+ {
+ bool answ = false;
+ // svuoto payload calcolato
+ ExecFlushRedisPattern((RedisValue)$"{rkeyPayload}:*");
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
+ var request = new RestRequest($"/api/licenza/refreshPayload");
+ string newEnigma = DataValidator.CalcHash($"{DateTime.Now:yyyyMMddHHmmss}");
+ LicenseCoord newBody = new LicenseCoord()
+ {
+ MasterKey = MasterKey,
+ CodInst = Installazione,
+ CodApp = Applicazione,
+ Enigma = newEnigma
+ };
+ request.AddJsonBody(newBody);
+ var response = client.Post(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
+ setRSV(rKeyLic, rawData, TimeSpan.FromDays(7));
+ }
+ Log.Info($"Richiesta RefreshPayload eseguita");
+ return answ;
+ }
+
public async Task resetActivList()
{
await Task.Delay(1);
@@ -346,6 +331,8 @@ namespace GPW.CORE.Data.Services
{
ExecFlushRedisPattern((RedisValue)$"{rKeyAttByLic}:*");
ExecFlushRedisPattern((RedisValue)$"{rKeyLic}:*");
+ ExecFlushRedisPattern((RedisValue)$"{rkeyPayload}:*");
+ ExecFlushRedisPattern((RedisValue)$"{rkeyTickets}:*");
}
public async Task setActivList(List newActList, int numDays)
@@ -353,7 +340,7 @@ namespace GPW.CORE.Data.Services
bool fatto = false;
string rKey = $"{rKeyAttByLic}:{MasterKey}";
var rawData = JsonConvert.SerializeObject(newActList);
- await setRSV(rKey, rawData, numDays * 24);
+ await setRSVAsync(rKey, rawData, numDays * 24);
fatto = true;
if (EA_InfoUpdated != null)
{
@@ -367,7 +354,7 @@ namespace GPW.CORE.Data.Services
bool fatto = false;
string cacheKey = $"{rKeyLic}:{MasterKey}";
var rawData = JsonConvert.SerializeObject(newAppDto);
- await setRSV(cacheKey, rawData, numDays * 24);
+ await setRSVAsync(cacheKey, rawData, numDays * 24);
fatto = true;
if (EA_InfoUpdated != null)
{
@@ -376,6 +363,254 @@ namespace GPW.CORE.Data.Services
return fatto;
}
+ ///
+ /// Tenta attivazione licenza dato codice impiego
+ ///
+ ///
+ ///
+ public bool TryActivation(string CodImpiego, string Chiave)
+ {
+ bool answ = false;
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ //client.Authenticator = new HttpBasicAuthenticator("username", "password");
+ string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
+ var request = new RestRequest($"/api/attivazioni");
+ Dictionary parDict = new Dictionary();
+ parDict.Add(CodImpiego, Chiave);
+ UserLicenseRequest newBody = new UserLicenseRequest()
+ {
+ MasterKey = MasterKey,
+ ParamDict = parDict
+ };
+ request.AddJsonBody(newBody);
+ var response = client.Post(request);
+ // controllo risposta
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ // verifico risposta
+ string rawData = $"{response.Content}";
+ try
+ {
+ // deserializzo
+ AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject(rawData);
+ answ = datiAttivazione != null;
+ ResetLicenseData();
+ }
+ catch
+ { }
+ }
+ Log.Info($"Richiesta tryActivation | CodImpiego: {CodImpiego}");
+ return answ;
+ }
+
+ ///
+ /// Tenta attivazione licenze dato dizionario codici impiego + chiavi
+ ///
+ /// Dizionario parametri attivazione di tipo (CodImpiego,Chiave)
+ ///
+ public async Task TryActivationMult(Dictionary ParamsList)
+ {
+ bool answ = false;
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ //client.Authenticator = new HttpBasicAuthenticator("username", "password");
+ string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
+ var request = new RestRequest($"/api/attivazioni");
+ UserLicenseRequest newBody = new UserLicenseRequest()
+ {
+ MasterKey = MasterKey,
+ ParamDict = ParamsList
+ };
+ request.AddJsonBody(newBody);
+ var response = client.Post(request);
+ // controllo risposta
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ // verifico risposta
+ string rawData = $"{response.Content}";
+ try
+ {
+ if (rawData.Contains("["))
+ {
+ // deserializzo
+ List datiAttivazione = JsonConvert.DeserializeObject>(rawData);
+ answ = datiAttivazione != null;
+ }
+ else
+ {
+ // deserializzo singolo
+ AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject(rawData);
+ answ = datiAttivazione != null;
+ ResetLicenseData();
+ await RefreshLicense();
+ }
+ }
+ catch
+ { }
+ }
+ Log.Info($"Richiesta tryActivationMult | num params: {ParamsList.Count}");
+ return answ;
+ }
+
+ ///
+ /// Tenta refresh licenza dato codice impiego (aggiorna la authKey...)
+ ///
+ ///
+ ///
+ public async Task TryRefreshActivation(string CodImpiego, string Chiave)
+ {
+ bool answ = false;
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ //client.Authenticator = new HttpBasicAuthenticator("username", "password");
+ string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
+ var request = new RestRequest($"/api/attivazioni/refreshKey");
+ Dictionary parDict = new Dictionary();
+ parDict.Add(CodImpiego, Chiave);
+ UserLicenseRequest newBody = new UserLicenseRequest()
+ {
+ MasterKey = MasterKey,
+ ParamDict = parDict
+ };
+ request.AddJsonBody(newBody);
+ var response = client.Post(request);
+ // controllo risposta
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ // verifico risposta
+ string rawData = $"{response.Content}";
+ try
+ {
+ if (rawData.Contains("["))
+ {
+ // deserializzo
+ List datiAttivazione = JsonConvert.DeserializeObject>(rawData);
+ answ = datiAttivazione != null;
+ }
+ else
+ {
+ // deserializzo singolo
+ AttivazioneDTO datiAttivazione = JsonConvert.DeserializeObject(rawData);
+ answ = datiAttivazione != null;
+ ResetLicenseData();
+ await RefreshLicense();
+ }
+ }
+ catch
+ { }
+ }
+ Log.Info($"Richiesta TryRefreshActivation | CodImpiego: {CodImpiego}");
+ return answ;
+ }
+ public void ResetTicketCache()
+ {
+ ExecFlushRedisPattern((RedisValue)$"{rkeyTickets}:*");
+ // ricarico
+ var newList = getTickets();
+ }
+
+
+ ///
+ /// Recupera num ticket da sistema LiMan online
+ ///
+ ///
+ private async Task> getTickets()
+ {
+ List answ = new List();
+#if false
+ // cerco in cache locale...
+ string rawData = memLayer.ML.getRSV(rkeyTickets);
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ answ = JsonConvert.DeserializeObject>(rawData);
+ }
+ // se vuoto rileggo
+ if (answ.Count == 0)
+ {
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ //client.Authenticator = new HttpBasicAuthenticator("username", "password");
+ string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
+ var request = new RestRequest($"/api/ticket/{installazione}?CodApp={applicazione}&Chiave={MKeyEnc}");
+ var response = client.Get(request);
+ // controllo risposta
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ // salvo in redis contenuto serializzato
+ rawData = response.Content;
+ // deserializzo
+ answ = JsonConvert.DeserializeObject>(rawData);
+ // salvo in redis per TTL std
+ memLayer.ML.setRSV(rkeyTickets, rawData, 20);
+ }
+ }
+#endif
+ return answ;
+ }
+
+ ///
+ /// Tenta invio di un ticket x licenza indicata
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool SendTicketReq(string contName, string contEmail, string contPhone, string reqBody, string codImpiego, int idxSubLic)
+ {
+ bool answ = false;
+ // cerco online
+ RestClient client = new RestClient(apiUrl);
+ string MKeyEnc = HttpUtility.UrlEncode(MasterKey);
+ var request = new RestRequest($"/api/ticket/sendReq");
+
+ SupportRequest richiesta = new SupportRequest()
+ {
+ ContactName = contName,
+ ContactEmail = contEmail,
+ ContactPhone = contPhone,
+ ReqBody = reqBody,
+ CodInst = Installazione,
+ CodApp = Applicazione,
+ MasterKey = MasterKey,
+ idxSubLic = idxSubLic,
+ CodImp = codImpiego,
+ Tipo = TipologiaTicket.Licenze
+ };
+
+ request.AddJsonBody(richiesta);
+ var response = client.Post(request);
+
+ // controllo risposta
+ if (response.StatusCode == System.Net.HttpStatusCode.OK)
+ {
+ // verifico risposta
+ string rawData = response.Content;
+ try
+ {
+ if (rawData.StartsWith("["))
+ {
+ // deserializzo
+ List tickets = JsonConvert.DeserializeObject>(rawData);
+ answ = tickets != null;
+ }
+ else
+ {
+ // deserializzo singolo
+ TicketDTO tickets = JsonConvert.DeserializeObject(rawData);
+ answ = tickets != null;
+ }
+ }
+ catch
+ { }
+ }
+ Log.Info($"Richiesta SendTicketReq inviata | idxSub: {idxSubLic}");
+ return answ;
+ }
+
#endregion Public Methods
#region Protected Fields
@@ -383,12 +618,22 @@ namespace GPW.CORE.Data.Services
///
/// Chiave redis x attivazioni della licenza
///
- protected const string rKeyAttByLic = "LongCache:AttByLic";
+ protected const string rKeyAttByLic = "GPW.CORE:LongCache:AttByLic";
///
/// Chiave redis x info licenza
///
- protected const string rKeyLic = "LongCache:LicData";
+ protected const string rKeyLic = "GPW.CORE:LongCache:LicData";
+
+ ///
+ /// Info payload
+ ///
+ protected const string rkeyPayload = "GPW.CORE:LongCache:Payload";
+
+ ///
+ /// Info tickets
+ ///
+ protected const string rkeyTickets = "GPW.CORE:LongCache:Tickets";
protected Random rnd = new Random();
@@ -539,13 +784,41 @@ namespace GPW.CORE.Data.Services
}
///
- /// Salvataggio chiave in redis
+ /// Salvataggio chiave in Redis
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected bool setRSV(string rKey, string rVal, TimeSpan TTL)
+ {
+ bool fatto = false;
+ fatto = redisDb.StringSet(rKey, rVal, TTL);
+ return fatto;
+ }
+
+ ///
+ /// Salvataggio chiave in Redis Async
+ ///
+ ///
+ ///
+ ///
+ ///
+ protected async Task setRSVAsync(string rKey, string rVal, TimeSpan TTL)
+ {
+ bool fatto = false;
+ fatto = await redisDb.StringSetAsync(rKey, rVal, TTL);
+ return fatto;
+ }
+
+ ///
+ /// Salvataggio chiave in Redis Async
///
///
///
///
///
- protected async Task setRSV(string rKey, string rVal, int cacheMult)
+ protected async Task setRSVAsync(string rKey, string rVal, int cacheMult)
{
bool fatto = false;
fatto = await redisDb.StringSetAsync(rKey, rVal, getCache(cacheMult));
@@ -553,15 +826,15 @@ namespace GPW.CORE.Data.Services
}
///
- /// Salvataggio chiave INT in redis
+ /// Salvataggio chiave INT in Redis Async
///
///
///
///
///
- protected async Task setRSV(string rKey, int rValInt, int cacheMult)
+ protected async Task setRSVAsync(string rKey, int rValInt, int cacheMult)
{
- return await setRSV(rKey, $"{rValInt}", cacheMult);
+ return await setRSVAsync(rKey, $"{rValInt}", cacheMult);
}
#endregion Protected Methods
diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html
index 664f135..5a7176d 100644
--- a/Resources/ChangeLog.html
+++ b/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
GPW - Gestione Presenze Web
- Versione: 4.1.2506.2419
+ Versione: 4.1.2506.2518
Note di rilascio:
-
diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt
index 242ca5e..ed9bf70 100644
--- a/Resources/VersNum.txt
+++ b/Resources/VersNum.txt
@@ -1 +1 @@
-4.1.2506.2419
+4.1.2506.2518
diff --git a/Resources/manifest.xml b/Resources/manifest.xml
index 30911dd..019bb0c 100644
--- a/Resources/manifest.xml
+++ b/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 4.1.2506.2419
+ 4.1.2506.2518
http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip
http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html
false
|