diff --git a/GPW_Admin/GPW_Admin.csproj b/GPW_Admin/GPW_Admin.csproj index 3dee88a..c03f47a 100644 --- a/GPW_Admin/GPW_Admin.csproj +++ b/GPW_Admin/GPW_Admin.csproj @@ -659,6 +659,7 @@ + @@ -1079,6 +1080,13 @@ cmp_righePag.ascx + + cmp_ticketFreeActiv.ascx + ASPXCodeBehind + + + cmp_ticketFreeActiv.ascx + cmp_toggle.ascx ASPXCodeBehind diff --git a/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx b/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx new file mode 100644 index 0000000..bd28888 --- /dev/null +++ b/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx @@ -0,0 +1,79 @@ +<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_ticketFreeActiv.ascx.cs" Inherits="GPW_Admin.WebUserControls.cmp_ticketFreeActiv" %> + +
+
+ + +
+
+ + + +
+
+ matr: + +
+
+
+
+ nato: + + + + +
+
+ +
+
+
+
+ +
+
+ periodo lavorativo: + + --> + +
+
+ Attivo: + +
+
+
+
+
+
+ Dati richiesta +
+
+ +
+ + <%--
+
--%> +
+ +
+ +
+
+
+ +
+ +
+
+
+
+ Invio richiesta +
+
+ + + + + + \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.cs b/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.cs new file mode 100644 index 0000000..fe965e2 --- /dev/null +++ b/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.cs @@ -0,0 +1,92 @@ +using GPW_data; +using SteamWare; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; + +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; + } + } + + /// + /// Cod impiego calcolato + /// + protected string CodImpiego + { + get + { + return DataProxy.DP.hashCodImpiego(currRowDip); + } + } + + protected DS_Applicazione.DipendentiRow currRowDip + { + get + { + return DataProxy.DP.getRowDip(idxDipSel); + } + } + + #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 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(txtEmail.Text.Trim(), txtPhone.Text.Trim(), txtCausale.Text.Trim(), CodImpiego).Result; + frmView.DataBind(); + raiseAddNew(); + } + } + + protected void Page_Load(object sender, EventArgs e) + { + } + + #endregion Protected Methods + } +} \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.designer.cs b/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.designer.cs new file mode 100644 index 0000000..62e4f49 --- /dev/null +++ b/GPW_Admin/WebUserControls/cmp_ticketFreeActiv.ascx.designer.cs @@ -0,0 +1,80 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace GPW_Admin.WebUserControls +{ + + + public partial class cmp_ticketFreeActiv + { + + /// + /// frmView control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.FormView frmView; + + /// + /// txtEmail control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtEmail; + + /// + /// txtPhone control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtPhone; + + /// + /// txtCausale control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.TextBox txtCausale; + + /// + /// lbtSendReq control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.LinkButton lbtSendReq; + + /// + /// ods control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.ObjectDataSource ods; + + /// + /// hfIdxDip control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfIdxDip; + } +} diff --git a/GPW_Admin/WebUserControls/cmp_userLicense.ascx b/GPW_Admin/WebUserControls/cmp_userLicense.ascx index 56e7821..029e5b2 100644 --- a/GPW_Admin/WebUserControls/cmp_userLicense.ascx +++ b/GPW_Admin/WebUserControls/cmp_userLicense.ascx @@ -3,7 +3,7 @@
-
+
@@ -41,7 +41,7 @@
-
+
Attiva Utente Cessazione Utente Assegna licenza diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx index e4b3e9d..5a9414f 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx @@ -41,8 +41,9 @@ - - + + + @@ -221,7 +222,7 @@ DataValueField="value" /> - @@ -232,7 +233,7 @@ - + --%>
@@ -334,4 +335,5 @@ \ No newline at end of file + TypeName="GPW_data.DS_UtilityTableAdapters.v_selGruppiTableAdapter"> + \ No newline at end of file diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs index d577b9c..68bc8e4 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs @@ -33,6 +33,20 @@ namespace GPW_Admin.WebUserControls } } + public bool isTicketReq + { + get + { + bool answ = false; + bool.TryParse(hfReqTicket.Value, out answ); + return answ; + } + set + { + hfReqTicket.Value = $"{value}"; + } + } + public int numLicenze { get => licenzeGPW.licenzeAttive; @@ -104,6 +118,7 @@ namespace GPW_Admin.WebUserControls /// protected void btnReset_Click(object sender, EventArgs e) { + isTicketReq = false; resetSelezione(); } @@ -164,7 +179,7 @@ namespace GPW_Admin.WebUserControls protected void grView_SelectedIndexChanged(object sender, EventArgs e) { - // mostro gestione licenza DIP + // altrimenti mostro gestione licenza DIP raiseAddNew(); } @@ -232,6 +247,26 @@ namespace GPW_Admin.WebUserControls grView.DataBind(); } + /// + /// Richiesta selezione utente + /// + /// + /// + protected void lbtSelect_Click(object sender, EventArgs e) + { + isTicketReq = false; + } + + /// + /// Richiesta inserimento ticket supporto + /// + /// + /// + protected void lbtTicket_Click(object sender, EventArgs e) + { + isTicketReq = true; + } + /// /// check licenze in fase di update... /// @@ -260,6 +295,7 @@ namespace GPW_Admin.WebUserControls { if (!Page.IsPostBack) { + isTicketReq = false; fullRefresh(); } fixVisibility(); @@ -342,6 +378,37 @@ namespace GPW_Admin.WebUserControls #region Public Methods + /// + /// Verifica licenza (se sia libera x modifca o prima associazione) + /// + /// + /// + public bool checkFreeEdit(object idxDip) + { + 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; + } + /// /// Verifica licenza (se sia validata/associata a quelle in memoria) /// diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.designer.cs b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.designer.cs index f830949..991d9d7 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.designer.cs +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.designer.cs @@ -103,5 +103,14 @@ namespace GPW_Admin.WebUserControls /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.ObjectDataSource odsGruppi; + + /// + /// hfReqTicket control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.HiddenField hfReqTicket; } } diff --git a/GPW_Admin/dipendenti.aspx b/GPW_Admin/dipendenti.aspx index e2475e1..4f7f265 100644 --- a/GPW_Admin/dipendenti.aspx +++ b/GPW_Admin/dipendenti.aspx @@ -5,6 +5,7 @@ <%@ Register Src="~/WebUserControls/cmp_userCard.ascx" TagPrefix="uc1" TagName="cmp_userCard" %> <%@ Register Src="~/WebUserControls/cmp_toggle.ascx" TagPrefix="uc1" TagName="cmp_toggle" %> <%@ Register Src="~/WebUserControls/cmp_userLicense.ascx" TagPrefix="uc1" TagName="cmp_userLicense" %> +<%@ Register Src="~/WebUserControls/cmp_ticketFreeActiv.ascx" TagPrefix="uc1" TagName="cmp_ticketFreeActiv" %>
@@ -23,6 +24,7 @@
+
diff --git a/GPW_Admin/dipendenti.aspx.cs b/GPW_Admin/dipendenti.aspx.cs index b833b05..acfd8ad 100644 --- a/GPW_Admin/dipendenti.aspx.cs +++ b/GPW_Admin/dipendenti.aspx.cs @@ -59,17 +59,28 @@ namespace GPW_Admin cmp_userCard.showAll = mod_adminDipendenti1.showAll; cmp_userCard.showExt = cmp_toggleLinkExt.toggleValue; cmp_userLicense.Visible = IdxDipSel > 0; + cmp_ticketFreeActiv.Visible = cmp_ticketFreeActiv.idxDipSel > 0; } private void Mod_adminDipendenti1_eh_addNew(object sender, EventArgs e) { - IdxDipSel = mod_adminDipendenti1.IdxDipSel; + if (mod_adminDipendenti1.isTicketReq) + { + IdxDipSel = 0; + cmp_ticketFreeActiv.idxDipSel = mod_adminDipendenti1.IdxDipSel; + } + else + { + IdxDipSel = mod_adminDipendenti1.IdxDipSel; + cmp_ticketFreeActiv.idxDipSel = 0; + } fixDisplay(); } private void Mod_adminDipendenti1_eh_doReset(object sender, EventArgs e) { IdxDipSel = 0; + cmp_ticketFreeActiv.idxDipSel = 0; fixDisplay(); } diff --git a/GPW_Admin/dipendenti.aspx.designer.cs b/GPW_Admin/dipendenti.aspx.designer.cs index 7472f0a..0946717 100644 --- a/GPW_Admin/dipendenti.aspx.designer.cs +++ b/GPW_Admin/dipendenti.aspx.designer.cs @@ -41,6 +41,15 @@ namespace GPW_Admin /// protected global::GPW_Admin.WebUserControls.cmp_userLicense cmp_userLicense; + /// + /// cmp_ticketFreeActiv control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::GPW_Admin.WebUserControls.cmp_ticketFreeActiv cmp_ticketFreeActiv; + /// /// mod_adminDipendenti1 control. /// diff --git a/GPW_Data/ObjLicenze.cs b/GPW_Data/ObjLicenze.cs index 9e65411..3d9871f 100644 --- a/GPW_Data/ObjLicenze.cs +++ b/GPW_Data/ObjLicenze.cs @@ -10,6 +10,19 @@ namespace GPW_data { #region Public Enums + public enum StatoRichiesta + { + ND = 0, + + Richiesta, + + Valutazione, + + Approvata, + + Rifiutata + } + public enum TipoLicenza { ND = 0, @@ -95,6 +108,97 @@ namespace GPW_data #endregion Public Properties } + public class SupportRequest + { + #region Public Properties + + public string CodApp { get; set; } = ""; + public string CodImp { get; set; } = ""; + public string CodInst { get; set; } = ""; + public string ContactEmail { get; set; } = ""; + public string ContactPhone { get; set; } = ""; + public int idxSubLic { get; set; } = 0; + + public bool IsValid + { + get => !string.IsNullOrEmpty(MasterKey) && !string.IsNullOrEmpty(ContactEmail) && !string.IsNullOrEmpty(CodInst) && !string.IsNullOrEmpty(CodApp); + } + + public string MasterKey { get; set; } = ""; + public string ReqBody { get; set; } = ""; + + #endregion Public Properties + } + + /// + /// Oggetto Ticket + /// + public class TicketDTO + { + #region Public Properties + + /// + /// Codice univoco della sub licenza (opzionale) + /// + public string CodImpiego { get; set; } = ""; + + /// + /// Contatto email del cliente richiedente + /// + public string ContactEmail { get; set; } = ""; + + /// + /// Contatto telefonico del cliente richiedente + /// + public string ContactPhone { get; set; } = ""; + + public DateTime DtReq { get; set; } = DateTime.Now; + + /// + /// IDX licenza master + /// + public int IdxLic { get; set; } = 0; + + /// + /// IDX licenza child (opzionale) + /// + public int IdxSubLic { get; set; } = 0; + + public int IdxTicket { get; set; } = 0; + + /// + /// Motivazione della richiesta + /// + public string ReqBody { get; set; } = ""; + + /// + /// Stato richiesta + /// + public StatoRichiesta Status { get; set; } = StatoRichiesta.ND; + + /// + /// Risposta alla richiesta + /// + public string SupplAnsw { get; set; } = ""; + + /// + /// Email del responsabile dell'azione (interno - supplier) + /// + public string SupplEmail { get; set; } = ""; + + /// + /// Cod dell'user responsabile dell'azione (interno - supplier) + /// + public string SupplUserCode { get; set; } = ""; + + /// + /// Tipologia di licenza gestita + /// + public TipoLicenza Tipo { get; set; } = TipoLicenza.UserKey; + + #endregion Public Properties + } + public class UserLicenseRequest { #region Public Properties diff --git a/GPW_Data/licenzeGPW.cs b/GPW_Data/licenzeGPW.cs index 8195e31..d186603 100644 --- a/GPW_Data/licenzeGPW.cs +++ b/GPW_Data/licenzeGPW.cs @@ -680,6 +680,64 @@ namespace GPW_data return await Task.FromResult(answ); } + /// + /// Tenta invio di un ticket x licenza indicata + /// + /// + /// + /// + /// + /// + /// + public static async Task sendTicketReq(string contEmail, string contPhone, string reqBody, string codImpiego, int idxSubLic = 0) + { + bool answ = false; + // cerco online + RestClient client = new RestClient(apiUrl); + string MKeyEnc = HttpUtility.UrlEncode(MasterKey); + var request = new RestRequest($"/api/ticket/sendReq", DataFormat.Json); + + SupportRequest richiesta = new SupportRequest() + { + ContactEmail = contEmail, + ContactPhone = contPhone, + ReqBody = reqBody, + CodInst = installazione, + CodApp = applicazione, + MasterKey = MasterKey, + idxSubLic = idxSubLic, + CodImp = codImpiego + }; + + 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 + { } + } + return await Task.FromResult(answ); + } + /// /// Tenta attivazione licenza dato codice impiego ///