示例#1
0
        protected void LinkBackAdmin_Click(object sender, EventArgs e)
        {
            try
            {
                objUtente.Read(" WHERE UTE_ID_UTENTE = " + Convert.ToInt32(Session["UTE_ID_UTENTE_LAST"].ToString()));
                Session["UTE_ID_UTENTE"]  = objUtente.Ute_id_utente.ToString();
                Session["UTE_COGNOME"]    = objUtente.Ute_cognome.ToString();
                Session["UTE_NOME"]       = objUtente.Ute_nome.ToString();
                Session["UTE_SIGLA"]      = objUtente.Ute_sigla.ToString();
                Session["CLI_ID_CLIENTE"] = objUtente.Cli_id_cliente.ToString();
                Session["IMPERSONATE"]    = "0";

                Dictionary <string, int> dizionarioPermessi = objUtente.BuildPermissions();
                Session["dizionarioPermessi"] = dizionarioPermessi;

                string strScript = @"<script type='text/javascript'>
                                        self.location.href='/Web/Home/mainpage.aspx';
                                     </script>";

                if (!Page.ClientScript.IsClientScriptBlockRegistered("Alert_JS"))
                {
                    Page.ClientScript.RegisterClientScriptBlock(GetType(), "Alert_JS", strScript);
                }
            }
            catch (Exception ex)
            {
                // Gestione messaggistica all'utente e trace in DB dell'errore
                if (!ex.Data.Contains("Class.Method"))
                {
                    ex.Data.Add("Class.Method", "Web_frm_MSU_CDC.ButtonSalva_Click.");
                }
                ExceptionPolicy.HandleException(ex, "Propagate Policy");
            }
        }
示例#2
0
 private void BindData()
 {
     try
     {
         objUtente.Ute_id_utente = qUTE_ID_UTENTE;
         objUtente.Read();
         GetValues();
     }
     catch (Exception ex)
     {
         // Gestione messaggistica all'utente e trace in DB dell'errore
         ExceptionPolicy.HandleException(ex, "Propagate Policy");
     }
 }
示例#3
0
        /// <summary>
        /// Renderizza il footer comune a tutte le pagine.
        /// </summary>
        /// <returns></returns>
        public string renderFooter()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div class='footerSDG'>&copy; SDG " + DateTime.Today.Year + "</div>");

            #region Logo

            Utente  objUtente  = new Utente();
            Clienti objClienti = new Clienti();

            int versione = 0;
            objUtente.Ute_id_utente = Convert.ToInt32(Session["UTE_ID_UTENTE"]);
            objUtente.Read();

            objClienti.Read(objUtente.Cli_id_cliente.ToSqlInt16(), "it");
            versione = objClienti.Cli_versione_reporting.Value;

            if (!objClienti.Cli_logo_cliente.IsNull && objClienti.Cli_logo_cliente.ToString() != "" && !isMobile())
            {
                sb.Append("<div class='footerCliente'><img src='../Images/Loghi/" + objClienti.Cli_logo_cliente.ToString() + "' alt='" + objClienti.Cli_ragione_sociale.ToString() + "' /></div>");
            }

            #endregion

            return(sb.ToString());
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            qMODALITA    = Request.QueryString["MODALITA"];
            qPROVENIENZA = Request.QueryString["PROVENIENZA"];

            //qRUL_ID_RUOLO = Convert.ToInt32(Request.QueryString["RUL_ID_RUOLO"]);
            qUTE_ID_UTENTE = Convert.ToInt32(Request.QueryString["UTE_ID_UTENTE"]);

            if (Request.QueryString["URL_ID_RUOLI_UTENTE"] != null)
            {
                qURL_ID_RUOLI_UTENTE = Convert.ToInt32(Request.QueryString["URL_ID_RUOLI_UTENTE"]);
            }

            SetPageControlAccess();

            //Set controlli per i permessi
            //Prima di effettuare eventuali disabilitazioni di altro genere
            BaseEnableControls(Page.Controls, allowEdit);

            if (!IsPostBack)
            {
                objUtente.Ute_id_utente = qUTE_ID_UTENTE;
                objUtente.Read();

                LabelTitolo.InnerText               = GetValueDizionarioUI("INDIRIZZI");
                Label_indirizzo.InnerText           = GetValueDizionarioUI("INDIRIZZO");
                ButtonSalva.Text                    = GetValueDizionarioUI("SALVA");
                ButtonAnnulla.Text                  = GetValueDizionarioUI("USCITA");
                Label_numero_civico.InnerText       = GetValueDizionarioUI("NUMERO_CIVICO");
                Label_tipologia_indirizzo.InnerText = GetValueDizionarioUI("TIPOLOGIA_INDIRIZZO");
                Label_data_disattivazione.InnerText = GetValueDizionarioUI("DATA_DISABILITAZIONE");
                Label_attivo.InnerText              = GetValueDizionarioUI("ATTIVO");
                Label_note.InnerText                = GetValueDizionarioUI("NOTE");

                Lookup_tipo_indirizzo lookup_Tipo_Indirizzo = new Lookup_tipo_indirizzo();
                Dropdown_tipologia_indirizzo.DataSource     = lookup_Tipo_Indirizzo.GetLookupTipoIndirizzo("LOOKUP_TIPO_INDIRIZZO");
                Dropdown_tipologia_indirizzo.DataValueField = "LTI_TIPO_INDIRIZZO";
                Dropdown_tipologia_indirizzo.DataTextField  = "LTI_TIPO_INDIRIZZO";
                Dropdown_tipologia_indirizzo.DataBind();
            }


            //Registrazioni javascript
            Page.ClientScript.RegisterStartupScript(this.GetType(), "varMODALITA", "var modalita = '" + qMODALITA + "';", true);
        }
        catch (Exception ex)
        {
            // Gestione messaggistica all'utente e trace in DB dell'errore
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
        }
    }
示例#5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Utente objUtente = new Utente();

            //string userId = (Request.Form["STR_USERID"].ToString() != null)?Request.Form["STR_USERID"].ToString():"giorgio.belloni";
            //Response.Write(userId);
            string userId = Request.Form["STR_USERID"].ToString();

            if (userId.ToLower() != "admin")
            {
                objUtente.Read(" WHERE UTE_USER_ID = '" + userId.Replace("'", "''") + "'");
                Session["UTE_ID_UTENTE"]     = objUtente.Ute_id_utente.ToString();
                Session["UTE_COGNOME"]       = objUtente.Ute_cognome.ToString();
                Session["UTE_NOME"]          = objUtente.Ute_nome.ToString();
                Session["UTE_SIGLA"]         = objUtente.Ute_sigla.ToString();
                Session["CLI_ID_CLIENTE"]    = objUtente.Cli_id_cliente.ToString();
                Session["NAZ_ID_NAZIONE"]    = 1;
                Session["CULTURE_INFO_NAME"] = "it";
                Session["RIV_ID_RICHIESTA"]  = 0;

                objUtente.UltimoAccesso();

                Dictionary <string, int> dizionarioPermessi = objUtente.BuildPermissions();
                Session["dizionarioPermessi"] = dizionarioPermessi;


                //Faccio l'autenticazione senza fare il login
                FormsAuthenticationTicket authTicket = new
                                                       FormsAuthenticationTicket(1,                         // version
                                                                                 userId,                    // user name
                                                                                 DateTime.Now,              // creation
                                                                                 DateTime.Now.AddHours(10), // Expiration
                                                                                 false,                     // Persistent
                                                                                 "");                       // User data

                // Now encrypt the ticket.
                string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
                // Create a cookie and add the encrypted
                // cookie as data.
                HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                // Add the cookie to the outgoing cookies
                Response.Cookies.Add(authCookie);
                //Fine autenticazione

                Response.Redirect("../HOME/mainpage.aspx", false);
            }
        }
示例#6
0
    /// <summary>
    /// Alla conferma recupero le informazioni dell'utente impersonato e rimando l'utente alla Dashboard.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnImpersonaUtente_Click(object sender, EventArgs e)
    {
        try
        {
            //Memorizzo in questa sessione l'id dell'utente che sta eseguendo l'impersonate
            Session["UTE_ID_UTENTE_LAST"] = Session["UTE_ID_UTENTE"];

            //Ricavo i dati per l'impersonificazione
            objUtente.Read(" WHERE UTE_ID_UTENTE = " + txtUtente.SelectedValue);
            Session["UTE_ID_UTENTE"]      = objUtente.Ute_id_utente.ToString();
            Session["UTE_COGNOME"]        = objUtente.Ute_cognome.ToString();
            Session["UTE_NOME"]           = objUtente.Ute_nome.ToString();
            Session["UTE_SIGLA"]          = objUtente.Ute_sigla.ToString();
            Session["CLI_ID_CLIENTE"]     = objUtente.Cli_id_cliente.ToString();
            Session["IS_GESTIONE_GRUPPO"] = objUtente.Ute_gestione_gruppo.Value;
            Session["IMPERSONATE"]        = "1";

            Dictionary <string, int> dizionarioPermessi = objUtente.BuildPermissions();
            Session["dizionarioPermessi"] = dizionarioPermessi;

            string strScript = @"<script type='text/javascript'>                                                                                                
                                    // self.parent.location.reload();
                                    document.location.href='../Home/mainpage.aspx';
                                </script>";

            if (!this.ClientScript.IsStartupScriptRegistered("Alert_JS"))
            {
                this.ClientScript.RegisterStartupScript(GetType(), "Alert_JS", strScript);
            }
        }
        catch (Exception ex)
        {
            // Gestione messaggistica all'utente e trace in DB dell'errore
            if (!ex.Data.Contains("Class.Method"))
            {
                ex.Data.Add("Class.Method", "Web_frm_MSE_IMP.ButtonSalva_Click.");
            }
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //PanelRuoloUtente.Visible = true;

        //Ripresa parametri di pagina
        qMODALITA    = Request.QueryString["MODALITA"];
        qPROVENIENZA = Request.QueryString["PROVENIENZA"];

        qWRF_ID_WORKFLOW = Convert.ToInt32(Request.QueryString["WRF_ID_WORKFLOW"]);
        qUTE_ID_UTENTE   = Convert.ToInt32(Request.QueryString["UTE_ID_UTENTE"]);

        SetPageControlAccess();

        //Set controlli per i permessi
        //Prima di effettuare eventuali disabilitazioni di altro genere
        BaseEnableControls(Page.Controls, allowEdit);

        if (!IsPostBack)
        {
            LabelWorkflow.InnerText      = GetValueDizionarioUI("WORKFLOW");
            LabelUtente.InnerText        = GetValueDizionarioUI("UTENTE");
            LabelDataCreazione.InnerText = GetValueDizionarioUI("DATA_CREAZIONE");
            LabelTitolo.InnerText        = GetValueDizionarioUI("WF_ASSOCIATI");
            ButtonSalva.Text             = GetValueDizionarioUI("SALVA");
            ButtonAnnulla.Text           = GetValueDizionarioUI("USCITA");

            objUtente.Ute_id_utente = qUTE_ID_UTENTE;
            objUtente.Read();


            string sqlWhereClause = " WHERE  WRF_ID_WORKFLOW IN(SELECT WRF_ID_WORKFLOW FROM CROSS_CLIENTE_WORKFLOW WHERE CLI_ID_CLIENTE=" + objUtente.Cli_id_cliente.Value + ") ";
            sqlWhereClause += " AND  (WRF_ID_WORKFLOW NOT IN (SELECT WRF_ID_WORKFLOW FROM CROSS_UTENTE_WORKFLOW WHERE UTE_ID_UTENTE = " + qUTE_ID_UTENTE + ") ";
            //if (qMODALITA != "NEW")
            //    sqlWhereClause += " OR WRF_ID_WORKFLOW IN(SELECT WRF_ID_WORKFLOW FROM CROSS_UTENTE_WORKFLOW WHERE UTE_ID_UTENTE = " + qUTE_ID_UTENTE + " AND cuw_id_utente_workflow = " + q + ") ";
            sqlWhereClause += ") ";

            //Lookup
            txtWorkflow.DataSource     = Workflow.List(sqlWhereClause);
            txtWorkflow.DataValueField = "WRF_ID_WORKFLOW";
            txtWorkflow.DataTextField  = "WRF_DESCRIZIONE";
            txtWorkflow.DataBind();
            //txtWorkflow.Items.Insert(0, new ListItem(" ", "-1"));
            txtWorkflow.SelectedIndex = 0;
            if (qWRF_ID_WORKFLOW != 0)
            {
                txtWorkflow.SelectedValue = qWRF_ID_WORKFLOW.ToString();
            }


            txtUtente.DataSource     = objUtente.getListDropDown();
            txtUtente.DataValueField = "UTE_ID_UTENTE";
            txtUtente.DataTextField  = "UTE_COGNOME_NOME";
            txtUtente.DataBind();
            txtUtente.Items.Insert(0, new ListItem(" ", "-1"));
            txtUtente.SelectedIndex = 0;
            if (qUTE_ID_UTENTE != 0)
            {
                txtUtente.SelectedValue = qUTE_ID_UTENTE.ToString();
            }

            //Funzione che nasconde i campi che per questo determinato cliente non devono essere visibili.
            showHideFields("MSE_UTE_WRF");

            // DataBinding
            switch (qMODALITA)
            {
            case "NEW":
                break;

            case "VIEW":
                BindData();
                break;

            case "EDIT":
                BindData();
                break;
            }


            //Registrazioni javascript
            Page.ClientScript.RegisterStartupScript(this.GetType(), "varMODALITA", "var modalita = '" + qMODALITA + "';", true);
        }

        /*
         * dsUtenti = objUtente.getListDropDownAbil();
         * for (int i = 0; i < txtUtente.Items.Count; i++)
         * {
         *  foreach (DataRow dr in dsUtenti.Tables[0].Rows)
         *  {
         *      if (txtUtente.Items[i].Value.CompareTo(Convert.ToString(dr["UTE_ID_UTENTE"])) == 0)
         *      {
         *          if (!Convert.ToBoolean(dr["UTE_STATO_UTENTE"]))
         *              txtUtente.Items[i].Attributes["disabled"] = "disabled";
         *      }
         *  }
         * }
         */
        // Campi read-only
        txtDataCreazione.Disabled = true;
        txtUtente.Enabled         = false;

        //string js_msgWORKFLOW = "var msgWORKFLOW = '" + GetValueDizionarioUI("ERR_MSG_CAMPO_OBBLIGATORIO") + "';";
        //Page.ClientScript.RegisterStartupScript(this.GetType(), "msgWORKFLOW", js_msgWORKFLOW, true);

        //if (!this.ClientScript.IsStartupScriptRegistered("ButtonAnnulla_Js"))
        //{
        //    this.ClientScript.RegisterStartupScript(GetType(), "ButtonAnnulla_Js", this.ButtonAnnulla_Js());
        //}
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UTE_ID_UTENTE"] != null)
        {
            qUTE_ID_UTENTE = Convert.ToInt32(Session["UTE_ID_UTENTE"]);
        }
        if (qUTE_ID_UTENTE <= 0)
        {
            Response.Redirect("../LOGIN/frm_LGN.aspx", false);
        }

        qCAMBIAPWD = Request.QueryString["CAMBIOPWD"];

        objUtente.Ute_id_utente = qUTE_ID_UTENTE;
        objUtente.Read();

        StringBuilder sb = new StringBuilder(100);

        sb.Append(GetValueDizionarioUI("BUONGIORNO"));
        sb.Append(" ");
        sb.Append(objUtente.Ute_nome.Value);
        sb.Append(" ");
        sb.Append(objUtente.Ute_cognome.Value);
        sb.Append(".<br /><br /><br />");
        if (!objUtente.Ute_session_id.IsNull && qCAMBIAPWD == "")
        {
            sb.Append(GetValueDizionarioUI("MSG_SESSIONE_ATTIVA"));
            sb.Append("<br /><br />");
        }
        if (!objUtente.Ute_ultimo_accesso.IsNull)
        {
            sb.Append(GetValueDizionarioUI("MSG_ULT_ACCESSO"));
            sb.Append(" ");
            sb.Append(objUtente.Ute_ultimo_accesso.Value);
            sb.Append(".<br />");
        }
        if (qCAMBIAPWD == "SI")
        {
            sb.Append("La password è stata cambiata con successo");
            sb.Append(".<br />");
        }

        LabelBenvenuto.InnerHtml = sb.ToString();

        if (objSistema.Sis_flag_pwd_cambia != 1)
        {
            ButtonCambiaPassword.Visible = false;
        }

        //Ogni login è l'ultimo Accesso Utente
        objUtente.UltimoAccesso();
        objUtente.Login_Logout("Login");

        //sb = new StringBuilder(100);

        //sb.Append(GetValueDizionarioUI("NON_SEI"));
        //sb.Append(" ");
        //sb.Append(objUtente.Ute_nome.Value);
        //sb.Append(" ");
        //sb.Append(objUtente.Ute_cognome.Value);
        //sb.Append("? ");
        //LabelNoUtente.Text = sb.ToString();

        //AnchorLogin.InnerHtml = GetValueDizionarioUI("CLICCA_QUI");
    }
示例#9
0
    private void ButtonChangePassword_Click(object sender, EventArgs e)
    {
        int maxPassword = 1;

        strERRORE = "";
        bool passwordVerified = false;
        bool passwordValid    = false;

        try
        {
            objUtente.Ute_id_utente = Convert.ToInt32(Session["UTE_ID_UTENTE"]);
            objUtente.Read();

            if (Session["oldPassword"] == null)
            {
                oldPassword            = (string)objUtente.Ute_password;
                Session["oldPassword"] = oldPassword;
            }
            else
            {
                oldPassword = Session["oldPassword"].ToString();
            }

            if (EncryptPwd(InputOldPassword.Text).CompareTo(oldPassword) == 0)
            {
                // Recupero Password
                objUtenteTrc.Ute_id_utente = Convert.ToInt32(Session["UTE_ID_UTENTE"]);
                objUtenteTrc.Ute_password  = EncryptPwd(InputNewPassword.Text);

                try
                {
                    if (objSistema.Sis_max_password_consecutive != -1)
                    {
                        maxPassword = (int)objSistema.Sis_max_password_consecutive;
                    }

                    passwordVerified   = objUtenteTrc.CheckPassword(maxPassword);      //objUtente-> in Utente.cs
                    errMaxRipetizioni += " " + maxPassword.ToString() + " password.";
                }
                catch (Exception ex)
                {
                    strERRORE = ex.Message;

                    // Gestione messaggistica all'utente e trace in DB dell'errore
                    ExceptionPolicy.HandleException(ex, "Propagate Policy");
                }

                //Verifica caratteri obbligatori
                passwordValid = PasswordConstraints(InputNewPassword.Text);
                if (!passwordValid)
                {
                    Base_Alert(pwdAvviso);
                }
                else if (!passwordVerified)
                {
                    Base_Alert(errMaxRipetizioni);
                }
                else
                {
                    try
                    {
                        objUtente.Ute_id_utente = Convert.ToInt32(Session["UTE_ID_UTENTE"]);
                        objUtente.Read();
                        objUtente.Ute_password = EncryptPwd(InputNewPassword.Text);

                        if (objSistema.Sis_durata_password != -1)
                        {
                            objUtente.Ute_expiration_date = DateTime.Now.AddMonths((int)objSistema.Sis_durata_password);
                        }
                        else
                        {
                            objUtente.Ute_expiration_date = SqlDateTime.Null;
                        }

                        objUtente.Update();

                        objUtenteTrc.Ute_id_utente = Convert.ToInt32(Session["UTE_ID_UTENTE"]);
                        objUtenteTrc.Ute_password  = EncryptPwd(InputNewPassword.Text);
                        objUtenteTrc.Create();

                        if (objSistema.Sis_flag_visualizza_info_page == 1)
                        {
                            pagina = "frm_LGN_2.aspx";
                        }
                        else
                        {
                            pagina = "../HOME/mainpage.aspx";
                        }

                        string js_Redirect = "alert('" + GetValueDizionarioUI("CAMBIO_PWD") + "');document.location.href='" + pagina + "';";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "msgRedirect", js_Redirect, true);
                    }
                    catch (Exception ex)
                    {
                        // Gestione messaggistica all'utente e trace in DB dell'errore
                        ExceptionPolicy.HandleException(ex, "Propagate Policy");
                    }
                }
            }
            else
            {
                Base_Alert(GetValueDizionarioUI("ERR_MSG_VECCHIA_PWD_ERRATA"));
            }
        }
        catch (Exception ex)
        {
            // Gestione messaggistica all'utente e trace in DB dell'errore
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
        }
    }
示例#10
0
    protected void ButtonInviaResetPwd_Click(object sender, EventArgs e)
    {
        try
        {
            string valore = "";
            int    contatoreUtentiSelez = 0;
            string emailAddress         = string.Empty;
            string password             = string.Empty;
            string msg            = string.Empty;
            string strChangePwdOK = GetValueDizionarioUI("PWD_INVIATE_OK");
            string strChangePwdKO = GetValueDizionarioUI("PWD_INVIATE_KO");
            char[] charSeparators = new char[] { ';' };

            if (this.fieldSelected.Value != "")
            {
                //Creo nuova riga nella hystory
                valore = fieldSelected.Value;
                string[] arrFieldSelected;
                arrFieldSelected = valore.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries);
                string emailMittente = ConfigurationManager.AppSettings["EmailMittente"];

                if (arrFieldSelected.Length > 0)
                {
                    for (int i = 0; i < arrFieldSelected.Length; i++)
                    {
                        objUtente.Ute_id_utente = Convert.ToInt32(arrFieldSelected[contatoreUtentiSelez].Replace("val_", ""));
                        objUtente.Read();
                        objClienti.Read(Convert.ToInt32(objUtente.Cli_id_cliente), qCultureInfoName);

                        emailAddress = (objUtente.Ute_email.IsNull) ? ("") : (objUtente.Ute_email.ToString());


                        MailMessage email = new MailMessage();
                        MailAddress oFrom = new MailAddress(emailMittente);
                        email.From       = oFrom;
                        email.IsBodyHtml = true;
                        email.Priority   = MailPriority.Normal;
                        email.Subject    = "Invio Password";
                        email.To.Clear();
                        email.To.Add(emailAddress);
                        email.Body = string.Empty;

                        if (emailAddress != "")
                        {
                            password   = objUtilita.GenerateRandomPassword();
                            msg        = "<p>Il link per accedere all'applicazione &egrave; : <strong><a href='" + objClienti.Cli_link_taf.ToString() + "'>" + objClienti.Cli_link_taf.ToString() + "</a></strong></p>";
                            msg       += "<p>La sua UserId &egrave; : <strong>" + objUtente.Ute_user_id.ToString() + "</strong></p>";
                            msg       += "<p>La sua Password &egrave; : <strong>" + password + "</strong></p>";
                            email.Body = Sistema.FormattaEmailPwd(msg);
                            Sistema.SendEmail(email);
                            objUtente.Ute_password         = EncryptPwd(password);
                            objUtente.Ute_flag_pwd_inviata = 1;
                            objUtente.Ute_data_invio_pwd   = DateTime.Now;
                            objUtente.Ute_expiration_date  = DateTime.Today.AddDays(-1);
                            objUtente.Update();
                            string strScript = @"<script type='text/javascript'>
                                alert('" + strChangePwdOK + @"');
                                </script>";

                            if (!this.ClientScript.IsStartupScriptRegistered("Alert_JS"))
                            {
                                this.ClientScript.RegisterStartupScript(GetType(), "Alert_JS", strScript);
                            }
                        }
                        contatoreUtentiSelez++;
                    }
                }
            }
            else
            {
                string strScript = "<script type='text/javascript'>alert('" + strChangePwdKO + "')</script>";
                if (!this.ClientScript.IsStartupScriptRegistered("Alert_JS"))
                {
                    this.ClientScript.RegisterStartupScript(GetType(), "Alert_JS", strScript);
                }
                throw new System.Exception("GridViewFatture:no DataKey objects Selected.");
            }
        }
        catch (Exception ex)
        {
            // Gestione messaggistica all'utente e trace in DB dell'errore
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
            Response.End();
        }
    }
示例#11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            qMODALITA    = Request.QueryString["MODALITA"];
            qPROVENIENZA = Request.QueryString["PROVENIENZA"];

            qRUL_ID_RUOLO  = Convert.ToInt32(Request.QueryString["RUL_ID_RUOLO"]);
            qUTE_ID_UTENTE = Convert.ToInt32(Request.QueryString["UTE_ID_UTENTE"]);

            if (Request.QueryString["URL_ID_RUOLI_UTENTE"] != null)
            {
                qURL_ID_RUOLI_UTENTE = Convert.ToInt32(Request.QueryString["URL_ID_RUOLI_UTENTE"]);
            }

            SetPageControlAccess();

            //Set controlli per i permessi
            //Prima di effettuare eventuali disabilitazioni di altro genere
            BaseEnableControls(Page.Controls, allowEdit);

            if (!IsPostBack)
            {
                objUtente.Ute_id_utente = qUTE_ID_UTENTE;
                objUtente.Read();

                lblRUL_ID_RUOLO.InnerText          = GetValueDizionarioUI("RUOLO");
                lblUTE_ID_UTENTE.InnerText         = GetValueDizionarioUI("UTENTE");
                lblURL_DATA_ASSEGNAZIONE.InnerText = GetValueDizionarioUI("DATA_CREAZIONE");
                LabelTitolo.InnerText = GetValueDizionarioUI("RUOLI");
                lblURL_STATO_RUOLO_UTENTE.InnerText = GetValueDizionarioUI("ABILITATO");
                ButtonSalva.Text   = GetValueDizionarioUI("SALVA");
                ButtonAnnulla.Text = GetValueDizionarioUI("USCITA");

                //Lookup
                //Non deve essere possibile aggiungere come ruolo ad un utente qualsiasi l'utente admin
                objRuoli.SqlWhereClause  = " WHERE RUL_ID_RUOLO <> 1 AND RUL_ID_RUOLO IN(SELECT RUL_ID_RUOLO FROM CROSS_CLIENTE_RUOLI WHERE CLI_ID_CLIENTE=" + objUtente.Cli_id_cliente.Value + ") ";
                objRuoli.SqlWhereClause += " AND  (RUL_ID_RUOLO NOT IN (SELECT RUL_ID_RUOLO FROM RUOLI_UTENTE WHERE UTE_ID_UTENTE = " + qUTE_ID_UTENTE + ") ";
                if (qMODALITA != "NEW")
                {
                    objRuoli.SqlWhereClause += " OR RUL_ID_RUOLO IN(SELECT RUL_ID_RUOLO FROM RUOLI_UTENTE WHERE UTE_ID_UTENTE = " + qUTE_ID_UTENTE + " AND URL_ID_RUOLI_UTENTE = " + qURL_ID_RUOLI_UTENTE + ") ";
                }
                objRuoli.SqlWhereClause += ") ";

                txtRUL_ID_RUOLO.DataSource     = objRuoli.getListDropDown();
                txtRUL_ID_RUOLO.DataValueField = "RUL_ID_RUOLO";
                txtRUL_ID_RUOLO.DataTextField  = "RUL_RUOLO";
                txtRUL_ID_RUOLO.DataBind();
                txtRUL_ID_RUOLO.Items.Insert(0, new ListItem(" ", ""));
                txtRUL_ID_RUOLO.SelectedIndex = 0;
                if (qRUL_ID_RUOLO != 0 && qRUL_ID_RUOLO != 1)
                {
                    txtRUL_ID_RUOLO.SelectedValue = qRUL_ID_RUOLO.ToString();
                }

                if (qUTE_ID_UTENTE != 0)
                {
                    objUtente.SqlWhereClause = " AND UTE_ID_UTENTE = " + qUTE_ID_UTENTE;
                }

                txtUTE_ID_UTENTE.DataSource     = objUtente.getListDropDown();
                txtUTE_ID_UTENTE.DataValueField = "UTE_ID_UTENTE";
                txtUTE_ID_UTENTE.DataTextField  = "UTE_COGNOME_NOME";
                txtUTE_ID_UTENTE.DataBind();
                txtUTE_ID_UTENTE.Items.Insert(0, new ListItem(" ", "-1"));
                txtUTE_ID_UTENTE.SelectedIndex = -1;
                if (qUTE_ID_UTENTE != 0)
                {
                    txtUTE_ID_UTENTE.SelectedValue = qUTE_ID_UTENTE.ToString();
                }

                //Funzione che nasconde i campi che per questo determinato cliente non devono essere visibili.
                showHideFields("MSE_RUL_UTE");

                // DataBinding
                switch (qMODALITA)
                {
                case "NEW":
                    txtURL_STATO_RUOLO_UTENTE.Checked = true;
                    txtURL_STATO_RUOLO_UTENTE.Enabled = false;
                    break;

                case "VIEW":
                    BindData();
                    ButtonAnnulla.Enabled = true;
                    break;

                case "EDIT":
                    BindData();
                    break;
                }
            }

            if (qUTE_ID_UTENTE != 0)
            {
                objUtente.SqlWhereClause = " WHERE UTE_ID_UTENTE = " + qUTE_ID_UTENTE;
            }

            dsUtenti = objUtente.getListDropDownAbil();
            for (int i = 0; i < txtUTE_ID_UTENTE.Items.Count; i++)
            {
                if (txtUTE_ID_UTENTE.Items[i].Value != "-1")
                {
                    DataRow[] r = dsUtenti.Tables[0].Select(" UTE_ID_UTENTE=" + txtUTE_ID_UTENTE.Items[i].Value);
                    if (r != null)
                    {
                        if (r[0]["UTE_STATO_UTENTE"].ToString() == "False")
                        {
                            txtUTE_ID_UTENTE.Items[i].Attributes["disabled"] = "disabled";
                        }
                    }
                }
            }

            // Campi read-only
            txtURL_DATA_ASSEGNAZIONE.Disabled = true;

            switch (qPROVENIENZA)
            {
            case "RUL":
                txtRUL_ID_RUOLO.Enabled = false;
                if (qUTE_ID_UTENTE != 0)
                {
                    txtUTE_ID_UTENTE.Enabled = false;
                }
                break;

            case "UTE":
                txtUTE_ID_UTENTE.Enabled = false;
                if (qRUL_ID_RUOLO != 0)
                {
                    txtRUL_ID_RUOLO.Enabled = false;
                }
                break;
            }

            //Registrazioni javascript
            Page.ClientScript.RegisterStartupScript(this.GetType(), "varMODALITA", "var modalita = '" + qMODALITA + "';", true);
        }
        catch (Exception ex)
        {
            // Gestione messaggistica all'utente e trace in DB dell'errore
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
        }
    }
示例#12
0
    /// <summary>
    /// Reset della password. Viene inviata una mail all'utente con la nuova password.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ButtonReset_Click(object sender, EventArgs e)
    {
        try
        {
            string emailDestinatario = string.Empty;

            BusinessObjects.ConfigurationSetting objConfigurationSetting = new BusinessObjects.ConfigurationSetting();
            string emailMittente = objConfigurationSetting.getValue("EmailNoReply");

            string  idDestinatario = string.Empty;
            string  Password       = objUtilita.GenerateRandomPassword();
            Utente  objUtente      = new Utente();
            Clienti objClienti     = new Clienti();
            objUtente.ReadByUser(InputUser.Text);
            emailDestinatario = objUtente.Ute_email.ToString();

            objClienti.Read(objUtente.Cli_id_cliente, qCultureInfoName);

            if (objUtente.Ute_id_utente.IsNull)
            {
                idDestinatario = "";
            }
            else
            {
                idDestinatario = objUtente.Ute_id_utente.ToString();
            }

            MailMessage email = new MailMessage();
            MailAddress oFrom = new MailAddress(emailMittente);
            email.From = oFrom;
            //Devo prima cancellare i valori precedenti.
            email.To.Clear();
            email.IsBodyHtml = true;
            email.Priority   = MailPriority.Normal;
            email.Subject    = "Invio / Reset password di accesso";
            email.Body       = FormattaEmail(Password, objClienti.Cli_link_taf.ToString());

            if (idDestinatario == "")
            {
                divLoginMessage.Visible = true;
                LabelMessage.InnerText  = "Errore durante il reset della password User Id non presente o errato.";
                LabelMessage.Style.Add("color", "red");
            }
            else
            {
                objUtente.Ute_id_utente = Convert.ToInt32(idDestinatario);
                objUtente.Read();

                email.To.Add(emailDestinatario);
                SendEmail(email);

                objUtente.Ute_password        = EncryptPwd(Password);
                objUtente.Ute_expiration_date = DateTime.Now.AddDays(-1);

                objUtente.Update();

                divLoginMessage.Visible = true;
                LabelMessage.InnerText  = "Password resettata correttamente, controllare la casella di posta elettronica.";
            }
        }
        catch (Exception ex)
        {
            strERRORE = ex.Message;
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
        }
    }