Ejemplo n.º 1
0
        public bool BindTaskComplete(TASK_STATUS task, string helpInfo)
        {
            pnlStatusComplete.Visible = true;

            bool isComplete = false;

            if (task != null)
            {
                if (task.STATUS == Convert.ToInt32(TaskStatus.Complete).ToString())
                {
                    cbStatusComplete.Checked = isComplete = true;
                    cbStatusComplete.Enabled = false;
                    PERSON person = SQMModelMgr.LookupPerson((decimal)task.COMPLETE_ID, "");
                    if (person != null)
                    {
                        cbStatusComplete.Text = "Completed by " + person.FIRST_NAME + " " + person.LAST_NAME;
                    }
                }

                if (!string.IsNullOrEmpty(helpInfo))
                {
                    AddToolTip(task.TASK_STEP, helpInfo);
                }
            }

            return(isComplete);
        }
Ejemplo n.º 2
0
        protected void lnkUserView_Click(object sender, EventArgs e)
        {
            LinkButton lnk    = (LinkButton)sender;
            decimal    userID = Convert.ToDecimal(lnk.CommandArgument.ToString().Trim());

            SessionManager.SelectedUser = SQMModelMgr.LookupPerson(entities, userID, "", false);

            Response.Redirect("/Admin/Administrate_ViewUser.aspx");
        }
Ejemplo n.º 3
0
        protected void lnkBuyerView_Click(object sender, EventArgs e)
        {
            LinkButton lnk      = (LinkButton)sender;
            decimal    personID = Convert.ToDecimal(lnk.CommandArgument.ToString().Trim());

            PERSON buyerPerson = SQMModelMgr.LookupPerson(entities, personID, "", false);

            SessionManager.Buyer = buyerPerson.BUYER.First();

            Response.Redirect("/Admin/Administrate_ViewBuyer.aspx");
        }
Ejemplo n.º 4
0
 protected void OnPersonListClick(decimal personID)
 {
     if (personID > 0)
     {
         PERSON person = SQMModelMgr.LookupPerson(personID, "");
         rsbPerson.Text = string.Format("{0}, {1}", person.LAST_NAME, person.FIRST_NAME);
         if (OnSearchItemSelect != null)
         {
             OnSearchItemSelect(personID.ToString());
         }
     }
 }
Ejemplo n.º 5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            PSsqmEntities ctx  = new PSsqmEntities();
            PERSON        user = SQMModelMgr.LookupPerson(ctx, SessionManager.UserContext.Person.PERSON_ID, "", false);

            user.PHONE = tbUserPhone.Text;
            user       = SQMModelMgr.UpdatePerson(ctx, user, SessionManager.UserContext.UserName());
            if (user != null)
            {
                SessionManager.UserContext.Person = user;  // ??
            }
        }
Ejemplo n.º 6
0
        public static List <PERSON> InvolvedPersonList(INCIDENT incident)
        {
            List <PERSON> involvedList = new List <PERSON>();

            if (incident.ISSUE_TYPE_ID == (int)EHSIncidentTypeId.InjuryIllness)
            {
                PSsqmEntities         ctx      = new PSsqmEntities();
                INCFORM_INJURYILLNESS iiDetail = EHSIncidentMgr.SelectInjuryIllnessDetailsById(ctx, incident.INCIDENT_ID);
                if (iiDetail != null && iiDetail.INVOLVED_PERSON_ID.HasValue)
                {
                    involvedList = SQMModelMgr.GetSupvHierarchy(ctx, SQMModelMgr.LookupPerson(ctx, (decimal)iiDetail.INVOLVED_PERSON_ID, "", false), 2, true);
                }
            }

            return(involvedList);
        }
Ejemplo n.º 7
0
        public PERSON UpdateUser()
        {
            PSsqmEntities ctx  = new PSsqmEntities();
            PERSON        user = SQMModelMgr.LookupPerson(ctx, SessionManager.UserContext.Person.PERSON_ID, "", false);

            user.PHONE = tbUserPhone.Text;

            user = SQMModelMgr.UpdatePerson(ctx, user, SessionManager.UserContext.UserName());

            if (OnPersonUpdate != null)
            {
                OnPersonUpdate(user);
            }


            return(user);
        }
Ejemplo n.º 8
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            PSsqmEntities ctx  = new PSsqmEntities();
            PERSON        user = SQMModelMgr.LookupPerson(ctx, SessionManager.UserContext.Person.PERSON_ID, "", false);

            user.PHONE = tbUserPhone.Text;
            if (!string.IsNullOrEmpty(ddlUserLang.SelectedValue))
            {
                user.PREFERRED_LANG_ID = Convert.ToInt32(ddlUserLang.SelectedValue);
                SessionManager.SessionContext.SetLanguage((int)user.PREFERRED_LANG_ID);
            }
            user = SQMModelMgr.UpdatePerson(ctx, user, SessionManager.UserContext.UserName());
            if (user != null)
            {
                SessionManager.UserContext.Person = user;                  // ??
            }
        }
Ejemplo n.º 9
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);
        }
        private void SetUserList(bool loadAll)
        {
            BUYER         buyer      = SessionManager.Buyer;
            List <PERSON> personList = null;

            if (loadAll)
            {
                personList = SQMModelMgr.SelectPersonList(SessionManager.ActiveCompany().COMPANY_ID, 0, false);
                foreach (PERSON person in personList)
                {
                    person.SSO_ID = person.FIRST_NAME + " " + person.LAST_NAME;
                }
            }
            else
            {
                PERSON person = SQMModelMgr.LookupPerson(entities, buyer.PERSON_ID, "", false);
                if (person != null)
                {
                    person.SSO_ID = person.FIRST_NAME + " " + person.LAST_NAME;
                    personList    = new List <PERSON>();
                    personList.Add(person);
                }
            }

            ddlUsers.DataSource     = personList;
            ddlUsers.DataTextField  = "SSO_ID";
            ddlUsers.DataValueField = "PERSON_ID";
            ddlUsers.DataBind();
            ddlUsers.Items.Insert(0, new ListItem("--- no user selected ---", "0"));

            if (buyer.PERSON_ID > 0)
            {
                ddlUsers.SelectedValue = buyer.PERSON_ID.ToString();
            }
            else
            {
                ddlUsers.SelectedValue = "0";
            }
        }
Ejemplo n.º 11
0
        public void rptResponseList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    ResponseItem response = (ResponseItem)e.Item.DataItem;

                    Label lbl = (Label)e.Item.FindControl("lblPersonName_out");
                    lbl.Text = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson(response.Response.PERSON_ID, ""));
                    if (!string.IsNullOrEmpty(response.Response.REFERENCE_DATA))
                    {
                        Control parent = lbl.Parent;
                        int     idx    = parent.Controls.IndexOf(lbl) + 1;
                        lbl          = new Label();
                        lbl.Text     = response.Response.REFERENCE_DATA;
                        lbl.CssClass = "refText";
                        parent.Controls.AddAt(idx, new LiteralControl("<br />"));
                        parent.Controls.AddAt(idx + 1, lbl);
                    }
                    lbl      = (Label)e.Item.FindControl("lblResponseDate_out");
                    lbl.Text = SQMBasePage.FormatDate(WebSiteCommon.LocalTime(response.Response.RESPONSE_DT, SessionManager.UserContext.TimeZoneID), "g", true);
                    RadTextBox rt = (RadTextBox)e.Item.FindControl("rtResponseText_out");
                    rt.Text = response.Response.RESPONSE_TEXT;

                    if (response.AttachmentList != null && response.AttachmentList.Count > 0)
                    {
                        Ucl_Attach attch = (Ucl_Attach)Page.LoadControl("/Include/Ucl_Attach.ascx");
                        // rt.Parent.Controls.AddAt(rt.Parent.Controls.IndexOf(rt),new LiteralControl("<br/>"));
                        rt.Parent.Controls.AddAt(rt.Parent.Controls.IndexOf(rt) + 1, attch);
                        attch.BindListAttachment(response.AttachmentList, "1", 0, false);
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 12
0
        public UserContext Initialize(string SSOID, string pwd, bool activeOnly)
        {
            SQM.Website.PSsqmEntities ctx = new PSsqmEntities();
            this.LoginStatus = LoginStatus.SSOUndefined;
            SQM_ACCESS access = SQMModelMgr.LookupCredentials(ctx, SSOID, pwd, true);

            if (access != null)
            {
                string key = SQMModelMgr.GetPasswordKey();
                // AW - for now, we want to allow if the password = the password OR the encrypted password
                string password = WebSiteCommon.Decrypt(access.PASSWORD, key);
                //string encrypt = WebSiteCommon.Encrypt(pwd, key);
                //string ss = encrypt;

                /*
                 * if ((string.IsNullOrEmpty(pwd) && (SSOID.ToLower() != "admin")) || (pwd != password && pwd != access.PASSWORD))
                 *      this.LoginStatus = LoginStatus.PasswordMismatch;
                 */
                //if (!string.IsNullOrEmpty(access.PASSWORD)  && (pwd != password && pwd != access.PASSWORD))

                if (pwd != password && pwd != access.PASSWORD)
                {
                    this.LoginStatus = LoginStatus.PasswordMismatch;
                }
                else if (activeOnly && access.STATUS == "I")
                {
                    this.LoginStatus = LoginStatus.Inactive;
                }
                else if (access.STATUS == "L")
                {
                    this.LoginStatus = LoginStatus.Locked;
                }
                else
                {
                    if ((this.Person = SQMModelMgr.LookupPerson(ctx, 0, access.SSO_ID, false)) == null)
                    {
                        this.LoginStatus = LoginStatus.PersonUndefined;
                    }
                    else
                    {
                        this.LoginStatus = LoginStatus.Success;
                        this.HRLocation  = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID));

                        if (this.HRLocation.Company == null)
                        {
                            this.LoginStatus = LoginStatus.CompanyUndefined;
                        }
                        else
                        {
                            this.PrivList = SQMModelMgr.SelectPrivGroupPerson(this.Person.PRIV_GROUP, "COMMON");

                            SessionManager.EffLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID));

                            this.WorkingLocation = new BusinessLocation();
                            this.WorkingLocation = SessionManager.EffLocation;

                            this.PlantAccessList = new List <decimal>();
                            this.PlantAccessList.Add(this.WorkingLocation.Plant.PLANT_ID);
                            if (!string.IsNullOrEmpty(Person.NEW_LOCATION_CD))
                            {
                                decimal  plantID;
                                string[] locs = Person.NEW_LOCATION_CD.Split(',');
                                foreach (string locid in locs)
                                {
                                    if (!string.IsNullOrEmpty(locid))
                                    {
                                        if (decimal.TryParse(locid, out plantID) && plantID != this.WorkingLocation.Plant.PLANT_ID)
                                        {
                                            this.PlantAccessList.Add(plantID);
                                        }
                                    }
                                }
                            }

                            access.LAST_LOGON_DT = WebSiteCommon.CurrentUTCTime();
                            int ctxstatus = 0;
                            SQMModelMgr.UpdateCredentials(ctx, access, "", out ctxstatus);
                            this.Credentials = access;
                            this.TimeZoneID  = this.HRLocation.Plant.LOCAL_TIMEZONE;
                            this.LocalTime   = !string.IsNullOrEmpty(this.TimeZoneID) ? WebSiteCommon.LocalTime(DateTime.UtcNow, this.TimeZoneID) : DateTime.UtcNow;
                            this.Language    = SQMModelMgr.LookupLanguage(ctx, "", this.Person.PREFERRED_LANG_ID.HasValue ? (int)this.Person.PREFERRED_LANG_ID : 1, false);

                            if (SessionManager.CreateSessionContext(this) == null)
                            {
                                this.LoginStatus = LoginStatus.SessionError;
                            }

                            this.InboxReviews = 0;
                        }
                    }
                }
            }
            return(this);
        }
        public void LoadProfileInput(DateTime targetDate, EHSProfileStatus selectStatus)
        {
            AccessMode accessMode = UserContext.CheckAccess("EHS", "311");

            LocalProfile().LoadPeriod(targetDate);
            if (LocalProfile().InputPeriod != null)
            {
                LocalProfile().MapPlantAccountingInputs(true, false);

                uclInputHdr.BindProfileInputHdr(LocalProfile());
                EHSProfileStatus status = BindProfileInputList(LocalProfile().MeasureList(true, accessMode).ToList(), LocalProfile().Profile);
                if (status == EHSProfileStatus.Normal)
                {
                    if (LocalProfile().Profile.APPROVER_ID == SessionManager.UserContext.Person.PERSON_ID || accessMode >= AccessMode.Admin)
                    {
                        cbFinalApproval.Enabled = true;
                    }
                    if (LocalProfile().InputPeriod.PlantAccounting.APPROVER_ID.HasValue&& LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                    {
                        cbFinalApproval.Checked  = true;
                        cbFinalApproval.Enabled  = false;
                        hfWasApproved.Value      = lblFinalApprovalBy.Text = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)LocalProfile().InputPeriod.PlantAccounting.APPROVER_ID, ""));
                        lblFinalApprovalBy.Text += ("  " + SQMBasePage.FormatDate((DateTime)LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT, "", false));
                    }
                    else
                    {
                        cbFinalApproval.Checked = false;
                        hfWasApproved.Value     = lblFinalApprovalBy.Text = "";
                    }
                }
                MessageDisplay(selectStatus == EHSProfileStatus.Normal ? status : selectStatus);
                btnSave1.Enabled = btnSave2.Enabled = btnCancel1.Enabled = btnCancel2.Enabled = UserContext.CheckAccess("EHS", "311") >= AccessMode.Update ? true : false;
            }
            else
            {
                MessageDisplay(EHSProfileStatus.NoInputs);
            }
        }
        protected void rgAlertTaskList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;
                RadComboBox  ddl = null;
                PERSON       responsiblePerson = null;

                try
                {
                    TASK_STATUS task = (TASK_STATUS)e.Item.DataItem;

                    hf       = (HiddenField)e.Item.FindControl("hfTaskID");
                    hf.Value = task.TASK_ID > 0 ? task.TASK_ID.ToString() : "";

                    hf       = (HiddenField)e.Item.FindControl("hfLocation");
                    hf.Value = task.RECORD_SUBID.ToString();

                    lbl = (Label)e.Item.FindControl("lblLocation");
                    PLANT plant = SQMModelMgr.LookupPlant((decimal)task.RECORD_SUBID);
                    if (plant != null)
                    {
                        lbl.Text = plant.PLANT_NAME;
                        hf       = (HiddenField)e.Item.FindControl("hfLocationTZ");
                        hf.Value = plant.LOCAL_TIMEZONE;
                    }
                    else
                    {
                        lbl.Text = task.RECORD_SUBID.ToString();
                    }

                    lbl      = (Label)e.Item.FindControl("lblTaskComments");
                    lbl.Text = task.COMMENTS;

                    if (task.COMPLETE_DT.HasValue)
                    {
                        lbl      = (Label)e.Item.FindControl("lblTaskCompleteDT");
                        lbl.Text = Convert.ToDateTime(task.COMPLETE_DT).ToShortDateString();
                    }

                    ddl = (RadComboBox)e.Item.FindControl("ddlResponsible");
                    List <PERSON> responsibleList = SQMModelMgr.SelectPlantPrivgroupPersonList((decimal)task.RECORD_SUBID, new string[1] {
                        ddlResponsibleGroup.SelectedValue
                    }, false);
                    if (responsibleList.Count > 0)
                    {
                        foreach (PERSON person in responsibleList)
                        {
                            ddl.Items.Add(new RadComboBoxItem(SQMModelMgr.FormatPersonListItem(person), person.PERSON_ID.ToString()));
                        }
                    }
                    if (task.RESPONSIBLE_ID.HasValue)
                    {
                        if ((responsiblePerson = SQMModelMgr.LookupPerson((decimal)task.RESPONSIBLE_ID, "")) != null)
                        {
                            if (ddl.Items.FindItemByValue(responsiblePerson.PERSON_ID.ToString()) != null)
                            {
                                ddl.SelectedValue = responsiblePerson.PERSON_ID.ToString();
                            }
                            else
                            {
                                ddl.Items.Add(new RadComboBoxItem(SQMModelMgr.FormatPersonListItem(responsiblePerson), responsiblePerson.PERSON_ID.ToString()));
                            }
                        }
                    }
                    if (task.COMPLETE_DT.HasValue)
                    {
                        ddl.Enabled = false;
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 15
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);
            }
        }
Ejemplo n.º 16
0
        AlertData PopulateByIncidentId(decimal iid)
        {
            AlertData d        = new AlertData();
            var       entities = new PSsqmEntities();

            d.incident = EHSIncidentMgr.SelectIncidentById(entities, iid);

            if (d.incident != null)
            {
                try
                {
                    string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)d.incident.DETECT_PLANT_ID);
                    d.incidentLocation = plantName;
                    d.incidentNumber   = WebSiteCommon.FormatID(iid, 6);

                    string  incidentType   = EHSIncidentMgr.SelectIncidentTypeByIncidentId(iid);
                    decimal incidentTypeId = EHSIncidentMgr.SelectIncidentTypeIdByIncidentId(iid);
                    decimal companyId      = d.incident.DETECT_COMPANY_ID;
                    var     questions      = EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 0);
                    questions.AddRange(EHSIncidentMgr.SelectIncidentQuestionList(incidentTypeId, companyId, 1));

                    d.answerList = EHSIncidentMgr.GetIncidentAnswerList(d.incident.INCIDENT_ID);
                    INCIDENT_ANSWER answer = null;

                    // Date/Time

                    d.incidentDate = d.incident.INCIDENT_DT.ToShortDateString();
                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.TimeOfDay).SingleOrDefault()) != null)
                    {
                        if (!string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            d.incidentTime = Convert.ToDateTime(answer.ANSWER_VALUE).ToShortTimeString();
                        }
                    }

                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Shift).SingleOrDefault()) != null)
                    {
                        if (!string.IsNullOrEmpty(SQMBasePage.GetXLAT(reportXLAT, "SHIFT", answer.ANSWER_VALUE).DESCRIPTION))
                        {
                            answer.ANSWER_VALUE = SQMBasePage.GetXLAT(reportXLAT, "SHIFT", answer.ANSWER_VALUE).DESCRIPTION;
                        }
                    }

                    if ((answer = d.answerList.Where(a => a.INCIDENT_QUESTION_ID == (decimal)EHSQuestionId.Department).SingleOrDefault()) != null)
                    {
                        d.incidentDept = answer.ANSWER_VALUE;
                        decimal deptID = 0;
                        if (decimal.TryParse(answer.ANSWER_VALUE, out deptID))
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, deptID);
                            if (dept != null)
                            {
                                d.incidentDept = dept.DEPT_NAME;
                            }
                        }
                    }

                    // Incident Type

                    d.incidentType = incidentType;

                    // Description

                    d.incidentDescription = d.incident.DESCRIPTION;

                    d.detectPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.CREATE_PERSON, "", false);
                    if (d.detectPerson != null)
                    {
                        d.supervisorPerson = SQMModelMgr.LookupPersonByEmpID(entities, d.detectPerson.SUPV_EMP_ID);
                    }

                    if (d.incident.ISSUE_TYPE_ID == (decimal)EHSIncidentTypeId.InjuryIllness)
                    {
                        if (d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_ID.HasValue)
                        {
                            d.involvedPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_ID, "", false);
                            if (d.involvedPerson != null)
                            {
                                if (d.incident.INCFORM_INJURYILLNESS.SUPERVISOR_PERSON_ID.HasValue)                                             // supervisor was known
                                {
                                    d.supervisorPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.SUPERVISOR_PERSON_ID, "", false);
                                }
                                else
                                {
                                    // get current supervisor
                                    d.supervisorPerson = SQMModelMgr.LookupPersonByEmpID(entities, d.involvedPerson.SUPV_EMP_ID);
                                }
                            }
                        }
                        else
                        {
                            d.involvedPerson            = new PERSON();
                            d.involvedPerson.FIRST_NAME = d.incident.INCFORM_INJURYILLNESS.INVOLVED_PERSON_NAME;
                        }

                        if (d.incident.INCFORM_INJURYILLNESS.DEPT_ID.HasValue)
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, (decimal)d.incident.INCFORM_INJURYILLNESS.DEPT_ID);
                            if (dept != null)
                            {
                                d.incidentDept = dept.DEPT_NAME;
                            }
                        }
                        else
                        {
                            d.incidentDept = d.incident.INCFORM_INJURYILLNESS.DEPARTMENT;
                        }
                    }

                    // Containment
                    foreach (INCFORM_CONTAIN cc in EHSIncidentMgr.GetContainmentList(iid, null, false))
                    {
                        if (cc.ASSIGNED_PERSON_ID.HasValue)
                        {
                            cc.ASSIGNED_PERSON = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)cc.ASSIGNED_PERSON_ID, ""));
                        }
                        d.containList.Add(cc);
                    }

                    // Root Cause(s)
                    d.root5YList = EHSIncidentMgr.GetRootCauseList(iid).Where(l => !string.IsNullOrEmpty(l.ITEM_DESCRIPTION)).ToList();
                    if (d.root5YList != null && d.root5YList.Count > 0)
                    {
                        d.incident.INCFORM_CAUSATION.Load();
                        if (d.incident.INCFORM_CAUSATION != null && d.incident.INCFORM_CAUSATION.Count > 0)
                        {
                            d.causation = d.incident.INCFORM_CAUSATION.ElementAt(0);
                        }
                    }

                    // Corrective Actions
                    foreach (TASK_STATUS ac in EHSIncidentMgr.GetCorrectiveActionList(iid, null, false))
                    {
                        if (ac.RESPONSIBLE_ID.HasValue)
                        {
                            ac.COMMENTS = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)ac.RESPONSIBLE_ID, ""));
                        }
                        d.actionList.Add(ac);
                    }

                    var files = (from a in entities.ATTACHMENT
                                 where
                                 (a.RECORD_ID == iid && a.RECORD_TYPE == 40 && a.DISPLAY_TYPE > 0) &&
                                 (a.FILE_NAME.ToLower().Contains(".jpg") || a.FILE_NAME.ToLower().Contains(".jpeg") ||
                                  a.FILE_NAME.ToLower().Contains(".gif") || a.FILE_NAME.ToLower().Contains(".png") ||
                                  a.FILE_NAME.ToLower().Contains(".bmp"))
                                 orderby a.RECORD_TYPE, a.FILE_NAME
                                 select new
                    {
                        Data = (from f in entities.ATTACHMENT_FILE where f.ATTACHMENT_ID == a.ATTACHMENT_ID select f.ATTACHMENT_DATA).FirstOrDefault(),
                        Description = (string.IsNullOrEmpty(a.FILE_DESC)) ? "" : a.FILE_DESC,
                    }).ToList();


                    d.approvalList = EHSIncidentMgr.GetApprovalList(entities, (decimal)d.incident.ISSUE_TYPE_ID, 10.0m, iid, null, 0);

                    if (files.Count > 0)
                    {
                        d.photoData     = new List <byte[]>();
                        d.photoCaptions = new List <string>();

                        foreach (var f in files)
                        {
                            d.photoData.Add(f.Data);
                            d.photoCaptions.Add(f.Description);
                        }
                    }
                }
                catch
                {
                }
            }

            return(d);
        }
Ejemplo n.º 17
0
 protected void SelectUser(decimal personID)
 {
     SetLocalPerson(SQMModelMgr.LookupPerson(entities, personID, "", false));
     DisplayUser();
 }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
0
        PdfPTable ActionSection(decimal questionId, List <TASK_STATUS> actions)
        {
            PdfPTable tableAction = new PdfPTable(new float[] { 80f, 50f, 150f, 50f, 150f, 55f });

            tableAction.TotalWidth  = 535f;
            tableAction.LockedWidth = true;

            // add a action header
            PdfPCell cell = new PdfPCell()
            {
                Padding = 1f, Border = 0
            };

            cell.AddElement(new Paragraph(Resources.LocalizedText.ResponsiblePerson, colHdrFont));
            tableAction.AddCell(cell);
            cell = new PdfPCell()
            {
                Padding = 1f, Border = 0
            };
            cell.AddElement(new Paragraph(Resources.LocalizedText.DueDate, colHdrFont));
            tableAction.AddCell(cell);
            cell = new PdfPCell()
            {
                Padding = 1f, Border = 0
            };
            cell.AddElement(new Paragraph(Resources.LocalizedText.Description, colHdrFont));
            tableAction.AddCell(cell);
            cell = new PdfPCell()
            {
                Padding = 1f, Border = 0
            };
            cell.AddElement(new Paragraph(Resources.LocalizedText.Status, colHdrFont));
            tableAction.AddCell(cell);
            cell = new PdfPCell()
            {
                Padding = 1f, Border = 0
            };
            cell.AddElement(new Paragraph(Resources.LocalizedText.Comments, colHdrFont));
            tableAction.AddCell(cell);
            cell = new PdfPCell()
            {
                Padding = 1f, Border = 0
            };
            cell.AddElement(new Paragraph(Resources.LocalizedText.Completed, colHdrFont));
            tableAction.AddCell(cell);

            foreach (TASK_STATUS ac in actions)
            {
                cell = new PdfPCell()
                {
                    Padding = 1f, Border = 0
                };
                string person = "";
                if (ac.RESPONSIBLE_ID.HasValue)
                {
                    person = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)ac.RESPONSIBLE_ID, ""));
                }
                cell.AddElement(new Paragraph(person, detailTxtFont));
                tableAction.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 1f, Border = 0
                };
                if (ac.DUE_DT.HasValue)
                {
                    cell.AddElement(new Paragraph(SQMBasePage.FormatDate((DateTime)ac.DUE_DT, "d", false), detailTxtFont));
                }
                else
                {
                    cell.AddElement(new Paragraph(" ", detailTxtFont));
                }
                tableAction.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 1f, Border = 0
                };
                try
                {
                    if (!ac.DESCRIPTION.Equals(null))
                    {
                        cell.AddElement(new Paragraph(FormatText(ac.DESCRIPTION), detailTxtFont));
                    }
                    else
                    {
                        cell.AddElement(new Paragraph(" ", detailTxtFont));
                    }
                }
                catch { cell.AddElement(new Paragraph(" ", detailTxtFont)); }
                tableAction.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 1f, Border = 0
                };
                if (!ac.STATUS.Equals(null))
                {
                    try
                    {
                        int        value  = Convert.ToInt16(ac.STATUS);
                        TaskStatus status = (TaskStatus)value;
                        cell.AddElement(new Paragraph(status.ToString(), detailTxtFont));
                    }
                    catch { cell.AddElement(new Paragraph(ac.STATUS, detailTxtFont)); }
                }
                else
                {
                    cell.AddElement(new Paragraph(" ", detailTxtFont));
                }
                tableAction.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 1f, Border = 0
                };
                try
                {
                    if (!ac.COMMENTS.Equals(null))
                    {
                        cell.AddElement(new Paragraph(FormatText(ac.COMMENTS), detailTxtFont));
                    }
                    else
                    {
                        cell.AddElement(new Paragraph(" ", detailTxtFont));
                    }
                }
                catch { cell.AddElement(new Paragraph(" ", detailTxtFont)); }
                tableAction.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 1f, Border = 0
                };
                if (ac.COMPLETE_DT.HasValue)
                {
                    cell.AddElement(new Paragraph(SQMBasePage.FormatDate((DateTime)ac.COMPLETE_DT, "d", false), detailTxtFont));
                }
                else
                {
                    cell.AddElement(new Paragraph(" ", detailTxtFont));
                }
                tableAction.AddCell(cell);
            }

            return(tableAction);
        }
Ejemplo n.º 20
0
        protected void btnTaskUpdate_Click(object sender, EventArgs e)
        {
            PSsqmEntities ctx = new PSsqmEntities();

            lblErrorMessage.Text = "";
            Button btn = (Button)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }

            TaskStatusMgr taskMgr = new TaskStatusMgr().CreateNew(0, 0);
            TASK_STATUS   task    = taskMgr.SelectTask(Convert.ToDecimal(btn.CommandArgument));

            //task.RECORD_TYPE = recordType;
            //task.RECORD_ID = recordID;
            //task.RECORD_SUBID = recordSubID;
            //task.TASK_STEP = taskStep;
            //task.TASK_TYPE = taskType;
            //task.TASK_SEQ = 0;
            task.DUE_DT = rdpTaskDueDT.SelectedDate;
            //task.RESPONSIBLE_ID = Convert.ToDecimal(ddlAssignPerson.SelectedValue.ToString());
            //task.DETAIL = lblTaskDetailValue.Text.ToString(); // this is the original detail, so we don't change it.
            //task.DESCRIPTION = tbTaskDescription.Text.ToString();
            task.COMMENTS = tbTaskComments.Text.ToString();
            //task.STATUS = ((int)TaskStatus.New).ToString();
            //task.CREATE_DT = SessionManager.UserContext.LocalTime != null ? SessionManager.UserContext.LocalTime : DateTime.UtcNow;
            //task.CREATE_ID = SessionManager.UserContext.Person.PERSON_ID;

            taskMgr.UpdateTask(task);
            taskMgr.UpdateTaskList(task.RECORD_ID);
            // send email
            PERSON assignTo = SQMModelMgr.LookupPerson(ctx, (decimal)task.RESPONSIBLE_ID, "", false);

            EHSNotificationMgr.NotifyTaskAssigment(task, assignTo.PLANT_ID);

            // reset the fields for the next add
            ddlAssignPersonAdd.SelectedValue = "";
            tbTaskDescriptionAdd.Text        = "";
            rdpTaskDueDTAdd.SelectedDate     = DateTime.Today;

            if (OnTaskAdd != null)
            {
                OnTaskAdd("added", task.RECORD_ID, (decimal)task.RECORD_SUBID);
            }
            if (task.RECORD_TYPE == (int)TaskRecordType.Audit)             // update the Question Status when adding tasks for an audit followup.
            {
                EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(task.RECORD_ID, (decimal)task.RECORD_SUBID);

                if (auditQuestion != null)
                {
                    auditQuestion.Status = "02";
                    EHSAuditMgr.UpdateAnswer(auditQuestion);
                }
                //SessionManager.ReturnRecordID = task.RECORD_ID;
                //SessionManager.ReturnObject = "AddTask";
                //SessionManager.ReturnStatus = true;
            }

            if (Page.Request.Url.ToString().Contains("AssessmentForm"))
            {
                // now update the list and stay on the popup if adding through assessment form
                BindTaskAdd(task.RECORD_TYPE, task.RECORD_ID, (decimal)task.RECORD_SUBID, task.TASK_STEP, task.TASK_TYPE, lblTaskDetailValue.Text.ToString(), assignTo.PLANT_ID, "");
                lblErrorMessage.Text = "";

                string script = "function f(){OpenUpdateTaskWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
            }
            else
            {
                SessionManager.ReturnRecordID = task.RECORD_ID;
                SessionManager.ReturnObject   = "UpdateTask";
                SessionManager.ReturnStatus   = true;

                if (OnTaskUpdate != null)
                {
                    OnTaskUpdate("update");
                }
            }
        }
Ejemplo n.º 21
0
        public void LoadProfileInput(DateTime targetDate, EHSProfileStatus selectStatus)
        {
            UserContext.CheckUserPrivilege(SysPriv.originate, SysScope.envdata);
            LocalProfile().LoadPeriod(targetDate);
            if (LocalProfile().InputPeriod != null)
            {
                LocalProfile().MapPlantAccountingInputs(true, false);

                uclInputHdr.BindProfileInputHdr(LocalProfile());
                EHSProfileStatus status = BindProfileInputList(LocalProfile().MeasureList(true, UserContext.GetScopePrivileges(SysScope.envdata)).ToList(), LocalProfile().Profile);
                if (status == EHSProfileStatus.Normal)
                {
                    if (LocalProfile().Profile.APPROVER_ID == SessionManager.UserContext.Person.PERSON_ID || UserContext.CheckUserPrivilege(SysPriv.approve, SysScope.envdata))
                    {
                        cbFinalApproval.Enabled = true;
                    }
                    if (LocalProfile().InputPeriod.PlantAccounting.APPROVER_ID.HasValue&& LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                    {
                        cbFinalApproval.Checked  = true;
                        cbFinalApproval.Enabled  = false;
                        hfWasApproved.Value      = lblFinalApprovalBy.Text = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)LocalProfile().InputPeriod.PlantAccounting.APPROVER_ID, ""));
                        lblFinalApprovalBy.Text += ("  " + SQMBasePage.FormatDate((DateTime)LocalProfile().InputPeriod.PlantAccounting.APPROVAL_DT, "", false));
                    }
                    else
                    {
                        cbFinalApproval.Checked = false;
                        hfWasApproved.Value     = lblFinalApprovalBy.Text = "";
                    }
                }
                MessageDisplay(selectStatus == EHSProfileStatus.Normal ? status : selectStatus);
                btnSave1.Enabled = btnSave2.Enabled = btnCancel1.Enabled = btnCancel2.Enabled = UserContext.GetMaxScopePrivilege(SysScope.envdata) < SysPriv.notify ? true : false;
            }
            else
            {
                MessageDisplay(EHSProfileStatus.NoInputs);
            }
        }
        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);
        }
Ejemplo n.º 23
0
        public void BindTaskUpdate(TASK_STATUS task, string context)
        {
            PSsqmEntities ctx = new PSsqmEntities();

            if (TaskXLATList == null || TaskXLATList.Count == 0)
            {
                TaskXLATList = SQMBasePage.SelectXLATList(new string[5] {
                    "TASK_STATUS", "RECORD_TYPE", "INCIDENT_STATUS", "NOTIFY_SCOPE_TASK", "ACTION_CATEGORY"
                });
            }

            CurrentTask = task;

            pnlUpdateTask.Visible         = true;
            btnTaskUpdate.CommandArgument = btnTaskComplete.CommandArgument = btnTaskAssign.CommandArgument = task.TASK_ID.ToString();

            if (task.STATUS == ((int)TaskStatus.Complete).ToString())
            {
                btnTaskComplete.Visible = btnTaskUpdate.Visible = btnTaskAssign.Visible = false;
                //tbTaskDescription.Enabled = rdpTaskDueDT.Enabled = tbTaskComments.Enabled = false;
                rdpTaskDueDT.Enabled = tbTaskComments.Enabled = false;
            }
            else
            {
                btnTaskComplete.Visible = btnTaskUpdate.Visible = btnTaskAssign.Visible = true;
                //tbTaskDescription.Enabled = rdpTaskDueDT.Enabled = tbTaskComments.Enabled = true;
                rdpTaskDueDT.Enabled = tbTaskComments.Enabled = true;
            }

            switch ((TaskRecordType)task.RECORD_TYPE)
            {
            case TaskRecordType.HealthSafetyIncident:
                lblTaskTypeValue.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "RECORD_TYPE" && l.XLAT_CODE == task.RECORD_TYPE.ToString()).FirstOrDefault().DESCRIPTION;
                if (task.TASK_STEP == "350")
                {                               // corrective action task
                    lblTaskTypeValue.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                }
                else
                {
                    lblTaskTypeValue.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                }
                break;

            case TaskRecordType.PreventativeAction:
                lblTaskTypeValue.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "RECORD_TYPE" && l.XLAT_CODE == task.RECORD_TYPE.ToString()).FirstOrDefault().DESCRIPTION;
                if (task.TASK_STEP == "350")
                {                               // corrective action task
                    lblTaskTypeValue.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                }
                else
                {
                    lblTaskTypeValue.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                }
                btnTaskLink.CommandArgument = task.RECORD_ID.ToString();
                btnTaskLink.Visible         = true;
                btnTaskAssign.Visible       = btnTaskComplete.Visible = false;
                break;

            case TaskRecordType.Audit:
                //AUDIT audit = EHSAuditMgr.SelectAuditById(ctx, task.RECORD_ID);
                lblTaskTypeValue.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "RECORD_TYPE" && l.XLAT_CODE == task.RECORD_TYPE.ToString()).FirstOrDefault().DESCRIPTION;
                if ((task.RECORD_SUBID.HasValue && task.RECORD_SUBID > 0) || task.TASK_STEP == "350")
                {                               // action required if subid references a specific audit question
                    lblTaskTypeValue.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                }
                else
                {
                    lblTaskTypeValue.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == "300").FirstOrDefault().DESCRIPTION);
                }
                break;

            default:
                return;

                break;
            }

            //tbTaskDescription.Text = task.DESCRIPTION;  // command of what to do
            lbTaskDescription.Text  = task.DESCRIPTION;         // command of what to do
            lblTaskDetailValue.Text = task.DETAIL;              // incident description or audit question
            PERSON createBy = null;                             // mt - predeclare create by person to better handle NULL CREATE_ID

            // get the Create By person name and display
            if (task.CREATE_ID.HasValue)
            {
                createBy = SQMModelMgr.LookupPerson(ctx, (decimal)task.CREATE_ID, "", false);
            }
            if (createBy == null)
            {
                lblCreatedByValue.Text = Resources.LocalizedText.AutomatedScheduler;
            }
            else
            {
                lblCreatedByValue.Text = SQMModelMgr.FormatPersonListItem(createBy, false, "LF");
            }

            PERSON assignTo = SQMModelMgr.LookupPerson(ctx, (decimal)task.RESPONSIBLE_ID, "", false);

            if (assignTo == null)
            {
                lblAssignPersonValue.Text = Resources.LocalizedText.AutomatedScheduler;
            }
            else
            {
                lblAssignPersonValue.Text = SQMModelMgr.FormatPersonListItem(assignTo, false, "LF");
            }

            rdpTaskDueDT.SelectedDate = (DateTime)task.DUE_DT;
            lblTaskStatusValue.Text   = TaskXLATList.Where(l => l.XLAT_GROUP == "TASK_STATUS" && l.XLAT_CODE == ((int)TaskMgr.CalculateTaskStatus(task)).ToString()).FirstOrDefault().DESCRIPTION;
            tbTaskComments.Text       = task.COMMENTS;

            int attachCount = SQM.Website.Classes.SQMDocumentMgr.GetAttachmentCountByRecord(CurrentTask.RECORD_TYPE, CurrentTask.RECORD_ID, CurrentTask.TASK_STEP, "");

            lnkAttachments.Text    = attachCount == 0 ? Resources.LocalizedText.Attachments : (Resources.LocalizedText.Attachments + " (" + attachCount.ToString() + ")");
            lnkAttachments.Visible = true;
        }
Ejemplo n.º 24
0
        public void rptProfileStatus_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                Label lbl;
                try
                {
                    EHSProfile profile = (EHSProfile)e.Item.DataItem;

                    Button btn = (Button)e.Item.FindControl("btnRollup");
                    btn.CommandArgument = profile.Plant.PLANT_ID.ToString();
                    btn = (Button)e.Item.FindControl("btnRollupYTD");
                    btn.CommandArgument = profile.Plant.PLANT_ID.ToString();

                    DateTime   lastUpdateDate;
                    TaskStatus status = profile.PeriodStatus(new string[0] {
                    }, true, out lastUpdateDate);

                    lbl       = (Label)e.Item.FindControl("lblInputs");
                    lbl.Text += profile.InputPeriod.NumComplete + " of " + profile.MeasureList(false).Count + " (Total)";
                    lbl       = (Label)e.Item.FindControl("lblReqdInputs");
                    lbl.Text  = profile.InputPeriod.NumRequiredComplete.ToString() + " of " + profile.InputPeriod.NumRequired.ToString() + " (Required)";
                    LinkButton lnk = (LinkButton)e.Item.FindControl("lnkInputs");
                    lnk.CommandArgument = profile.Plant.PLANT_ID.ToString();

                    lbl = (Label)e.Item.FindControl("lblRollupStatus");
                    lnk = (LinkButton)e.Item.FindControl("lnkHistory");
                    lnk.CommandArgument = profile.Plant.PLANT_ID.ToString();
                    if (profile.InputPeriod.PlantAccounting != null && profile.InputPeriod.PlantAccounting.FINALIZE_DT != null)
                    {
                        lbl.Text    = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)profile.InputPeriod.PlantAccounting.FINALIZE_ID, ""));
                        lbl.Text   += " ";
                        lbl.Text   += SQMBasePage.FormatDate((DateTime)profile.InputPeriod.PlantAccounting.FINALIZE_DT, "d", false);
                        lnk.Visible = true;
                    }

                    string currencyCode = SQMModelMgr.LookupPlant(profile.Plant.PLANT_ID).CURRENCY_CODE;
                    lbl      = (Label)e.Item.FindControl("lblRateStatus");
                    lbl.Text = currencyCode + ": ";
                    CURRENCY_XREF currentRate = CurrencyConverter.CurrentRate(currencyCode, profile.InputPeriod.PeriodYear, profile.InputPeriod.PeriodMonth);
                    if (currentRate != null && currentRate.EFF_MONTH > 0)
                    {
                        lbl.Text += (System.Environment.NewLine + SQMBasePage.FormatDate(new DateTime(currentRate.EFF_YEAR, currentRate.EFF_MONTH, DateTime.DaysInMonth(currentRate.EFF_YEAR, currentRate.EFF_MONTH)), "d", false));
                    }

                    if (profile.InputPeriod.PlantAccounting != null)
                    {
                        SETTINGS    sets = SQMSettings.GetSetting("EHS", "ACCTFIELDS"); // try to retrieve fields to display for this client
                        Ucl_EHSList ucl  = (Ucl_EHSList)e.Item.FindControl("uclProdList");
                        ucl.BindProdFieldsList(profile, sets == null ? "" : sets.VALUE);

                        if (profile.InputPeriod.PlantAccounting.APPROVER_ID.HasValue && profile.InputPeriod.PlantAccounting.APPROVAL_DT.HasValue)
                        {
                            lbl       = (Label)e.Item.FindControl("lblFinalStatus");
                            lbl.Text  = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)profile.InputPeriod.PlantAccounting.APPROVER_ID, ""));
                            lbl.Text += " ";
                            lbl.Text += SQMBasePage.FormatDate((DateTime)profile.InputPeriod.PlantAccounting.APPROVAL_DT, "", false);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ;
                }
            }
        }
Ejemplo n.º 25
0
        public UserContext Initialize(string SSOID, string pwd, bool activeOnly)
        {
            SQM.Website.PSsqmEntities ctx = new PSsqmEntities();
            this.LoginStatus = LoginStatus.SSOUndefined;
            SQM_ACCESS access = SQMModelMgr.LookupCredentials(ctx, SSOID, pwd, true);

            if (access != null)
            {
                string key = SQMModelMgr.GetPasswordKey();
                // AW - for now, we want to allow if the password = the password OR the encrypted password
                string password = WebSiteCommon.Decrypt(access.PASSWORD, key);
                //string encrypt = WebSiteCommon.Encrypt(pwd, key);
                //string ss = encrypt;

                /*
                 * if ((string.IsNullOrEmpty(pwd) && (SSOID.ToLower() != "admin")) || (pwd != password && pwd != access.PASSWORD))
                 *  this.LoginStatus = LoginStatus.PasswordMismatch;
                 */
                //if (!string.IsNullOrEmpty(access.PASSWORD)  && (pwd != password && pwd != access.PASSWORD))

                if (pwd != password && pwd != access.PASSWORD)
                {
                    this.LoginStatus = LoginStatus.PasswordMismatch;
                }
                else if (activeOnly && access.STATUS == "I")
                {
                    this.LoginStatus = LoginStatus.Inactive;
                }
                else if (access.STATUS == "L")
                {
                    this.LoginStatus = LoginStatus.Locked;
                }
                else
                {
                    if ((this.Person = SQMModelMgr.LookupPerson(ctx, 0, access.SSO_ID, false)) == null)
                    {
                        this.LoginStatus = LoginStatus.PersonUndefined;
                    }
                    else
                    {
                        this.LoginStatus = LoginStatus.Success;
                        this.HRLocation  = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID));

                        if (this.HRLocation.Company == null)
                        {
                            this.LoginStatus = LoginStatus.CompanyUndefined;
                        }
                        else
                        {
                            SessionManager.EffLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID));

                            if (this.Person.PERSON_RESP.ALT_COMPANY_ID > 0)
                            {
                                this.WorkingLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.PERSON_RESP.ALT_COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.PERSON_RESP.ALT_BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PERSON_RESP.ALT_PLANT_ID));
                            }
                            else
                            {
                                this.WorkingLocation = new BusinessLocation();
                                this.WorkingLocation = SessionManager.EffLocation;
                            }
                            //this.WorkingLocation = new BusinessLocation().Initialize(SQMModelMgr.LookupCompany((decimal)this.Person.COMPANY_ID), SQMModelMgr.LookupBusOrg((decimal)this.Person.BUS_ORG_ID), SQMModelMgr.LookupPlant((decimal)this.Person.PLANT_ID));

                            this.PlantAccessList = new List <decimal>();
                            if (!string.IsNullOrEmpty(Person.NEW_LOCATION_CD))
                            {
                                decimal  plantID;
                                string[] locs = Person.NEW_LOCATION_CD.Split(',');
                                foreach (string locid in locs)
                                {
                                    if (decimal.TryParse(locid, out plantID))
                                    {
                                        this.PlantAccessList.Add(plantID);
                                    }
                                }
                            }

                            access.LAST_LOGON_DT = WebSiteCommon.CurrentUTCTime();
                            int ctxstatus = 0;
                            SQMModelMgr.UpdateCredentials(ctx, access, "", out ctxstatus);
                            this.Credentials = access;
                            this.TimeZoneID  = WebSiteCommon.GetXlatValue("timeZone", this.Person.PREFERRED_TIMEZONE);

                            this.DelegateList          = new List <decimal>();
                            this.DelegateList          = SQMModelMgr.SelectDelegateList(ctx, this.Person.PERSON_ID).Select(l => l.PERSON_ID).ToList();
                            this.EscalationAssignments = SQMModelMgr.SelectPersonEscalationList(ctx, this.Person.PERSON_ID);

                            if (SessionManager.CreateSessionContext(this) == null)
                            {
                                this.LoginStatus = LoginStatus.SessionError;
                            }

                            this.InboxReviews = 0;
                            this.TaskList     = new List <TaskItem>();
                        }
                    }
                }
            }
            return(this);
        }
Ejemplo n.º 26
0
        AuditData PopulateByAuditId(decimal aid)
        {
            AuditData d        = new AuditData();
            var       entities = new PSsqmEntities();

            d.audit = EHSAuditMgr.SelectAuditById(entities, aid);

            if (d.audit != null)
            {
                try
                {
                    string plantName = EHSAuditMgr.SelectPlantNameById((decimal)d.audit.DETECT_PLANT_ID);
                    d.auditLocation = plantName;
                    d.auditNumber   = aid.ToString();

                    AUDIT_TYPE auditType = EHSAuditMgr.SelectAuditTypeById(entities, d.audit.AUDIT_TYPE_ID);
                    d.auditType = auditType.TITLE;                     // do I need this?
                    decimal auditTypeId = d.audit.AUDIT_TYPE_ID;       // if I have all this, why am I redefining it?
                    decimal companyId   = d.audit.DETECT_COMPANY_ID;
                    if (d.audit.DEPT_ID != null)
                    {
                        if (d.audit.DEPT_ID == 0)
                        {
                            d.auditDepartment = "Plant Wide";
                        }
                        else
                        {
                            DEPARTMENT dept = SQMModelMgr.LookupDepartment(entities, (decimal)d.audit.DEPT_ID);
                            d.auditDepartment = dept.DEPT_NAME;
                        }
                    }

                    var questions = EHSAuditMgr.SelectAuditQuestionList(auditTypeId, 0, aid);
                    d.questionList = questions;

                    List <AUDIT_TOPIC> topics          = new List <AUDIT_TOPIC>();
                    AUDIT_TOPIC        topic           = new AUDIT_TOPIC();
                    decimal            previousTopicId = 0;
                    foreach (EHSAuditQuestion question in questions)
                    {
                        if (question.TopicId != previousTopicId)
                        {
                            topic = new AUDIT_TOPIC();
                            topic.AUDIT_TOPIC_ID = question.TopicId;
                            topic.TITLE          = question.TopicTitle;
                            topics.Add(topic);
                            previousTopicId = question.TopicId;
                        }
                    }
                    d.topicList = topics;

                    // Date/Time

                    d.auditDate = d.audit.AUDIT_DT.ToShortDateString();
                    DateTime closeDate = d.audit.AUDIT_DT.AddDays(auditType.DAYS_TO_COMPLETE);
                    d.auditCloseDate = closeDate.ToShortDateString();

                    // Description

                    d.auditDescription = d.audit.DESCRIPTION;

                    d.auditPerson = SQMModelMgr.LookupPerson(entities, (decimal)d.audit.AUDIT_PERSON, "", false);

                    // Audit Exception Actions

                    foreach (TASK_STATUS ac in EHSAuditMgr.GetAuditActionList(aid, 0))
                    {
                        //if (ac.RESPONSIBLE_ID.HasValue)
                        //{
                        //	ac.COMMENTS = SQMModelMgr.FormatPersonListItem(SQMModelMgr.LookupPerson((decimal)ac.RESPONSIBLE_ID, ""));
                        //}
                        d.actionList.Add(ac);
                    }

                    // not showing the attachments at this point, but not deleting code... just in case
                    //var files = (from a in entities.ATTACHMENT
                    //			 where
                    //				(a.RECORD_ID == aid && a.RECORD_TYPE == 40 && a.DISPLAY_TYPE > 0) &&
                    //				(a.FILE_NAME.ToLower().Contains(".jpg") || a.FILE_NAME.ToLower().Contains(".jpeg") ||
                    //				a.FILE_NAME.ToLower().Contains(".gif") || a.FILE_NAME.ToLower().Contains(".png") ||
                    //				a.FILE_NAME.ToLower().Contains(".bmp"))
                    //			 orderby a.RECORD_TYPE, a.FILE_NAME
                    //			 select new
                    //			 {
                    //				 Data = (from f in entities.ATTACHMENT_FILE where f.ATTACHMENT_ID == a.ATTACHMENT_ID select f.ATTACHMENT_DATA).FirstOrDefault(),
                    //				 Description = (string.IsNullOrEmpty(a.FILE_DESC)) ? "" : a.FILE_DESC,
                    //			 }).ToList();


                    //if (files.Count > 0)
                    //{
                    //	d.photoData = new List<byte[]>();
                    //	d.photoCaptions = new List<string>();

                    //	foreach (var f in files)
                    //	{
                    //		d.photoData.Add(f.Data);
                    //		d.photoCaptions.Add(f.Description);
                    //	}
                    //}
                }
                catch
                {
                }
            }

            return(d);
        }
Ejemplo n.º 27
0
        protected void btnTaskAdd_Click(object sender, EventArgs e)
        {
            PSsqmEntities ctx = new PSsqmEntities();

            lblErrorMessage.Text = "";
            Button btn = (Button)sender;

            if (btn == null || string.IsNullOrEmpty(btn.CommandArgument))
            {
                return;
            }

            string[] cmd         = btn.CommandArgument.Split('~');     // recordType, recordID, recordSubID, taskStep, taskType, plantID
            int      recordType  = Convert.ToInt32(cmd[0]);
            decimal  recordID    = Convert.ToDecimal(cmd[1]);
            decimal  recordSubID = Convert.ToDecimal(cmd[2]);
            string   taskStep    = cmd[3];
            string   taskType    = cmd[4];

            decimal plantID = 0;

            decimal.TryParse(cmd[5], out plantID);

            // make sure that the Assign To Employee has been selected
            if (ddlAssignPersonAdd.SelectedValue.ToString().Equals(""))
            {
                // I don't think we need to bind the list at this point
                BindTaskAdd(recordType, recordID, recordSubID, taskStep, taskType, lblTaskDetailValueAdd.Text.ToString(), plantID, "");
                lblErrorMessage.Text = lblErrRequiredInputs.Text.ToString();
                string script = "function f(){OpenUpdateTaskWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
            }
            else
            {
                TaskStatusMgr taskMgr = new TaskStatusMgr();
                taskMgr.Initialize(recordType, recordID);
                TASK_STATUS task = new TASK_STATUS();
                task.RECORD_TYPE    = recordType;
                task.RECORD_ID      = recordID;
                task.RECORD_SUBID   = recordSubID;
                task.TASK_STEP      = taskStep;
                task.TASK_TYPE      = taskType;
                task.TASK_SEQ       = 0;
                task.DUE_DT         = rdpTaskDueDTAdd.SelectedDate;
                task.RESPONSIBLE_ID = Convert.ToDecimal(ddlAssignPersonAdd.SelectedValue.ToString());
                task.DETAIL         = lblTaskDetailValueAdd.Text.ToString();
                task.DESCRIPTION    = tbTaskDescriptionAdd.Text.ToString();
                task.STATUS         = ((int)TaskStatus.New).ToString();
                task.CREATE_DT      = SessionManager.UserContext.LocalTime != null ? SessionManager.UserContext.LocalTime : DateTime.UtcNow;
                task.CREATE_ID      = SessionManager.UserContext.Person.PERSON_ID;

                taskMgr.CreateTask(task);
                taskMgr.UpdateTaskList(task.RECORD_ID);
                // send email
                PERSON assignTo = SQMModelMgr.LookupPerson(ctx, (decimal)task.RESPONSIBLE_ID, "", false);
                EHSNotificationMgr.NotifyTaskAssigment(task, assignTo.PLANT_ID);

                // reset the fields for the next add
                ddlAssignPersonAdd.SelectedValue = "";
                tbTaskDescriptionAdd.Text        = "";
                rdpTaskDueDTAdd.SelectedDate     = DateTime.Today;

                if (OnTaskAdd != null)
                {
                    OnTaskAdd("added", task.RECORD_ID, (decimal)task.RECORD_SUBID);
                }
                if (recordType == (int)TaskRecordType.Audit)                 // update the Question Status when adding tasks for an audit followup.
                {
                    EHSAuditQuestion auditQuestion = EHSAuditMgr.SelectAuditQuestion(recordID, recordSubID);

                    if (auditQuestion != null)
                    {
                        auditQuestion.Status = "02";
                        EHSAuditMgr.UpdateAnswer(auditQuestion);
                    }
                    //SessionManager.ReturnRecordID = task.RECORD_ID;
                    //SessionManager.ReturnObject = "AddTask";
                    //SessionManager.ReturnStatus = true;
                }

                if (Page.Request.Url.ToString().Contains("AssessmentForm"))
                {
                    // now update the list and stay on the popup
                    BindTaskAdd(recordType, recordID, recordSubID, taskStep, taskType, lblTaskDetailValueAdd.Text.ToString(), plantID, "");
                    lblErrorMessage.Text = "";
                    string script = "function f(){OpenUpdateTaskWindow(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, true);
                }
                else
                {
                    SessionManager.ReturnRecordID = task.RECORD_ID;
                    SessionManager.ReturnObject   = "AddTask";
                    SessionManager.ReturnStatus   = true;
                }
            }
        }
Ejemplo n.º 28
0
        public PROB_DEFINE UpdateProblemDefinition(PROB_DEFINE prDefine)
        {
            foreach (INCIDENT incident in this.IncidentList)
            {
                if (this.ProbCase.PROBCASE_TYPE == "QI")
                {
                    QualityIssue qualityIssue = new QualityIssue().Load(incident.INCIDENT_ID);
                    string       str          = "";

                    // who reported the problem
                    str = incident.CREATE_BY;
                    if (incident.CREATE_PERSON != null && incident.CREATE_PERSON > 0)
                    {
                        PERSON  person  = SQMModelMgr.LookupPerson((decimal)incident.CREATE_PERSON, "");
                        COMPANY company = SQMModelMgr.LookupCompany(person.COMPANY_ID);
                        str += " (" + company.COMPANY_NAME + ")";
                    }
                    if (string.IsNullOrEmpty(prDefine.WHO_IS) || !prDefine.WHO_IS.Contains(str))
                    {
                        if (!string.IsNullOrEmpty(prDefine.WHO_IS))
                        {
                            prDefine.WHO_IS += ", ";
                        }
                        prDefine.WHO_IS += str;
                    }

                    // where did the problem occur
                    str = qualityIssue.DetectedLocation.Company.COMPANY_NAME;
                    if (incident.DETECT_BUS_ORG_ID != null && incident.DETECT_BUS_ORG_ID > 0)
                    {
                        str += (" /  " + qualityIssue.DetectedLocation.BusinessOrg.ORG_NAME);
                    }
                    if (incident.DETECT_PLANT_ID != null && incident.DETECT_PLANT_ID > 0)
                    {
                        str += (" / " + qualityIssue.DetectedLocation.Plant.PLANT_NAME);
                    }
                    if (string.IsNullOrEmpty(prDefine.WHERE_IS) || !prDefine.WHERE_IS.Contains(str))
                    {
                        if (!string.IsNullOrEmpty(prDefine.WHERE_IS))
                        {
                            prDefine.WHERE_IS += ", ";
                        }
                        prDefine.WHERE_IS += str;
                    }


                    // where detected
                    str = WebSiteCommon.GetXlatValueLong("issueResponsible", qualityIssue.IssueOccur.SOURCE);
                    if (string.IsNullOrEmpty(prDefine.DETECTED_IS) || !prDefine.DETECTED_IS.Contains(str))
                    {
                        if (!string.IsNullOrEmpty(prDefine.DETECTED_IS))
                        {
                            prDefine.DETECTED_IS += ", ";
                        }
                        prDefine.DETECTED_IS += str;
                    }

                    // who or where is impacted
                    if (!string.IsNullOrEmpty(prDefine.IMPACT_IS))
                    {
                        prDefine.IMPACT_IS += ", ";
                    }

                    prDefine.IMPACT_IS += WebSiteCommon.GetXlatValueLong("issueResponsible", qualityIssue.IssueOccur.SOURCE);

                    // when did the problem occur
                    str = WebSiteCommon.FormatDateString(WebSiteCommon.LocalTime(incident.INCIDENT_DT, SessionManager.UserContext.TimeZoneID), false);
                    if (string.IsNullOrEmpty(prDefine.WHEN_IS) || !prDefine.WHEN_IS.Contains(str))
                    {
                        if (!string.IsNullOrEmpty(prDefine.WHEN_IS))
                        {
                            prDefine.WHEN_IS += ", ";
                        }
                        prDefine.WHEN_IS += str;
                    }

                    // what is the problem
                    if (!string.IsNullOrEmpty(prDefine.WHAT_IS))
                    {
                        prDefine.WHAT_IS += ", ";
                    }
                    prDefine.WHAT_IS += (" " + qualityIssue.Partdata.Part.PART_NUM + "(" + qualityIssue.Partdata.Part.PART_NAME + ")");

                    // how many how often detected
                    double qty = 0;
                    if (!string.IsNullOrEmpty(prDefine.HOW_MANY))
                    {
                        qty = double.Parse(prDefine.HOW_MANY);
                    }
                    foreach (QI_OCCUR_ITEM item in qualityIssue.IssueOccur.QI_OCCUR_ITEM)
                    {
                        qty += Convert.ToDouble(item.INSPECT_NC_QTY);
                        foreach (QI_OCCUR_NC sample in item.QI_OCCUR_NC)
                        {
                            if (!string.IsNullOrEmpty(prDefine.NC_IS))
                            {
                                prDefine.NC_IS += ", ";
                            }
                            NONCONFORMANCE nc = SQMResourcesMgr.LookupNonconf(this.Entities, (decimal)sample.NONCONF_ID, "");
                            if (nc != null)
                            {
                                prDefine.NC_IS += (qualityIssue.IssueOccur.OCCUR_DESC + ": " + nc.NONCONF_DESC);
                            }
                        }
                    }
                    prDefine.HOW_MANY = qty.ToString();

                    str = qualityIssue.IssueOccur.OCCUR_DESC;
                    if (string.IsNullOrEmpty(prDefine.WHY_IS) || !prDefine.WHY_IS.Contains(str))
                    {
                        if (!string.IsNullOrEmpty(prDefine.WHY_IS))
                        {
                            prDefine.WHY_IS += ", ";
                        }
                        prDefine.WHY_IS += str;
                    }

                    prDefine.URGENT_IS = prDefine.MEASURE_IS = prDefine.OFTEN_IS = "TBD";
                }
            }

            return(prDefine);
        }
Ejemplo n.º 29
0
        protected void rgTaskList_ItemDataBound(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                HiddenField  hf;
                Label        lbl;

                try
                {
                    TASK_STATUS task = (TASK_STATUS)e.Item.DataItem;

                    LinkButton lnk = (LinkButton)e.Item.FindControl("lbTaskId");
                    lnk.Text = WebSiteCommon.FormatID(task.TASK_ID, 6);
                    if (task.DESCRIPTION != null)
                    {
                        if (task.DESCRIPTION.Length > 120)
                        {
                            lbl      = (Label)e.Item.FindControl("lblDescription");
                            lbl.Text = task.DESCRIPTION.Substring(0, 117) + "...";
                        }
                    }
                    lbl = (Label)e.Item.FindControl("lblTaskType");

                    lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "RECORD_TYPE" && l.XLAT_CODE == task.RECORD_TYPE.ToString()).FirstOrDefault().DESCRIPTION;
                    if (task.TASK_STEP == "350" || task.TASK_STEP == "400")
                    {
                        if (task.RECORD_TYPE == (int)TaskRecordType.Audit && task.RECORD_SUBID > 0)
                        {
                            lbl.Text += ("&nbsp;Exception");
                        }
                        lbl.Text += (" - " + TaskXLATList.Where(l => l.XLAT_GROUP == "NOTIFY_SCOPE_TASK" && l.XLAT_CODE == task.TASK_STEP).FirstOrDefault().DESCRIPTION);
                    }

                    lbl = (Label)e.Item.FindControl("lblCreateDT");
                    if (task.CREATE_DT.HasValue)
                    {
                        lbl.Text = Convert.ToDateTime(task.CREATE_DT).ToShortDateString();
                    }
                    lbl = (Label)e.Item.FindControl("lblDueDT");
                    if (task.DUE_DT.HasValue)
                    {
                        lbl.Text = Convert.ToDateTime(task.DUE_DT).ToShortDateString();
                    }

                    lbl      = (Label)e.Item.FindControl("lblStatus");
                    lbl.Text = TaskXLATList.Where(l => l.XLAT_GROUP == "TASK_STATUS" && l.XLAT_CODE == ((int)TaskMgr.CalculateTaskStatus(task)).ToString()).FirstOrDefault().DESCRIPTION_SHORT;

                    lbl = (Label)e.Item.FindControl("lblResponsiblePerson");
                    PERSON responsiblePerson = new PERSON();
                    try
                    {
                        PSsqmEntities entities = new PSsqmEntities();
                        responsiblePerson = SQMModelMgr.LookupPerson((decimal)task.RESPONSIBLE_ID, "");
                    }
                    catch { }

                    if (responsiblePerson != null)
                    {
                        lbl.Text = SQMModelMgr.FormatPersonListItem(responsiblePerson, false, "LF");
                    }
                }
                catch
                {
                }
            }
        }