diff --git a/GPW_Admin/WebUserControls/cmp_userLicense.ascx b/GPW_Admin/WebUserControls/cmp_userLicense.ascx index 04d3d3e..f15650f 100644 --- a/GPW_Admin/WebUserControls/cmp_userLicense.ascx +++ b/GPW_Admin/WebUserControls/cmp_userLicense.ascx @@ -42,9 +42,9 @@
- Attiva licenza + Attiva Utente Rimuovi licenza - Riassegna licenza + Assegna licenza
diff --git a/GPW_Admin/WebUserControls/cmp_userLicense.ascx.cs b/GPW_Admin/WebUserControls/cmp_userLicense.ascx.cs index 60a6e17..708083e 100644 --- a/GPW_Admin/WebUserControls/cmp_userLicense.ascx.cs +++ b/GPW_Admin/WebUserControls/cmp_userLicense.ascx.cs @@ -70,17 +70,33 @@ namespace GPW_Admin.WebUserControls protected void lbrRelease_Click(object sender, EventArgs e) { // riesegue controllo ed disattiva - DataProxy.DP.taDipendenti.updateActive(false, idxDipSel); + Dictionary ParamList = new Dictionary(); + ParamList.Add(CodImpiego, ChiaveUtente); + bool fatto = licenzeGPW.tryDeactivation(ParamList).Result; + if (fatto) + { + DataProxy.DP.taDipendenti.updateActive(false, idxDipSel); + } frmView.DataBind(); raiseReset(); } protected void lbtActivate_Click(object sender, EventArgs e) { - // riesegue controllo ed attiva - DataProxy.DP.taDipendenti.updateActive(true, idxDipSel); + // verifica SE ci sono licenze disponibili + if (licenzeGPW.licenzeOnline > licenzeGPW.attivazioniOnline) + { + // effettua riassegnazione + bool fatto = licenzeGPW.tryActivation(CodImpiego, ChiaveUtente).Result; + if (fatto) + { + // attiva utente + DataProxy.DP.taDipendenti.updateActive(true, idxDipSel); + } + } + frmView.DataBind(); - raiseReset(); + raiseAddNew(); } protected void lbtReissue_Click(object sender, EventArgs e) @@ -90,13 +106,8 @@ namespace GPW_Admin.WebUserControls { // effettua riassegnazione bool fatto = licenzeGPW.tryActivation(CodImpiego, ChiaveUtente).Result; - if (fatto) - { - bool step1 = licenzeGPW.RefreshAppInfo().Result; - bool step2 = licenzeGPW.RefreshActInfo().Result; - bool step3 = licenzeGPW.RefreshLicInfo().Result; - raiseReset(); - } + frmView.DataBind(); + raiseAddNew(); } } diff --git a/GPW_Admin/WebUserControls/cmp_userLicense.ascx.designer.cs b/GPW_Admin/WebUserControls/cmp_userLicense.ascx.designer.cs index 0486b78..824b9f9 100644 --- a/GPW_Admin/WebUserControls/cmp_userLicense.ascx.designer.cs +++ b/GPW_Admin/WebUserControls/cmp_userLicense.ascx.designer.cs @@ -1,10 +1,10 @@ //------------------------------------------------------------------------------ -// -// Codice generato da uno strumento. +// +// This code was generated by a tool. // -// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se -// il codice viene rigenerato. -// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// //------------------------------------------------------------------------------ namespace GPW_Admin.WebUserControls @@ -15,29 +15,29 @@ namespace GPW_Admin.WebUserControls { /// - /// Controllo frmView. + /// frmView control. /// /// - /// Campo generato automaticamente. - /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.FormView frmView; /// - /// Controllo ods. + /// ods control. /// /// - /// Campo generato automaticamente. - /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. /// protected global::System.Web.UI.WebControls.ObjectDataSource ods; /// - /// Controllo hfIdxDip. + /// hfIdxDip control. /// /// - /// Campo generato automaticamente. - /// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind. + /// 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/mod_adminDipendenti.ascx b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx index 39e985a..7d1b977 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx @@ -9,7 +9,7 @@
-  Licenze locali: disponibili <%: numLicenze %> / attivate <%: utentiAttivi %> +  Licenze locali: disponibili <%: numLicenze %> / utenti attivi <%: utentiAttivi %>
diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs index 0476044..0f0bad0 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs @@ -68,6 +68,12 @@ namespace GPW_Admin.WebUserControls bool refreshAct = licenzeGPW.RefreshActInfo().Result; } + private void fixVisibility() + { + lbtFixMissing.Visible = (numLicenzeOnline == numLicenze && attivazioniOnline != utentiAttivi); + grView.PageSize = utils.pageSize; + } + #endregion Private Methods #region Protected Methods @@ -213,12 +219,16 @@ namespace GPW_Admin.WebUserControls { raiseReset(); } + + // cmq faccio refresh + fullRefresh(); } } protected void lbtRefresh_Click(object sender, EventArgs e) { fullRefresh(); + grView.DataBind(); } /// @@ -251,8 +261,7 @@ namespace GPW_Admin.WebUserControls { fullRefresh(); } - lbtFixMissing.Visible = (numLicenzeOnline == numLicenze && attivazioniOnline != utentiAttivi); - grView.PageSize = utils.pageSize; + fixVisibility(); } /// @@ -374,7 +383,8 @@ namespace GPW_Admin.WebUserControls public void doUpdate() { - grView.PageSize = utils.pageSize; + fullRefresh(); + fixVisibility(); grView.DataBind(); } diff --git a/GPW_Admin/dipendenti.aspx.cs b/GPW_Admin/dipendenti.aspx.cs index 95e2c88..b833b05 100644 --- a/GPW_Admin/dipendenti.aspx.cs +++ b/GPW_Admin/dipendenti.aspx.cs @@ -37,9 +37,16 @@ namespace GPW_Admin fixDisplay(); } + private void Cmp_userLicense_eh_addNew(object sender, EventArgs e) + { + mod_adminDipendenti1.doUpdate(); + fixDisplay(); + } + private void Cmp_userLicense_eh_doReset(object sender, EventArgs e) { //IdxDipSel = 0; + mod_adminDipendenti1.doUpdate(); fixDisplay(); } @@ -92,6 +99,7 @@ namespace GPW_Admin mod_adminDipendenti1.eh_addNew += Mod_adminDipendenti1_eh_addNew; mod_adminDipendenti1.eh_doReset += Mod_adminDipendenti1_eh_doReset; cmp_userLicense.eh_doReset += Cmp_userLicense_eh_doReset; + cmp_userLicense.eh_addNew += Cmp_userLicense_eh_addNew; } #endregion Protected Methods diff --git a/GPW_Data/licenzeGPW.cs b/GPW_Data/licenzeGPW.cs index ae844e2..ae88493 100644 --- a/GPW_Data/licenzeGPW.cs +++ b/GPW_Data/licenzeGPW.cs @@ -16,10 +16,10 @@ namespace GPW_data #region Protected Fields /// - /// Urla di abse chiamate API gestione licenze - /// protected static string apiUrl = "https://localhost:44351/"; + /// Url di base chiamate API gestione licenze /// - protected static string apiUrl = "https://iis01.egalware.com/ELM.API/"; + //protected static string apiUrl = "https://iis01.egalware.com/ELM.API/"; + protected static string apiUrl = "https://localhost:44351/"; /// /// Durata cache statica locale dati licenza @@ -543,6 +543,41 @@ namespace GPW_data return await Task.FromResult(answ); } + /// + /// Tenta disattivazione licenza dato codice impiego + /// + /// Dizionario codici da eliminare (CodImpiego/MasterKey) + /// + public static async Task tryDeactivation(Dictionary ParamsList) + { + bool answ = false; + // cerco attivazione... + var refreshDone = RefreshActInfo().Result; + if (refreshDone) + { + // cerco online + RestClient client = new RestClient(apiUrl); + //client.Authenticator = new HttpBasicAuthenticator("username", "password"); + var request = new RestRequest($"/api/attivazioni", DataFormat.Json); + UserLicenseRequest newBody = new UserLicenseRequest() + { + MasterKey = MasterKey, + ParamDict = ParamsList + }; + request.AddJsonBody(newBody); + var response = client.Delete(request); + // controllo risposta + if (response.StatusCode == System.Net.HttpStatusCode.OK) + { + // verifico risposta + string rawData = response.Content; + bool.TryParse(rawData, out answ); + } + } + + return await Task.FromResult(answ); + } + #endregion Public Methods } } \ No newline at end of file