Пример #1
0
        public static List <PROB_CASE> SelectUserCaseList(List <PROB_CASE> problemCaseList)
        {
            var userCaseList = new List <PROB_CASE>();

            using (PSsqmEntities entities = new PSsqmEntities())
            {
                try
                {
                    foreach (PROB_CASE probCase in problemCaseList)
                    {
                        List <INCIDENT> incidentList = ProblemCase.LookupProbIncidentList(entities, probCase);
                        foreach (INCIDENT incident in incidentList)
                        {
                            if (SessionManager.PlantAccess((decimal)incident.DETECT_PLANT_ID) || (incident.RESP_PLANT_ID.HasValue && SessionManager.PlantAccess((decimal)incident.RESP_PLANT_ID)))
                            {
                                userCaseList.Add(probCase);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    //  SQMLogger.LogException(ex);
                }
            }

            return(userCaseList);
        }
Пример #2
0
        public static List <ProblemCase> QualifyCaseList(List <PROB_CASE> problemCaseList, decimal[] plantIDS)
        {
            var   qualCaseList = new List <ProblemCase>();
            PLANT plant        = null;

            using (PSsqmEntities entities = new PSsqmEntities())
            {
                try
                {
                    foreach (PROB_CASE probCase in problemCaseList)
                    {
                        INCIDENT incident = ProblemCase.LookupProbIncidentList(entities, probCase).FirstOrDefault();
                        if (incident != null && ((incident.DETECT_PLANT_ID.HasValue && plantIDS.Contains((decimal)incident.DETECT_PLANT_ID)) || (incident.RESP_PLANT_ID.HasValue && plantIDS.Contains((decimal)incident.RESP_PLANT_ID))))
                        {
                            if (plant == null || plant.PLANT_ID != incident.DETECT_PLANT_ID)
                            {
                                plant = SQMModelMgr.LookupPlant((decimal)incident.DETECT_PLANT_ID);
                            }
                            ProblemCase problemCase = new ProblemCase();
                            problemCase.IncidentList = new List <INCIDENT>();
                            problemCase.ProbCase     = probCase;
                            problemCase.IncidentList.Add(incident);
                            problemCase.Plant = plant;
                            if (incident.INCIDENT_TYPE == "QI")
                            {
                                ;  // todo get qi_occur and part number
                            }
                            qualCaseList.Add(problemCase);
                        }
                    }
                }
                catch (Exception ex)
                {
                    //  SQMLogger.LogException(ex);
                }
            }

            return(qualCaseList);
        }
Пример #3
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;
                }
            }
        }