Example #1
0
        public static ProblemCase UpdateProblemCase(ProblemCase theCase)
        {
            ProblemCase retCase = null;

            try
            {
                theCase.ProbCase = (PROB_CASE)SQMModelMgr.SetObjectTimestamp((object)theCase.ProbCase, SessionManager.UserContext.UserName(), CaseState(theCase));
                if (theCase.ProbCase.EntityState == System.Data.EntityState.Added || theCase.ProbCase.EntityState == System.Data.EntityState.Detached)
                {
                    theCase.Entities.AddToPROB_CASE(theCase.ProbCase);
                }
                if (!string.IsNullOrEmpty(theCase.StepComplete))
                {
                    theCase.TeamTask.SetTaskComplete(theCase.StepComplete, "C", 0, true);
                    if (theCase.StepComplete == "8" && theCase.ProbCase.CLOSE_DT.HasValue == false)
                    {
                        DateTime closeDate = DateTime.UtcNow;
                        theCase.ProbCase.PROB_CLOSE.NOTIFY_DT = theCase.ProbCase.CLOSE_DT = closeDate;
                        theCase.ProbCase.PROB_CLOSE.STATUS    = "C";
                        foreach (PROB_OCCUR occur in theCase.ProbCase.PROB_OCCUR)
                        {
                            theCase.Entities.ExecuteStoreCommand("UPDATE INCIDENT SET CLOSE_DATE_8D = {0} WHERE INCIDENT_ID = " + occur.INCIDENT_ID, closeDate);
                        }
                    }
                }
                int progress;

                if (theCase.ProbCase.PROB_CONTAIN != null)
                {
                    for (int n = 0; n < theCase.ProbCase.PROB_CONTAIN.PROB_CONTAIN_ACTION.Count; n++)
                    {
                        PROB_CONTAIN_ACTION contain = theCase.ProbCase.PROB_CONTAIN.PROB_CONTAIN_ACTION.ElementAt(n);
                        if (contain.STATUS == "D")
                        {
                            theCase.Entities.DeleteObject(contain);
                        }
                    }
                }
                if (theCase.ProbCase.PROB_CAUSE_ACTION != null)
                {
                    for (int n = 0; n < theCase.ProbCase.PROB_CAUSE_ACTION.Count; n++)
                    {
                        PROB_CAUSE_ACTION action = theCase.ProbCase.PROB_CAUSE_ACTION.ElementAt(n);
                        if (action.STATUS == "D")
                        {
                            theCase.Entities.DeleteObject(action);
                        }
                    }
                }
                if (theCase.ProbCase.PROB_PREVENT != null)
                {
                    for (int n = 0; n < theCase.ProbCase.PROB_PREVENT_LIST.Count; n++)
                    {
                        PROB_PREVENT_LIST prevent = theCase.ProbCase.PROB_PREVENT_LIST.ElementAt(n);
                        if (prevent.CONFIRM_STATUS == "D")
                        {
                            theCase.Entities.DeleteObject(prevent);
                        }
                    }
                }

                theCase.ProbCase.PROGRESS = theCase.CheckCaseStatus(); // theCase.CheckCaseNextStep();

                theCase.Entities.SaveChanges();

                if (theCase.IsNew)
                {
                    if (SessionManager.DocumentContext == null)
                    {
                        SessionManager.DocumentContext = new SQM.Shared.DocumentScope().CreateNew(SessionManager.UserContext.WorkingLocation.Company.COMPANY_ID, "BLI", 0, "", SessionManager.UserContext.WorkingLocation.Plant.PLANT_ID, "", 0);
                    }
                    SQM.Website.Classes.SQMDocumentMgr.UpdateAttachmentRecordID(theCase.Entities, 21, SessionManager.DocumentContext.SessionID, theCase.ProbCase.PROBCASE_ID);
                }

                theCase.TeamTask.UpdateTaskList(theCase.ProbCase.PROBCASE_ID);

                theCase.UpdateStatus = CaseUpdateStatus.Success;
                retCase              = theCase;
                retCase.IsNew        = false;
                theCase.StepComplete = "";
            }
            catch (Exception e)
            {
                theCase.UpdateStatus = CaseUpdateStatus.SaveError;
                retCase = theCase;
                // SQMLogger.LogException(e);
            }
            return(retCase);
        }
Example #2
0
        public SQM.Shared.CorrectiveAction CreateCorrectiveAction(PROB_CAUSE_STEP cause, PROB_CAUSE_ACTION existingAction)
        {
            SQM.Shared.CorrectiveAction action = CreateCorrectiveAction(cause);
            action.ActionNo   = existingAction.ACTION_NO;
            action.ActionCode = existingAction.ACTION_CD;
            action.Action     = existingAction.ACTION_DESC;
            action.ActionCode = existingAction.ACTION_CD;
            if (existingAction.EFF_DT.HasValue)
            {
                action.EffDate = Convert.ToDateTime(existingAction.EFF_DT);
            }
            action.Responsible1 = existingAction.RESPONSIBLE1;
            if (existingAction.RESPONSIBLE1_PERSON.HasValue)
            {
                action.Responsible1ID = (decimal)existingAction.RESPONSIBLE1_PERSON;
            }
            action.Responsible2       = existingAction.RESPONSIBLE2;
            action.VerifyStatus       = existingAction.VERIFY_STATUS;
            action.VerifyObservations = existingAction.VERIFY_OBSERVATIONS;

            return(action);
        }