diff --git a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs index 504225b..4f23db4 100644 --- a/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs +++ b/GPW_Admin/WebUserControls/mod_adminDipendenti.ascx.cs @@ -308,11 +308,54 @@ namespace GPW_Admin.WebUserControls { if (!licenzeGPW.checkLicenze) { - // annullo insert se licenze sforate... + // annullo update se licenze sforate... e.Cancel = true; grView.EditIndex = -1; grView.DataBind(); } + else + { + // disattivo la licenza corrente... + var localUserList = licenzeGPW.getDipAttivi(); + // cerco! + if (e.InputParameters["Original_idxDipendente"] != null) + { + string origIdxDip = $"{e.InputParameters["Original_idxDipendente"]}"; + int idxDip = 0; + int.TryParse(origIdxDip, out idxDip); + if (idxDip > 0) + { + 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(); + + if (currAct != null) + { + // riesegue controllo ed disattiva + Dictionary ParamList = new Dictionary(); + ParamList.Add(currAct.CodImpiego, currAct.Chiave); + bool fatto = licenzeGPW.tryDeactivation(ParamList).Result; + if (fatto) + { + DataProxy.DP.taDipendenti.updateActive(false, idxDip); + } + } + else + { + // annullo update se attivazione NON trovata... + e.Cancel = true; + grView.EditIndex = -1; + grView.DataBind(); + } + + } + } + + + } } } @@ -410,7 +453,7 @@ namespace GPW_Admin.WebUserControls #region Public Methods /// - /// Verifica licenza (se sia libera x modifca o prima associazione) + /// Verifica licenza (se sia libera x modifica o prima associazione) /// /// /// diff --git a/GPW_Data/licenzeGPW.cs b/GPW_Data/licenzeGPW.cs index 216e3fa..6cd0080 100644 --- a/GPW_Data/licenzeGPW.cs +++ b/GPW_Data/licenzeGPW.cs @@ -982,14 +982,14 @@ namespace GPW_data // cerco online RestClient client = new RestClient(apiUrl); //client.Authenticator = new HttpBasicAuthenticator("username", "password"); - var request = new RestRequest($"/api/attivazioni", DataFormat.Json); + var request = new RestRequest($"/api/attivazioni/removeKey", DataFormat.Json); UserLicenseRequest newBody = new UserLicenseRequest() { MasterKey = MasterKey, ParamDict = ParamsList }; request.AddJsonBody(newBody); - var response = client.Delete(request); + var response = client.Post(request); // controllo risposta if (response.StatusCode == System.Net.HttpStatusCode.OK) {