private bool IsMap() { Classi.Utente _Utente = new TheSite.Classi.Utente(Context.User.Identity.Name); DataSet Ds = _Utente.GetMap(); if (Ds.Tables[0].Rows.Count > 0) { if (Ds.Tables[0].Rows[0]["FUNZIONE_ID"] != DBNull.Value) { FunId = Ds.Tables[0].Rows[0]["FUNZIONE_ID"].ToString(); } if (Ds.Tables[0].Rows[0]["LETTURA"] != DBNull.Value) { return((int.Parse(Ds.Tables[0].Rows[0]["LETTURA"].ToString()) == -1)?true:false); } else { return(false); } } else { return(false); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnsElimina_Click(object sender, System.EventArgs e) { this.txtsCognome.DBDefaultValue = DBNull.Value; this.txtsNome.DBDefaultValue = DBNull.Value; this.txtsEmail.DBDefaultValue = DBNull.Value; this.txtsTelefono.DBDefaultValue = DBNull.Value; this.txtsPassword.DBDefaultValue = " "; int i_RowsAffected = 0; Classi.Utente _Utente = new TheSite.Classi.Utente(); S_Controls.Collections.S_ControlsCollection _SCollection = new S_Controls.Collections.S_ControlsCollection(); _SCollection.AddItems(this.PanelEdit.Controls); try { i_RowsAffected = _Utente.Delete(_SCollection, itemId); if (i_RowsAffected == -1) { Response.Redirect((String)ViewState["UrlReferrer"]); } } catch { string s_Err = "Errore: cancellazione non riuscita"; PanelMess.ShowError(s_Err, true); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BttConferma_Click(object sender, System.EventArgs e) { Classi.Sicurezza _Sic = new Classi.Sicurezza(); Classi.Utente _Utente = new TheSite.Classi.Utente(); txtsPasword.Text = _Sic.EncryptMD5(txtsPasword.Text); //txtsPasword.Text = _Sic.EncryptSHA1(txtsPasword.Text); try { int i_IdUtente = _Utente.Login(this); if (i_IdUtente > 0) { string url = FormsAuthentication.GetRedirectUrl(txtsUserName.Text, false); // FormsAuthentication.SetAuthCookie(txtsUserName.Text,false); // // Response.Redirect(url); string[] a_roles = _Utente.GetRuoli(txtsUserName.Text); string roleStr = ""; double ore = 8; foreach (String role in a_roles) { //if(role.ToUpper()=="CALLCENTER") // ore=8; roleStr += role; roleStr += ";"; } FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, txtsUserName.Text, DateTime.Now, // issue time DateTime.Now.AddHours(ore), // expires every hour false, // don't persist cookie roleStr, // roles FormsAuthentication.FormsCookiePath); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(ticket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); // Redirect back to original URL. Response.Redirect(url); } else { PanelMess.ShowError("Utenza o Password errati", true); } } catch (Exception ex) { Console.WriteLine(ex.Message); //PanelMess.ShowError("Errore interno al Data Base.", true); PanelMess.ShowError(ex.Message.ToString(), true); } }
private void Page_Load(object sender, System.EventArgs e) { try { user.Text = Request.Params["user"]; password.Text = Request.Params["password"]; //user.Text="callcenter"; //password.Text="callcenter01"; usr = Request.Params["user"]; //usr="******"; Sicurezza sic = new Sicurezza(); pwd = sic.EncryptMD5(Request.Params["password"]); //pwd=sic.EncryptMD5("callcenter01"); /*PROCEDURE SP_AUTENTICA_UTENTI (p_UserName in varchar2, * p_Password in varchar2, * IO_CURSOR IN OUT T_CURSOR)*/ S_ControlsCollection _SColl = new S_ControlsCollection(); S_Controls.Collections.S_Object UserName = new S_Object(); UserName.ParameterName = "p_UserName"; UserName.DbType = CustomDBType.VarChar; UserName.Size = 50; UserName.Direction = ParameterDirection.Input; UserName.Value = usr; UserName.Index = 0; _SColl.Add(UserName); S_Controls.Collections.S_Object Password = new S_Object(); Password.ParameterName = "p_Password"; Password.DbType = CustomDBType.VarChar; Password.Size = 50; Password.Direction = ParameterDirection.Input; Password.Value = pwd; Password.Index = 1; _SColl.Add(Password); Classi.Utente _Utente = new TheSite.Classi.Utente(); int res = _Utente.Login(_SColl); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("autenticato", res.ToString()); } catch (Exception exc) { lblH.Text = exc.ToString(); } }
/// <summary> /// Popola le listbox dei ruoli /// </summary> private void AggiornaListBox() { _DsListBox = new DataSet(); this.CreaTabelle(); if (itemId > 0) { Classi.Utente _Utente = new TheSite.Classi.Utente(); DataView o_Dv = new DataView(_Utente.GetRuoli(itemId).Tables[0]); if (o_Dv.Count > 0) { foreach (DataRowView o_Drv in o_Dv) { DataRow o_Dr = _DsListBox.Tables["UtentiRuoli"].NewRow(); o_Dr["Id"] = o_Drv["RUOLO_ID"].ToString(); o_Dr["Ruolo"] = o_Drv["DESCRIZIONE"].ToString(); o_Dr["IdUtente"] = o_Drv["UTENTE_ID"].ToString(); _DsListBox.Tables["UtentiRuoli"].Rows.Add(o_Dr); } } } Session.Add("UtentiRuoli", _DsListBox.Tables["UtentiRuoli"]); this.ListBoxRight.DataSource = _DsListBox.Tables["UtentiRuoli"]; this.ListBoxRight.DataValueField = "Id"; this.ListBoxRight.DataTextField = "Ruolo"; this.ListBoxRight.DataBind(); this.ListBoxRight.SelectedIndex = 0; Classi.Ruolo _Ruolo = new TheSite.Classi.Ruolo(); DataView o_DvRuoli = new DataView(_Ruolo.GetData().Tables[0]); if (o_DvRuoli.Count > 0) { foreach (DataRowView o_DrvR in o_DvRuoli) { if (ListBoxRight.Items.FindByValue(o_DrvR["ID"].ToString()) == null) { DataRow o_DrR = _DsListBox.Tables["Ruoli"].NewRow(); o_DrR["Id"] = o_DrvR["ID"].ToString(); o_DrR["Ruolo"] = o_DrvR["DESCRIZIONE"].ToString(); _DsListBox.Tables["Ruoli"].Rows.Add(o_DrR); } } } this.ListBoxLeft.DataSource = _DsListBox.Tables["Ruoli"]; this.ListBoxLeft.DataValueField = "Id"; this.ListBoxLeft.DataTextField = "Ruolo"; this.ListBoxLeft.DataBind(); this.ListBoxLeft.SelectedIndex = 0; }
/// <summary> /// Aggiorna i ruoli associati all'utente. /// </summary> /// <param name="UpdateDataTable"></param> private void UpdateRuoli(DataTable UpdateDataTable) { foreach (DataRow dr in UpdateDataTable.Rows) { if (dr["Operazione"] != DBNull.Value) { Classi.Utente _Utente = new TheSite.Classi.Utente(); try { S_Controls.Collections.S_ControlsCollection _SColl = new S_Controls.Collections.S_ControlsCollection(); S_Controls.Collections.S_Object s_UtenteId = new S_Controls.Collections.S_Object(); s_UtenteId.ParameterName = "p_Utente_Id"; s_UtenteId.DbType = ApplicationDataLayer.DBType.CustomDBType.Integer; s_UtenteId.Direction = ParameterDirection.Input; s_UtenteId.Index = 0; s_UtenteId.Value = Convert.ToInt32(dr["IdUtente"].ToString()); S_Controls.Collections.S_Object s_RuoloId = new S_Controls.Collections.S_Object(); s_RuoloId.ParameterName = "p_Ruolo_Id"; s_RuoloId.DbType = ApplicationDataLayer.DBType.CustomDBType.Integer; s_RuoloId.Direction = ParameterDirection.Input; s_RuoloId.Index = 1; s_RuoloId.Value = Convert.ToInt32(dr["Id"].ToString()); _SColl.Add(s_UtenteId); _SColl.Add(s_RuoloId); Classi.ExecuteType Operazione; if (dr["Operazione"].ToString() == "I") { Operazione = Classi.ExecuteType.Insert; } else { Operazione = Classi.ExecuteType.Delete; } _Utente.UpdateRuoli(_SColl, Operazione); } catch { string s_Err = "Errore: aggiornamento non riuscito"; PanelMess.ShowError(s_Err, true); } } } }
private void changePwd() { if (!IsUtente()) { PanelMess.ShowError("Non hai inserito la Tua Password!", true); return; } // // if (txtsNewPasword.Text.Length==8) // { // PanelMess.ShowError("La Password deve essere almeno di 8 caratteri!", true); // } Classi.Sicurezza _Sicurezza = new Classi.Sicurezza(); Classi.Utente _Utente = new TheSite.Classi.Utente(); this.txtsNewPasword.Text = _Sicurezza.EncryptMD5(this.txtsNewPasword.Text); S_ControlsCollection _SColl = new S_ControlsCollection(); S_Controls.Collections.S_Object s_p_Utente_Id = new S_Object(); s_p_Utente_Id.ParameterName = "p_Utente_Id"; s_p_Utente_Id.DbType = CustomDBType.Integer; s_p_Utente_Id.Direction = ParameterDirection.Input; s_p_Utente_Id.Index = 0; s_p_Utente_Id.Value = i_IdUtente; _SColl.Add(s_p_Utente_Id); S_Controls.Collections.S_Object s_p_Password = new S_Object(); s_p_Password.ParameterName = "p_Password"; s_p_Password.DbType = CustomDBType.VarChar; s_p_Password.Direction = ParameterDirection.Input; s_p_Password.Index = 1; s_p_Password.Size = 50; s_p_Password.Value = this.txtsNewPasword.Text; _SColl.Add(s_p_Password); i_IdUtente = _Utente.ChangePassword(_SColl); if (i_IdUtente > 0) { PanelMess.ShowMessage("Cambio Password completato con successo!", true); } else { PanelMess.ShowError("Errore nel cambio della Password!", true); } }
private void btnsRicerca_Click(object sender, System.EventArgs e) { Classi.Utente _Utente = new TheSite.Classi.Utente(); this.txtsUserName.DBDefaultValue = "%"; this.txtsCognome.DBDefaultValue = "%"; this.txtsNome.DBDefaultValue = "%"; this.txtsEmail.DBDefaultValue = "%"; this.txtsTelefono.DBDefaultValue = "%"; S_ControlsCollection _SCollection = new S_ControlsCollection(); _SCollection.AddItems(this.PanelRicerca.Controls); DataSet _MyDs = _Utente.GetData(_SCollection).Copy(); this.DataGridRicerca.DataSource = _MyDs.Tables[0]; this.DataGridRicerca.DataBind(); this.GridTitle1.NumeroRecords = _MyDs.Tables[0].Rows.Count.ToString(); }
/// <summary> /// Verifica che l'utente corrente abbia inserito la propria password /// Ritorna True se è l'utente corrente in caso contrario false. /// </summary> private bool IsUtente() { Classi.Sicurezza _Sic = new Classi.Sicurezza(); Classi.Utente _Utente = new TheSite.Classi.Utente(); txtsPasword.Text = _Sic.EncryptMD5(txtsPasword.Text); string UserName = Context.User.Identity.Name; S_ControlsCollection _SColl = new S_ControlsCollection(); S_Controls.Collections.S_Object s_p_UserName = new S_Object(); s_p_UserName.ParameterName = "p_UserName"; s_p_UserName.DbType = CustomDBType.VarChar; s_p_UserName.Direction = ParameterDirection.Input; s_p_UserName.Index = 0; s_p_UserName.Size = 50; s_p_UserName.Value = UserName; _SColl.Add(s_p_UserName); S_Controls.Collections.S_Object s_p_Password = new S_Object(); s_p_Password.ParameterName = "p_Password"; s_p_Password.DbType = CustomDBType.VarChar; s_p_Password.Direction = ParameterDirection.Input; s_p_Password.Index = 1; s_p_Password.Size = 50; s_p_Password.Value = txtsPasword.Text; _SColl.Add(s_p_Password); i_IdUtente = _Utente.Login(_SColl); if (i_IdUtente > 0) { return(true); } else { return(false); } }
private void Page_Load(object sender, System.EventArgs e) { FunId = Int32.Parse(Request.Params["FunId"]); // // Verify that the current user has access to edit this module // if (PortalSecurity.HasEditPermissions(moduleId) == false) // { // Response.Redirect("~/Admin/EditAccessDenied.aspx"); // } if (Request.Params["ItemId"] != null) { itemId = Int32.Parse(Request.Params["ItemId"]); } if (!Page.IsPostBack) { if (itemId != 0) { Classi.Utente _Utente = new TheSite.Classi.Utente(); DataSet _MyDs = _Utente.GetSingleData(itemId).Copy(); if (_MyDs.Tables[0].Rows.Count == 1) { DataRow _Dr = _MyDs.Tables[0].Rows[0]; this.txtsUserName.Text = (string)_Dr["USERNAME"]; if (_Dr["COGNOME"] != DBNull.Value) { this.txtsCognome.Text = (string)_Dr["COGNOME"]; } if (_Dr["NOME"] != DBNull.Value) { this.txtsNome.Text = (string)_Dr["NOME"]; } if (_Dr["EMAIL"] != DBNull.Value) { this.txtsEmail.Text = (string)_Dr["EMAIL"]; } if (_Dr["TELEFONO"] != DBNull.Value) { this.txtsTelefono.Text = (string)_Dr["TELEFONO"]; } this.lblFirstAndLast.Text = _Utente.GetFirstAndLastUser(_Dr); if (_Dr["id_progetto"] != DBNull.Value) { BindProgetti(int.Parse(_Dr["id_progetto"].ToString())); } else { BindProgetti(0); } this.AggiornaListBox(); // this.txtsPassword.Enabled=false; // this.txtConfermaPassword.Enabled=false; this.lblOperazione.Text = "Modifica"; this.lblFirstAndLast.Visible = true; this.ListBoxLeft.Enabled = true; this.ListBoxRight.Enabled = true; this.btnAssocia.Enabled = true; this.btnElimina.Enabled = true; this.btnsElimina.Visible = true; this.btnsElimina.Attributes.Add("onclick", "return confirm('Si vuole effettuare la cancellazione?')"); } } else { this.lblOperazione.Text = "Nuovo"; this.lblFirstAndLast.Visible = false; this.btnsElimina.Visible = false; this.txtsPassword.Text = "PASSWORD"; this.txtConfermaPassword.Text = txtsPassword.Text; BindProgetti(0); } ViewState["UrlReferrer"] = Request.UrlReferrer.ToString(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnsSalva_Click(object sender, System.EventArgs e) { Classi.Sicurezza _Sicurezza = new Classi.Sicurezza(); this.txtsCognome.DBDefaultValue = DBNull.Value; this.txtsNome.DBDefaultValue = DBNull.Value; this.txtsEmail.DBDefaultValue = DBNull.Value; this.txtsTelefono.DBDefaultValue = DBNull.Value; this.txtsPassword.DBDefaultValue = " "; // if (itemId == 0) // this.txtsPassword.Text = _Sicurezza.EncryptSHA1(this.txtsPassword.Text); if (itemId == 0) { this.txtsPassword.Text = _Sicurezza.EncryptMD5(this.txtsPassword.Text); } else if (this.txtsPassword.Text != "") { this.txtsPassword.Text = _Sicurezza.EncryptMD5(this.txtsPassword.Text); } int i_RowsAffected = 0; Classi.Utente _Utente = new TheSite.Classi.Utente(); S_Controls.Collections.S_ControlsCollection _SCollection = new S_Controls.Collections.S_ControlsCollection(); _SCollection.AddItems(this.PanelEdit.Controls); try { if (itemId == 0) { i_RowsAffected = _Utente.Add(_SCollection); } else { i_RowsAffected = _Utente.Update(_SCollection, itemId); } if (i_RowsAffected > 0) { if (this.ListBoxRight.Items.Count > 0) { DataTable o_Dt = (DataTable)Session["UtentiRuoli"]; DataView o_Dv = new DataView(o_Dt); foreach (ListItem o_Litem in this.ListBoxRight.Items) { o_Dv.RowFilter = "Id = " + o_Litem.Value.ToString(); if (o_Dv.Count == 0) { DataRow o_Dr = o_Dt.NewRow(); o_Dr["Id"] = o_Litem.Value.ToString(); o_Dr["Ruolo"] = o_Litem.Text.ToString(); o_Dr["IdUtente"] = i_RowsAffected; o_Dr["Operazione"] = "I"; o_Dt.Rows.Add(o_Dr); } else if (o_Dv.Count == 1) { o_Dv[0]["Operazione"] = DBNull.Value; } } this.UpdateRuoli(o_Dt); Session.Remove("UtentiRuoli"); } Response.Redirect((String)ViewState["UrlReferrer"]); } } catch (Exception ex) { string s_Err = "Errore: "; if (ex.Message.Substring(0, 8) == "ORA-00001") { s_Err += " nome utente già presente"; } else { s_Err += " aggiornamento non riuscito"; } PanelMess.ShowError(s_Err, true); } }