public override ExecutionResult Run(IStepExecutionContext context) { FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id); finding.ExpirationDate = this.ExpirationDate; finding.ContainmentAction = this.ContainmentAction; finding.CauseAnalysis = this.CauseAnalysis; finding.Comment = this.Comment; int newStateId = _findingStateRepository.GetOneByCode("ENC"); //Delete Evidences foreach (var deleteEvidence in DeleteEvidencesUrls) { _findingEvidenceRepository.Delete(finding.FindingID, deleteEvidence); } //Add Evidences foreach (var newEvidence in NewEvidencesUrls) { _findingEvidenceRepository.Add(finding.FindingID, newEvidence); } //Add to history if the first time edit if (finding.FindingStateID != newStateId) { _findingStatesHistoryRepository.Add(finding.FindingID, newStateId, finding.ResponsibleUserID); } finding.FindingStateID = newStateId; _findingRepository.Update(finding); finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false); _hub.Clients.All.SendAsync("transferfindingsdata", finding); return(ExecutionResult.Next()); }
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()); }