Inizio modifica x visualizzazione elenco tickets in GPW
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
<div class="px-2">
|
||||
<asp:LinkButton runat="server" ID="lbtFixMissing" CssClass="btn btn-primary" OnClick="lbtFixMissing_Click">Allocazione Licenze <i class="fa fa-cloud-upload" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
<div class="px-2">
|
||||
<asp:LinkButton runat="server" ID="lbtShowTickets" CssClass="btn btn-info" OnClick="lbtShowTickets_Click"><i class="fa fa-ticket" aria-hidden="true"></i> Ticket aperti <span class="badge"><%: numTickets %></span></asp:LinkButton>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-2">
|
||||
|
||||
@@ -57,6 +57,11 @@ namespace GPW_Admin.WebUserControls
|
||||
get => licenzeGPW.licenzeOnline;
|
||||
}
|
||||
|
||||
public int numTickets
|
||||
{
|
||||
get => licenzeGPW.numTickets;
|
||||
}
|
||||
|
||||
public bool showAll
|
||||
{
|
||||
get
|
||||
@@ -72,24 +77,106 @@ namespace GPW_Admin.WebUserControls
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
#region Public Methods
|
||||
|
||||
private static void fullRefresh()
|
||||
/// <summary>
|
||||
/// Verifica licenza (se sia libera x modifca o prima associazione)
|
||||
/// </summary>
|
||||
/// <param name="idxDIp"></param>
|
||||
/// <returns></returns>
|
||||
public bool checkFreeEdit(object idxDip)
|
||||
{
|
||||
// eseguo call di recupero da online
|
||||
bool refreshApp = licenzeGPW.RefreshAppInfo().Result;
|
||||
bool refreshAct = licenzeGPW.RefreshActInfo().Result;
|
||||
bool refreshPayload = licenzeGPW.RefreshPayload().Result;
|
||||
//bool refreshLic = licenzeGPW.RefreshLicInfo().Result;
|
||||
bool answ = false;
|
||||
int IdxDip = 0;
|
||||
int.TryParse($"{idxDip}", out IdxDip);
|
||||
if (IdxDip > 0)
|
||||
{
|
||||
var localUserList = DataProxy.DP.taDipendenti.getAttivi(false);
|
||||
// cerco!
|
||||
var currUser = localUserList.Where(x => x.idxDipendente == IdxDip).FirstOrDefault();
|
||||
|
||||
// verifico SE sia disponibile licenza...
|
||||
var activationsList = licenzeGPW.ListaAttivazioni;
|
||||
var currHash = DataProxy.DP.hashCodImpiego(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 void fixVisibility()
|
||||
/// <summary>
|
||||
/// Verifica licenza (se sia validata/associata a quelle in memoria)
|
||||
/// </summary>
|
||||
/// <param name="idxDIp"></param>
|
||||
/// <returns></returns>
|
||||
public bool checkLic(object idxDip)
|
||||
{
|
||||
lbtFixMissing.Visible = (numLicenzeOnline == numLicenze && attivazioniOnline != utentiAttivi);
|
||||
grView.PageSize = utils.pageSize;
|
||||
bool answ = false;
|
||||
int IdxDip = 0;
|
||||
int.TryParse($"{idxDip}", out IdxDip);
|
||||
if (IdxDip > 0)
|
||||
{
|
||||
var localUserList = DataProxy.DP.taDipendenti.getAttivi(false);
|
||||
// cerco!
|
||||
var currUser = localUserList.Where(x => x.idxDipendente == IdxDip).FirstOrDefault();
|
||||
|
||||
// verifico SE sia disponibile licenza...
|
||||
var activationsList = licenzeGPW.ListaAttivazioni;
|
||||
var currHash = DataProxy.DP.hashCodImpiego(currUser);
|
||||
var currAct = activationsList.Where(x => x.CodImpiego == currHash).FirstOrDefault();
|
||||
answ = (currAct != null && currAct.CodImpiego == currHash);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
/// <summary>
|
||||
/// determina se sia eliminabile il record (=non usato)
|
||||
/// </summary>
|
||||
/// <param name="idxMaker"></param>
|
||||
/// <returns></returns>
|
||||
public bool delEnabled(object idxObj)
|
||||
{
|
||||
bool answ = true;
|
||||
// solo se ha diritti scrittura controllo
|
||||
if (idxObj != null)
|
||||
{
|
||||
int trovati = 0;
|
||||
int idxDip = 0;
|
||||
_ = int.TryParse(idxObj.ToString(), out idxDip);
|
||||
trovati = DataProxy.DP.taTimb.getLastByDip(idxDip).Count;
|
||||
// controllo se ci sono record correlati...
|
||||
if (trovati > 0)
|
||||
{
|
||||
answ = false;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void doUpdate()
|
||||
{
|
||||
fullRefresh();
|
||||
fixVisibility();
|
||||
grView.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
||||
/// </summary>
|
||||
public void resetSelezione()
|
||||
{
|
||||
grView.SelectedIndex = -1;
|
||||
grView.DataBind();
|
||||
raiseReset();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
@@ -257,6 +344,12 @@ namespace GPW_Admin.WebUserControls
|
||||
isTicketReq = false;
|
||||
}
|
||||
|
||||
protected void lbtShowTickets_Click(object sender, EventArgs e)
|
||||
{
|
||||
// mostro blocco tickets
|
||||
// !!! FARE FixMe !!! TODO
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Richiesta inserimento ticket supporto
|
||||
/// </summary>
|
||||
@@ -376,105 +469,23 @@ namespace GPW_Admin.WebUserControls
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Public Methods
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Verifica licenza (se sia libera x modifca o prima associazione)
|
||||
/// </summary>
|
||||
/// <param name="idxDIp"></param>
|
||||
/// <returns></returns>
|
||||
public bool checkFreeEdit(object idxDip)
|
||||
private static void fullRefresh()
|
||||
{
|
||||
bool answ = false;
|
||||
int IdxDip = 0;
|
||||
int.TryParse($"{idxDip}", out IdxDip);
|
||||
if (IdxDip > 0)
|
||||
{
|
||||
var localUserList = DataProxy.DP.taDipendenti.getAttivi(false);
|
||||
// cerco!
|
||||
var currUser = localUserList.Where(x => x.idxDipendente == IdxDip).FirstOrDefault();
|
||||
|
||||
// verifico SE sia disponibile licenza...
|
||||
var activationsList = licenzeGPW.ListaAttivazioni;
|
||||
var currHash = DataProxy.DP.hashCodImpiego(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;
|
||||
// eseguo call di recupero da online
|
||||
bool refreshApp = licenzeGPW.RefreshAppInfo().Result;
|
||||
bool refreshAct = licenzeGPW.RefreshActInfo().Result;
|
||||
bool refreshPayload = licenzeGPW.RefreshPayload().Result;
|
||||
//bool refreshLic = licenzeGPW.RefreshLicInfo().Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifica licenza (se sia validata/associata a quelle in memoria)
|
||||
/// </summary>
|
||||
/// <param name="idxDIp"></param>
|
||||
/// <returns></returns>
|
||||
public bool checkLic(object idxDip)
|
||||
private void fixVisibility()
|
||||
{
|
||||
bool answ = false;
|
||||
int IdxDip = 0;
|
||||
int.TryParse($"{idxDip}", out IdxDip);
|
||||
if (IdxDip > 0)
|
||||
{
|
||||
var localUserList = DataProxy.DP.taDipendenti.getAttivi(false);
|
||||
// cerco!
|
||||
var currUser = localUserList.Where(x => x.idxDipendente == IdxDip).FirstOrDefault();
|
||||
|
||||
// verifico SE sia disponibile licenza...
|
||||
var activationsList = licenzeGPW.ListaAttivazioni;
|
||||
var currHash = DataProxy.DP.hashCodImpiego(currUser);
|
||||
var currAct = activationsList.Where(x => x.CodImpiego == currHash).FirstOrDefault();
|
||||
answ = (currAct != null && currAct.CodImpiego == currHash);
|
||||
}
|
||||
return answ;
|
||||
lbtFixMissing.Visible = (numLicenzeOnline == numLicenze && attivazioniOnline != utentiAttivi);
|
||||
grView.PageSize = utils.pageSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// determina se sia eliminabile il record (=non usato)
|
||||
/// </summary>
|
||||
/// <param name="idxMaker"></param>
|
||||
/// <returns></returns>
|
||||
public bool delEnabled(object idxObj)
|
||||
{
|
||||
bool answ = true;
|
||||
// solo se ha diritti scrittura controllo
|
||||
if (idxObj != null)
|
||||
{
|
||||
int trovati = 0;
|
||||
int idxDip = 0;
|
||||
_ = int.TryParse(idxObj.ToString(), out idxDip);
|
||||
trovati = DataProxy.DP.taTimb.getLastByDip(idxDip).Count;
|
||||
// controllo se ci sono record correlati...
|
||||
if (trovati > 0)
|
||||
{
|
||||
answ = false;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public void doUpdate()
|
||||
{
|
||||
fullRefresh();
|
||||
fixVisibility();
|
||||
grView.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// resetta la selezione dei valori in caso di modifiche su altri controlli
|
||||
/// </summary>
|
||||
public void resetSelezione()
|
||||
{
|
||||
grView.SelectedIndex = -1;
|
||||
grView.DataBind();
|
||||
raiseReset();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+47
-38
@@ -1,10 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// <generato automaticamente>
|
||||
// Codice generato da uno strumento.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
|
||||
// il codice viene rigenerato.
|
||||
// </generato automaticamente>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace GPW_Admin.WebUserControls
|
||||
@@ -15,101 +15,110 @@ namespace GPW_Admin.WebUserControls
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// divDB control.
|
||||
/// Controllo divDB.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divDB;
|
||||
|
||||
/// <summary>
|
||||
/// divOnline control.
|
||||
/// Controllo divOnline.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divOnline;
|
||||
|
||||
/// <summary>
|
||||
/// lbtRefresh control.
|
||||
/// Controllo lbtRefresh.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.LinkButton lbtRefresh;
|
||||
|
||||
/// <summary>
|
||||
/// lbtFixMissing control.
|
||||
/// Controllo lbtFixMissing.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.LinkButton lbtFixMissing;
|
||||
|
||||
/// <summary>
|
||||
/// chkshowAll control.
|
||||
/// Controllo lbtShowTickets.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.LinkButton lbtShowTickets;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo chkshowAll.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.CheckBox chkshowAll;
|
||||
|
||||
/// <summary>
|
||||
/// grView control.
|
||||
/// Controllo grView.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.GridView grView;
|
||||
|
||||
/// <summary>
|
||||
/// ods control.
|
||||
/// Controllo ods.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ObjectDataSource ods;
|
||||
|
||||
/// <summary>
|
||||
/// lblNumRec control.
|
||||
/// Controllo lblNumRec.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblNumRec;
|
||||
|
||||
/// <summary>
|
||||
/// odsOrario control.
|
||||
/// Controllo odsOrario.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ObjectDataSource odsOrario;
|
||||
|
||||
/// <summary>
|
||||
/// odsGruppi control.
|
||||
/// Controllo odsGruppi.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ObjectDataSource odsGruppi;
|
||||
|
||||
/// <summary>
|
||||
/// hfReqTicket control.
|
||||
/// Controllo hfReqTicket.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.HiddenField hfReqTicket;
|
||||
}
|
||||
|
||||
+432
-373
@@ -32,74 +32,12 @@ namespace GPW_data
|
||||
private static string rkeyLicInfo = memLayer.ML.redHash($"LiMan:LicInfo");
|
||||
|
||||
private static string rkeyPayload = memLayer.ML.redHash($"LiMan:Payload");
|
||||
private static string rkeyTickets = memLayer.ML.redHash($"LiMan:Tickets");
|
||||
|
||||
private static string rkeyVetoRefPayL = memLayer.ML.redHash($"LiMan:VetoRefPayL");
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Info applicativo corrente (da cache con eventuale recupero online...)
|
||||
/// </summary>
|
||||
private static LiManObj.ApplicativoDTO InfoApplicativo
|
||||
{
|
||||
get
|
||||
{
|
||||
LiManObj.ApplicativoDTO answ = new LiManObj.ApplicativoDTO();
|
||||
// cerco da cache
|
||||
string rawData = memLayer.ML.getRSV(rkeyLicInfo);
|
||||
// se no ci fosse --> refresh online!
|
||||
if (string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var fatto = RefreshAppInfo().Result;
|
||||
if (fatto)
|
||||
{
|
||||
rawData = memLayer.ML.getRSV(rkeyLicInfo);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
try
|
||||
{
|
||||
// verifico se ho 1 risultato o molti...se inizia per "[" è molti
|
||||
if (rawData.StartsWith("["))
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<LiManObj.ApplicativoDTO>(rawData);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache statica locale dati licenza, random circa 1 h
|
||||
/// </summary>
|
||||
private static int LicCacheTTL
|
||||
{
|
||||
get
|
||||
{
|
||||
Random rndGen = new Random();
|
||||
return rndGen.Next(50, 70) * 60;
|
||||
}
|
||||
}
|
||||
|
||||
private static LiManObj.ApplicativoDTO myInfoApplicativo { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -162,11 +100,21 @@ namespace GPW_data
|
||||
/// </summary>
|
||||
public static string modApp => _modApp();
|
||||
|
||||
/// <summary>
|
||||
/// numero di Ticket APERTI
|
||||
/// </summary>
|
||||
public static int numTickets => getNumTickets().Result;
|
||||
|
||||
/// <summary>
|
||||
/// scadenza licenze x applicativo
|
||||
/// </summary>
|
||||
public static DateTime scadenzaLicenza => _scadenzaLicenza();
|
||||
|
||||
/// <summary>
|
||||
/// Elenco dei Ticket da info online
|
||||
/// </summary>
|
||||
public static List<TicketDTO> TicketsList => getTickets().Result;
|
||||
|
||||
/// <summary>
|
||||
/// numero di utenti attivi
|
||||
/// </summary>
|
||||
@@ -174,329 +122,68 @@ namespace GPW_data
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive da info online
|
||||
/// Info applicativo corrente (da cache con eventuale recupero online...)
|
||||
/// </summary>
|
||||
private static int _attivazioniOnline()
|
||||
private static LiManObj.ApplicativoDTO InfoApplicativo
|
||||
{
|
||||
return InfoApplicativo.NumLicenzeAttive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// chaive licenza
|
||||
/// </summary>
|
||||
private static string _authKey()
|
||||
{
|
||||
string answ = "";
|
||||
// controllo su db...
|
||||
try
|
||||
get
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valString;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica se numero licenze copre utenti attivi...
|
||||
/// </summary>
|
||||
private static bool _checkLicenze()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
// effettua refresh attivazioni...
|
||||
var fatto = RefreshActInfo().Result;
|
||||
answ = utentiAttivi <= licenzeAttive;
|
||||
if (!answ && memLayer.ML.confReadInt("_logLevel") > 5)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("WARNING licenze: utenti attivi {0} / licenziati {1}", utentiAttivi, licenzeAttive), tipoLog.WARNING);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica se il payload delle licenze attivate sia valido (con server online)
|
||||
/// </summary>
|
||||
private static bool _checkPayload()
|
||||
{
|
||||
bool answ = false;
|
||||
string currPayload = "";
|
||||
tryCheckPayloadOnline(ref answ, ref currPayload);
|
||||
|
||||
// se OK resetto counter, altrimenti incremento
|
||||
if (!answ)
|
||||
{
|
||||
bool okRefreshPayload = string.IsNullOrEmpty(memLayer.ML.getRSV(rkeyVetoRefPayL));
|
||||
if (okRefreshPayload)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// richiedo update payload impostando TTL a 1 sec...
|
||||
memLayer.ML.setRSV(rkeyPayload, "", 1);
|
||||
var okApp = RefreshAppInfo().Result;
|
||||
var okLic = RefreshActInfo().Result;
|
||||
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");
|
||||
|
||||
sw.Start();
|
||||
tryCheckPayloadOnline(ref answ, ref currPayload);
|
||||
sw.Stop();
|
||||
logger.lg.scriviLog($"Rivalutato payload con esito {answ} in {sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// nome installazione sw
|
||||
/// </summary>
|
||||
private static string _installazione()
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey("installazione")[0].valString;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore recupero chiave installazione da AKV: {0}", exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive sul sw (SE CONFORMI A CHIAVE)
|
||||
/// </summary>
|
||||
private static int _licenzeAttive()
|
||||
{
|
||||
int answ = 0;
|
||||
int licenzeMax = licenseMan.getLicenseNum(installazione, applicazione);
|
||||
// verifico dato su DB sia valido... expiry date con quel numero sia > della data odierna
|
||||
if (scadenzaLicenza >= DateTime.Today)
|
||||
{
|
||||
answ = licenzeDb;
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = licenzeMax;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive su DB (NON verificate!)
|
||||
/// </summary>
|
||||
private static int _licenzeDb()
|
||||
{
|
||||
int answ = 0;
|
||||
// controllo su db...
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valInt;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze disponibili da info online
|
||||
/// </summary>
|
||||
private static int _licenzeOnline()
|
||||
{
|
||||
return InfoApplicativo.NumLicenze;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco attivazioni attuali
|
||||
/// </summary>
|
||||
private static List<LiManObj.AttivazioneDTO> _ListaAttivazioni()
|
||||
{
|
||||
List<LiManObj.AttivazioneDTO> answ = new List<LiManObj.AttivazioneDTO>();
|
||||
// cerco da cache
|
||||
string rawData = memLayer.ML.getRSV(rkeyActInfo);
|
||||
// se no ci fosse --> refresh online!
|
||||
if (string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var fatto = RefreshActInfo().Result;
|
||||
if (fatto)
|
||||
{
|
||||
rawData = memLayer.ML.getRSV(rkeyActInfo);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<List<LiManObj.AttivazioneDTO>>(rawData);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiave Licenza Master
|
||||
/// </summary>
|
||||
private static string _MasterKey()
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valString;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore recupero chiave MasterKey da AKV: {0}", exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modalità applicazione (pagina test.aspx)
|
||||
/// </summary>
|
||||
private static string _modApp()
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey("appMode")[0].valString;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore recupero chiave appMode da AKV: {0}", exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scadenza licenze x applicativo
|
||||
/// </summary>
|
||||
private static DateTime _scadenzaLicenza()
|
||||
{
|
||||
DateTime answ = licenseMan.expiryDateByAuthKey(installazione, applicazione, DataProxy.DP.taAKV.getByKey(installazione)[0].valInt, DataProxy.DP.taAKV.getByKey(installazione)[0].valString);
|
||||
return answ;
|
||||
}
|
||||
|
||||
private static bool _userPayloadOk(int idxDip)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
// recupero riga dip
|
||||
var userTab = DataProxy.DP.taDipendenti.getByIdx(idxDip);
|
||||
if (userTab != null && userTab.Count > 0)
|
||||
{
|
||||
var userRow = userTab[0];
|
||||
// calcolo suo codice...
|
||||
var codImpCurr = DataProxy.DP.hashCodImpiego(userRow);
|
||||
// cerco dip tra elenco json
|
||||
var userLocalList = ListaAttivazioni;
|
||||
var foundRec = userLocalList.Where(x => x.CodImpiego == codImpCurr);
|
||||
answ = foundRec.Count() > 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di utenti attivi
|
||||
/// </summary>
|
||||
private static int _utentiAttivi()
|
||||
{
|
||||
int answ = DataProxy.DP.taDipendenti.getAttivi(false).Count;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calcolo Hash data stringa input
|
||||
/// </summary>
|
||||
/// <param name="rawData"></param>
|
||||
/// <returns></returns>
|
||||
private 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;
|
||||
}
|
||||
|
||||
private static string calcPayload()
|
||||
{
|
||||
string answ = "";
|
||||
// costruisco stringa da elenco impieghi...
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// ciclo tutti gli utenti attivi
|
||||
var localUserList = DataProxy.DP.taDipendenti.getAttivi(false);
|
||||
List<string> codiciImpiego = new List<string>();
|
||||
// ciclo x ogni dip attivo...
|
||||
foreach (var item in localUserList)
|
||||
{
|
||||
codiciImpiego.Add(DataProxy.DP.hashCodImpiego(item));
|
||||
}
|
||||
// riordino
|
||||
var ordList = codiciImpiego.OrderBy(x => x);
|
||||
foreach (var item in ordList)
|
||||
{
|
||||
sb.AppendLine(item);
|
||||
}
|
||||
string rawData = sb.ToString();
|
||||
|
||||
// hashing!
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
byte[] InputBytes = Encoding.UTF8.GetBytes(rawData);
|
||||
var byteHash = md5.ComputeHash(InputBytes);
|
||||
answ = BitConverter.ToString(byteHash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
private static void tryCheckPayloadOnline(ref bool answ, ref string currPayload)
|
||||
{
|
||||
try
|
||||
{
|
||||
// cerco payload licenze locale...
|
||||
currPayload = memLayer.ML.getRSV(rkeyPayload);
|
||||
LiManObj.ApplicativoDTO answ = new LiManObj.ApplicativoDTO();
|
||||
// cerco da cache
|
||||
string rawData = memLayer.ML.getRSV(rkeyLicInfo);
|
||||
// se no ci fosse --> refresh online!
|
||||
if (string.IsNullOrEmpty(currPayload))
|
||||
if (string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
currPayload = calcPayload();
|
||||
memLayer.ML.setRSV(rkeyPayload, currPayload, LicCacheTTL);
|
||||
var fatto = RefreshAppInfo().Result;
|
||||
if (fatto)
|
||||
{
|
||||
rawData = memLayer.ML.getRSV(rkeyLicInfo);
|
||||
}
|
||||
}
|
||||
// confronto payload calc con quello della licenza
|
||||
var currInfo = InfoApplicativo;
|
||||
answ = (InfoApplicativo.Payload == currPayload);
|
||||
// se fallisce --> resetto payload calcolato
|
||||
if (!answ)
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
memLayer.ML.setRSV(rkeyAppInfo, "", 1);
|
||||
memLayer.ML.setRSV(rkeyPayload, "", 1);
|
||||
try
|
||||
{
|
||||
// verifico se ho 1 risultato o molti...se inizia per "[" è molti
|
||||
if (rawData.StartsWith("["))
|
||||
{
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<LiManObj.ApplicativoDTO>(rawData);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
/// <summary>
|
||||
/// Durata cache statica locale dati licenza, random circa 1 h
|
||||
/// </summary>
|
||||
private static int LicCacheTTL
|
||||
{
|
||||
get
|
||||
{
|
||||
Random rndGen = new Random();
|
||||
return rndGen.Next(50, 70) * 60;
|
||||
}
|
||||
}
|
||||
|
||||
private static LiManObj.ApplicativoDTO myInfoApplicativo { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
@@ -911,5 +598,377 @@ namespace GPW_data
|
||||
public static bool userPayloadOk(int idxDip) => _userPayloadOk(idxDip);
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive da info online
|
||||
/// </summary>
|
||||
private static int _attivazioniOnline()
|
||||
{
|
||||
return InfoApplicativo.NumLicenzeAttive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// chaive licenza
|
||||
/// </summary>
|
||||
private static string _authKey()
|
||||
{
|
||||
string answ = "";
|
||||
// controllo su db...
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valString;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica se numero licenze copre utenti attivi...
|
||||
/// </summary>
|
||||
private static bool _checkLicenze()
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
// effettua refresh attivazioni...
|
||||
var fatto = RefreshActInfo().Result;
|
||||
answ = utentiAttivi <= licenzeAttive;
|
||||
if (!answ && memLayer.ML.confReadInt("_logLevel") > 5)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("WARNING licenze: utenti attivi {0} / licenziati {1}", utentiAttivi, licenzeAttive), tipoLog.WARNING);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica se il payload delle licenze attivate sia valido (con server online)
|
||||
/// </summary>
|
||||
private static bool _checkPayload()
|
||||
{
|
||||
bool answ = false;
|
||||
string currPayload = "";
|
||||
tryCheckPayloadOnline(ref answ, ref currPayload);
|
||||
|
||||
// se OK resetto counter, altrimenti incremento
|
||||
if (!answ)
|
||||
{
|
||||
bool okRefreshPayload = string.IsNullOrEmpty(memLayer.ML.getRSV(rkeyVetoRefPayL));
|
||||
if (okRefreshPayload)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
// richiedo update payload impostando TTL a 1 sec...
|
||||
memLayer.ML.setRSV(rkeyPayload, "", 1);
|
||||
var okApp = RefreshAppInfo().Result;
|
||||
var okLic = RefreshActInfo().Result;
|
||||
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");
|
||||
|
||||
sw.Start();
|
||||
tryCheckPayloadOnline(ref answ, ref currPayload);
|
||||
sw.Stop();
|
||||
logger.lg.scriviLog($"Rivalutato payload con esito {answ} in {sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// nome installazione sw
|
||||
/// </summary>
|
||||
private static string _installazione()
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey("installazione")[0].valString;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore recupero chiave installazione da AKV: {0}", exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive sul sw (SE CONFORMI A CHIAVE)
|
||||
/// </summary>
|
||||
private static int _licenzeAttive()
|
||||
{
|
||||
int answ = 0;
|
||||
int licenzeMax = licenseMan.getLicenseNum(installazione, applicazione);
|
||||
// verifico dato su DB sia valido... expiry date con quel numero sia > della data odierna
|
||||
if (scadenzaLicenza >= DateTime.Today)
|
||||
{
|
||||
answ = licenzeDb;
|
||||
}
|
||||
else
|
||||
{
|
||||
answ = licenzeMax;
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze attive su DB (NON verificate!)
|
||||
/// </summary>
|
||||
private static int _licenzeDb()
|
||||
{
|
||||
int answ = 0;
|
||||
// controllo su db...
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valInt;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di licenze disponibili da info online
|
||||
/// </summary>
|
||||
private static int _licenzeOnline()
|
||||
{
|
||||
return InfoApplicativo.NumLicenze;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco attivazioni attuali
|
||||
/// </summary>
|
||||
private static List<LiManObj.AttivazioneDTO> _ListaAttivazioni()
|
||||
{
|
||||
List<LiManObj.AttivazioneDTO> answ = new List<LiManObj.AttivazioneDTO>();
|
||||
// cerco da cache
|
||||
string rawData = memLayer.ML.getRSV(rkeyActInfo);
|
||||
// se no ci fosse --> refresh online!
|
||||
if (string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var fatto = RefreshActInfo().Result;
|
||||
if (fatto)
|
||||
{
|
||||
rawData = memLayer.ML.getRSV(rkeyActInfo);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<List<LiManObj.AttivazioneDTO>>(rawData);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiave Licenza Master
|
||||
/// </summary>
|
||||
private static string _MasterKey()
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey(installazione)[0].valString;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore recupero chiave MasterKey da AKV: {0}", exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// modalità applicazione (pagina test.aspx)
|
||||
/// </summary>
|
||||
private static string _modApp()
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
answ = DataProxy.DP.taAKV.getByKey("appMode")[0].valString;
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
logger.lg.scriviLog(string.Format("Errore recupero chiave appMode da AKV: {0}", exc), tipoLog.EXCEPTION);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// scadenza licenze x applicativo
|
||||
/// </summary>
|
||||
private static DateTime _scadenzaLicenza()
|
||||
{
|
||||
DateTime answ = licenseMan.expiryDateByAuthKey(installazione, applicazione, DataProxy.DP.taAKV.getByKey(installazione)[0].valInt, DataProxy.DP.taAKV.getByKey(installazione)[0].valString);
|
||||
return answ;
|
||||
}
|
||||
|
||||
private static bool _userPayloadOk(int idxDip)
|
||||
{
|
||||
bool answ = false;
|
||||
try
|
||||
{
|
||||
// recupero riga dip
|
||||
var userTab = DataProxy.DP.taDipendenti.getByIdx(idxDip);
|
||||
if (userTab != null && userTab.Count > 0)
|
||||
{
|
||||
var userRow = userTab[0];
|
||||
// calcolo suo codice...
|
||||
var codImpCurr = DataProxy.DP.hashCodImpiego(userRow);
|
||||
// cerco dip tra elenco json
|
||||
var userLocalList = ListaAttivazioni;
|
||||
var foundRec = userLocalList.Where(x => x.CodImpiego == codImpCurr);
|
||||
answ = foundRec.Count() > 0;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// numero di utenti attivi
|
||||
/// </summary>
|
||||
private static int _utentiAttivi()
|
||||
{
|
||||
int answ = DataProxy.DP.taDipendenti.getAttivi(false).Count;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calcolo Hash data stringa input
|
||||
/// </summary>
|
||||
/// <param name="rawData"></param>
|
||||
/// <returns></returns>
|
||||
private 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;
|
||||
}
|
||||
|
||||
private static string calcPayload()
|
||||
{
|
||||
string answ = "";
|
||||
// costruisco stringa da elenco impieghi...
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
// ciclo tutti gli utenti attivi
|
||||
var localUserList = DataProxy.DP.taDipendenti.getAttivi(false);
|
||||
List<string> codiciImpiego = new List<string>();
|
||||
// ciclo x ogni dip attivo...
|
||||
foreach (var item in localUserList)
|
||||
{
|
||||
codiciImpiego.Add(DataProxy.DP.hashCodImpiego(item));
|
||||
}
|
||||
// riordino
|
||||
var ordList = codiciImpiego.OrderBy(x => x);
|
||||
foreach (var item in ordList)
|
||||
{
|
||||
sb.AppendLine(item);
|
||||
}
|
||||
string rawData = sb.ToString();
|
||||
|
||||
// hashing!
|
||||
using (var md5 = MD5.Create())
|
||||
{
|
||||
byte[] InputBytes = Encoding.UTF8.GetBytes(rawData);
|
||||
var byteHash = md5.ComputeHash(InputBytes);
|
||||
answ = BitConverter.ToString(byteHash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera num ticket da sistema LiMan online
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static async Task<int> getNumTickets()
|
||||
{
|
||||
var elenco = await getTickets();
|
||||
var openTickets = elenco
|
||||
.Where(x => x.Status <= StatoRichiesta.Valutazione)
|
||||
.ToList();
|
||||
return await Task.FromResult(openTickets.Count);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera num ticket da sistema LiMan online
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private static async Task<List<TicketDTO>> getTickets()
|
||||
{
|
||||
List<TicketDTO> answ = new List<TicketDTO>();
|
||||
// cerco in cache locale...
|
||||
string rawData = memLayer.ML.getRSV(rkeyTickets);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
answ = JsonConvert.DeserializeObject<List<TicketDTO>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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}", DataFormat.Json);
|
||||
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<List<TicketDTO>>(rawData);
|
||||
// salvo in redis per TTL std
|
||||
memLayer.ML.setRSV(rkeyTickets, rawData, 60);
|
||||
}
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
private static void tryCheckPayloadOnline(ref bool answ, ref string currPayload)
|
||||
{
|
||||
try
|
||||
{
|
||||
// cerco payload licenze locale...
|
||||
currPayload = memLayer.ML.getRSV(rkeyPayload);
|
||||
// se no ci fosse --> refresh online!
|
||||
if (string.IsNullOrEmpty(currPayload))
|
||||
{
|
||||
currPayload = calcPayload();
|
||||
memLayer.ML.setRSV(rkeyPayload, currPayload, LicCacheTTL);
|
||||
}
|
||||
// confronto payload calc con quello della licenza
|
||||
var currInfo = InfoApplicativo;
|
||||
answ = (InfoApplicativo.Payload == currPayload);
|
||||
// se fallisce --> resetto payload calcolato
|
||||
if (!answ)
|
||||
{
|
||||
memLayer.ML.setRSV(rkeyAppInfo, "", 1);
|
||||
memLayer.ML.setRSV(rkeyPayload, "", 1);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user