Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
        public void Update(CorrectiveActionWorkflowData correctiveAction)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                //var correctiveActionToUpdate = _ctx.CorrectiveActions.FirstOrDefault(x => x.CorrectiveActionID == correctiveAction.CorrectiveActionID);
                //correctiveActionToUpdate.CorrectiveActionStateID = correctiveAction.CorrectiveActionStateID;
                //correctiveActionToUpdate.MaxDateEfficiencyEvaluation = correctiveAction.MaxDateEfficiencyEvaluation;
                //correctiveActionToUpdate.MaxDateImplementation = correctiveAction.MaxDateImplementation;
                //correctiveActionToUpdate.DeadlineDateEvaluation = correctiveAction.DeadlineDateEvaluation;
                //correctiveActionToUpdate.DeadlineDatePlanification = correctiveAction.DeadlineDatePlanification;
                //correctiveActionToUpdate.Impact = correctiveAction.Impact;
                //_ctx.CorrectiveActions.Update(correctiveActionToUpdate);
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;

                //var correctiveActionToUpdate = _ctx.CorrectiveActions.FirstOrDefault(x => x.CorrectiveActionID == correctiveAction.CorrectiveActionID);
                //correctiveActionToUpdate.CorrectiveActionStateID = correctiveAction.CorrectiveActionStateID;
                //correctiveActionToUpdate.MaxDateEfficiencyEvaluation = correctiveAction.MaxDateEfficiencyEvaluation;
                //correctiveActionToUpdate.MaxDateImplementation = correctiveAction.MaxDateImplementation;
                //correctiveActionToUpdate.Impact = correctiveAction.Impact;
                _ctx.CorrectiveActions.Update(_mapper.Map <CorrectiveActionWorkflowData, CorrectiveActions>(correctiveAction));
                _ctx.SaveChanges();
            }
        }
        public async Task Execute(Domain.CorrectiveAction.CorrectiveAction correctiveAction, IFormFile[] Evidences)
        {
            try
            {
                if (Evidences != null)
                {
                    await InsertFiles(Evidences, correctiveAction);
                }

                var workflowId = _correctiveActionRepository.GetWorkflowId(correctiveAction.CorrectiveActionID);

                var correctiveActionWorkflow = new CorrectiveActionWorkflowData();

                correctiveActionWorkflow.WorkflowId           = workflowId;
                correctiveActionWorkflow.isEffective          = correctiveAction.isEffective;
                correctiveActionWorkflow.EvidencesUrl         = correctiveAction.NewEvidencesUrls;
                correctiveActionWorkflow.EvaluationCommentary = correctiveAction.EvaluationCommentary;

                await _workflowCore.ExecuteEvent("ReviewedCorrectiveAction", workflowId, correctiveActionWorkflow);
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Exemplo n.º 4
0
        public async Task Execute(CorrectiveActionWorkflowData correctiveAction)
        {
            correctiveAction.Flow          = "CorrectiveAction";
            correctiveAction.FlowVersion   = 1;
            correctiveAction.EmitterUserID = _httpContextAccessor.HttpContext.User.FindFirst("id").Value;
            var flowId = await _workflowCore.StartFlow(correctiveAction);

            //var newCorrectiveAction = _correctiveActionRepository.Add(correctiveAction);
            //return _mapper.Map<Domain.CorrectiveAction.CorrectiveAction, CorrectiveActionOutput>(newCorrectiveAction);
        }
Exemplo n.º 5
0
        public CorrectiveActionWorkflowData Add(CorrectiveActionWorkflowData correctiveAction)
        {
            using (var scope = _serviceProvider.CreateScope())
            {
                var _mapper = scope.ServiceProvider.GetService(typeof(IMapper)) as IMapper;
                var _ctx    = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext;

                CorrectiveActions mappedCorrectiveAction = _mapper.Map <CorrectiveActionWorkflowData, CorrectiveActions>(correctiveAction);

                _ctx.CorrectiveActions.Add(mappedCorrectiveAction);
                _ctx.SaveChanges();

                return(_mapper.Map <CorrectiveActions, CorrectiveActionWorkflowData>(mappedCorrectiveAction));
            }
        }
Exemplo n.º 6
0
        public override ExecutionResult Run(IStepExecutionContext context)
        {
            FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id);

            finding.Description       = this.Description;
            finding.PlantLocationID   = this.PlantLocationID;
            finding.SectorLocationID  = this.SectorLocationID;
            finding.PlantTreatmentID  = this.PlantTreatmentID;
            finding.SectorTreatmentID = this.SectorTreatmentID;
            finding.ResponsibleUserID = this.ResponsibleUserID;
            finding.FindingTypeID     = this.FindingTypeID;
            finding.ExpirationDate    = this.ExpirationDate;



            if (State == "ApproveWithPDCA")
            {
                int newStateId = _findingStateRepository.GetOneByCode("APD");
                finding.FindingStateID = newStateId;
                _findingRepository.Update(finding);
                var correctiveAction = new CorrectiveActionWorkflowData();
                correctiveAction.Description       = finding.Description;
                correctiveAction.PlantLocationID   = finding.PlantLocationID;
                correctiveAction.SectorLocationID  = finding.SectorLocationID;
                correctiveAction.PlantTreatmentID  = finding.PlantTreatmentID;
                correctiveAction.SectorTreatmentID = finding.SectorTreatmentID;
                correctiveAction.ResponsibleUserID = finding.ResponsibleUserID;
                correctiveAction.FindingID         = finding.FindingID;
                correctiveAction.EmitterUserID     = EmitterUserID;
                correctiveAction.ReviewerUserID    = ReviewerUserID;
                correctiveAction.CreationDate      = DateTime.Today;
                correctiveAction.Flow        = "CorrectiveAction";
                correctiveAction.FlowVersion = 1;
                _workflowCore.StartFlow(correctiveAction);
            }
            else if (State == "Approve")
            {
                int newStateId = _findingStateRepository.GetOneByCode("APR");
                finding.FindingStateID = newStateId;
                _findingRepository.Update(finding);
            }

            //Delete Evidences
            foreach (var deleteEvidence in DeleteEvidencesUrls)
            {
                _findingEvidenceRepository.Delete(finding.FindingID, deleteEvidence);
            }

            //Add Evidences
            foreach (var newEvidence in NewEvidencesUrls)
            {
                _findingEvidenceRepository.Add(finding.FindingID, newEvidence);
            }

            //Left obtain Responsible SGC ID
            string IDRESPONSIBLESGC = finding.ResponsibleUserID;

            _findingStatesHistoryRepository.Add(finding.FindingID, finding.FindingStateID, IDRESPONSIBLESGC);

            finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false);
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailSectorBoss());
            EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailColaboratorSB());
            var email = _findingRepository.GetResponsibleUserEmail(finding.ResponsibleUserID);

            EmailAddresses.Add(email);

            this.EmailSubject = Data.EmailStrings.GetSubjectFinding(finding.FindingTypeName, "approve");
            this.EmailMessage = Data.EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "approve");

            _hub.Clients.All.SendAsync("transferfindingsdata", finding);
            //Get Responsible User Email.
            return(ExecutionResult.Next());
        }
Exemplo n.º 7
0
 public async Task Execute(CorrectiveActionWorkflowData correctiveAction)
 {
     correctiveAction.EmitterUserID = _httpContextAccessor.HttpContext.User.FindFirst("id").Value;
     await _workflowCore.ExecuteEvent("FinishedAnalysis", correctiveAction.WorkflowId, correctiveAction);
 }