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 void OverloadOfAddAddsItemToCollection() { var emailAddresses = new EmailAddresses(); const string addressText = "*****@*****.**"; emailAddresses.Add(addressText, ContactType.Business); emailAddresses.Count.Should().Be(1); emailAddresses[0].ContactType.Should().Be(ContactType.Business); emailAddresses[0].EmailAddressText.Should().Be(addressText); }
public override ExecutionResult Run(IStepExecutionContext context) { FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id); finding.FinalComment = this.FinalComment; int newStateId = _findingStateRepository.GetOneByCode("RCZ"); 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); //} //WE NEED GET THE RESPONSIBLESGCUSERID var RESPONSIBLESGCUSERID = finding.ResponsibleUserID; _findingStatesHistoryRepository.Add(finding.FindingID, finding.FindingStateID, RESPONSIBLESGCUSERID); finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false); //usuario creador de hallazgo EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.EmitterUserID)); this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "reject"); this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "reject"); _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()); }