Files
GPW/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.cs
2022-02-03 07:29:11 +01:00

110 lines
2.8 KiB
C#

using GPW_data;
using System;
using System.Linq;
namespace GPW_Admin.WebUserControls
{
public partial class cmp_ticketFreeActiv : BaseUserControl
{
#region Protected Properties
protected string ChiaveUtente
{
get
{
string answ = "";
if (currRowDip != null)
{
answ = currRowDip.authKey;
}
return answ;
}
}
/// <summary>
/// Cod impiego calcolato
/// </summary>
protected string CodImpiego
{
get
{
return DataProxy.DP.hashCodImpiego(currRowDip);
}
}
protected DS_Applicazione.DipendentiRow currRowDip
{
get
{
return DataProxy.DP.getRowDip(idxDipSel);
}
}
protected int idxSubLic
{
get
{
int answ = 0;
// verifico SE sia disponibile licenza...
var activationsList = licenzeGPW.ListaAttivazioni;
var currHash = DataProxy.DP.hashCodImpiego(currRowDip);
var currAct = activationsList.Where(x => x.CodImpiego == currHash).FirstOrDefault();
if (currAct != null)
{
answ = currAct.IdxSubLic;
}
return answ;
}
}
#endregion Protected Properties
#region Public Properties
public int idxDipSel
{
get
{
int answ = 0;
int.TryParse(hfIdxDip.Value, out answ);
return answ;
}
set
{
hfIdxDip.Value = $"{value}";
}
}
#endregion Public Properties
#region Protected Methods
protected void lbtClosePage_Click(object sender, EventArgs e)
{
raiseReset();
}
protected void lbtSendReq_Click(object sender, EventArgs e)
{
// genero nuova authKey x SMART device
var rigaDip = DataProxy.DP.getRowDip(idxDipSel);
if (rigaDip != null)
{
DateTime adesso = DateTime.Now;
// chiama resync dati licenza (cod impiego / codAuth)
bool fatto = licenzeGPW.sendTicketReq(txtRichiedente.Text.Trim(), txtEmail.Text.Trim(), txtPhone.Text.Trim(), txtCausale.Text.Trim(), CodImpiego, idxSubLic).Result;
//chiudo
licenzeGPW.resetTicketCache();
txtCausale.Text = "";
raiseReset();
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
#endregion Protected Methods
}
}