public static string getDominioMailCliente(int idCliente) { string dominioMail = string.Empty; try { Clienti objClienti = new Clienti(); objClienti.Read(Convert.ToInt32(idCliente), "it"); //Metto it perchè tanto la lingua in questo caso non incide per le informazioni che mi servono if (!objClienti.Cli_dominio_mail.IsNull) { dominioMail = objClienti.Cli_dominio_mail.ToString(); } else { dominioMail = ""; } return(dominioMail); } catch (Exception ex) { return(ex.Message); } }
/// <summary> /// Renderizza il footer comune a tutte le pagine. /// </summary> /// <returns></returns> public string renderFooter() { StringBuilder sb = new StringBuilder(); sb.Append("<div class='footerSDG'>© 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()); }
/// <summary> /// Nota da visualizzare al cliente /// </summary> private void BindNotaCliente() { try { int idCliente = Convert.ToInt32(Session["CLI_ID_CLIENTE"].ToString()); objClienti.Read(idCliente, qCultureInfoName); //if (!objClienti.Cli_nota_home.IsNull && objClienti.Cli_nota_home.Value != "") // pNotaCliente.InnerHtml = objClienti.Cli_nota_home.Value.Replace(Environment.NewLine, "<br />"); //else // pNotaCliente.Visible = false; } catch (Exception ex) { ExceptionPolicy.HandleException(ex, "Propagate Policy"); } }
private void BindNotaCliente() { try { int idCliente = Convert.ToInt32(Session["CLI_ID_CLIENTE"].ToString()); objClienti.Read(idCliente, qCultureInfoName); if (!objClienti.Cli_nota_home.IsNull && objClienti.Cli_nota_home.Value != "") { pNotaCliente.InnerHtml = objClienti.Cli_nota_home.Value.Replace(Environment.NewLine, "<br />"); } else { pNotaCliente.Visible = false; } } catch (Exception ex) { // Gestione messaggistica all'utente e trace in DB dell'errore ExceptionPolicy.HandleException(ex, "Propagate Policy"); } }
protected void ButtonSalva_Click(object sender, EventArgs e) { SetValues(); if (objUtente.existUser() != 0) { lblMessaggioError.InnerText = getDizionarioUI("ERR_UTE_VALORI_DUPLICATI"); divRecordError.Visible = true; } else { string PwdResetNotExist = getDizionarioUI("PWD_RESET_NOT_EXIST"); switch (qMODALITA) { case "NEW": try { //Ricavo dal cliente la password di default per settarla objClienti.Read(Convert.ToInt32(DropDownListCliente.SelectedValue), qCultureInfoName); if (objClienti.Cli_password_reset.ToString() != "" && !objClienti.Cli_password_reset.IsNull) { Database db = DatabaseFactory.CreateDatabase("CONNECTION_STRING"); DbConnection c = db.CreateConnection(); DbTransaction t = null; try { c.Open(); t = c.BeginTransaction(); objUtente.Ute_password = EncryptPwd(objClienti.Cli_password_reset.ToString()); objUtente.Ute_creato_da = base.idLoggedUser; objUtente.Create(db, t); RuoliUtente objRuoliUtente = new RuoliUtente(); objRuoliUtente.Ute_id_utente = objUtente.Ute_id_utente; objRuoliUtente.CreateByDefaultCliente(Convert.ToInt32(DropDownListCliente.SelectedValue), db, t); CrossUtenteWorkflow objCrossUtenteWorkflow = new CrossUtenteWorkflow(); objCrossUtenteWorkflow.Ute_id_utente = objUtente.Ute_id_utente; objCrossUtenteWorkflow.CreateByDefaultCliente(Convert.ToInt32(DropDownListCliente.SelectedValue), db, t); t.Commit(); } catch (Exception ex) { try { t.Rollback(); } catch (Exception ex2) { ex2.Data.Add("Class.Method", "frm_MSE_UTE.ButtonSalva.Rollback"); ex2.Data.Add("SQL", "Rollback error"); } if (ex != null) { ex.Data["Class.Method"] += "frm_MSE_UTE.ButtonSalva"; ex.Data.Add("SQL", ex.Message); throw ex; } } finally { c.Close(); } Response.Redirect("frm_MSE_UTE.aspx?MODALITA=EDIT&UTE_ID_UTENTE=" + objUtente.Ute_id_utente, false); } else { string strScript = @"<script type='text/javascript'> alert('" + PwdResetNotExist + @"'); </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 ExceptionPolicy.HandleException(ex, "Propagate Policy"); } break; case "EDIT": try { //Update record relations objUtente.Ute_aggiornato_da = base.idLoggedUser; objUtente.Ute_id_utente = qUTE_ID_UTENTE; objUtente.Update(); Response.Redirect("frm_MSE_UTE.aspx?MODALITA=EDIT&UTE_ID_UTENTE=" + objUtente.Ute_id_utente, false); } catch (Exception ex) { // Gestione messaggistica all'utente e trace in DB dell'errore ExceptionPolicy.HandleException(ex, "Propagate Policy"); } break; } GetValues(); Page.ClientScript.RegisterStartupScript(this.GetType(), "varMODALITA", "$('#modalPage', parent.document).modal('hide');", true); } }
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 è : <strong><a href='" + objClienti.Cli_link_taf.ToString() + "'>" + objClienti.Cli_link_taf.ToString() + "</a></strong></p>"; msg += "<p>La sua UserId è : <strong>" + objUtente.Ute_user_id.ToString() + "</strong></p>"; msg += "<p>La sua Password è : <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(); } }
protected void ButtonLogin_Click(object sender, EventArgs e) { Utente objUtente = new Utente(); Audit objAudit = new Audit(); int naz_id_nazione; bool passwordVerified = false; bool macAddressVerified = false; string pagina = string.Empty; int nroMaxSessioni = 0; int nroSessioniAttive = 0; //Ricavo informazioni sul browser dell'utente che si collega. vInfoBrowser = "Impostazioni Browser" + Environment.NewLine + "Type = " + Request.Browser.Type + Environment.NewLine + "Name = " + Request.Browser.Browser + Environment.NewLine + "Version = " + Request.Browser.Version + Environment.NewLine + "Major Version = " + Request.Browser.MajorVersion + Environment.NewLine + "Minor Version = " + Request.Browser.MinorVersion + Environment.NewLine + "Platform = " + Request.Browser.Platform + Environment.NewLine + "Is Beta = " + Request.Browser.Beta + Environment.NewLine + "Is Crawler = " + Request.Browser.Crawler + Environment.NewLine + "Is AOL = " + Request.Browser.AOL + Environment.NewLine + "Is Win32 = " + Request.Browser.Win32 + Environment.NewLine + "Supports Frames = " + Request.Browser.Frames + Environment.NewLine + "Supports Tables = " + Request.Browser.Tables + Environment.NewLine + "Supports Cookies = " + Request.Browser.Cookies + Environment.NewLine + "Supports VBScript = " + Request.Browser.VBScript + Environment.NewLine + "Supports JavaScript = " + Request.Browser.EcmaScriptVersion.ToString() + Environment.NewLine + "Supports Java Applets = " + Request.Browser.JavaApplets + Environment.NewLine + "Supports ActiveX Controls = " + Request.Browser.ActiveXControls + Environment.NewLine + "Supports Callback = " + Request.Browser.SupportsCallback + Environment.NewLine + "User Agent = " + HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"].ToString().ToLower(); divLoginMessage.Visible = false; strERRORE = ""; try { objUtente.Ute_user_id = InputUser.Text; objUtente.Ute_password = EncryptPwd(InputPassword.Text); if (!IsPostBack) { objUtente.Ute_user_id = autoLoginId; passwordVerified = objUtente.CheckLogin(false); if (passwordVerified) { autoLoginKerberosVerified = true; } } else { passwordVerified = objUtente.CheckLogin(true); //objUtente-> in Utente.cs } //Ricavo il nro massimo delle sessioni disponibili per l'utente corrente //e il nro di sessioni effettivamente attive per l'utente corrente if (passwordVerified) { nroMaxSessioni = objUtente.Ute_nro_max_sessioni.Value; nroSessioniAttive = objSessioniUtenti.CountSessioni(objUtente.Ute_id_utente.Value); } else { //Messi dei valori di comodo per farlo entrare nel successivo IF della password errata. nroMaxSessioni = 1; nroSessioniAttive = 0; } //******************************************************************************** // Commentare DA QUI per creare dll che non controlla il mac address //******************************************************************************** /* * byte[] defaultParameters = { 99, 99, 99 }; * JsonTextReader readerMacAddress = MacAddress.GetArrayMacAddress(); * Utilita objUtilita = new Utilita(); * byte[] microsoftAdvertisingClass = objUtilita.getMicrosoftAdvertisingClass(); * string macAddressCheck = string.Empty; * * while (readerMacAddress.Read() && passwordVerified) * { * if (readerMacAddress.TokenType.ToString() == "String" && !macAddressVerified) * { * defaultParameters = Encoding.ASCII.GetBytes(readerMacAddress.Value.ToString()); * int z = 0; * foreach (string val in readerMacAddress.Value.ToString().Split(',')) * { * defaultParameters[z] = Convert.ToByte(val); * z++; * } * //logger.Log(" -> defaultParameters -> " + readerMacAddress.Value.ToString()); * int i = 0; * int countCheck = 0; * foreach (byte b in microsoftAdvertisingClass) * { * macAddressCheck += b + ","; * if (b == defaultParameters[i]) * { * //logger.Log(" -> mcAddressVerified -> true"); * countCheck++; * if (countCheck == 15) * { * macAddressVerified = true; * break; * } * } * else * { * //logger.Log(" -> mcAddressVerified -> false -> bity:" + b.ToString() + " defaultParameters["+i.ToString()+"]-> " + defaultParameters[i].ToString()); * macAddressVerified = false; * } * i++; * } * } * } */ //******************************************************************************** // Commentare FIN QUI per creare dll che non controlla il mac address //******************************************************************************** Session["RIV_ID_RICHIESTA"] = 0; //******************************************************************************** if (nroSessioniAttive >= nroMaxSessioni) { errMessage = GetValueDizionarioUI("ERR_MSG_MAX_SESSIONI_ATTIVE"); LabelMessage.InnerText = errMessage; LabelMessage.Style.Add("color", "red"); divLoginMessage.Visible = true; } else if (passwordVerified) { Session["UTE_ID_UTENTE"] = objUtente.Ute_id_utente.Value; Session["UTE_SIGLA"] = (objUtente.Ute_sigla.IsNull) ? (string.Empty) : (objUtente.Ute_sigla.Value); Session["IP_ADDRESS"] = Convert.ToString(Request.ServerVariables["REMOTE_ADDR"]); Session["UTE_COGNOME"] = objUtente.Ute_cognome.Value; Session["UTE_NOME"] = objUtente.Ute_nome.Value; Session["CLI_ID_CLIENTE"] = objUtente.Cli_id_cliente.Value; Session["IS_GESTIONE_GRUPPO"] = objUtente.Ute_gestione_gruppo.Value; if (objUtente.Tpi_acronimo.Value != "") { Session["ACRONIMO_INSTALLAZIONE"] = objUtente.Tpi_acronimo.Value; } else { Session["ACRONIMO_INSTALLAZIONE"] = ""; } Response.Write(Session["UTE_ID_UTENTE"].ToString()); try { objAudit.Ute_id_utente = objUtente.Ute_id_utente; objAudit.Aud_ip_address = Convert.ToString(Session["IP_ADDRESS"]); objAudit.Aud_device = vInfoBrowser; //HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"].ToString().ToLower(); objAudit.TraceAction("Login"); Session["AUD_ID_AUDIT"] = objAudit.Aud_id_audit; Dictionary <string, int> dizionarioPermessi = objUtente.BuildPermissions(); Session["dizionarioPermessi"] = dizionarioPermessi; // Create the authentication ticket FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, // version InputUser.Text, // 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); if (hLingua.SelectedValue != "") { naz_id_nazione = Convert.ToInt32(hLingua.SelectedValue); } else { naz_id_nazione = idLingua; } Session["NAZ_ID_NAZIONE"] = naz_id_nazione; // La Culture Info deve sempre essere IT in quanto non devo cambiare formato di date e numeri Session["CULTURE_INFO_NAME"] = "it"; Session["SIGLA_LINGUA"] = hSiglaLingua.Value; setSessionId(); //Faccio la read del cliente per acronimo del cliente per andare alle richieste viaggio corrispondenti objClienti.Read(objUtente.Cli_id_cliente, qCultureInfoName); pagina = "../HOME/mainpage.aspx"; if (objUtente.Ute_id_utente != 1) // Admin { pagina = "../RichiestaViaggio_" + objClienti.Cli_acronimo.Value + "/frm_MSB_RIV.aspx?MENU=1"; } if (objSistema.Sis_flag_pwd_cambia_primo_accesso == 1 && objUtente.Ute_ultimo_accesso.IsNull) { //Ogni login è l'ultimo Accesso Utente objUtente.UltimoAccesso(); objUtente.Login_Logout("Login"); Response.Redirect("../LOGIN/frm_PWD.aspx?SCADUTA=SI", false); } else if (objSistema.Sis_flag_pwd_cambia == 1) { if (objUtente.Ute_expiration_date.IsNull) { if (objSistema.Sis_flag_visualizza_info_page == 1) { Response.Redirect("frm_LGN_2.aspx", false); } else { //Ogni login è l'ultimo Accesso Utente objUtente.UltimoAccesso(); Response.Redirect(pagina, false); } } else if (Convert.ToDateTime(objUtente.Ute_expiration_date.Value) < Convert.ToDateTime(DateTime.Now.ToShortDateString())) { //Ogni login è l'ultimo Accesso Utente objUtente.UltimoAccesso(); objUtente.Login_Logout("Login"); Response.Redirect("../LOGIN/frm_PWD.aspx?SCADUTA=SI", false); } else { if (objSistema.Sis_flag_visualizza_info_page == 1) { Response.Redirect("frm_LGN_2.aspx", false); } else { //Ogni login è l'ultimo Accesso Utente objUtente.UltimoAccesso(); objUtente.Login_Logout("Login"); Response.Redirect(pagina, false); } } } else { if (objSistema.Sis_flag_visualizza_info_page == 1) { Response.Redirect("frm_LGN_2.aspx", false); } else { //Ogni login è l'ultimo Accesso Utente objUtente.UltimoAccesso(); objUtente.Login_Logout("Login"); Response.Redirect(pagina, false); } } } catch (Exception ex) { strERRORE = ex.Message; ExceptionPolicy.HandleException(ex, "Propagate Policy"); Response.Redirect("../Login/frm_LGN.aspx", false); } } else { if (!autoLoginKerberosVerified) { divLoginMessage.Visible = true; LabelMessage.InnerText = "Utente non presente nel sistema di autenticazione."; LabelMessage.Style.Add("color", "red"); InputUser.Text = autoLoginId; } else if (!passwordVerified) { divLoginMessage.Visible = true; LabelMessage.InnerText = "Password non valida."; LabelMessage.Style.Add("color", "red"); if (objSistema.Sis_max_tentativi_password != -1) { objUtente.Ute_user_id = InputUser.Text; if (objUtente.AccessoErrato() == 1) { objUtente.SqlWhereClause = " WHERE UTE_USER_ID = '" + InputUser.Text + "' "; objUtente.DisattivaUserID(); LabelMessage.InnerHtml = errDisabledUser; LabelMessage.Style.Add("color", "red"); } } } else if (!macAddressVerified) { divLoginMessage.Visible = true; LabelMessage.InnerText = "Mac Address non valido. Contattare l'amministratore di sistema."; // + macAddressCheck; LabelMessage.Style.Add("color", "red"); } else { if (objUtente.CheckUser()) { objAudit.Ute_id_utente = objUtente.Ute_id_utente; objAudit.Aud_ip_address = Convert.ToString(Session["IP_ADDRESS"]); objAudit.TraceAction("LoginFailed"); } LabelMessage.InnerText = errMessage; LabelMessage.Style.Add("color", "red"); divLoginMessage.Visible = true; strERRORE = errMessage; } } } catch (Exception ex) { ExceptionPolicy.HandleException(ex, "Propagate Policy"); } }
/// <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"); } }