private void PopulateDdlUserRoles() { this.DdlMandateUserRole.Items.Clear(); foreach (OrgRisultatoRicerca r in DelegheManager.GetRolesForUser(this.txtCodiceProprietario.Text)) { this.DdlMandateUserRole.Items.Add(new ListItem(r.DescParent, r.IDParent)); } this.plcRoleDelegate.Visible = true; }
private void searchDeleghe(SearchDelegaInfo searchInfo) { this.SearchDelegheMemento = searchInfo; SearchPagingContext pagingContext = new SearchPagingContext(); pagingContext.PageSize = this.gridViewResult.PageSize; pagingContext.Page = this.SelectedPage; this.ListaDeleghe = DelegheManager.SearchDeleghe(this, searchInfo, ref pagingContext); this.BindGridAndSelect(searchInfo.TipoDelega, searchInfo.StatoDelega); this.buildGridNavigator(pagingContext); }
private void ReadRetValueFromPopup() { if (!string.IsNullOrEmpty(this.proceed_delete.Value)) { //Crea la lista delle deleghe da revocare, dopo averle revocate si ricarica //l'elenco delle deleghe assegnate ArrayList listaDeleghe = new ArrayList(); for (int i = 0; i < this.gridViewResult.Rows.Count; i++) { CheckBox chkSelection = this.gridViewResult.Rows[i].Cells[0].FindControl("cbSel") as CheckBox; if (chkSelection != null && chkSelection.Checked) { DocsPaWR.InfoDelega delega = (DocsPaWR.InfoDelega) this.ListaDeleghe[i]; listaDeleghe.Add(delega); } } string msg = string.Empty; if (DelegheManager.RevocaDelega(this, (DocsPaWR.InfoDelega[])listaDeleghe.ToArray(typeof(DocsPaWR.InfoDelega)), out msg)) { this.fillDeleghe("assegnate", this.MandateDdlState.SelectedValue); } else { string messaggio = string.Empty; if (string.IsNullOrEmpty(msg)) { messaggio = "ErrorMandateBtnDelete"; } else { messaggio = "ErrorCustom"; } this.disabilitaCheckDataGrid(); ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('" + messaggio + "', 'error', '', '" + utils.FormatJs(msg) + "');", true); return; } this.proceed_delete.Value = string.Empty; this.UpPnlButtons.Update(); } if (!string.IsNullOrEmpty(this.NewMandate.ReturnValue)) { this.fillDeleghe("assegnate", this.MandateDdlState.SelectedValue); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "setReturnValue", "SetRetValue('NewMandate','');", true); } if (!string.IsNullOrEmpty(this.EditMandate.ReturnValue)) { this.fillDeleghe("assegnate", this.MandateDdlState.SelectedValue); ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "setReturnValue", "SetRetValue('EditMandate','');", true); } }
/// <summary> /// GESTIONE DELLA SESSIONE: /// ----------------------------------------------------------------------------- /// sia il tool di amministrazione sia Docspa si trovano sotto lo stesso progetto /// quindi hanno in comune il presente Global.asax . /// /// Esiste una sessione denominata "AppWA" che all'accesso del tool di amm.ne /// viene impostata a "ADMIN"; all'accesso di Docspa viene impostata a "DOCSPA". /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Session_End(object sender, EventArgs e) { try { // Reperimento infoutente dalla sessione var infoUtente = UserManager.getInfoUtente(Session); if (infoUtente != null) { if (infoUtente.delegato != null) { if (DelegheManager.DismettiDelega(infoUtente)) { infoUtente = infoUtente.delegato; } } } //ABBATANGELI - Cancello anche eventuali cookie creati da asp.net if (Response.Cookies.Count > 0) { foreach (var lName in Response.Cookies.AllKeys) { if (lName == FormsAuthentication.FormsCookieName || lName.ToLower() == "asp.net_sessionid") { Response.Cookies[lName].Expires = DateTime.Today.AddDays(-1); } } } if (infoUtente != null) { LoginManager.LogOut2( infoUtente.userId, infoUtente.idAmministrazione, Session.SessionID, infoUtente.dst); } } catch (Exception) { // Ignored } }
private void DismettiDelega() { if (DelegheManager.DismettiDelega()) { DocsPaWR.Utente utenteDelegato = UserManager.getUtenteDelegato(); DocsPaWR.Ruolo ruoloDelegato = RoleManager.getRuoloDelegato(); //Ripristino il vecchio infoUtente (del delegato) RoleManager.SetRoleInSession(utenteDelegato.ruoli[0]); UIManager.RegistryManager.SetRFListInSession(UIManager.UserManager.getListaRegistriWithRF(utenteDelegato.ruoli[0].systemId, "1", "")); UIManager.RegistryManager.SetRegAndRFListInSession(UIManager.UserManager.getListaRegistriWithRF(utenteDelegato.ruoli[0].systemId, "", "")); UserManager.SetUserInSession(utenteDelegato); Session.Remove("userDelegato"); Session.Remove("userDataDelegato"); Session.Remove("userRuoloDelegato"); Session["ESERCITADELEGA"] = false; //Rimuovo le notifiche dell'utente delegante per far si che il centro notifiche venga aggiornato correttamente HttpContext.Current.Session.Remove("ListAllNotify"); Response.Redirect("../Index.aspx"); } }
private void ReadRetValueFromPopup() { if (!string.IsNullOrEmpty(this.proceed_permanent.Value)) { if (this.DelegaSel == null) { DocsPaWR.InfoDelega delega = (DocsPaWR.InfoDelega)(ViewState["delega"]); if (DelegheManager.CreaNuovaDelega(delega)) { this.CloseMask(true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateInserting', 'error', '');", true); this.proceed_permanent.Value = string.Empty; this.UpPnlButtons.Update(); } } else { this.Modifica(); } } }
private void Modifica() { string[] valoriRuolo = this.MandateDdlRole.SelectedValue.ToString().Split('_'); string idUtenteOld = ""; string idRuoloOld = ""; string idRuoloDeleganteOld = ""; string tipoDelega = ""; string dataScadenzaOld = ""; string dataDecorrenzaOld = ""; //recupero le informazioni sulla delega che si vuole modificare DocsPaWR.Ruolo ruolo = RoleManager.getRuoloByIdGruppo(RoleManager.getRuoloById(this.DdlMandateUserRole.SelectedValue).idGruppo); if (this.DelegaSel.id_utente_delegato != this.idPeople.Value) { idUtenteOld = this.DelegaSel.id_utente_delegato; this.DelegaSel.id_utente_delegato = this.idPeople.Value; this.DelegaSel.cod_utente_delegato = this.txtCodiceProprietario.Text; } if (this.DelegaSel.id_ruolo_delegato != ruolo.systemId) { idRuoloOld = this.DelegaSel.id_ruolo_delegato; this.DelegaSel.id_ruolo_delegato = ruolo.systemId; this.DelegaSel.cod_ruolo_delegato = ruolo.codiceRubrica; } idRuoloDeleganteOld = this.DelegaSel.id_ruolo_delegante; this.DelegaSel.id_ruolo_delegante = valoriRuolo[0]; if (valoriRuolo[0].ToUpper().Equals("TUTTI")) { this.DelegaSel.id_ruolo_delegante = "0"; } if (idRuoloDeleganteOld.Equals(this.DelegaSel.id_ruolo_delegante)) { idRuoloDeleganteOld = ""; } //this.DelegaSel.cod_ruolo_delegante = ruolo.codiceRubrica; this.DelegaSel.cod_ruolo_delegante = this.MandateDdlRole.SelectedItem.Text; tipoDelega = "I"; DateTime dataDecorrenza = Utils.dateformat.ConvertToDate(this.DelegaSel.dataDecorrenza); DateTime dataScadenza = Utils.dateformat.ConvertToDate(this.DelegaSel.dataScadenza); if (dataDecorrenza < DateTime.Now && (dataScadenza == new DateTime() || dataScadenza > DateTime.Now)) { tipoDelega = "A"; } if (dataScadenza != new DateTime() && dataScadenza < DateTime.Now) { tipoDelega = "S"; } dataScadenzaOld = this.DelegaSel.dataScadenza; dataDecorrenzaOld = this.DelegaSel.dataDecorrenza; string ora; if (this.ddlHourFrom.SelectedIndex == 0) { ora = System.DateTime.Now.Hour.ToString(); } else { ora = this.ddlHourFrom.SelectedValue; } if (ora.Length == 1) { ora = "0" + this.ddlHourFrom.SelectedValue; } if (Convert.ToDateTime(this.txtDateFrom.Text).Date.ToShortDateString().Equals(DateTime.Now.ToShortDateString()) && ora.Equals(DateTime.Now.Hour.ToString())) { this.DelegaSel.dataDecorrenza = Convert.ToDateTime(this.txtDateFrom.Text).Date.ToShortDateString() + " " + ora + "." + (DateTime.Now.Minute).ToString() + ".00"; } else { this.DelegaSel.dataDecorrenza = Convert.ToDateTime(this.txtDateFrom.Text).Date.ToShortDateString() + " " + ora + ".00.00"; } if (this.ddlHourTo.SelectedIndex == 0) { ora = System.DateTime.Now.Hour.ToString(); } else { ora = this.ddlHourTo.SelectedValue; } if (ora.Length == 1) { ora = "0" + this.ddlHourTo.SelectedValue; } if (!string.IsNullOrEmpty(this.txtDateTo.Text)) { this.DelegaSel.dataScadenza = Convert.ToDateTime(this.txtDateTo.Text).Date.ToShortDateString() + " " + ora + ".00.00"; } else { this.DelegaSel.dataScadenza = string.Empty; } if (System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator.Contains(":")) { this.DelegaSel.dataDecorrenza = this.DelegaSel.dataDecorrenza.Replace('.', ':'); this.DelegaSel.dataScadenza = this.DelegaSel.dataScadenza.Replace('.', ':'); } if (DelegaSel.inEsercizio == "1" && tipoDelega.Equals("A")) { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateActiveUpdating', 'warning', '');", true); return; } else { if (DelegheManager.ModificaDelega(this.DelegaSel, tipoDelega, idRuoloOld, idUtenteOld, dataScadenzaOld, dataDecorrenzaOld, idRuoloDeleganteOld)) { this.CloseMask(true); } else { //Se la modifica non è andata a buon fine, ripristino i valori originali this.DelegaSel.dataScadenza = dataScadenzaOld; this.DelegaSel.dataDecorrenza = dataDecorrenzaOld; this.DelegaSel.id_ruolo_delegato = idRuoloOld; this.DelegaSel.id_utente_delegato = idUtenteOld; ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateUpdating', 'error', '');", true); return; } } }
/// <summary> /// Creazione di una nuova delega /// </summary> private void CreaDelega() { DocsPaWR.InfoDelega delega = new DocsPaWR.InfoDelega(); if (this.MandateDdlRole.Items.Count > 1 && this.MandateDdlRole.SelectedIndex == 0) { delega.id_ruolo_delegante = "0"; delega.cod_ruolo_delegante = "TUTTI"; } else { string[] valoriRuolo = this.MandateDdlRole.SelectedValue.ToString().Split('_'); delega.id_ruolo_delegante = valoriRuolo[0]; delega.cod_ruolo_delegante = this.MandateDdlRole.SelectedItem.Text; } delega.id_utente_delegante = UserManager.GetInfoUser().idPeople; DocsPaWR.Corrispondente corr = new DocsPaWR.Corrispondente(); DocsPaWR.Ruolo ruolo = RoleManager.getRuoloByIdGruppo(RoleManager.getRuoloById(this.DdlMandateUserRole.SelectedValue).idGruppo); corr = UserManager.getCorrispondenteByIdPeople(this, UserManager.GetInfoUser().idPeople, DocsPaWR.AddressbookTipoUtente.INTERNO); delega.cod_utente_delegante = corr.codiceRubrica; delega.id_ruolo_delegato = ruolo.systemId; delega.id_uo_delegato = ruolo.uo.systemId; delega.cod_ruolo_delegato = ruolo.codiceRubrica; delega.id_utente_delegato = this.idPeople.Value; delega.cod_utente_delegato = this.txtCodiceProprietario.Text; string ora; if (this.ddlHourFrom.SelectedIndex == 0) { ora = System.DateTime.Now.Hour.ToString(); } else { ora = this.ddlHourFrom.SelectedValue; } if (ora.Length == 1) { ora = "0" + this.ddlHourFrom.SelectedValue; } if (Convert.ToDateTime(this.txtDateFrom.Text).Date.ToShortDateString().Equals(DateTime.Now.ToShortDateString()) && ora.Equals(DateTime.Now.Hour.ToString())) { delega.dataDecorrenza = Convert.ToDateTime(this.txtDateFrom.Text).Date.ToShortDateString() + " " + ora + "." + (DateTime.Now.Minute).ToString() + ".00"; } else { delega.dataDecorrenza = Convert.ToDateTime(this.txtDateFrom.Text).Date.ToShortDateString() + " " + ora + ".00.00"; } if (this.ddlHourTo.SelectedIndex == 0) { ora = System.DateTime.Now.Hour.ToString(); } else { ora = this.ddlHourTo.SelectedValue; } if (ora.Length == 1) { ora = "0" + this.ddlHourTo.SelectedValue; } if (!string.IsNullOrEmpty(this.txtDateTo.Text)) { delega.dataScadenza = Convert.ToDateTime(this.txtDateTo.Text).Date.ToShortDateString() + " " + ora + ".00.00"; } else { delega.dataScadenza = string.Empty; } if (System.Globalization.DateTimeFormatInfo.CurrentInfo.TimeSeparator.Contains(":")) { delega.dataDecorrenza = delega.dataDecorrenza.Replace('.', ':'); delega.dataScadenza = delega.dataScadenza.Replace('.', ':'); } //Verifica che non sia stata già creata una delega nello stesso periodo (univocità dell'assegnazione di responsabilità) if (DelegheManager.VerificaUnicaDelega(delega)) { if (string.IsNullOrEmpty(this.txtDateTo.Text)) { ViewState.Add("delega", delega); ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxConfirmModal", "ajaxConfirmModal('ConfirmMandatePermanent', 'proceed_permanent', '');", true); return; } else { if (DelegheManager.CreaNuovaDelega(delega)) { this.CloseMask(true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateInserting', 'error', '');", true); return; } } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateOverlappingPeriods', 'warning', '');", true); return; } }
private void EsercitaDelega() { GridViewRow item = null; //Ricerca delle delega selezionata che si vuole esercitare for (int i = 0; i < this.gridViewResult.Rows.Count; i++) { RadioButton rbSelection = this.gridViewResult.Rows[i].Cells[0].FindControl("rbSel") as RadioButton; if (rbSelection.Checked) { item = this.gridViewResult.Rows[i]; } } if (item != null) { DocsPaWR.InfoUtente infoUtDelegato = UserManager.GetInfoUser(); //Imposto nuovo utente (delegante) per esercitare la delega DocsPaWR.UserLogin userLogin = new DocsPaWR.UserLogin(); DocsPaWR.Utente utente = DelegheManager.getUtenteById(this, item.Cells[7].Text); userLogin.UserName = utente.userId; userLogin.Password = ""; userLogin.IdAmministrazione = UserManager.GetInfoUser().idAmministrazione; userLogin.IPAddress = this.Request.UserHostAddress; DocsPaWR.LoginResult loginResult; utente = DelegheManager.EsercitaDelega(this, userLogin, item.Cells[11].Text, item.Cells[9].Text, out loginResult); switch (loginResult) { case DocsPaWR.LoginResult.OK: if (utente != null) { utente.urlWA = utils.getHttpFullPath(); //Memorizzo le info sul delegato che serviranno nel momento in cui //si dismette la delega UserManager.setDelegato(infoUtDelegato); DocsPaWR.Utente utenteDelegato = UserManager.GetUserInSession(); DocsPaWR.Ruolo ruoloDelegato = RoleManager.GetRoleInSession(); UserManager.setUtenteDelegato(this, utenteDelegato); RoleManager.setRuoloDelegato(ruoloDelegato); //Nuovo utente (delegante) RoleManager.SetRoleInSession(utente.ruoli[0]); UIManager.RegistryManager.SetRFListInSession(UIManager.UserManager.getListaRegistriWithRF(utente.ruoli[0].systemId, "1", "")); UIManager.RegistryManager.SetRegAndRFListInSession(UIManager.UserManager.getListaRegistriWithRF(utente.ruoli[0].systemId, "", "")); UserManager.SetUserInSession(utente); Session["ESERCITADELEGA"] = true; // disconnessione utente delegante se loggato LoginManager.LogOut(utente.userId, utente.idAmministrazione, this.Session.SessionID); //Rimuovo le notifiche del vecchio utente per far si che il centro notifiche venga aggiornato correttamente HttpContext.Current.Session.Remove("ListAllNotify"); Response.Redirect("../Index.aspx"); } break; case DocsPaWR.LoginResult.USER_ALREADY_LOGGED_IN: ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('WarningMandateUserAlreadyLoggedIn', 'warning', '');", true); break; case DocsPaWR.LoginResult.NO_RUOLI: ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('WarningMandateNoRoles', 'warning', '');", true); break; default: // Application Error ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateGeneral', 'error', '');", true); break; } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "ajaxDialogModal", "ajaxDialogModal('ErrorMandateNoneSelected', 'error', '');", true); } }