protected void btnVerify_Click(object sender, EventArgs e)
        {
            // retrieve the email from SQM_ACCESS
            lblForgotInvalidEmail.Visible = false;
            lblForgotNotSent.Visible      = false;
            lblForgotNotUpdated.Visible   = false;
            string strength            = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "COMPANY", "TASK", "PasswordComplexity").VALUE;
            string strEmailCompanyName = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailFromSystem").VALUE;
            int    msg = WebSiteCommon.RecoverPassword(tbEmail.Text.ToString(), "", strEmailCompanyName + " " + lblForgotPasswordEmailSubject.Text.ToString(), lblForgotPasswordEmailBody1a.Text.ToString() + strEmailCompanyName + lblForgotPasswordEmailBody1b.Text.ToString(), lblForgotPasswordEmailBody2.Text.ToString(), "<br><br>" + WebSiteCommon.GetXlatValueLong("passwordComplexity", strength) + "<br><br>" + lblForgotPasswordEmailBody3.Text.ToString());

            switch (msg)
            {
            case 10:
                tbEmail.Focus();
                lblForgotInvalidEmail.Visible = true;
                BindPwdForgot();
                break;

            case 20:
                tbEmail.Focus();
                lblForgotNotSent.Visible = true;
                BindPwdForgot();
                break;

            case 30:
                tbEmail.Focus();
                lblForgotNotUpdated.Visible = true;
                BindPwdForgot();
                break;

            default:
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "AlertPostback('" + hfForgotPasswordSent.Value + "','login');", true);
                break;
            }
        }
        public static void NotifyOnCreate(decimal incidentId, decimal plantId)
        {
            var entities = new PSsqmEntities();

            decimal companyId = SessionManager.UserContext.HRLocation.Company.COMPANY_ID;
            decimal busOrgId  = SessionManager.UserContext.HRLocation.BusinessOrg.BUS_ORG_ID;
            var     emailIds  = new HashSet <decimal>();

            INCIDENT incident         = EHSIncidentMgr.SelectIncidentById(entities, incidentId);
            string   incidentLocation = EHSIncidentMgr.SelectIncidentLocationNameByIncidentId(incidentId);
            string   incidentType     = EHSIncidentMgr.SelectIncidentTypeByIncidentId(incidentId);

            List <ATTACHMENT> attachList = SQM.Website.Classes.SQMDocumentMgr.SelectAttachmentListByRecord(40, incidentId, "", "");

            List <NOTIFY> notifications = SQMModelMgr.SelectNotifyHierarchy(companyId, busOrgId, plantId, 0, TaskRecordType.HealthSafetyIncident);

            foreach (NOTIFY n in notifications)
            {
                if (n.NOTIFY_PERSON1 != null)
                {
                    emailIds.Add((decimal)n.NOTIFY_PERSON1);
                }
                if (n.NOTIFY_PERSON2 != null)
                {
                    emailIds.Add((decimal)n.NOTIFY_PERSON2);
                }
            }

            if (emailIds.Count > 0)
            {
                string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string emailSubject = "Incident Created: " + incidentType + " (" + incidentLocation + ")";
                string emailBody    = "A new incident has been created:<br/>" +
                                      "<br/>" +
                                      incidentLocation + "<br/>" +
                                      incidentType + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + appUrl + " to view the incident.";

                foreach (decimal eid in emailIds)
                {
                    string emailAddress = (from p in entities.PERSON where p.PERSON_ID == eid select p.EMAIL).FirstOrDefault();

                    Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "", "web", attachList));
                    thread.IsBackground = true;
                    thread.Start();

                    //WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "");
                }
            }
        }
        protected bool ShouldSendNotification()
        {
            bool shouldSend = false;

            var      entities = new PSsqmEntities();
            TimeSpan timeBetweenNotifications = new TimeSpan(24, 0, 0);
            DateTime lastSentDate;

            SETTINGS stHours = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "HoursBetweenNotifications");

            if (stHours != null)
            {
                if (!string.IsNullOrEmpty(stHours.VALUE))
                {
                    int hours;
                    if (Int32.TryParse(stHours.VALUE, out hours))
                    {
                        timeBetweenNotifications = new TimeSpan(hours, 0, 0);
                    }
                }

                SETTINGS stLastSent = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "NotificationLastSent");

                if (stLastSent != null)
                {
                    if (DateTime.TryParse(stLastSent.VALUE, out lastSentDate))
                    {
                        WriteLine("Last sent date: " + lastSentDate);
                        shouldSend = (DateTime.Now.Subtract(timeBetweenNotifications) > lastSentDate);

                        if (shouldSend == true)
                        {
                            // Set last sent date to now
                            stLastSent.VALUE = DateTime.Now.ToString();
                            SQMSettings.UpdateSettings(entities, stLastSent, "Automated Emailer");
                        }
                    }
                    else
                    {
                        shouldSend = false;
                    }
                }
                else
                {
                    WriteLine("Missing value in SETTINGS table: NotificationLastSent");
                    shouldSend = false;
                }
            }
            else
            {
                WriteLine("Missing value in SETTINGS table: HoursBetweenNotifications");
                shouldSend = false;
            }

            WriteLine("Should send: " + shouldSend);

            return(shouldSend);
        }
        public void BindPwdEdit(bool bShowButtons)
        {
            string strength = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "COMPANY", "TASK", "PasswordComplexity").VALUE;

            lblPasswordPolicy.Text = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "PASSWORDCOMPLEXITY", "TASK", strength).VALUE;

            string script = "function f(){OpenPasswordEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        }
Example #5
0
        protected void lnkEditCode_Click(object sender, EventArgs e)
        {
            LinkButton lnk = (LinkButton)sender;

            string[] args = lnk.CommandArgument.ToString().Split('~');
            selectedCode = SQMSettings.SelectSettingByCode(entities, ddlSettingGroup.SelectedValue.ToString(), ddlSettingFamily.SelectedValue.ToString(), args[0]);
            uclSearchBar.SetButtonsEnabled(false, false, false, true, false, false);
            uclSearchBar.SetButtonsVisible(false, false, false, true, false, false);
            uclSearchBar.SetButtonsNotClicked();
            uclSearchBar.TitleItem.Text = selectedCode.SETTING_CD;
            tbValue.Enabled             = true;
            DisplaySetting(args[1]);
        }
Example #6
0
        protected bool SaveSettings(bool updateSetting)
        {
            PSsqmEntities Entities = new PSsqmEntities();
            string        strCode  = selectedCode.SETTING_CD;
            SETTINGS      settings = SQMSettings.SelectSettingByCode(Entities, ddlSettingGroup.SelectedValue.ToString(), ddlSettingFamily.SelectedValue.ToString(), strCode);

            bool success;

            // AW20131106 - need to verify that the SSO_ID and email address are unique in the system
            bool bErrors = false;

            settings.VALUE = tbValue.Text.ToString();
            // update the code
            selectedCode = SQMSettings.UpdateSettings(Entities, settings, SessionManager.UserContext.UserName());
            return(true);
        }
Example #7
0
        public static int NotifyIncidentTaskAssigment(INCIDENT incident, TASK_STATUS theTask, string scopeAction)
        {
            int    status = 0;
            PLANT  plant  = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
            PERSON person = SQMModelMgr.LookupPerson((decimal)theTask.RESPONSIBLE_ID, "");

            if (person != null && !string.IsNullOrEmpty(person.EMAIL))
            {
                List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS"
                });
                string appUrl = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string emailTo      = person.EMAIL;
                string actionText   = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == scopeAction).FirstOrDefault().DESCRIPTION;
                string emailSubject = "Health/Safety Incident " + actionText + ": " + incident.ISSUE_TYPE + " (" + plant.PLANT_NAME + ")";
                string emailBody    = "You have been assigned to one or more tasks regarding the following Incident: <br/>" +
                                      "<br/>" +
                                      "Incident ID: " + WebSiteCommon.FormatID(incident.INCIDENT_ID, 6) + "<br/>" +
                                      plant.PLANT_NAME + "<br/>" +
                                      incident.ISSUE_TYPE + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      theTask.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "Due : " + theTask.DUE_DT.ToString() + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + (appUrl + incidentPath) + " to view this incident.";

                Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null));
                thread.IsBackground = true;
                thread.Start();
            }

            return(status);
        }
Example #8
0
        public static void NotifyOnAuditCreate(decimal auditId, decimal personId)
        {
            var entities = new PSsqmEntities();

            decimal companyId = SessionManager.UserContext.HRLocation.Company.COMPANY_ID;
            decimal busOrgId  = SessionManager.UserContext.HRLocation.BusinessOrg.BUS_ORG_ID;
            var     emailIds  = new HashSet <decimal>();

            AUDIT  audit     = EHSAuditMgr.SelectAuditById(entities, auditId);
            string auditType = EHSAuditMgr.SelectAuditTypeByAuditId(auditId);

            emailIds.Add((decimal)audit.AUDIT_PERSON);

            if (emailIds.Count > 0)
            {
                string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string emailSubject = "Audit Created: " + auditType;
                string emailBody    = "A new audit has been created:<br/>" +
                                      "<br/>" +
                                      auditType + "<br/>" +
                                      "<br/>" +
                                      "Please log in to " + appUrl + auditPath + " to view the audit.";

                foreach (decimal eid in emailIds)
                {
                    string emailAddress = (from p in entities.PERSON where p.PERSON_ID == eid select p.EMAIL).FirstOrDefault();

                    Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "", "web"));
                    thread.IsBackground = true;
                    thread.Start();

                    //WebSiteCommon.SendEmail(emailAddress, emailSubject, emailBody, "");
                }
            }
        }
Example #9
0
        protected void SetupPage()
        {
            hdCurrentActiveMenu.Value = SessionManager.CurrentMenuItem;

            lbBusinessCard1_out.Text = SessionManager.UserContext.UserName(); // +": " + SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME;
            lblActiveLocation.Text   = SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME;
            if (SessionManager.StatOfTheDay != null)
            {
                lblActiveLocation.Text   = SessionManager.UserContext.HRLocation.Company.COMPANY_NAME + ", " + SessionManager.UserContext.HRLocation.Plant.PLANT_NAME + ": ";
                lblStatOfTheDay_out.Text = SQMBasePage.FormatValue(SessionManager.StatOfTheDay.Value, 0);
                lblStatOfTheDay.Visible  = lblStatOfTheDay_out.Visible = true;
            }
            else
            {
                lblStatOfTheDay_out.Text = "n/a";
            }
            pnlStatOfTheDay.Visible = true;

            if (ddlUserLang.Items.Count == 0)
            {
                foreach (LOCAL_LANGUAGE lang in SQMModelMgr.SelectLanguageList(new PSsqmEntities(), true))
                {
                    ddlUserLang.Items.Add(new RadComboBoxItem(lang.LANGUAGE_NAME, lang.LANGUAGE_ID.ToString()));
                }
            }
            tbUserPhone.Text = SessionManager.UserContext.Person.PHONE;
            if (ddlUserLang.FindItemByValue(SessionManager.UserContext.Person.PREFERRED_LANG_ID.ToString()) != null)
            {
                ddlUserLang.SelectedValue = SessionManager.UserContext.Person.PREFERRED_LANG_ID.ToString();
            }

            // ABW 20160118 - show password reset based on parameter
            SETTINGS setsPwdReset = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "COMPANY", "TASK", "PasswordResetEnable");

            if (setsPwdReset != null && setsPwdReset.VALUE.ToUpper() == "Y")
            {
                trChangePwd.Visible = true;
            }
        }
        protected void DisplayUser()
        {
            PERSON           person = LocalPerson();
            BusinessLocation businessLocation;
            SETTINGS         setsPwdReset = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordResetEnable");
            SQM_ACCESS       sysAccess    = SQMModelMgr.LookupCredentials(entities, person.SSO_ID, "", false);

            divPageBody.Visible = true;
            ddlPlantSelect.ClearCheckedItems();

            DisplayErrorMessage(null);

            string addFields = SessionManager.GetUserSetting("COMPANY", "PERSON_ADD_FIELDS") == null ? "" : SessionManager.GetUserSetting("COMPANY", "PERSON_ADD_FIELDS").VALUE;

            if (addFields.Contains("jobcode"))
            {
                trJobCode.Visible = true;
            }
            else
            {
                trJobCode.Visible = false;
            }

            if (addFields.Contains("supv"))
            {
                lblEmpSupv.Visible = tbSupvEmpID.Visible = true;
            }
            else
            {
                lblEmpID.Visible = true;
            }

            if (person == null || string.IsNullOrEmpty(person.STATUS))                 // new user
            {
                winUserEdit.Title        = hfAddUser.Value;
                businessLocation         = new BusinessLocation();
                businessLocation.Company = SessionManager.EffLocation.Company;
                SetStatusList("ddlUserStatus", "A", true);
                tbUserSSOID.Enabled = true;
                tbUserSSOID.Text    = "";
                tbUserSSOID.Focus();
            }
            else
            {
                winUserEdit.Title   = hfUpdateUser.Value;
                tbUserSSOID.Enabled = setsPwdReset != null && setsPwdReset.VALUE.ToUpper() == "Y" ? true : false;
                tbUserFirstName.Focus();

                lblPlantAccess.Text = "";
                if (person.PLANT_ID > 0)
                {
                    ddlHRLocation.SelectedValue = person.PLANT_ID.ToString();
                    if (ddlPlantSelect.Items.FindItemByValue(person.PLANT_ID.ToString()) != null)
                    {
                        ddlPlantSelect.Items.FindItemByValue(person.PLANT_ID.ToString()).Checked = true;
                    }
                }

                if (!string.IsNullOrEmpty(person.NEW_LOCATION_CD))
                {
                    RadComboBoxItem plantItem = null;
                    string[]        locs      = person.NEW_LOCATION_CD.Split(',');
                    foreach (string locid in locs)
                    {
                        if (!string.IsNullOrEmpty(locid))
                        {
                            if ((plantItem = ddlPlantSelect.Items.FindItemByValue(locid)) != null)
                            {
                                ddlPlantSelect.Items.FindItemByValue(locid).Checked = true;
                                if (locs.Length > 2)
                                {
                                    lblPlantAccess.Text += lblPlantAccess.Text.Length == 0 ? plantItem.Text : (", " + plantItem.Text);
                                }
                            }
                        }
                    }
                }
            }

            // AW20131106 - do not want to be able to change a SSO ID once a person has been added
            if (!string.IsNullOrEmpty(person.SSO_ID.Trim()))
            {
                tbUserSSOID.Text = person.SSO_ID;
            }

            tbUserFirstName.Text  = person.FIRST_NAME;
            tbUserLastName.Text   = person.LAST_NAME;
            tbUserMiddleName.Text = !string.IsNullOrEmpty(person.MIDDLE_NAME) ? person.MIDDLE_NAME : "";
            if (ddlJobCode.Items.FindItemByValue(person.JOBCODE_CD) != null)
            {
                ddlJobCode.SelectedValue = person.JOBCODE_CD;
            }
            else
            {
                ddlJobCode.SelectedValue = "";
            }

            if (ddlPrivGroup.Items.FindItemByValue(person.PRIV_GROUP) != null)
            {
                ddlPrivGroup.SelectedValue = person.PRIV_GROUP;
            }
            else
            {
                ddlPrivGroup.SelectedValue = "";
            }

            tbUserPhone.Text = person.PHONE;
            tbUserEmail.Text = person.EMAIL;
            tbEmpID.Text     = person.EMP_ID;
            tbSupvEmpID.Text = person.SUPV_EMP_ID;
            SetStatusList("ddlUserStatus", person.STATUS, true);
            if (sysAccess != null && sysAccess.LAST_LOGON_DT.HasValue)
            {
                lblUserLoginDate_out.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)sysAccess.LAST_LOGON_DT, WebSiteCommon.GetXlatValue("timeZone", person.PREFERRED_TIMEZONE)), "g", true);
            }
            else
            {
                lblUserLoginDate_out.Text = "";
            }
            lblUserLastUpdate.Text = person.LAST_UPD_BY + "  " + SQMBasePage.FormatDate(WebSiteCommon.LocalTime((DateTime)person.LAST_UPD_DT, SessionManager.UserContext.TimeZoneID), "g", true);

            if (ddlUserLanguage.Items.FindByValue(person.PREFERRED_LANG_ID.ToString()) != null)
            {
                ddlUserLanguage.SelectedValue = person.PREFERRED_LANG_ID.ToString();
            }
            if (ddlUserTimezone.Items.FindByValue(person.PREFERRED_TIMEZONE) != null)
            {
                ddlUserTimezone.SelectedValue = person.PREFERRED_TIMEZONE;
            }


            List <SysModule> sysmodList = SQMSettings.SystemModuleItems();
            string           prod = "";
            RadComboBoxItem  item = null; RadComboBoxItem itemSep = null;

            lblPrivScope.Text = "";
            if (person.PRIV_GROUP != null)
            {
                foreach (PRIVLIST jp in SQMModelMgr.SelectPrivList(person.PRIV_GROUP).ToList())
                {
                    lblPrivScope.Text += (" " + ((SysPriv)jp.PRIV).ToString() + ": " + jp.SCOPE + ",");
                }
            }
            lblPrivScope.Text = lblPrivScope.Text.TrimEnd(',');

            if (setsPwdReset != null && setsPwdReset.VALUE.ToUpper() == "Y")
            {
                trResetPassword.Visible = true;
            }

            cbUserEmailLock.Checked    = SQMModelMgr.PersonFieldLocked(person, LockField.email);
            cbPrivGroupLock.Checked    = SQMModelMgr.PersonFieldLocked(person, LockField.priv);
            cbHRLocationLock.Checked   = SQMModelMgr.PersonFieldLocked(person, LockField.plant);
            cbUserLanguageLock.Checked = SQMModelMgr.PersonFieldLocked(person, LockField.lang);

            string script = "function f(){OpenUserEditWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";

            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
        }
Example #11
0
        public static int NotifyIncidentStatus(INCIDENT incident, string scopeAction)
        {
            int    status = 0;
            string notifyScope;

            if ((EHSIncidentTypeId)incident.ISSUE_TYPE_ID == EHSIncidentTypeId.InjuryIllness)
            {
                notifyScope = "IN-" + incident.ISSUE_TYPE_ID.ToString();
            }
            else
            {
                notifyScope = "IN-" + ((int)EHSIncidentTypeId.Any).ToString();
            }

            PLANT         plant            = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
            List <PERSON> notifyPersonList = InvolvedPersonList(incident);

            notifyPersonList.AddRange(GetNotifyPersonList(plant, notifyScope, scopeAction));

            if (notifyPersonList.Count > 0)
            {
                List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[3] {
                    "NOTIFY_SCOPE", "NOTIFY_SCOPE_TASK", "NOTIFY_TASK_STATUS"
                });
                string appUrl = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailURL").VALUE;
                if (string.IsNullOrEmpty(appUrl))
                {
                    appUrl = "the website";
                }

                string actionText   = XLATList.Where(x => x.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && x.XLAT_CODE == scopeAction).FirstOrDefault().DESCRIPTION;
                string emailSubject = "Health/Safety Incident " + actionText + ": " + incident.ISSUE_TYPE + " (" + plant.PLANT_NAME + ")";
                string emailBody    = "A new Health/Safety incident has been " + actionText + " :<br/>" +
                                      "<br/>" +
                                      "Incident ID: " + WebSiteCommon.FormatID(incident.INCIDENT_ID, 6) + "<br/>" +
                                      plant.PLANT_NAME + "<br/>" +
                                      incident.ISSUE_TYPE + "<br/>" +
                                      "<br/>" +
                                      incident.DESCRIPTION + "<br/>" +
                                      "<br/>" +
                                      "On : " + DateTime.Now.ToString() +
                                      "<br/>" +
                                      "By : " + incident.LAST_UPD_BY +
                                      "<br/>" +
                                      "Please log in to " + (appUrl + incidentPath) + " to view this incident.";

                string emailTo = "";
                foreach (PERSON person in notifyPersonList.Where(l => !string.IsNullOrEmpty(l.EMAIL)).ToList())
                {
                    emailTo += string.IsNullOrEmpty(emailTo) ? person.EMAIL : ("," + person.EMAIL);
                }

                Thread thread = new Thread(() => WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null));
                thread.IsBackground = true;
                thread.Start();
            }

            //WebSiteCommon.SendEmail(emailTo, emailSubject, emailBody, "", "web", null);

            return(status);
        }
        protected void btnPassSave_Click(object sender, EventArgs e)
        {
            int status = 0;

            lblPassPolicyFail.Visible    = false;
            lblPasswordNoConfirm.Visible = false;
            lblPassFailUpdate.Visible    = false;
            lblPassFailError.Visible     = false;
            lblPassFail10.Visible        = false;
            divErrorMsg.Visible          = false;

            // validate the password criteria
            if (tbNewPassword.Text != tbConfirmPassword.Text)
            {
                status = -1;
            }
            else
            {
                status = SQMModelMgr.ChangeUserPassword(SessionManager.UserContext.Credentials.SSO_ID, "", tbCurrentPassword.Text.ToString().Trim(), tbNewPassword.Text.ToString().Trim());
            }

            if (status == 0)
            {
                // send a confirmation email
                string strEmailCompanyName = SQMSettings.SelectSettingByCode(new PSsqmEntities(), "MAIL", "TASK", "MailFromSystem").VALUE; // WebConfigurationManager.AppSettings["MailFromSystem"];
                string strEmailBody        = lblPasswordEmailBody1a.Text.ToString() + strEmailCompanyName + lblPasswordEmailBody1b.Text.ToString() + "<br><br>" + lblPasswordEmailBody2.Text.ToString();
                // ABW 20140117 - we are now usig the email on the Person record
                //string strEmailSent = WebSiteCommon.SendEmail(SessionManager.UserContext.Credentials.RECOVERY_EMAIL, lblPasswordEmailSubject.Text.ToString(), strEmailBody.Trim(), "");
                string strEmailSent = WebSiteCommon.SendEmail(SessionManager.UserContext.Person.EMAIL, strEmailCompanyName + lblPasswordEmailSubject.Text.ToString(), strEmailBody.Trim(), "");

                if (strCurrentControl.Equals("login"))
                {
                    ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "AlertPostback('" + hfPasswordChangedSucces.Value + "','loginContinue');", true);
                }
                else
                {
                    hideControl();
                }

                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
            }
            else
            {
                divErrorMsg.Visible = true;
                switch (status)
                {
                case -1:
                    lblPasswordNoConfirm.Visible = true;
                    break;

                case 10:
                    lblPassFail10.Visible = true;
                    break;

                case 100:
                    lblPassPolicyFail.Visible = true;
                    break;

                case 110:
                    lblPassPolicyFail.Visible = true;
                    break;

                case 120:
                    lblPassPolicyFail.Visible = true;
                    break;

                case 130:
                    lblPassPolicyFail.Visible = true;
                    break;

                case 140:
                    lblPassPolicyFail.Visible = true;
                    break;

                default:
                    lblPassFailUpdate.Visible = true;
                    lblPassFailError.Visible  = true;
                    lblPassFailError.Text     = status.ToString();
                    break;
                }
                BindPwdEdit(true);
            }
            // hide the control?
        }
Example #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SETTINGS sets = null;

            if (IsPostBack)
            {
                // Save the current view port width (used for responsive design later)
                var vpWidth = viewPortWidth.Value;
                if (!string.IsNullOrEmpty(vpWidth))
                {
                    Session["vpWidth"] = vpWidth;
                }
                else
                {
                    Session["vpWidth"] = "1000";
                }
            }
            else
            {
                try
                {
                    if (SessionManager.SessionContext != null || SessionManager.UserContext != null)
                    {
                        SessionManager.Clear();
                        Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
                    }

                    string info = System.Configuration.ConfigurationManager.AppSettings["MainInfo"];
                    if (!string.IsNullOrEmpty(info))
                    {
                        lblMainInfo.Text    = info;
                        lblMainInfo.Visible = true;
                    }

                    System.Web.HttpBrowserCapabilities browser = Request.Browser;

                    SETTINGS setsPwdReset = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordResetEnable");
                    if (setsPwdReset != null && setsPwdReset.VALUE.ToUpper() == "Y")
                    {
                        lnkForgotPassword.Visible = true;
                    }

                    SETTINGS setsLoginPosting = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "LoginPostingsEnable");
                    if (setsLoginPosting == null || setsLoginPosting.VALUE.ToUpper() == "Y")
                    {
                        // url format login.aspx/?t=ltc:60&p=EHS
                        // execOverride == override query params to force ticker and image posting

                        System.Collections.Specialized.NameValueCollection qry = new System.Collections.Specialized.NameValueCollection();
                        string execOverride = System.Configuration.ConfigurationManager.AppSettings["LoginOverride"];
                        if (execOverride != null && execOverride == "QAI")
                        {
                            qry.Add("t", "ltc");
                            qry.Add("p", "EHS,QS");
                        }
                        else
                        {
                            sets = SQMSettings.GetSetting("ENV", "LOGINIMAGE");                              // force login splash page display
                            if (sets != null && sets.VALUE.ToUpper() == "Y")
                            {
                                qry.Add("p", "EHS,QS");
                            }
                            sets = SQMSettings.GetSetting("ENV", "LOGINSTAT");
                            if (sets != null && sets.VALUE.ToUpper() == "LTC")
                            {
                                qry.Add("t", "ltc");
                            }
                        }

                        sets = SQMSettings.GetSetting("ENV", "LOGINMESSAGE");
                        if (sets != null && !string.IsNullOrEmpty(sets.VALUE))
                        {
                            lblLoginMessage.Text    = sets.VALUE;
                            divLoginMessage.Visible = true;
                        }


                        if (Request.QueryString.Count > 0)
                        {
                            // AW 02/2016 - don't wipe out the current Collection, just add to it
                            //qry = Request.QueryString;
                            qry.Add(Request.QueryString);
                        }

                        if (qry.Get("t") != null)
                        {
                            string[] args = qry.Get("t").ToString().Split(':');

                            COMPANY      company  = new COMPANY();
                            decimal[]    plantIDS = SQMModelMgr.SelectPlantList(entities, 1, 0).Where(l => l.LOCATION_TYPE == "P").OrderBy(l => l.PLANT_NAME).Select(l => l.PLANT_ID).ToArray();
                            SQMMetricMgr stsmgr   = new SQMMetricMgr().CreateNew(company, "0", DateTime.Now, DateTime.Now, plantIDS);
                            stsmgr.ehsCtl = new EHSCalcsCtl().CreateNew(1, DateSpanOption.SelectRange, "E");
                            stsmgr.ehsCtl.ElapsedTimeSeries(plantIDS, new decimal[1] {
                                8
                            }, new decimal[1] {
                                63
                            }, "YES", true);

                            GaugeDefinition tikCfg = new GaugeDefinition().Initialize();
                            tikCfg.Width       = 450;                       // 0;
                            tikCfg.Unit        = args.Length > 1 ? Convert.ToInt32(args[1]) : 80;
                            tikCfg.Position    = "none";
                            tikCfg.NewRow      = false;
                            pnlPosting.Visible = true;
                            divTicker.Visible  = true;
                            uclGauge.CreateTicker(tikCfg, stsmgr.ehsCtl.Results.metricSeries, divTicker);
                        }

                        if (qry.Get("p") != null)
                        {
                            string[] args = qry.Get("p").ToString().Split(',');
                            if (args.Contains("EHS"))
                            {
                                pnlPosting.Visible = true;
                                imgPostingEHS.Style.Add("MARGIN-TOP", "8px");
                                imgPostingEHS.Src = SQM.Website.Classes.SQMDocumentMgr.GetImageSourceString(SQM.Website.Classes.SQMDocumentMgr.FindCurrentDocument("SYS", 31));
                            }
                            if (args.Contains("QS"))
                            {
                                pnlPosting.Visible = true;
                                imgPostingQS.Style.Add("MARGIN-TOP", "8px");
                                imgPostingQS.Src = SQM.Website.Classes.SQMDocumentMgr.GetImageSourceString(SQM.Website.Classes.SQMDocumentMgr.FindCurrentDocument("SYS", 32));
                            }
                        }
                    }

                    string externalLinks = System.Configuration.ConfigurationManager.AppSettings["ExternalLinks"];
                    if (!string.IsNullOrEmpty(externalLinks))
                    {
                        string[] linkArray = externalLinks.Split(',');
                        foreach (string link in linkArray)
                        {
                            divLinks.Controls.Add(new LiteralControl("&nbsp;&nbsp;&nbsp;"));
                            HyperLink hlk = new HyperLink();
                            hlk.NavigateUrl = hlk.Text = link;
                            hlk.Target      = "_blank";
                            hlk.CssClass    = "linkUnderline";
                            divLinks.Controls.Add(hlk);
                        }
                        divLinks.Visible = true;
                    }
                }
                catch
                {
                    divAnnouncements.Visible = false;
                }

                if (Request.QueryString["rdp"] != null)
                {
                    ViewState["RedirectPath"] = Request.QueryString["rdp"];
                }
            }
        }
Example #14
0
        private void uclCaseEdit_OnSaveClick(string cmdArg)
        {
            bool bNotify;

            CaseCtl().problemCase.UpdateStatus = CaseUpdateStatus.Success;
            switch (cmdArg)
            {
            case "0":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase0(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase0();
                }
                break;

            case "1":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase1(CaseCtl().problemCase, out bNotify);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase1(bNotify);
                    if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success && bNotify)
                    {
                        try
                        {
                            string appUrl = SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE;
                            PERSON person = null;
                            PLANT  plant  = SQMModelMgr.LookupPlant((decimal)CaseCtl().problemCase.IncidentList[0].DETECT_PLANT_ID);
                            int    emailStatus;
                            bool   bUpdateTasks = false;
                            foreach (TASK_STATUS task in CaseCtl().problemCase.TeamTask.TaskList.Where(t => t.TASK_TYPE == "C" && t.TASK_SEQ == 0).ToList())
                            {
                                if (task.RESPONSIBLE_ID.HasValue && (person = SQMModelMgr.LookupPerson((decimal)task.RESPONSIBLE_ID, "")) != null && !task.NOTIFY_DT.HasValue)
                                {
                                    task.NOTIFY_DT = DateTime.UtcNow;
                                    List <TaskItem> taskList = new List <TaskItem>();
                                    TaskItem        taskItem = new TaskItem();
                                    taskItem.RecordID    = CaseCtl().problemCase.ProbCase.PROBCASE_ID;
                                    taskItem.RecordKey   = CaseCtl().problemCase.ProbCase.PROBCASE_ID.ToString();
                                    taskItem.RecordType  = 21;
                                    taskItem.NotifyType  = TaskNotification.Owner;
                                    taskItem.Taskstatus  = TaskMgr.CalculateTaskStatus(task);
                                    taskItem.Detail      = SQMModelMgr.FormatPersonListItem(person);
                                    taskItem.Description = WebSiteCommon.FormatID(CaseCtl().problemCase.ProbCase.PROBCASE_ID, 6) + " / " + WebSiteCommon.GetXlatValue("caseStep", task.TASK_STEP);
                                    taskItem.Plant       = plant;
                                    taskItem.Task        = task;
                                    //  taskItem.Task = task;
                                    taskList.Add(taskItem);
                                    Thread thread = new Thread(() => TaskMgr.MailTaskList(taskList, person.EMAIL, "web"));
                                    thread.IsBackground = true;
                                    thread.Start();
                                    bUpdateTasks = true;
                                    //  if ((emailStatus = TaskMgr.MailTaskList(taskList, person.EMAIL, "web")) > 0)
                                    //      bUpdateTasks = true;
                                }
                            }
                            if (bUpdateTasks)
                            {
                                CaseCtl().Update();     // save task notify dates
                            }
                        }
                        catch (Exception ex)
                        {
                            //  SQMLogger.LogException(ex);
                        }
                    }
                }
                break;

            case "2":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase2(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase2();
                }
                break;

            case "3":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase3(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase3();
                }
                break;

            case "4":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase4(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase4();
                }
                break;

            case "5":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase5(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase5();
                }
                break;

            case "6":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase6(CaseCtl().problemCase);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase6();
                }
                break;

            case "7":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase7(CaseCtl().problemCase, true);
                if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
                {
                    CaseCtl().Update();
                    uclCaseEdit.BindCase7();
                }
                break;

            case "8":
                CaseCtl().problemCase = uclCaseEdit.UpdateCase8(CaseCtl().problemCase, out bNotify);
                CaseCtl().Update();
                uclCaseEdit.BindCase8(bNotify);
                if (bNotify && CaseCtl().problemCase != null)
                {
                    List <decimal?> teamList = new List <decimal?>();
                    teamList = CaseCtl().problemCase.TeamTask.TaskList.Where(l => l.TASK_TYPE == "C" && l.RESPONSIBLE_ID > 0).Select(l => l.RESPONSIBLE_ID).Distinct().ToList();
                    PERSON person = null;
                    // string emailStatus;
                    foreach (decimal?personID in teamList)
                    {
                        if ((person = SQMModelMgr.LookupPerson((decimal)personID, "")) != null)
                        {
                            Thread thread = new Thread(() => WebSiteCommon.SendEmail(person.EMAIL, CaseCtl().problemCase.ProbCase.PROB_CLOSE.MESSAGE_TITLE, CaseCtl().problemCase.ProbCase.PROB_CLOSE.MESSAGE, ""));
                            thread.IsBackground = true;
                            thread.Start();
                        }
                    }
                }
                break;

            default:
                break;
            }

            if (CaseCtl().problemCase.UpdateStatus == CaseUpdateStatus.Success)
            {
                ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
                SetupPage();
            }
            else
            {
                ErrorAlert(CaseCtl().problemCase.UpdateStatus);
            }
        }
Example #15
0
        protected bool SaveUser(bool updateUser)
        {
            bool  bErrors = false;
            bool  success;
            Label lblErrorMessage = null;

            PERSON person        = LocalPerson();
            string currentSSOID  = LocalPerson().SSO_ID;
            PERSON currentPerson = new PERSON();

            if (isNew)
            {
                person.SSO_ID = string.IsNullOrEmpty(tbUserSSOID.Text) ? "" : tbUserSSOID.Text.Trim();  // trim traling blanks when creating new user
            }
            else
            {
                person             = SQMModelMgr.LookupPerson(entities, person.PERSON_ID, "", false);
                person.SSO_ID      = string.IsNullOrEmpty(tbUserSSOID.Text) ? "" : tbUserSSOID.Text;
                currentPerson.ROLE = person.ROLE;
            }

            person.FIRST_NAME = string.IsNullOrEmpty(tbUserFirstName.Text) ? "" : tbUserFirstName.Text;
            person.LAST_NAME  = string.IsNullOrEmpty(tbUserLastName.Text) ? "" : tbUserLastName.Text;
            person.JOB_TITLE  = tbUserTitle.Text;
            person.PHONE      = tbUserPhone.Text;
            person.EMAIL      = tbUserEmail.Text;

            if (!string.IsNullOrEmpty(ddlUserLanguage.SelectedValue))
            {
                person.PREFERRED_LANG_ID = Convert.ToInt32(ddlUserLanguage.SelectedValue);
            }
            if (!string.IsNullOrEmpty(ddlUserTimezone.SelectedValue))
            {
                person.PREFERRED_TIMEZONE = ddlUserTimezone.SelectedValue;
            }

            person.COMPANY_ID = SessionManager.EffLocation.Company.COMPANY_ID;
            if (!string.IsNullOrEmpty(ddlHRLocation.SelectedValue))
            {
                PLANT plant = SQMModelMgr.LookupPlant(Convert.ToDecimal(ddlHRLocation.SelectedValue));
                if (plant != null)
                {
                    person.PLANT_ID   = plant.PLANT_ID;
                    person.BUS_ORG_ID = (decimal)plant.BUS_ORG_ID;
                }
            }
            person.NEW_LOCATION_CD = "";

            foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect))
            {
                person.NEW_LOCATION_CD += (item.Value + ",");
            }
            person.NEW_LOCATION_CD = person.NEW_LOCATION_CD.TrimEnd(',');

            person.OLD_LOCATION_CD = "";

            foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlCustPlantSelect))
            {
                person.OLD_LOCATION_CD += (item.Value + ",");
            }
            person.OLD_LOCATION_CD = person.OLD_LOCATION_CD.TrimEnd(',');

            person.STATUS = ddlUserStatus.SelectedValue;

            // roles were originally a list - let's keep the logic below just in case we need to restore a multi-role strategy
            //person.PERSON_ROLE.Clear();
            person.ROLE           = GetSelectedUserRole();
            person.RCV_ESCALATION = cbUserRcvEscalation.Checked;

            person.PERSON_ACCESS.Clear();
            string prod = "";

            foreach (RadComboBoxItem accessItem in ddlModuleAccess.Items)
            {
                if (accessItem.IsSeparator)
                {
                    prod = accessItem.Value;
                }
                if (accessItem.Checked || person.ROLE <= 100)
                {
                    person = SQMModelMgr.AddPersonAccess(person, prod, accessItem.Value, true);
                }
            }

            SetLocalPerson(person);

            if (string.IsNullOrEmpty(tbUserSSOID.Text) || string.IsNullOrEmpty(tbUserFirstName.Text) || string.IsNullOrEmpty(tbUserLastName.Text) ||
                string.IsNullOrEmpty(tbUserEmail.Text) || ddlUserRole.SelectedIndex < 0 || string.IsNullOrEmpty(ddlHRLocation.SelectedValue) ||
                string.IsNullOrEmpty(ddlHRLocation.SelectedValue))
            {
                lblErrorMessage = lblErrRequiredInputs;
            }

            if (lblErrorMessage == null)
            {
                // AW20131106 - need to verify that the SSO_ID and email address are unique in the system
                lblDuplicateSSOId.Visible = false;
                lblDuplicateEmail.Visible = false;
                string strSSOId = tbUserSSOID.Text;
                string strEmail = tbUserEmail.Text;
                if (isNew) // || !strSSOId.Equals(person.SSO_ID))
                {
                    // verify unique sso_id
                    strSSOId = tbUserSSOID.Text.Trim();
                    SQM.Website.PSsqmEntities ctxAccess = new PSsqmEntities();
                    SQM_ACCESS access = SQMModelMgr.LookupCredentials(ctxAccess, strSSOId, "", false);
                    if (access != null && access.SSO_ID.ToLower().Equals(strSSOId.ToLower()))
                    {
                        lblErrorMessage = lblDuplicateSSOId;
                    }
                }
                if (lblErrorMessage == null && (isNew || !strEmail.Equals(person.EMAIL)))
                {
                    // verify unique email
                    SQM.Website.PSsqmEntities ctxAccess = new PSsqmEntities();
                    //SQM_ACCESS access = SQMModelMgr.LookupCredentialsByEmail(ctxAccess, strEmail, false);
                    // ABW 20140117 - we want to look up email on person record...
                    PERSON personEmail = SQMModelMgr.LookupPersonByEmail(ctxAccess, strEmail);
                    if (personEmail != null && personEmail.EMAIL.Trim().ToLower().Equals(strEmail.Trim().ToLower()))
                    {
                        lblErrorMessage = lblDuplicateEmail;
                    }
                }
            }
            if (lblErrorMessage != null)
            {
                DisplayUser();
                DisplayErrorMessage(lblErrorMessage);
                return(false);
            }

            if (updateUser)
            {
                List <SETTINGS> MailSettings = SQMSettings.SelectSettingsGroup("MAIL", ""); // ABW 20140805
                SETTINGS        setting      = new SETTINGS();                              // ABW 20140805
                SetLocalPerson(SQMModelMgr.UpdatePerson(entities, person, SessionManager.UserContext.UserName(), false, currentSSOID));
                //selectedUser = SQMModelMgr.UpdatePerson(entities, person, SessionManager.UserContext.UserName(), Convert.ToBoolean(GetFindControlValue("cbIsBuyer", hfBase, out success)), GetFindControlValue("tbBuyerCode", hfBase, out success));
                // AW20131106 - send an email for new users with random password generation

                setting = MailSettings.Find(x => x.SETTING_CD == "MailFromSystem"); // ABW 20140805
                string strEmailCompanyName = "";                                    // ABW 20140805
                if (setting != null)                                                // ABW 20140805
                {
                    strEmailCompanyName = setting.VALUE;
                }

                if (isNew)
                {
                    // send a confirmation email
                    // string strength = WebConfigurationManager.AppSettings["PasswordComplexity"]; // ABW 20140805
                    SETTINGS complexity = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordComplexity"); // ABW 20140805
                    string   strength   = "";                                                                                 // ABW 20140805
                    if (complexity == null)
                    {
                        strength = "4";
                    }
                    else
                    {
                        strength = complexity.VALUE;
                    }

                    SQM.Website.PSsqmEntities ctxAccess = new PSsqmEntities();
                    SQM_ACCESS access      = SQMModelMgr.LookupCredentials(ctxAccess, LocalPerson().SSO_ID, "", false);
                    string     key         = SQMModelMgr.GetPasswordKey();
                    string     strPassword = WebSiteCommon.Decrypt(access.PASSWORD, key);

                    // ABW 20140805 - Build the email based on fields in the SETTINGS table
                    // the following is standard email
                    //string strEmailBody = lblPasswordEmailBody1a.Text.ToString() + strEmailCompanyName + lblPasswordEmailBody1b.Text.ToString() + " " + selectedUser.SSO_ID + lblPasswordEmailBody2.Text.ToString() + " " + strPassword;
                    //strEmailBody += "<br><br>" + WebSiteCommon.GetXlatValueLong("passwordComplexity", strength) + "<br><br>" + lblPasswordEmailBody3.Text.ToString().Trim();

                    // the following is for TI only
                    //string strEmailBody = "Risk Management Professional,<br><br>TI Automotive Risk Management is pleased to offer you access to the TI Automotive Risk Management Portal (Portal)<br><br>The Portal will be used to provide tracking for:<br>";
                    //strEmailBody += "<ul><li>Environmental performance tracking</li><li>Insurer Recommendations response</li><li>Internal Risk Quality Index Recommendations Response</li><li>Safety Alerts</li>";
                    //strEmailBody += "<br>A new user account has been created for you in the Portal.<br><br>Access the website by clicking on the link: <a href='http://Ti.qai.luxinteractive.com'>Ti.qai.luxinteractive.com</a><br><br>";
                    //strEmailBody += "Your username has been assigned: <font color='red'>" + selectedUser.SSO_ID + "</font><br>Your temporary password is: <font color='red'>" + strPassword + "</font>";
                    //strEmailBody += "<br>Once you gain access to the Portal you must change your password. " + WebSiteCommon.GetXlatValueLong("passwordComplexity", strength) + "<br><br>" + lblPasswordEmailBody3.Text.ToString().Trim();
                    //strEmailBody += "<br><br><b>Michael D. Wildfong</b><br>Global Director Facilities Risk Management<br>TI Automotive<br>1272 Doris Road<br>Auburn Hills, MI 48326<br>t: +1 248 494 5320<br>m: + 1 810 265 1677<br>f: +1 248 494 5302";
                    //strEmailBody += "<br>e: <a href='mailto:[email protected]'>[email protected]</a>";

                    // ABW 20140805 - Build the email based on fields in the SETTINGS table
                    string strEmailSubject = "";
                    setting = MailSettings.Find(x => x.SETTING_CD == "NewUserSubject");
                    if (setting == null)
                    {
                        strEmailSubject = strEmailCompanyName + " " + lblPasswordEmailSubject.Text.ToString();
                    }
                    else
                    {
                        strEmailSubject = setting.VALUE.Trim();
                    }
                    setting = MailSettings.Find(x => x.SETTING_CD == "NewUserWelcome");
                    string strEmailBody = "";
                    if (setting == null)
                    {
                        strEmailBody = lblPasswordEmailBody1a.Text.ToString();
                    }
                    else
                    {
                        strEmailBody = setting.VALUE.Trim();
                    }
                    strEmailBody += lblPasswordEmailBody1b.Text.ToString() + " " + LocalPerson().SSO_ID + lblPasswordEmailBody2.Text.ToString() + " " + strPassword;
                    setting       = MailSettings.Find(x => x.SETTING_CD == "MailURL");
                    if (setting != null)
                    {
                        strEmailBody += lblPasswordEmailBody2b.Text.ToString() + "<a href='" + setting.VALUE + "'>" + setting.VALUE + "</a>";
                    }
                    complexity = SQMSettings.SelectSettingByCode(entities, "PASSWORDCOMPLEXITY", "TASK", strength);                     // ABW 20140805
                    if (complexity != null)
                    {
                        strEmailBody += "<br><br>" + complexity.VALUE + "<br><br>";
                    }
                    setting = MailSettings.Find(x => x.SETTING_CD == "NewUserSignature");
                    if (setting == null)
                    {
                        strEmailBody += "<br><br>" + lblPasswordEmailBody3.Text.ToString();
                    }
                    else
                    {
                        strEmailBody += "<br><br>" + setting.VALUE.Trim();
                    }

                    // ABW 20140117 - we are now using the email on the Person record
                    Thread thread = new Thread(() => WebSiteCommon.SendEmail(person.EMAIL, strEmailSubject, strEmailBody.Trim(), ""));
                    thread.IsBackground = true;
                    thread.Start();
                }
                else
                {
                    bool roleChanged = person.ROLE != currentPerson.ROLE || person.PERSON_ACCESS.Count != currentPerson.PERSON_ACCESS.Count ? true : false;
                    if (roleChanged)
                    {
//						string strEmailBody = lblUserRoleEmailBodya.Text + strEmailCompanyName + lblUserRoleEmailBodyb.Text + "<br><br>" + lblUserRoleEmailBodyc.Text;
                        // ABW 20140805 - Build the email based on fields in the SETTINGS table
                        string strEmailSubject = "";
                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeSubject");
                        if (setting == null)
                        {
                            strEmailSubject = lblUserRoleEmailSubjecta.Text + strEmailCompanyName + lblUserRoleEmailSubjectb.Text;
                        }
                        else
                        {
                            strEmailSubject = setting.VALUE.Trim();
                        }
                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeWelcome");
                        string strEmailBody = "";
                        if (setting == null)
                        {
                            strEmailBody = lblUserRoleEmailBodya.Text + strEmailCompanyName + lblUserRoleEmailBodyb.Text;
                        }
                        else
                        {
                            strEmailBody = setting.VALUE.Trim();
                        }

                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeSignature");
                        if (setting == null)
                        {
                            strEmailBody += "<br><br>" + lblUserRoleEmailBodyc.Text;
                        }
                        else
                        {
                            strEmailBody += "<br><br>" + setting.VALUE.Trim();
                        }
                        Thread thread = new Thread(() => WebSiteCommon.SendEmail(person.EMAIL, strEmailSubject, strEmailBody, ""));
                        thread.IsBackground = true;
                        thread.Start();
                    }
                    if (cbResetPassword.Checked)
                    {
                        // build the email body in 3 segments
                        SETTINGS complexity = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordComplexity");
                        string   strength   = "";
                        if (complexity == null)
                        {
                            strength = "4";
                        }
                        else
                        {
                            strength = complexity.VALUE;
                        }
                        string strEmailSubject = "";
                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminPasswordResetSubject");
                        if (setting == null)
                        {
                            strEmailSubject = strEmailCompanyName + " " + lblResetEmailSubject.Text.ToString();
                        }
                        else
                        {
                            strEmailSubject = setting.VALUE.Trim();
                        }
                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminPasswordResetWelcome");
                        string strEmailBodya = "";
                        string strEmailBodyb = "";
                        string strEmailBodyc = "";
                        if (setting == null)
                        {
                            strEmailBodya = lblPasswordEmailBody1a.Text.ToString();
                        }
                        else
                        {
                            strEmailBodya = setting.VALUE.Trim();
                        }
                        strEmailBodya += lblPasswordEmailBody1b.Text.ToString();
                        strEmailBodyb  = lblPasswordEmailBody2.Text.ToString();
                        setting        = MailSettings.Find(x => x.SETTING_CD == "MailURL");
                        if (setting != null)
                        {
                            strEmailBodyc += lblPasswordEmailBody2b.Text.ToString() + "<a href='" + setting.VALUE + "'>" + setting.VALUE + "</a>";
                        }
                        complexity = SQMSettings.SelectSettingByCode(entities, "PASSWORDCOMPLEXITY", "TASK", strength);
                        if (complexity != null)
                        {
                            strEmailBodyc += "<br><br>" + complexity.VALUE + "<br><br>";
                        }
                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminPasswordResetSignature");
                        if (setting == null)
                        {
                            strEmailBodyc += "<br><br>" + lblPasswordEmailBody3.Text.ToString();
                        }
                        else
                        {
                            strEmailBodyc += "<br><br>" + setting.VALUE.Trim();
                        }
                        int msg = WebSiteCommon.RecoverPassword(person.EMAIL, person.SSO_ID, strEmailSubject, strEmailBodya, strEmailBodyb, strEmailBodyc);
                    }
                }
                isNew = false;
                if (SQMModelMgr.updateStatus < 0)  // report error
                {
                    AlertUpdateResult(SQMModelMgr.updateStatus);
                }
            }
            else
            {
                SetLocalPerson(person);
            }
            return(true);
        }
 private void uclSearchBar_OnSaveClick()
 {
     IssueCtl().qualityIssue = uclQualityIssue.UpdateIssue(IssueCtl().qualityIssue);
     if (IssueCtl().qualityIssue.Status == QualityIssue.UpdateStatus.Success)
     {
         if (IssueCtl().Update() != null)
         {
             uclQualityIssue.SaveAttachments(IssueCtl().qualityIssue);
             if (IssueCtl().qualityIssue.ShouldSendMail())
             {
                 IssueCtl().qualityIssue.Incident.RESP_TEAMID = IssueCtl().qualityIssue.MailNotify(SQMSettings.SelectSettingByCode(entities, "MAIL", "TASK", "MailURL").VALUE);
                 IssueCtl().Update();
             }
             IssueCtl().qualityIssue.ResetIndicators(false);
             uclQualityIssue.BindIssue();
             uclSearchBar1.TitleItem.Text = IssueCtl().qualityIssue.IssueID;
             ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alertResult('hfAlertSaveSuccess');", true);
         }
         else
         {
             ErrorAlert(QualityIssue.UpdateStatus.SaveError);
         }
     }
     else
     {
         ErrorAlert(IssueCtl().qualityIssue.Status);
     }
 }
        protected bool SaveUser(bool updateUser)
        {
            bool  bErrors = false;
            bool  success;
            Label lblErrorMessage = null;

            PERSON person        = LocalPerson();
            string currentSSOID  = LocalPerson().SSO_ID;
            PERSON currentPerson = new PERSON();

            if (isNew)
            {
                person.SSO_ID = string.IsNullOrEmpty(tbUserSSOID.Text) ? "" : tbUserSSOID.Text.Trim();  // trim traling blanks when creating new user
            }
            else
            {
                person             = SQMModelMgr.LookupPerson(entities, person.PERSON_ID, "", false);
                person.SSO_ID      = string.IsNullOrEmpty(tbUserSSOID.Text) ? "" : tbUserSSOID.Text;
                currentPerson.ROLE = person.ROLE;
            }

            person.FIRST_NAME  = string.IsNullOrEmpty(tbUserFirstName.Text) ? "" : tbUserFirstName.Text;
            person.LAST_NAME   = string.IsNullOrEmpty(tbUserLastName.Text) ? "" : tbUserLastName.Text;
            person.MIDDLE_NAME = string.IsNullOrEmpty(tbUserMiddleName.Text) ? "" : tbUserMiddleName.Text;
            person.JOBCODE_CD  = ddlJobCode.SelectedValue;
            if (string.IsNullOrEmpty(ddlPrivGroup.SelectedValue))
            {
                person.PRIV_GROUP = null;
            }
            else
            {
                person.PRIV_GROUP = ddlPrivGroup.SelectedValue;
            }
            person.PHONE       = tbUserPhone.Text;
            person.EMAIL       = tbUserEmail.Text;
            person.EMP_ID      = tbEmpID.Text;
            person.SUPV_EMP_ID = tbSupvEmpID.Text;

            if (!string.IsNullOrEmpty(ddlUserLanguage.SelectedValue))
            {
                person.PREFERRED_LANG_ID = Convert.ToInt32(ddlUserLanguage.SelectedValue);
            }
            if (!string.IsNullOrEmpty(ddlUserTimezone.SelectedValue))
            {
                person.PREFERRED_TIMEZONE = ddlUserTimezone.SelectedValue;
            }

            person.COMPANY_ID = SessionManager.EffLocation.Company.COMPANY_ID;
            if (!string.IsNullOrEmpty(ddlHRLocation.SelectedValue))
            {
                PLANT plant = SQMModelMgr.LookupPlant(Convert.ToDecimal(ddlHRLocation.SelectedValue));
                if (plant != null)
                {
                    person.PLANT_ID   = plant.PLANT_ID;
                    person.BUS_ORG_ID = (decimal)plant.BUS_ORG_ID;
                }
            }

            person.NEW_LOCATION_CD = "";
            foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect))
            {
                if (string.IsNullOrEmpty(person.NEW_LOCATION_CD))
                {
                    person.NEW_LOCATION_CD = ",";
                }
                person.NEW_LOCATION_CD += (item.Value + ",");
            }

            person.OLD_LOCATION_CD = "";

            /* quality module reference
             * foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlCustPlantSelect))
             * {
             *  person.OLD_LOCATION_CD += (item.Value + ",");
             * }
             * person.OLD_LOCATION_CD = person.OLD_LOCATION_CD.TrimEnd(',');
             */
            person.STATUS = ddlUserStatus.SelectedValue;

            // roles were originally a list - let's keep the logic below just in case we need to restore a multi-role strategy
            //person.PERSON_ROLE.Clear();
            person.ROLE           = 100;   /////
            person.RCV_ESCALATION = true;

            person.LOCKS = "";
            if (cbUserEmailLock.Checked)
            {
                person.LOCKS += (LockField.email.ToString() + ",");
            }
            if (cbPrivGroupLock.Checked)
            {
                person.LOCKS += (LockField.priv.ToString() + ",");
            }
            if (cbHRLocationLock.Checked)
            {
                person.LOCKS += (LockField.plant.ToString() + ",");
            }
            if (cbUserLanguageLock.Checked)
            {
                person.LOCKS += (LockField.lang.ToString() + ",");
            }
            person.LOCKS = person.LOCKS.TrimEnd(',');

            SetLocalPerson(person);

            if (string.IsNullOrEmpty(tbUserSSOID.Text) || string.IsNullOrEmpty(tbUserFirstName.Text) || string.IsNullOrEmpty(tbUserLastName.Text) ||
                ddlJobCode.SelectedIndex < 0 || string.IsNullOrEmpty(ddlHRLocation.SelectedValue) ||
                string.IsNullOrEmpty(ddlHRLocation.SelectedValue))
            {
                lblErrorMessage = lblErrRequiredInputs;
            }

            if (lblErrorMessage == null)
            {
                // AW20131106 - need to verify that the SSO_ID and email address are unique in the system
                lblDuplicateSSOId.Visible = false;
                lblDuplicateEmail.Visible = false;
                string strSSOId = tbUserSSOID.Text;
                string strEmail = tbUserEmail.Text;
                if (isNew) // || !strSSOId.Equals(person.SSO_ID))
                {
                    // verify unique sso_id
                    strSSOId = tbUserSSOID.Text.Trim();
                    SQM.Website.PSsqmEntities ctxAccess = new PSsqmEntities();
                    SQM_ACCESS access = SQMModelMgr.LookupCredentials(ctxAccess, strSSOId, "", false);
                    if (access != null && access.SSO_ID.ToLower().Equals(strSSOId.ToLower()))
                    {
                        lblErrorMessage = lblDuplicateSSOId;
                    }
                }
                if (lblErrorMessage == null && (isNew || !strEmail.Equals(person.EMAIL)))
                {
                    // verify unique email
                    SQM.Website.PSsqmEntities ctxAccess = new PSsqmEntities();
                    //SQM_ACCESS access = SQMModelMgr.LookupCredentialsByEmail(ctxAccess, strEmail, false);
                    // ABW 20140117 - we want to look up email on person record...
                    PERSON personEmail = SQMModelMgr.LookupPersonByEmail(ctxAccess, strEmail);
                    if (personEmail != null && personEmail.EMAIL.Trim().ToLower().Equals(strEmail.Trim().ToLower()))
                    {
                        lblErrorMessage = lblDuplicateEmail;
                    }
                }
            }
            if (lblErrorMessage != null)
            {
                DisplayUser();
                DisplayErrorMessage(lblErrorMessage);
                return(false);
            }

            if (updateUser)
            {
                string defaultPwd  = "";
                string environment = System.Configuration.ConfigurationManager.AppSettings["environment"].ToString();
                string altEmail    = !string.IsNullOrEmpty(environment) && environment.ToLower() == "dev" ?  System.Configuration.ConfigurationManager.AppSettings["altEmail"].ToString() : "";
                if (isNew)
                {
                    SETTINGS pwdInitial = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordDefault");
                    if (pwdInitial != null)
                    {
                        switch (pwdInitial.VALUE.ToUpper())
                        {
                        case "LASTNAME":
                            defaultPwd = person.LAST_NAME;
                            break;

                        case "EMPID":
                            defaultPwd = person.EMP_ID;
                            break;

                        default:
                            break;
                        }
                    }
                }
                SetLocalPerson(SQMModelMgr.UpdatePerson(entities, person, SessionManager.UserContext.UserName(), false, currentSSOID, defaultPwd));
                //selectedUser = SQMModelMgr.UpdatePerson(entities, person, SessionManager.UserContext.UserName(), Convert.ToBoolean(GetFindControlValue("cbIsBuyer", hfBase, out success)), GetFindControlValue("tbBuyerCode", hfBase, out success));
                // AW20131106 - send an email for new users with random password generation
                List <SETTINGS> MailSettings = SQMSettings.SelectSettingsGroup("MAIL", ""); // ABW 20140805
                SETTINGS        setting      = new SETTINGS();                              // ABW 20140805
                setting = MailSettings.Find(x => x.SETTING_CD == "MailFromSystem");         // ABW 20140805
                string strEmailCompanyName = "";                                            // ABW 20140805
                if (setting != null)                                                        // ABW 20140805
                {
                    strEmailCompanyName = setting.VALUE;
                }
                bool sendEmail = false;
                setting = MailSettings.Find(x => x.SETTING_CD == "SendNewUserEmail");
                if (setting != null && setting.VALUE.ToLower().Equals("true"))                 // ABW 20140805
                {
                    sendEmail = true;
                }

                List <XLAT> XLATList = SQMBasePage.SelectXLATList(new string[1] {
                    "USER_EMAIL"
                }, 0);
                string         strEmailSubject = "";
                string         strEmailBody    = "";
                LOCAL_LANGUAGE lang            = SQMModelMgr.LookupLanguage(new PSsqmEntities(), "", (int)person.PREFERRED_LANG_ID, false);
                string         strTemp         = "";

                if (isNew && (string.IsNullOrEmpty(defaultPwd) || sendEmail))                  // send email notice only when a default password was not set
                {
                    // send a confirmation email
                    // string strength = WebConfigurationManager.AppSettings["PasswordComplexity"]; // ABW 20140805
                    SETTINGS complexity = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordComplexity"); // ABW 20140805
                    string   strength   = "";                                                                                 // ABW 20140805
                    if (complexity == null)
                    {
                        strength = "4";
                    }
                    else
                    {
                        strength = complexity.VALUE;
                    }

                    SQM.Website.PSsqmEntities ctxAccess = new PSsqmEntities();
                    SQM_ACCESS access      = SQMModelMgr.LookupCredentials(ctxAccess, LocalPerson().SSO_ID, "", false);
                    string     key         = SQMModelMgr.GetPasswordKey();
                    string     strPassword = WebSiteCommon.Decrypt(access.PASSWORD, key);

                    // ABW 20140805 - Build the email based on fields in the SETTINGS table
                    //string strEmailSubject = "";
                    //setting = MailSettings.Find(x => x.SETTING_CD == "NewUserSubject");
                    //if (setting == null)
                    //	strEmailSubject = strEmailCompanyName + " " + lblPasswordEmailSubject.Text.ToString();
                    //else
                    //	strEmailSubject = setting.VALUE.Trim();
                    //setting = MailSettings.Find(x => x.SETTING_CD == "NewUserWelcome");
                    //string strEmailBody = "";
                    //if (setting == null)
                    //	strEmailBody = lblPasswordEmailBody1a.Text.ToString();
                    //else
                    //	strEmailBody = setting.VALUE.Trim();
                    //strEmailBody += lblPasswordEmailBody1b.Text.ToString() + " " + LocalPerson().SSO_ID + lblPasswordEmailBody2.Text.ToString() + " " + strPassword;
                    //setting = MailSettings.Find(x => x.SETTING_CD == "MailURL");
                    //if (setting != null)
                    //	strEmailBody += lblPasswordEmailBody2b.Text.ToString() + "<a href='" + setting.VALUE + "'>" + setting.VALUE + "</a>";
                    //complexity = SQMSettings.SelectSettingByCode(entities, "PASSWORDCOMPLEXITY", "TASK", strength); // ABW 20140805
                    //if (complexity != null)
                    //	strEmailBody += "<br><br>" + complexity.VALUE + "<br><br>";
                    //setting = MailSettings.Find(x => x.SETTING_CD == "NewUserSignature");
                    //if (setting == null)
                    //	strEmailBody += "<br><br>" + lblPasswordEmailBody3.Text.ToString();
                    //else
                    //	strEmailBody += "<br><br>" + setting.VALUE.Trim();

                    // ABW 20160115 - Build the email based on fields in the XLAT table
                    strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserSubject", lang.NLS_LANGUAGE).DESCRIPTION;
                    if (strTemp == null || strTemp == "")
                    {
                        strEmailSubject = strEmailCompanyName + " " + lblPasswordEmailSubject.Text.ToString();
                    }
                    else
                    {
                        strEmailSubject = strTemp.Trim();
                    }
                    strTemp      = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserWelcome", lang.NLS_LANGUAGE).DESCRIPTION;
                    strEmailBody = "";
                    if (strTemp == null || strTemp == "")
                    {
                        strEmailBody = lblPasswordEmailBody1a.Text.ToString();
                    }
                    else
                    {
                        strEmailBody = strTemp.Trim();
                    }
                    strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserBodyUsername", lang.NLS_LANGUAGE).DESCRIPTION;
                    if (strTemp == null || strTemp == "")
                    {
                        strEmailBody += lblPasswordEmailBody1b.Text.ToString();
                    }
                    else
                    {
                        strEmailBody += strTemp.Trim();
                    }
                    strEmailBody += " " + LocalPerson().SSO_ID;
                    strTemp       = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserBodyPassword", lang.NLS_LANGUAGE).DESCRIPTION;
                    if (strTemp == null || strTemp == "")
                    {
                        strEmailBody += lblPasswordEmailBody2.Text.ToString();
                    }
                    else
                    {
                        strEmailBody += strTemp.Trim();
                    }
                    strEmailBody += " " + strPassword;
                    strTemp       = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserBodyUrl", lang.NLS_LANGUAGE).DESCRIPTION;
                    string strUrlLabel = "";
                    if (strTemp == null || strTemp == "")
                    {
                        strUrlLabel = lblPasswordEmailBody2b.Text.ToString();
                    }
                    else
                    {
                        strUrlLabel = strTemp.Trim();
                    }
                    setting = MailSettings.Find(x => x.SETTING_CD == "MailURL");
                    if (setting != null)
                    {
                        strEmailBody += strUrlLabel + " <a href='" + setting.VALUE + "'>" + setting.VALUE + "</a>";
                    }
                    complexity = SQMSettings.SelectSettingByCode(entities, "PASSWORDCOMPLEXITY", "TASK", strength);                     // ABW 20140805
                    if (complexity != null)
                    {
                        strEmailBody += "<br><br>" + complexity.VALUE + "<br><br>";
                    }
                    strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserSignature", lang.NLS_LANGUAGE).DESCRIPTION;
                    if (strTemp == null || strTemp == "")
                    {
                        strEmailBody += "<br><br>" + lblPasswordEmailBody3.Text.ToString();
                    }
                    else
                    {
                        strEmailBody += "<br><br>" + strTemp.Trim();
                    }

                    // ABW 20140117 - we are now using the email on the Person record

                    /*
                     * Thread thread = new Thread(() => WebSiteCommon.SendEmail(person.EMAIL, strEmailSubject, strEmailBody.Trim(), ""));
                     * thread.IsBackground = true;
                     * thread.Start();
                     */
                    string mailStatus = WebSiteCommon.SendEmail(person.EMAIL, strEmailSubject, strEmailBody.Trim(), "");
                    EHSNotificationMgr.WriteEmailLog(entities, person.EMAIL, "", strEmailSubject, strEmailBody, 0, LocalPerson().PERSON_ID, ("user password notification - is new = " + isNew.ToString()), mailStatus, altEmail);
                }
                else
                {
                    bool roleChanged = person.ROLE != currentPerson.ROLE ? true : false;
                    // ABW 20160115 - send an email based on a parameter
                    setting = MailSettings.Find(x => x.SETTING_CD == "SendChangeUserEmail");
                    if (setting != null && setting.VALUE.ToLower().Equals("true"))
                    {
                        sendEmail = true;
                    }
                    else
                    {
                        sendEmail = false;
                    }

                    if (roleChanged && sendEmail)
                    {
                        //ABW 20140805 - Build the email based on fields in the SETTINGS table
                        //strEmailSubject = "";
                        //setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeSubject");
                        //if (setting == null)
                        //	strEmailSubject = lblUserRoleEmailSubjecta.Text + strEmailCompanyName + lblUserRoleEmailSubjectb.Text;
                        //else
                        //	strEmailSubject = setting.VALUE.Trim();
                        //setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeWelcome");
                        //string strEmailBody = "";
                        //if (setting == null)
                        //	strEmailBody = lblUserRoleEmailBodya.Text + strEmailCompanyName + lblUserRoleEmailBodyb.Text;
                        //else
                        //	strEmailBody = setting.VALUE.Trim();

                        //setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeSignature");
                        //if (setting == null)
                        //	strEmailBody += "<br><br>" + lblUserRoleEmailBodyc.Text;
                        //else
                        //	strEmailBody += "<br><br>" + setting.VALUE.Trim();

                        //ABW 20160115 - Build the email based on fields in the XLAT table
                        strEmailSubject = "";
                        strTemp         = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "AdminRoleChangeSubject", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailSubject = lblUserRoleEmailSubjecta.Text + strEmailCompanyName + lblUserRoleEmailSubjectb.Text;
                        }
                        else
                        {
                            strEmailSubject = strTemp.Trim();
                        }

                        strEmailBody = "";
                        strTemp      = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "AdminRoleChangeWelcome", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailBody = lblUserRoleEmailBodya.Text + strEmailCompanyName + lblUserRoleEmailBodyb.Text;
                        }
                        else
                        {
                            strEmailBody = strTemp.Trim();
                        }

                        setting = MailSettings.Find(x => x.SETTING_CD == "AdminRoleChangeSignature");
                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "AdminRoleChangeSignature", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailBody += "<br><br>" + lblUserRoleEmailBodyc.Text;
                        }
                        else
                        {
                            strEmailBody += strTemp.Trim();
                        }

                        /*
                         * Thread thread = new Thread(() => WebSiteCommon.SendEmail(person.EMAIL, strEmailSubject, strEmailBody, ""));
                         * thread.IsBackground = true;
                         * thread.Start();
                         */
                        string mailStatus = WebSiteCommon.SendEmail(person.EMAIL, strEmailSubject, strEmailBody, "");
                        EHSNotificationMgr.WriteEmailLog(entities, person.EMAIL, "", strEmailSubject, strEmailBody, 0, LocalPerson().PERSON_ID, "user role changed", mailStatus, altEmail);
                    }

                    if (cbResetPassword.Checked)                     // always send an email when the password changes
                    {
                        // build the email body in 3 segments
                        SETTINGS complexity = SQMSettings.SelectSettingByCode(entities, "COMPANY", "TASK", "PasswordComplexity");
                        string   strength   = "";
                        if (complexity == null)
                        {
                            strength = "4";
                        }
                        else
                        {
                            strength = complexity.VALUE;
                        }

                        // ABW 20140805 - Build the email based on fields in the SETTINGS table
                        //string strEmailSubject = "";
                        //setting = MailSettings.Find(x => x.SETTING_CD == "AdminPasswordResetSubject");
                        //if (setting == null)
                        //	strEmailSubject = strEmailCompanyName + " " + lblResetEmailSubject.Text.ToString();
                        //else
                        //	strEmailSubject = setting.VALUE.Trim();
                        //setting = MailSettings.Find(x => x.SETTING_CD == "AdminPasswordResetWelcome");
                        //string strEmailBodya = "";
                        //string strEmailBodyb = "";
                        //string strEmailBodyc = "";
                        //if (setting == null)
                        //	strEmailBodya = lblPasswordEmailBody1a.Text.ToString();
                        //else
                        //	strEmailBodya = setting.VALUE.Trim();
                        //strEmailBodya += lblPasswordEmailBody1b.Text.ToString();
                        //strEmailBodyb = lblPasswordEmailBody2.Text.ToString();
                        //setting = MailSettings.Find(x => x.SETTING_CD == "MailURL");
                        //if (setting != null)
                        //	strEmailBodyc += lblPasswordEmailBody2b.Text.ToString() + "<a href='" + setting.VALUE + "'>" + setting.VALUE + "</a>";
                        //complexity = SQMSettings.SelectSettingByCode(entities, "PASSWORDCOMPLEXITY", "TASK", strength);
                        //if (complexity != null)
                        //	strEmailBodyc += "<br><br>" + complexity.VALUE + "<br><br>";
                        //setting = MailSettings.Find(x => x.SETTING_CD == "AdminPasswordResetSignature");
                        //if (setting == null)
                        //	strEmailBodyc += "<br><br>" + lblPasswordEmailBody3.Text.ToString();
                        //else
                        //	strEmailBodyc += "<br><br>" + setting.VALUE.Trim();

                        // ABW 20160115 - Build the email based on fields in the XLAT table
                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "AdminPasswordResetSubject", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailSubject = strEmailCompanyName + " " + lblPasswordEmailSubject.Text.ToString();
                        }
                        else
                        {
                            strEmailSubject = strTemp.Trim();
                        }

                        string strEmailBodya = "";
                        string strEmailBodyb = "";
                        string strEmailBodyc = "";
                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "AdminPasswordResetWelcome", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailBodya = lblResetEmailBody1a.Text.ToString();
                        }
                        else
                        {
                            strEmailBodya = strTemp.Trim();
                        }

                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserBodyUsername", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailBodya += lblPasswordEmailBody1b.Text.ToString();
                        }
                        else
                        {
                            strEmailBodya += strTemp.Trim();
                        }

                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserBodyPassword", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailBodyb = lblPasswordEmailBody2.Text.ToString();
                        }
                        else
                        {
                            strEmailBodyb = strTemp.Trim();
                        }

                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserBodyUrl", lang.NLS_LANGUAGE).DESCRIPTION;
                        string strUrlLabel = "";
                        if (strTemp == null || strTemp == "")
                        {
                            strUrlLabel = lblPasswordEmailBody2b.Text.ToString();
                        }
                        else
                        {
                            strUrlLabel = strTemp.Trim();
                        }
                        setting = MailSettings.Find(x => x.SETTING_CD == "MailURL");
                        if (setting != null)
                        {
                            strEmailBodyc += strUrlLabel.Trim() + "<a href='" + setting.VALUE + "'>" + setting.VALUE + "</a>";
                        }
                        complexity = SQMSettings.SelectSettingByCode(entities, "PASSWORDCOMPLEXITY", "TASK", strength);
                        if (complexity != null)
                        {
                            strEmailBodyc += "<br><br>" + complexity.VALUE + "<br><br>";
                        }

                        strTemp = SQMBasePage.GetXLAT(XLATList, "USER_EMAIL", "NewUserSignature", lang.NLS_LANGUAGE).DESCRIPTION;
                        if (strTemp == null || strTemp == "")
                        {
                            strEmailBodyc += "<br><br>" + lblPasswordEmailBody3.Text.ToString();
                        }
                        else
                        {
                            strEmailBodyc += "<br><br>" + strTemp.Trim();
                        }

                        int msg = WebSiteCommon.RecoverPassword(person.EMAIL, person.SSO_ID, strEmailSubject, strEmailBodya, strEmailBodyb, strEmailBodyc);
                        EHSNotificationMgr.WriteEmailLog(entities, person.EMAIL, "", strEmailSubject, strEmailBodya, 0, LocalPerson().PERSON_ID, "recover password", msg.ToString(), altEmail);
                    }
                }
                isNew = false;
                if (SQMModelMgr.updateStatus < 0)  // report error
                {
                    AlertUpdateResult(SQMModelMgr.updateStatus);
                }
            }
            else
            {
                SetLocalPerson(person);
            }
            return(true);
        }