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) { if (context.PersistenceData == null && FindingID == 0) { //NEW FINDING FindingWorkflowData finding = new FindingWorkflowData(Description, PlantLocationId, SectorLocationId, PlantTreatmentId, SectorTreatmentId, FindingTypeId, EmitterUserId, ResponsibleUserId); finding.WorkflowId = context.Workflow.Id; finding.FindingStateID = _findingStateRepository.GetOneByCode("ESP"); //Go to DB and save the Finding. FindingWorkflowData createdFinding = _findingRepository.Add(finding); //Add State to history _findingStatesHistoryRepository.Add(createdFinding.FindingID, createdFinding.FindingStateID, createdFinding.EmitterUserID); //Add Evidence foreach (var evidence in NewEvidencesUrls) { _findingEvidenceRepository.Add(createdFinding.FindingID, evidence); } //Get the email of the Responsible User //EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(ResponsibleUserId)); //GetType the email of the finding responsible EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleFinding()); createdFinding = _findingRepository.GetOneByWorkflowId(createdFinding.WorkflowId); this.EmailSubject = EmailStrings.GetSubjectFinding(createdFinding.FindingTypeName, "new"); this.EmailMessage = EmailStrings.GetMessageFinding(createdFinding, _emailSettings.Url, "new"); _hub.Clients.All.SendAsync("transferfindingsdata", createdFinding); //_hub.Clients.All.SendCoreAsync("transferfindingsdata", createdFinding) return(ExecutionResult.Next()); } else { _findingRepository.setWorkflowID(FindingID, context.Workflow.Id); 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()); }