コード例 #1
0
        public int AddUpdateINCFORM_APPROVAL(decimal incidentId)
        {
            var itemList = new List <INCFORM_APPROVAL>();
            int status   = 0;

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                status = ctx.ExecuteStoreCommand("DELETE FROM INCFORM_APPROVAL WHERE INCIDENT_ID = " + incidentId.ToString());

                foreach (RepeaterItem item in rptApprovals.Items)
                {
                    HiddenField   hf     = (HiddenField)item.FindControl("hfItemSeq");
                    Label         lba    = (Label)item.FindControl("lbApprover");
                    Label         lbm    = (Label)item.FindControl("lbApproveMessage");
                    Label         lb     = (Label)item.FindControl("lbItemSeq");
                    Label         lbjobd = (Label)item.FindControl("lbApproverJob");
                    CheckBox      cba    = (CheckBox)item.FindControl("cbIsAccepted");
                    RadDatePicker rda    = (RadDatePicker)item.FindControl("rdpAcceptDate");

                    if (cba.Checked == true)
                    {
                        INCFORM_APPROVAL approval = new INCFORM_APPROVAL();
                        approval.INCIDENT_ID      = incidentId;
                        approval.ITEM_SEQ         = Convert.ToInt32(hf.Value);
                        approval.IsAccepted       = true;
                        approval.APPROVAL_MESSAGE = lbm.Text;
                        approval.APPROVER_TITLE   = lbjobd.Text;
                        approval.APPROVAL_DATE    = rda.SelectedDate;
                        hf = (HiddenField)item.FindControl("hfPersonID");
                        if (string.IsNullOrEmpty(hf.Value) || hf.Value == "0")
                        {
                            approval.APPROVER_PERSON_ID = SessionManager.UserContext.Person.PERSON_ID;
                            approval.APPROVER_PERSON    = SessionManager.UserContext.UserName();
                        }
                        else
                        {
                            approval.APPROVER_PERSON_ID = Convert.ToDecimal(hf.Value);
                            approval.APPROVER_PERSON    = lba.Text;
                        }
                        ctx.AddToINCFORM_APPROVAL(approval);
                    }
                }

                status = ctx.SaveChanges();
            }

            return(status);
        }
コード例 #2
0
        public void rptApprovals_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                int minRowsToValidate = 1;

                try
                {
                    INCFORM_APPROVAL approval = (INCFORM_APPROVAL)e.Item.DataItem;

                    HiddenField   hf     = (HiddenField)e.Item.FindControl("hfItemSeq");
                    Label         lba    = (Label)e.Item.FindControl("lbApprover");
                    Label         lbm    = (Label)e.Item.FindControl("lbApproveMessage");
                    Label         lb     = (Label)e.Item.FindControl("lbItemSeq");
                    Label         lbjobd = (Label)e.Item.FindControl("lbApproverJob");
                    CheckBox      cba    = (CheckBox)e.Item.FindControl("cbIsAccepted");
                    RadDatePicker rda    = (RadDatePicker)e.Item.FindControl("rdpAcceptDate");

                    hf.Value         = approval.ITEM_SEQ.ToString();
                    hf               = (HiddenField)e.Item.FindControl("hfPersonID");
                    hf.Value         = approval.APPROVER_PERSON_ID.ToString();
                    lb.Visible       = false;
                    lbjobd.Text      = approval.APPROVER_TITLE;
                    lba.Text         = !string.IsNullOrEmpty(approval.APPROVER_PERSON) ? approval.APPROVER_PERSON : "";
                    lbm.Text         = approval.APPROVAL_MESSAGE;
                    cba.Checked      = approval.IsAccepted;
                    rda.SelectedDate = approval.APPROVAL_DATE;

                    // Set user access:
                    if (SessionManager.CheckUserPrivilege((SysPriv)approval.ITEM_SEQ, SysScope.incident))
                    {
                        lba.Text    = SessionManager.UserContext.UserName();
                        cba.Enabled = true;
                    }
                    else
                    {
                        cba.Enabled = false;
                    }
                }
                catch { }
            }

            if (e.Item.ItemType == ListItemType.Footer)
            {
                //Button addanother = (Button)e.Item.FindControl("btnAddApproval");
                //addanother.Visible = ApproveAccess;
            }
        }
コード例 #3
0
        PdfPTable ReviewSection(AlertData pageData)
        {
            PdfPTable tableReview = new PdfPTable(new float[] { 170f, 210f, 160f });

            tableReview.TotalWidth    = 540f;
            tableReview.LockedWidth   = true;
            tableReview.SpacingBefore = 15f;
            PdfPCell cell;

            INCFORM_APPROVAL reviewer = null;

            cell = new PdfPCell()
            {
                Padding = 1f, PaddingBottom = 4f, Border = 0
            };
            cell.Colspan        = 3;
            cell.BorderWidthTop = .25f;
            cell.AddElement(new Paragraph(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "REVIEW").DESCRIPTION_SHORT, detailHdrFont));
            tableReview.AddCell(cell);

            cell = new PdfPCell()
            {
                Padding = 1f, PaddingBottom = 4f, Border = 0
            };
            cell.Colspan = 3;
            cell.AddElement(new Paragraph(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "REVIEW").DESCRIPTION, detailTxtItalicFont));
            tableReview.AddCell(cell);

            cell = new PdfPCell()
            {
                Padding = 2f, PaddingBottom = 5f, Border = 0
            };
            cell.BorderWidthTop = cell.BorderWidthLeft = .25f;
            cell.AddElement(new Paragraph(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "REVIEW_1").DESCRIPTION_SHORT, detailTxtFont));
            tableReview.AddCell(cell);

            if ((reviewer = pageData.approvalList.Where(l => l.approval.ITEM_SEQ == (int)SysPriv.approve1).Select(l => l.approval).FirstOrDefault()) == null)
            {
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthLeft = .25f;
                cell.AddElement(new Paragraph("", detailTxtFont));
                tableReview.AddCell(cell);
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthLeft = cell.BorderWidthRight = .25f;
                cell.AddElement(new Paragraph(string.Format(""), detailTxtFont));
                tableReview.AddCell(cell);
            }
            else
            {
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthLeft = .25f;
                cell.AddElement(new Paragraph(reviewer.APPROVER_PERSON, detailTxtFont));
                tableReview.AddCell(cell);
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthLeft = cell.BorderWidthRight = .25f;
                cell.AddElement(new Paragraph(string.Format(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "DATED").DESCRIPTION_SHORT + ":  {0}", SQMBasePage.FormatDate((DateTime)reviewer.APPROVAL_DATE, "d", false)), detailTxtFont));
                tableReview.AddCell(cell);
            }

            cell = new PdfPCell()
            {
                Padding = 2f, PaddingBottom = 5f, Border = 0
            };
            cell.BorderWidthTop = cell.BorderWidthBottom = cell.BorderWidthLeft = .25f;
            cell.AddElement(new Paragraph(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "REVIEW_2").DESCRIPTION_SHORT, detailTxtFont));
            tableReview.AddCell(cell);
            if ((reviewer = pageData.approvalList.Where(l => l.approval.ITEM_SEQ == (int)SysPriv.approve2).Select(l => l.approval).FirstOrDefault()) == null)
            {
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthBottom = cell.BorderWidthLeft = .25f;
                cell.AddElement(new Paragraph("", detailTxtFont));
                tableReview.AddCell(cell);
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthBottom = cell.BorderWidthLeft = cell.BorderWidthRight = .25f;
                cell.AddElement(new Paragraph(string.Format(""), detailTxtFont));
                tableReview.AddCell(cell);
            }
            else
            {
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthBottom = cell.BorderWidthLeft = .25f;
                cell.AddElement(new Paragraph(reviewer.APPROVER_PERSON, detailTxtFont));
                tableReview.AddCell(cell);
                cell = new PdfPCell()
                {
                    Padding = 2f, PaddingBottom = 5f, Border = 0
                };
                cell.BorderWidthTop = cell.BorderWidthBottom = cell.BorderWidthLeft = cell.BorderWidthRight = .25f;
                cell.AddElement(new Paragraph(string.Format(SQMBasePage.GetXLAT(reportXLAT, "HS_5PHASE", "DATED").DESCRIPTION_SHORT + ":  {0}", SQMBasePage.FormatDate((DateTime)reviewer.APPROVAL_DATE, "d", false)), detailTxtFont));
                tableReview.AddCell(cell);
            }

            return(tableReview);
        }
コード例 #4
0
        public int AddUpdateINCFORM_APPROVAL(decimal incidentId, string option)
        {
            //To get approvertype from usercontext. -NIHARIKA SAXENA
            var approveerType = (SessionManager.UserContext.PrivList.Where(p => p.PRIV <= 100).FirstOrDefault()).PRIV_GROUP.ToString();
            //Check status of severityLevel of Global Safety Group
            bool severityLevel = false;

            var  itemList      = new List <INCFORM_APPROVAL>();
            int  status        = 0;
            int  numRequired   = 0;
            int  requiredCount = 0;
            int  approvalCount = 0;
            bool isRequired;
            bool isChanged = false;



            List <INCFORM_APPROVAL> approvalList = new List <INCFORM_APPROVAL>();

            using (PSsqmEntities ctx = new PSsqmEntities())
            {
                foreach (RepeaterItem item in rptApprovals.Items)
                {
                    isRequired = false;
                    HiddenField hfreq = (HiddenField)item.FindControl("hfReqdComplete");
                    if (hfreq.Value.ToLower() == "true")
                    {
                        ++numRequired;
                        isRequired = true;
                    }

                    INCFORM_APPROVAL approval = new INCFORM_APPROVAL();
                    approval.INCIDENT_ID    = incidentId;
                    approval.APPROVAL_LEVEL = 0;
                    approval.STEP           = ApprovalStep.STEP;
                    Label         lba    = (Label)item.FindControl("lbApprover");
                    Label         lb     = (Label)item.FindControl("lbItemSeq");
                    CheckBox      cba    = (CheckBox)item.FindControl("cbIsAccepted");
                    RadDatePicker rda    = (RadDatePicker)item.FindControl("rdpAcceptDate");
                    HiddenField   hfrole = (HiddenField)item.FindControl("hfRoleDesc");
                    HiddenField   hf     = (HiddenField)item.FindControl("hfItemSeq");
                    HiddenField   hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID");
                    approval.ITEM_SEQ       = Convert.ToInt32(hf.Value);
                    approval.APPROVER_TITLE = hfrole.Value;
                    if (IncidentId > MaxIncidentForNewFeature && ApprovalStep.STEP < 6)
                    {
                        approval.INCFORM_APPROVER_LIST_ID = Convert.ToDecimal(hfINCFORM_APPROVER_LIST_ID.Value);
                    }

                    //Update SEVERITY_LEVEL value. -
                    if (chkSeverityLevel00.Checked && chkSeverityLevel00.Visible == true)
                    {
                        severityLevel           = chkSeverityLevel00.Checked;
                        approval.SEVERITY_LEVEL = SysPriv.first_add.ToString();
                    }
                    else if (chkSeverityLevel01.Checked && chkSeverityLevel01.Visible == true)
                    {
                        severityLevel           = chkSeverityLevel01.Checked;
                        approval.SEVERITY_LEVEL = SysPriv.l1.ToString();
                    }

                    else if (chkSeverityLevel02.Checked && chkSeverityLevel02.Visible == true)
                    {
                        severityLevel           = chkSeverityLevel02.Checked;
                        approval.SEVERITY_LEVEL = SysPriv.l2.ToString();
                    }
                    else if (chkSeverityLevel03.Checked && chkSeverityLevel03.Visible == true)
                    {
                        severityLevel           = chkSeverityLevel03.Checked;
                        approval.SEVERITY_LEVEL = SysPriv.l3.ToString();
                    }
                    else if (chkSeverityLevel04.Checked && chkSeverityLevel04.Visible == true)
                    {
                        severityLevel           = chkSeverityLevel04.Checked;
                        approval.SEVERITY_LEVEL = SysPriv.l4.ToString();
                    }

                    approvalList.Add(approval);

                    if (cba.Checked == true)    // is approved
                    {
                        ++approvalCount;

                        if (isRequired)
                        {
                            ++requiredCount;
                        }

                        hf = (HiddenField)item.FindControl("hfApprovalID");
                        if (string.IsNullOrEmpty(hf.Value) || hf.Value == "0")
                        {
                            // save new approval to db
                            isChanged = true;
                            approval.APPROVAL_DATE = rda.SelectedDate;
                            approval.IsAccepted    = true;
                            hf = (HiddenField)item.FindControl("hfPersonID");
                            if (string.IsNullOrEmpty(hf.Value) || hf.Value == "0")
                            {
                                approval.APPROVER_PERSON_ID = SessionManager.UserContext.Person.PERSON_ID;
                                approval.APPROVER_PERSON    = SessionManager.UserContext.UserName();
                            }
                            else
                            {
                                approval.APPROVER_PERSON_ID = Convert.ToDecimal(hf.Value);
                                approval.APPROVER_PERSON    = lba.Text;
                            }

                            ctx.AddToINCFORM_APPROVAL(approval);
                        }
                    }
                }

                if (approveerType == "Global Safety Group")
                {
                    if (severityLevel)
                    {
                        lblResponseMsg.Text        = "";
                        chkSeverityLevel00.Enabled = false;

                        chkSeverityLevel01.Enabled = false;

                        chkSeverityLevel02.Enabled = false;

                        chkSeverityLevel03.Enabled = false;

                        chkSeverityLevel04.Enabled = false;

                        //status = ctx.ExecuteStoreCommand("DELETE FROM INCFORM_APPROVAL WHERE INCIDENT_ID = " + incidentId.ToString() + " AND STEP = " + ApprovalStep.ToString());
                        status = ctx.SaveChanges();
                    }
                    else
                    {
                        status = -1;
                    }
                }
                else
                {
                    status = ctx.SaveChanges();
                }

                bool   notifyStepComplete = false;
                string incidentStep       = "";

                // determine step status
                if (approvalCount > 0)
                {
                    if (ApprovalStep.STEP == 10.0m)
                    {
                        incidentStep = "Approvals";
                        IncidentStepStatus stat;
                        if ((numRequired > 0 && requiredCount == numRequired) || approvalCount == rptApprovals.Items.Count)
                        {
                            stat = (IncidentStepStatus)Math.Min(rptApprovals.Items.Count + 150, 155);
                            EHSIncidentMgr.UpdateIncidentStatus(incidentId, stat, true, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ));
                            notifyStepComplete = true;
                        }
                        else
                        {
                            incidentStep = ApprovalStep.STEP == 5.5m ? "CorrectiveActionApproval" : "InitialActionApproval";
                            stat         = (IncidentStepStatus)Math.Min(approvalCount + 150, 154);
                            EHSIncidentMgr.UpdateIncidentStatus(incidentId, stat, WebSiteCommon.LocalTime(DateTime.UtcNow, IncidentLocationTZ));
                        }
                    }
                    else
                    {
                        if ((numRequired > 0 && requiredCount == numRequired) || approvalCount == rptApprovals.Items.Count)
                        {
                            EHSIncidentMgr.UpdateIncidentApprovalStatus(incidentId, ApprovalStep.STEP);
                            notifyStepComplete = true;
                        }
                    }
                }

                // only send notifications when approvals are added
                if (isChanged)
                {
                    NotifyCycle notifyCycle;
                    try
                    {
                        notifyCycle = ApprovalStep.NOTIFY_CYCLE.HasValue ? (NotifyCycle)ApprovalStep.NOTIFY_CYCLE : NotifyCycle.None;
                    }
                    catch
                    {
                        notifyCycle = NotifyCycle.None;
                    }

                    if (notifyStepComplete && ApprovalStep.STEP == 10.0m)
                    {
                        EHSNotificationMgr.NotifyIncidentStatus(LocalIncident, ((int)SysPriv.approve).ToString(), "");
                    }

                    if (notifyCycle == NotifyCycle.notifyNext)
                    {
                        INCFORM_APPROVAL priorApproval = new INCFORM_APPROVAL();
                        foreach (INCFORM_APPROVAL approval in approvalList)
                        {
                            // notify missing approvers when prior roles approved or the step was completed by 380 or 390 priv
                            if (!approval.APPROVAL_DATE.HasValue && (priorApproval.APPROVAL_DATE.HasValue || notifyStepComplete))
                            {
                                List <string> infoList = new List <string>();
                                infoList.Add(approval.APPROVER_TITLE);
                                infoList.Add(priorApproval.APPROVER_TITLE);
                                EHSNotificationMgr.NotifyIncidentSignoffRequired(LocalIncident, approval, ApprovalStep.STEP_HEADING_TEXT, approval.ITEM_SEQ >= 390 ? "SIGNOFF" : "APPROVAL", infoList);
                            }
                            priorApproval = approval;
                        }
                    }
                }
            }
            if (IncidentId > MaxIncidentForNewFeature && ApprovalStep.STEP < 6)
            {
                bool isNotify = false;
                if (isChanged)
                {
                    using (PSsqmEntities ctx = new PSsqmEntities())
                    {
                        //foreach (RepeaterItem item in rptApprovals.Items)
                        //{
                        //    CheckBox cba = (CheckBox)item.FindControl("cbIsAccepted");
                        //    HiddenField hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID");
                        //    HiddenField hfAPPROVERType = (HiddenField)item.FindControl("hfAPPROVERType");
                        //    if (cba.Checked && (hfAPPROVERType.Value == "A" || hfAPPROVERType.Value == "N"))
                        //    {
                        //        isNotify = true;
                        //    }
                        //    else if (!cba.Checked && (hfAPPROVERType.Value == "A" || hfAPPROVERType.Value == "N"))
                        //    {
                        //        isNotify = false;
                        //        break;
                        //    }
                        //}
                        //if (isNotify)
                        //{

                        foreach (RepeaterItem item in rptApprovals.Items)
                        {
                            HiddenField   hfrole = (HiddenField)item.FindControl("hfRoleDesc");
                            CheckBox      cba    = (CheckBox)item.FindControl("cbIsAccepted");
                            HiddenField   hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID");
                            List <string> infoList = new List <string>();
                            infoList.Add(hfrole.Value);
                            decimal?applistid             = Convert.ToDecimal(hfINCFORM_APPROVER_LIST_ID.Value);
                            INCFORM_APPROVER_LIST appList = (from i in ctx.INCFORM_APPROVER_LIST where i.INCFORM_APPROVER_LIST_ID == applistid select i).FirstOrDefault();
                            PERSON person = (from i in ctx.PERSON where i.PERSON_ID == appList.PERSON_ID select i).FirstOrDefault();
                            if (!cba.Checked)
                            {
                                if (person != null)
                                {
                                    EHSNotificationMgr.NotifyApprover(LocalIncident, person.PERSON_ID, ApprovalStep.STEP_HEADING_TEXT, appList.PRIV >= 390 ? "SIGNOFF" : "APPROVAL", infoList);
                                }
                            }
                        }
                        //CheckBox cba = (CheckBox)item.FindControl("cbIsAccepted");
                        //HiddenField hfINCFORM_APPROVER_LIST_ID = (HiddenField)item.FindControl("hfINCFORM_APPROVER_LIST_ID");
                        //HiddenField hfAPPROVERType = (HiddenField)item.FindControl("hfAPPROVERType");
                        //if (!cba.Checked && (hfAPPROVERType.Value == "R"))
                        //{
                        //    decimal? applistid = Convert.ToDecimal(hfINCFORM_APPROVER_LIST_ID.Value);
                        //    INCFORM_APPROVER_LIST appList = (from i in ctx.INCFORM_APPROVER_LIST where i.INCFORM_APPROVER_LIST_ID == applistid select i).FirstOrDefault();
                        //    if (appList.PERSON_ID != null)
                        //    {
                        //        PERSON person = (from i in ctx.PERSON where i.PERSON_ID == appList.PERSON_ID select i).FirstOrDefault();
                        //        EHSNotificationMgr.NotifyRegionalApprover(person.PERSON_ID, "Notify Regional Approver");
                        //    }
                        //}

                        //}
                    }
                }
            }
            return(status);
        }
コード例 #5
0
        protected void btnConversion_Click(object sender, EventArgs e)
        {
            int             status   = 0;
            INCIDENT_ANSWER answer   = null;
            List <XLAT>     xlatList = SQMBasePage.SelectXLATList(new string[6] {
                "SHIFT", "INJURY_CAUSE", "INJURY_TYPE", "INJURY_PART", "INJURY_TENURE", "IQ_10"
            });

            foreach (EHSIncidentData eda in HSCalcs().ehsCtl.IncidentHst.Where(i => i.Incident.INCFORM_LAST_STEP_COMPLETED < 1 && i.Incident.INCIDENT_ID > 0))
            {
                INCIDENT incident = (from i in entities.INCIDENT where i.INCIDENT_ID == eda.Incident.INCIDENT_ID select i).SingleOrDefault();
                incident.INCIDENT_ANSWER.Load();

                // clear any prior conversion reecords
                string delCmd = " = " + incident.INCIDENT_ID.ToString();
                status = entities.ExecuteStoreCommand("DELETE FROM TASK_STATUS WHERE RECORD_TYPE = 40 AND RECORD_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_LOSTTIME_HIST WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_CONTAIN WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_ACTION WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_ROOT5Y WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_CAUSATION WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_APPROVAL WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_WITNESS WHERE INCIDENT_ID" + delCmd);
                status = entities.ExecuteStoreCommand("DELETE FROM INCFORM_INJURYILLNESS WHERE INCIDENT_ID" + delCmd);

                EHSIncidentTypeId issueType = (EHSIncidentTypeId)incident.ISSUE_TYPE_ID;
                try
                {
                    switch (issueType)
                    {
                    case EHSIncidentTypeId.PropertyDamage:
                    case EHSIncidentTypeId.PowerOutage:
                    case EHSIncidentTypeId.Fire:
                    case EHSIncidentTypeId.Explosion:
                    case EHSIncidentTypeId.ImsAudit:
                    case EHSIncidentTypeId.RegulatoryContact:
                    case EHSIncidentTypeId.FireSystemImpairment:
                    case EHSIncidentTypeId.SpillRelease:
                    case EHSIncidentTypeId.EhsWalk:
                    case EHSIncidentTypeId.NearMiss:
                    case EHSIncidentTypeId.InjuryIllness:
                        incident.INCFORM_LAST_STEP_COMPLETED = 100;                                                  // assume new status
                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 69).FirstOrDefault(); // containment
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 110;                                      // containment
                            INCFORM_CONTAIN contain = new INCFORM_CONTAIN();
                            contain.INCIDENT_ID        = incident.INCIDENT_ID;
                            contain.ITEM_SEQ           = 1;
                            contain.ITEM_DESCRIPTION   = answer.ANSWER_VALUE;
                            contain.ASSIGNED_PERSON_ID = incident.CREATE_PERSON;
                            contain.START_DATE         = contain.COMPLETION_DATE = incident.CREATE_DT;
                            contain.IsCompleted        = true;
                            contain.LAST_UPD_BY        = SessionManager.UserContext.UserName();
                            contain.LAST_UPD_DT        = DateTime.UtcNow;

                            entities.AddToINCFORM_CONTAIN(contain);
                        }

                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 24).FirstOrDefault();                                  // root cause
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 120;                                      // root cause
                            INCFORM_ROOT5Y rootc = new INCFORM_ROOT5Y();
                            rootc.INCIDENT_ID      = incident.INCIDENT_ID;
                            rootc.ITEM_SEQ         = 1;
                            rootc.ITEM_DESCRIPTION = answer.ANSWER_VALUE;
                            rootc.LAST_UPD_BY      = SessionManager.UserContext.UserName();
                            rootc.LAST_UPD_DT      = DateTime.UtcNow;

                            entities.AddToINCFORM_ROOT5Y(rootc);
                        }

                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 78).FirstOrDefault();                                  // causation
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 125;                                      // causation
                            INCFORM_CAUSATION cause = new INCFORM_CAUSATION();
                            cause.INCIDENT_ID   = incident.INCIDENT_ID;
                            cause.CAUSEATION_CD = xlatList.Where(l => l.XLAT_GROUP == "INJURY_CAUSE" && l.DESCRIPTION == answer.ANSWER_VALUE).FirstOrDefault() == null ? "1000" : xlatList.Where(l => l.XLAT_GROUP == "INJURY_CAUSE" && l.DESCRIPTION == answer.ANSWER_VALUE).FirstOrDefault().XLAT_CODE;
                            cause.LAST_UPD_BY   = SessionManager.UserContext.UserName();
                            cause.LAST_UPD_DT   = DateTime.UtcNow;

                            entities.AddToINCFORM_CAUSATION(cause);
                        }

                        answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 27).FirstOrDefault();                                  // corrective action
                        if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 130;                                      // corrective action
                            TASK_STATUS action = new TASK_STATUS();
                            action.RECORD_TYPE  = (int)TaskRecordType.HealthSafetyIncident;
                            action.RECORD_ID    = incident.INCIDENT_ID;
                            action.TASK_STEP    = ((int)SysPriv.action).ToString();
                            action.TASK_SEQ     = 0;
                            action.RECORD_SUBID = 0;
                            action.TASK_TYPE    = "T";
                            action.TASK_SEQ     = 0;
                            action.DESCRIPTION  = answer.ANSWER_VALUE;
                            action.DETAIL       = incident.DESCRIPTION;
                            action.STATUS       = "1";
                            action.CREATE_ID    = action.RESPONSIBLE_ID = action.COMPLETE_ID = incident.CREATE_PERSON;                                   // default action values
                            action.CREATE_DT    = action.DUE_DT = action.COMPLETE_DT = incident.CREATE_DT;
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 79).FirstOrDefault();                                 // responsible
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.RESPONSIBLE_ID = action.COMPLETE_ID = decimal.Parse(answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 65).FirstOrDefault();                                      // action due date
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.DUE_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 66).FirstOrDefault();                                      // action complete date
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.COMPLETE_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 70).FirstOrDefault();                                      // verification ?
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                action.COMMENTS = answer.ANSWER_VALUE;
                            }

                            entities.AddToTASK_STATUS(action);
                        }

                        if (incident.CLOSE_DATE_DATA_COMPLETE.HasValue || incident.CLOSE_DATE.HasValue)
                        {
                            incident.INCFORM_LAST_STEP_COMPLETED = 151;                                      // signoff
                            INCFORM_APPROVAL approval = new INCFORM_APPROVAL();
                            approval.INCIDENT_ID        = incident.INCIDENT_ID;
                            approval.ITEM_SEQ           = (int)SysPriv.approve1;
                            approval.APPROVAL_DATE      = incident.CLOSE_DATE.HasValue ? incident.CLOSE_DATE : incident.CLOSE_DATE_DATA_COMPLETE;
                            approval.IsAccepted         = true;
                            approval.APPROVER_PERSON_ID = incident.CLOSE_PERSON.HasValue ? incident.CLOSE_PERSON : incident.CREATE_PERSON;
                            PERSON person = (from p in entities.PERSON where p.PERSON_ID == approval.APPROVER_PERSON_ID select p).FirstOrDefault();
                            approval.APPROVAL_MESSAGE = approval.APPROVER_PERSON = (person.FIRST_NAME + " " + person.LAST_NAME);
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 67).FirstOrDefault();                                      // completed by
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                approval.APPROVAL_MESSAGE = approval.APPROVER_PERSON = answer.ANSWER_VALUE;
                                string[] names = answer.ANSWER_VALUE.ToLower().Split(' ');
                                if (names.Length > 1)
                                {
                                    string firstName = names[0];
                                    string lastnamne = names[1];
                                    person = (from p in entities.PERSON where p.FIRST_NAME.ToLower() == firstName && p.LAST_NAME.ToLower() == lastnamne select p).FirstOrDefault();
                                }
                            }
                            if (person != null)
                            {
                                approval.APPROVER_PERSON_ID = person.PERSON_ID;
                                approval.APPROVER_TITLE     = person.JOB_TITLE;
                            }

                            entities.AddToINCFORM_APPROVAL(approval);
                        }

                        if (issueType == EHSIncidentTypeId.InjuryIllness)
                        {
                            INCFORM_INJURYILLNESS inRec   = new INCFORM_INJURYILLNESS();
                            INCFORM_WITNESS       witness = new INCFORM_WITNESS();
                            INCFORM_LOSTTIME_HIST hist    = new INCFORM_LOSTTIME_HIST();

                            inRec.INCIDENT_ID = incident.INCIDENT_ID;
                            answer            = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 6).FirstOrDefault();                          // shift

                            inRec.SHIFT = GetXLATCode(xlatList, "SHIFT", answer.ANSWER_VALUE);
                            answer      = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 7).FirstOrDefault();                                // department
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.DEPARTMENT = answer.ANSWER_VALUE;
                                DEPARTMENT dept = (from d in entities.DEPARTMENT where d.DEPT_NAME.ToLower() == answer.ANSWER_VALUE.ToLower() select d).SingleOrDefault();
                                if (dept != null)
                                {
                                    inRec.DEPT_ID = dept.DEPT_ID;
                                }
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 8).FirstOrDefault();                                     // involved person
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INVOLVED_PERSON_NAME = answer.ANSWER_VALUE;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 4).FirstOrDefault();                                     // supervisor inform date
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.SUPERVISOR_INFORMED_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 5).FirstOrDefault();                                     // time of incident
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INCIDENT_TIME = TimeSpan.Parse(answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 9).FirstOrDefault();                                     // witness
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE) && answer.ANSWER_VALUE.Split(' ').Length > 1)
                            {
                                witness.INCIDENT_ID  = incident.INCIDENT_ID;
                                witness.WITNESS_NO   = 1;
                                witness.WITNESS_NAME = answer.ANSWER_VALUE;
                                witness.LAST_UPD_BY  = SessionManager.UserContext.UserName();
                                witness.LAST_UPD_DT  = DateTime.UtcNow;

                                entities.AddToINCFORM_WITNESS(witness);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 10).FirstOrDefault();                                     // inside/outside
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INSIDE_OUTSIDE_BLDNG = GetXLATCode(xlatList, "IQ_10", answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 11).FirstOrDefault();                                     // weather
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                ;                                                                                        // NO FIELD
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 12).FirstOrDefault(); // injury type
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INJURY_TYPE = GetXLATCode(xlatList, "INJURY_TYPE", answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 13).FirstOrDefault();                                     // body part
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.INJURY_BODY_PART = GetXLATCode(xlatList, "INJURY_PART", answer.ANSWER_VALUE);
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 15).FirstOrDefault();                                     // reocurrance
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.REOCCUR = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 16).FirstOrDefault();                                     // first aid case
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.FIRST_AID = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 37).FirstOrDefault();                                     // employee
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.COMPANY_SUPERVISED = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 58).FirstOrDefault();                                     // specific description
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.DESCRIPTION_LOCAL = answer.ANSWER_VALUE;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 62).FirstOrDefault();                                     // recordable
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.RECORDABLE = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 63).FirstOrDefault();                                     // lost time case
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.LOST_TIME = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;
                                if (inRec.LOST_TIME)
                                {
                                    hist.INCIDENT_ID      = incident.INCIDENT_ID;
                                    hist.WORK_STATUS      = "03";
                                    hist.ITEM_DESCRIPTION = "Lost Time";
                                    hist.BEGIN_DT         = incident.INCIDENT_DT;
                                    answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 3).FirstOrDefault();                                             // expected return date
                                    if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                                    {
                                        hist.RETURN_EXPECTED_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                                    }
                                    answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 55).FirstOrDefault();                                             // actual return date
                                    if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                                    {
                                        hist.RETURN_TOWORK_DT = DateTime.ParseExact(answer.ANSWER_VALUE, "M/d/yyyy hh:mm:ss tt", null);
                                    }
                                    hist.LAST_UPD_BY = SessionManager.UserContext.UserName();
                                    hist.LAST_UPD_DT = DateTime.UtcNow;

                                    entities.AddToINCFORM_LOSTTIME_HIST(hist);
                                }
                            }
                            answer = incident.INCIDENT_ANSWER.Where(a => a.INCIDENT_QUESTION_ID == 74).FirstOrDefault();                                     // occupational event ?
                            if (answer != null && !string.IsNullOrEmpty(answer.ANSWER_VALUE))
                            {
                                inRec.STD_PROCS_FOLLOWED = answer.ANSWER_VALUE.ToLower() == "yes" ? true : false;                                          // map to std procedures ?
                            }

                            entities.AddToINCFORM_INJURYILLNESS(inRec);
                        }

                        status = entities.SaveChanges();

                        break;

                    case EHSIncidentTypeId.PreventativeAction:
                        break;

                    default:
                        break;
                    }
                }
                catch
                {
                    decimal id;
                    id = incident.INCIDENT_ID;
                }
            }
        }