public override ExecutionResult Run(IStepExecutionContext context)
        {
            var correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(context.Workflow.Id);

            correctiveAction.CorrectiveActionStateID     = _correctiveActionStateRepository.GetByCode(STATE_PLANNED_CODE);
            correctiveAction.MaxDateEfficiencyEvaluation = MaxDateEfficiencyEvaluation;
            correctiveAction.MaxDateImplementation       = MaxDateImplementation;
            correctiveAction.DeadlineDateEvaluation      = MaxDateEfficiencyEvaluation.AddDays(_parametrizationCorrectiveActionRepository.GetByCode(STATE_PARAMETRIZATION_CORRECTIVEACTION_CODE_EVALUATION));
            correctiveAction.Impact = Impact;

            _correctiveActionRepository.Update(correctiveAction);
            _correctiveActionStateHistoryRepository.Add(correctiveAction.CorrectiveActionID, correctiveAction.CorrectiveActionStateID, EmitterUserID);

            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            EmailAddresses.Add(_userWorkflowRepository.GetUserEmailByID(correctiveAction.ResponsibleUserID));
            EmailAddresses.AddRange(_taskRepository.GetAllResponsibleUserEmailForCorrectiveAction(correctiveAction.CorrectiveActionID));
            EmailAddresses.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID)));

            correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(correctiveAction.WorkflowId);
            var emailType = "generate";

            this.EmailSubject = EmailStrings.GetSubjectCorrectiveAction(emailType);
            this.EmailMessage = EmailStrings.GetMessageCorrectiveAction(correctiveAction, _emailSettings.Url, emailType);

            return(ExecutionResult.Next());
        }
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            var correctiveAction = new CorrectiveActionWorkflowData();

            correctiveAction.WorkflowId                = context.Workflow.Id;
            correctiveAction.CreationDate              = CreationDate;
            correctiveAction.Description               = Description;
            correctiveAction.FindingID                 = FindingID;
            correctiveAction.EmitterUserID             = EmitterUserID;
            correctiveAction.PlantLocationID           = PlantLocationID;
            correctiveAction.SectorLocationID          = SectorLocationID;
            correctiveAction.PlantTreatmentID          = PlantTreatmentID;
            correctiveAction.SectorTreatmentID         = SectorTreatmentID;
            correctiveAction.ResponsibleUserID         = ResponsibleUserID;
            correctiveAction.ReviewerUserID            = ReviewerUserID;
            correctiveAction.DeadlineDatePlanification = CreationDate.AddDays(_parametrizationCorrectiveActionRepository.GetByCode(STATE_PARAMETRIZATION_CORRECTIVEACTION_CODE_PLANIFICATION));

            correctiveAction.CorrectiveActionStateID = _correctiveActionStateRepository.GetByCode(STATE_OPEN_CODE);
            CorrectiveActionWorkflowData correctiveActionWorkFlowData = _correctiveActionRepository.Add(correctiveAction);

            _correctiveActionStateHistoryRepository.Add(correctiveActionWorkFlowData.CorrectiveActionID, correctiveActionWorkFlowData.CorrectiveActionStateID, EmitterUserID);

            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            EmailAddresses.Add(_userWorkflowRepository.GetUserEmailByID(ResponsibleUserID));
            EmailAddresses.Add(_userWorkflowRepository.GetUserEmailByID(ReviewerUserID));
            EmailAddresses.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID)));

            correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(correctiveAction.WorkflowId);
            var emailType = "new";

            this.EmailSubject = EmailStrings.GetSubjectCorrectiveAction(emailType);
            this.EmailMessage = EmailStrings.GetMessageCorrectiveAction(correctiveAction, _emailSettings.Url, emailType);

            return(ExecutionResult.Next());
        }
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            var correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(context.Workflow.Id);

            correctiveAction.CorrectiveActionStateID      = _correctiveActionStateRepository.GetByCode(STATE_CLOSED_CODE);
            correctiveAction.EvaluationCommentary         = EvaluationCommentary;
            correctiveAction.dateTimeEfficiencyEvaluation = DateTime.Now;
            correctiveAction.isEffective = isEffective;

            _correctiveActionEvidenceRepository.Update(correctiveAction.CorrectiveActionID, EvidencesUrl, new List <string>());

            _correctiveActionRepository.Update(correctiveAction);
            _correctiveActionStateHistoryRepository.Add(correctiveAction.CorrectiveActionID, correctiveAction.CorrectiveActionStateID, EmitterUserID);

            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            EmailAddresses.Add(_userWorkflowRepository.GetUserEmailByID(correctiveAction.ResponsibleUserID));
            EmailAddresses.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID)));

            correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(correctiveAction.WorkflowId);
            var emailType = "reviewed";

            this.EmailSubject = EmailStrings.GetSubjectCorrectiveAction(emailType);
            this.EmailMessage = EmailStrings.GetMessageCorrectiveAction(correctiveAction, _emailSettings.Url, emailType);

            if (!isEffective)
            {
                //EmailMessage = "Se ha rechazado la evaluación de la accion correctiva. " + EvaluationCommentary;

                correctiveAction.Flow        = "CorrectiveAction";
                correctiveAction.FlowVersion = 1;
                _workflowCore.StartFlow(correctiveAction);
            }

            return(ExecutionResult.Next());
        }
示例#4
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            var correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(context.Workflow.Id);

            correctiveAction.CorrectiveActionStateID     = _correctiveActionStateRepository.GetByCode(STATE_PLANNED_CODE);
            correctiveAction.EffectiveDateImplementation = DateTime.Now;
            _correctiveActionRepository.Update(correctiveAction);
            _correctiveActionStateHistoryRepository.Add(correctiveAction.CorrectiveActionID, correctiveAction.CorrectiveActionStateID, EmitterUserID);

            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            EmailAddresses.Add(_userWorkflowRepository.GetUserEmailByID(correctiveAction.ResponsibleUserID));
            EmailAddresses.Add(_userWorkflowRepository.GetUserEmailByID(correctiveAction.ReviewerUserID));
            EmailAddresses.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID)));

            correctiveAction = _correctiveActionRepository.GetOneByWorkflowId(correctiveAction.WorkflowId);
            var emailType = "finishedtasks";

            this.EmailSubject = EmailStrings.GetSubjectCorrectiveAction(emailType);
            this.EmailMessage = EmailStrings.GetMessageCorrectiveAction(correctiveAction, _emailSettings.Url, emailType);

            return(ExecutionResult.Next());
        }