コード例 #1
0
 protected void lnkProblemCaseRedirect(Object sender, EventArgs e)
 {
     try
     {
         LinkButton lnk      = (LinkButton)sender;
         PROB_CASE  probCase = ProblemCase.LookupCaseByIncident(Convert.ToDecimal(lnk.CommandArgument));
         if (probCase != null)
         {
             SessionManager.ReturnObject = probCase.PROBCASE_ID;
             SessionManager.ReturnStatus = true;
             Response.Redirect("/Problem/Problem_Case.aspx?c=EHS");
         }
     }
     catch {; }
 }
コード例 #2
0
        public static List <INCIDENT> LookupProbIncidentList(PSsqmEntities ctx, PROB_CASE theCase)
        {
            List <INCIDENT> incidentList = new List <INCIDENT>();

            try
            {
                incidentList = (from o in ctx.PROB_OCCUR
                                join i in ctx.INCIDENT on o.INCIDENT_ID equals i.INCIDENT_ID
                                where (o.PROBCASE_ID == theCase.PROBCASE_ID) select i).ToList();
            }
            catch
            {
            }

            return(incidentList);
        }
コード例 #3
0
        public static PROB_CASE LookupCaseByIncident(decimal incidentID)
        {
            PROB_CASE theCase = null;

            using (PSsqmEntities entities = new PSsqmEntities())
            {
                try
                {
                    theCase = (from c in entities.PROB_CASE
                               join i in entities.PROB_OCCUR on c.PROBCASE_ID equals i.PROBCASE_ID into c_i
                               from i in c_i.DefaultIfEmpty()
                               where (i.INCIDENT_ID == incidentID)
                               select c).Single();
                }
                catch (Exception e)
                {
                    //   SQMLogger.LogException(e);
                }
            }

            return(theCase);
        }
コード例 #4
0
        public static PROB_CASE LookupCase(SQM.Website.PSsqmEntities ctx, decimal caseID)
        {
            PROB_CASE probCase = null;

            try
            {
                probCase = (from o in ctx.PROB_CASE.Include("PROB_OCCUR").Include("PROB_DEFINE").Include("PROB_CONTAIN").Include("PROB_CAUSE").Include("PROB_RISK").Include("PROB_VERIFY").Include("PROB_PREVENT").Include("PROB_CLOSE")
                            where (o.PROBCASE_ID == caseID)
                            select o).Single();

                if (probCase.PROB_CONTAIN != null)
                {
                    probCase.PROB_CONTAIN.PROB_CONTAIN_ACTION.Load();
                }
                if (probCase.PROB_CAUSE != null)
                {
                    probCase.PROB_CAUSE.PROB_CAUSE_STEP.Load();
                    if (probCase.PROB_CAUSE.PROB_CAUSE_STEP != null && probCase.PROB_CAUSE.PROB_CAUSE_STEP.Count > 0)
                    {
                        probCase.PROB_CAUSE_ACTION.Load();
                    }
                    if (probCase.PROB_VERIFY != null)
                    {
                        probCase.PROB_VERIFY.PROB_VERIFY_VERS.Load();
                    }
                }
                if (probCase.PROB_PREVENT != null)
                {
                    probCase.PROB_PREVENT_LIST.Load();
                }
            }
            catch (Exception e)
            {
                //  SQMLogger.LogException(e);
            }

            return(probCase);
        }
コード例 #5
0
        public void rptTaskList_OnItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
            {
                try
                {
                    TaskItem         item = (TaskItem)e.Item.DataItem;
                    Ucl_IncidentList ucl;
                    Ucl_EHSList      ecl;
                    LinkButton       lnk;
                    Label            lbl;
                    Image            img;
                    //TaskStatus status;
                    TaskRecordType taskType = (TaskRecordType)item.RecordType;
                    switch (taskType)
                    {
                    case TaskRecordType.QualityIssue:        // quality issue
                        lnk = (LinkButton)e.Item.FindControl("lnkTask");
                        if (!string.IsNullOrEmpty(item.Task.DESCRIPTION))
                        {
                            lnk.Text = item.Title + "<br>(" + item.Task.DESCRIPTION + ")";
                        }
                        else
                        {
                            lnk.Text = item.Title;
                        }

                        INCIDENT incident = (INCIDENT)item.Detail;
                        QI_OCCUR qiIssue  = (QI_OCCUR)item.Reference;
                        lnk.CommandArgument = item.RecordKey;
                        lbl          = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text     = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img          = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip  = item.Taskstatus.ToString();
                        QualityIncidentData issue = new QualityIncidentData();
                        issue.Incident         = incident;
                        issue.QIIssue          = qiIssue;
                        issue.Plant            = item.Plant;
                        issue.PlantResponsible = item.PlantResponsible;
                        issue.Person           = item.Person;
                        issue.Part             = item.Part;
                        List <QualityIncidentData> incidentList = new List <QualityIncidentData>();
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindQualityIncidentHeader(issue, true);
                        break;

                    case TaskRecordType.ProblemCase:        // 8D problem case
                        lnk      = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text = item.Title;
                        PROB_CASE probCase = (PROB_CASE)item.Detail;
                        lnk.CommandArgument = item.RecordKey;
                        lbl          = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text     = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img          = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip  = item.Taskstatus.ToString();
                        ProblemCase theCase = new ProblemCase();
                        theCase.ProbCase = probCase;
                        theCase.SetAliasID();
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindProblemCaseHeader(theCase, item);
                        break;

                    case TaskRecordType.ProfileInput:         // Profile inputs
                    case TaskRecordType.ProfileInputApproval: // approval
                    case TaskRecordType.ProfileInputFinalize: // finalize
                        lnk                 = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text            = item.Title;
                        lnk.CommandArgument = item.RecordKey;
                        lbl                 = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text            = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img                 = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl        = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip         = item.Taskstatus.ToString();
                        ecl                 = (Ucl_EHSList)e.Item.FindControl("uclEHSPeriod");
                        ecl.BindProfilePeriodHdr(item);
                        break;

                    case TaskRecordType.HealthSafetyIncident:        // Health & safety incidents
                        lnk                 = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text            = item.Title;
                        lnk.CommandArgument = item.RecordKey;
                        lbl                 = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text            = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img                 = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl        = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip         = item.Taskstatus.ToString();
                        INCIDENT EHSIncident = (INCIDENT)item.Detail;
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindIncidentListHeader(EHSIncident, item);
                        break;

                    case TaskRecordType.PreventativeAction:       // preventative action
                        lnk                 = (LinkButton)e.Item.FindControl("lnkTask");
                        lnk.Text            = item.Title;
                        lnk.CommandArgument = item.RecordKey;
                        lbl                 = (Label)e.Item.FindControl("lblDueDate");
                        lbl.Text            = SQMBasePage.FormatDate((DateTime)item.Task.DUE_DT, "d", false);
                        img                 = (Image)e.Item.FindControl("imgTaskStatus");
                        img.ImageUrl        = TaskMgr.TaskStatusImage(item.Taskstatus);
                        img.ToolTip         = item.Taskstatus.ToString();
                        INCIDENT EHSAction = (INCIDENT)item.Detail;
                        ucl = (Ucl_IncidentList)e.Item.FindControl("uclIssueList");
                        ucl.LinksDisabled = true;
                        ucl.BindIncidentListHeader(EHSAction, item);
                        break;

                    default:
                        break;
                    }

                    if (item.Taskstatus == TaskStatus.EscalationLevel1 || item.Taskstatus == TaskStatus.EscalationLevel2)
                    {
                        if (UserContext.RoleAccess() < AccessMode.Admin)
                        {
                            lnk         = (LinkButton)e.Item.FindControl("lnkTask");
                            lbl         = (Label)e.Item.FindControl("lblTask");
                            lbl.Text    = lnk.Text;
                            lnk.Visible = false;
                            lbl.Visible = true;
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
コード例 #6
0
        AlertData PopulateByProblemCaseId(decimal pcid)
        {
            AlertData d        = new AlertData();
            var       entities = new PSsqmEntities();

            PROB_CASE probCase = ProblemCase.LookupCase(entities, pcid);

            if (probCase != null)
            {
                List <INCIDENT> incidentList = ProblemCase.LookupProbIncidentList(entities, probCase);

                if (incidentList.Count > 0)
                {
                    var incident = incidentList[0];

                    string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)incident.DETECT_PLANT_ID);
                    d.incidentLocation = String.Format("Location: {0}", plantName);
                    d.incidentNumber   = String.Format("Incident #: {0}", incident.INCIDENT_ID);

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

                    d.incidentDateTime = incidentList[0].INCIDENT_DT.ToLongDateString();

                    var timeQuestion = questions.FirstOrDefault(q => q.QuestionId == 5);
                    if (timeQuestion != null)
                    {
                        string timeAnswer = (from a in entities.INCIDENT_ANSWER
                                             where
                                             a.INCIDENT_ID == incident.INCIDENT_ID &&
                                             a.INCIDENT_QUESTION_ID == 5
                                             select a.ANSWER_VALUE).FirstOrDefault();

                        if (!string.IsNullOrEmpty(timeAnswer))
                        {
                            d.incidentDateTime += " " + Convert.ToDateTime(timeAnswer).ToShortTimeString();
                        }
                    }

                    d.incidentType        = incidentType;
                    d.incidentDescription = probCase.DESC_LONG;


                    // Root Cause(s)

                    List <PROB_CAUSE_STEP> probCauses = (from i in entities.PROB_CAUSE_STEP
                                                         where
                                                         i.PROBCASE_ID == pcid &&
                                                         i.IS_ROOTCAUSE == true
                                                         select i).ToList();

                    if (probCauses.Count > 0)
                    {
                        d.incidentRootCause = (from rc in probCauses select rc.HOW_CONFIRMED).ToList();
                    }

                    // Containment

                    var containment = (from i in entities.PROB_CONTAIN
                                       where i.PROBCASE_ID == pcid
                                       select new
                    {
                        Recommendation = i.CONTAINMENT_DESC,
                        Action = i.INITIAL_ACTION,
                        Results = i.INITIAL_RESULTS
                    }).FirstOrDefault();

                    var actions = (from i in entities.PROB_CONTAIN_ACTION
                                   where i.PROBCASE_ID == pcid
                                   select i.ACTION_ITEM).ToList();

                    if (containment != null)
                    {
                        d.incidentContainment = new List <string> ();

                        //if (!string.IsNullOrEmpty(containment.Recommendation))
                        //{
                        //	d.incidentContainment.Add("RECOMMENDATION: " + containment.Recommendation);
                        //	d.incidentContainment.Add(" ");
                        //}

                        if (actions != null)
                        {
                            string strActions;
                            int    i = 1;
                            foreach (var actionItem in actions)
                            {
                                strActions = i++ + ") " + actionItem;
                                d.incidentContainment.Add(strActions);
                            }
                        }

                        if (!string.IsNullOrEmpty(containment.Results))
                        {
                            d.incidentContainment.Add(" ");
                            d.incidentContainment.Add("RESULTS: " + containment.Results);
                        }
                    }

                    // Corrective Actions

                    var correctiveActions = (from i in entities.PROB_CAUSE_ACTION
                                             where i.PROBCASE_ID == pcid
                                             select i.ACTION_DESC).ToList();

                    if (correctiveActions.Count() > 0)
                    {
                        d.incidentCorrectiveActions = new List <string>();
                        int i = 1;
                        foreach (var ca in correctiveActions)
                        {
                            d.incidentCorrectiveActions.Add(i++ + ") " + ca);
                        }
                    }

                    // Photos

                    var files = (from a in entities.ATTACHMENT
                                 where
                                 ((a.RECORD_ID == incident.INCIDENT_ID && a.RECORD_TYPE == 40) || (a.RECORD_ID == pcid && a.RECORD_TYPE == 21)) &&
                                 (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);
                        }
                    }
                }
            }

            return(d);
        }
コード例 #7
0
        void PopulateByProblemCaseId(decimal problemCaseId)
        {
            PROB_CASE probCase = ProblemCase.LookupCase(entities, problemCaseId);

            if (probCase != null)
            {
                List <INCIDENT> incidentList = ProblemCase.LookupProbIncidentList(entities, probCase);

                ltrDate.Text = probCase.CREATE_DT.ToString();
                if (incidentList.Count > 0)
                {
                    var incident = incidentList[0];

                    string plantName = EHSIncidentMgr.SelectPlantNameById((decimal)incident.DETECT_PLANT_ID);
                    lblPlantName.Text  = String.Format("Location: {0}", plantName);
                    lblIncidentId.Text = String.Format("Incident ID: {0}", incident.INCIDENT_ID);
                    //lblCaseId.Text = String.Format("Problem Case ID: {0}", probCase.PROBCASE_ID);

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

                    // Date/Time

                    ltrDate.Text = incidentList[0].INCIDENT_DT.ToLongDateString();

                    var timeQuestion = questions.FirstOrDefault(q => q.QuestionId == 5);
                    if (timeQuestion != null)
                    {
                        string timeAnswer = (from a in entities.INCIDENT_ANSWER
                                             where
                                             a.INCIDENT_ID == incident.INCIDENT_ID &&
                                             a.INCIDENT_QUESTION_ID == 5
                                             select a.ANSWER_VALUE).FirstOrDefault();

                        if (!string.IsNullOrEmpty(timeAnswer))
                        {
                            ltrTime.Text = Convert.ToDateTime(timeAnswer).ToShortTimeString();
                        }
                    }

                    // Incident Type

                    ltrIncidentType.Text = incidentType;

                    // Description

                    ltrDescription.Text = "<div style=\"width: 600px; word-wrap: break-word;\">" + Server.HtmlEncode(probCase.DESC_LONG) + "</div>";


                    // Root Cause(s)

                    List <PROB_CAUSE_STEP> probCauses = (from i in entities.PROB_CAUSE_STEP
                                                         where
                                                         i.PROBCASE_ID == problemCaseId &&
                                                         i.IS_ROOTCAUSE == true
                                                         select i).ToList();
                    if (probCauses.Count > 0)
                    {
                        ltrRootCause.Text = "<ul>";
                        foreach (var pc in probCauses)
                        {
                            ltrRootCause.Text += "<li>" + Server.HtmlEncode(pc.WHY_OCCUR) + "</li>";
                        }
                        ltrRootCause.Text += "</ul>";
                    }

                    // Containment

                    var containment = (from i in entities.PROB_CONTAIN
                                       where
                                       i.PROBCASE_ID == problemCaseId
                                       select new
                    {
                        Disposition = i.INITIAL_DISPOSITION,
                        Action = i.INITIAL_ACTION,
                        Results = i.INITIAL_RESULTS
                    }).FirstOrDefault();

                    if (containment != null)
                    {
                        ltrContainment.Text = "<ul><li>Initial Disposition: " + Server.HtmlEncode(containment.Disposition) + "</li>" +
                                              "<li>Action: " + Server.HtmlEncode(containment.Action) + "</li>" +
                                              "<li>Results: " + Server.HtmlEncode(containment.Results) + "</li>" +
                                              "</ul>";
                    }

                    // Corrective Actions

                    var correctiveActions = (from i in entities.PROB_CAUSE_ACTION
                                             where
                                             i.PROBCASE_ID == problemCaseId
                                             select i.ACTION_DESC).ToList();
                    if (correctiveActions.Count > 0)
                    {
                        ltrCorrectiveActions.Text = "<ul>";
                        foreach (var caDesc in correctiveActions)
                        {
                            ltrCorrectiveActions.Text += "<li>" + Server.HtmlEncode(caDesc) + "</li>";
                        }
                        ltrCorrectiveActions.Text += "</ul>";
                    }

                    // Photos

                    BindAttachmentsProbCase(incident.INCIDENT_ID, probCase.PROBCASE_ID);
                }
                else
                {
                    pnlContent.Visible = false;
                    pnlError.Visible   = true;
                }
            }
        }