public override ExecutionResult Run(IStepExecutionContext context) { AuditWorkflowData auditData = _auditRepository.GetOneByWorkflowId(context.Workflow.Id); auditData.Recomendations = Recomendations; auditData.Conclusion = Conclusion; auditData.AuditStateID = _auditStateRepository.GetOneByCode("IPA"); List <string> sectorPlantReferrents = _sectorPlantRepository.GetSectorPlantReferredEmail(auditData.PlantID, auditData.SectorID); EmailAddresses.AddRange(sectorPlantReferrents); _auditRepository.EmmitReport(auditData); //If auditor is internal, send email if (!string.IsNullOrEmpty(auditData.AuditorID)) { EmailAddresses.Add(_auditRepository.GetAuditorEmail(auditData.AuditorID)); } var emailType = "emmitreport"; this.EmailSubject = EmailStrings.GetSubjectAudit(auditData.AuditTypeName, emailType); this.EmailMessage = EmailStrings.GetMessageAudit(auditData, _emailSettings.Url, emailType); //Add responsible of SGC List <string> responsibleSGC = _userWorkflowRepository.GetUsersEmailResponsibleSGC(); EmailAddresses.AddRange(responsibleSGC); return(ExecutionResult.Next()); }
public override ExecutionResult Run(IStepExecutionContext context) { AuditWorkflowData auditData = _auditRepository.GetOneByWorkflowId(context.Workflow.Id); auditData.AuditTeam = AuditTeam; auditData.DocumentsAnalysisDate = DocumentsAnalysisDate; auditData.DocumentAnalysisDuration = DocumentAnalysisDuration; auditData.ReportEmittedDate = ReportEmittedDate; auditData.CloseMeetingDate = CloseMeetingDate; auditData.CloseMeetingDuration = CloseMeetingDuration; auditData.CloseDate = CloseDate; auditData.AuditStateID = _auditStateRepository.GetOneByCode("PPA"); _auditRepository.PlanAudit(auditData, AuditStandardAspects); //List<string> sectorPlantReferrents = _sectorPlantRepository.GetSectorPlantReferredEmail(auditData.PlantID, auditData.SectorID); //EmailAddresses.AddRange(sectorPlantReferrents); ////If auditor is internal, send email //if (!string.IsNullOrEmpty(auditData.AuditorID)) //{ // EmailAddresses.Add(_auditRepository.GetAuditorEmail(auditData.AuditorID)); //} ////Left responsible of SGC EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC()); //auditData = _auditRepository.GetOneByWorkflowId(auditData.WorkflowId); var emailType = "plan"; this.EmailSubject = EmailStrings.GetSubjectAudit(auditData.AuditTypeName, emailType); this.EmailMessage = EmailStrings.GetMessageAudit(auditData, _emailSettings.Url, emailType); return(ExecutionResult.Next()); }
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) { AuditWorkflowData auditWorkflowData = _auditRepository.GetOneByWorkflowId(context.Workflow.Id); auditWorkflowData.AuditStateID = _auditStateRepository.GetOneByCode("PRZ"); auditWorkflowData.ApprovePlanComments = ApprovePlanComments; _auditRepository.ApproveOrRejectAuditPlan(auditWorkflowData); List <string> sectorPlantReferrents = _sectorPlantRepository.GetSectorPlantReferredEmail(auditWorkflowData.PlantID, auditWorkflowData.SectorID); EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC()); ////If auditor is internal, send email if (!string.IsNullOrEmpty(auditWorkflowData.AuditorID)) { EmailAddresses.Add(_auditRepository.GetAuditorEmail(auditWorkflowData.AuditorID)); } //Left responsible of SGC auditWorkflowData = _auditRepository.GetOneByWorkflowId(auditWorkflowData.WorkflowId); var emailType = "rejectplan"; this.EmailSubject = EmailStrings.GetSubjectAudit(auditWorkflowData.AuditTypeName, emailType); this.EmailMessage = EmailStrings.GetMessageAudit(auditWorkflowData, _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()); }
public override ExecutionResult Run(IStepExecutionContext context) { int newFindingStateId; var finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id); if (finding.FindingStateID == _findingStateRepository.GetOneByCode("PDR")) { //ReassignWithApprovalStep newFindingStateId = _findingStatesHistoryRepository.GetPreviousState(this.FindingID, finding.FindingStateID); } else { //ReassignWithoutApprovalStep newFindingStateId = finding.FindingStateID; } //last responsable user mail EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(this.ResponsibleUserId)); finding.ResponsibleUserID = this.ReassignedUserID; finding.FindingStateID = newFindingStateId; finding.PlantTreatmentID = this.PlantTreatmentID; finding.SectorTreatmentID = this.SectorTreatmentID; _findingRepository.Update(finding); //Left get SGC Responsible user id string SGC_RESPONSIBLE_USER_ID = this.ResponsibleUserId; var result = _reassignmentsFindingHistoryRepository.Add(this.FindingID, this.ReassignedUserID, SGC_RESPONSIBLE_USER_ID, "Approve"); _findingStatesHistoryRepository.Add(this.FindingID, newFindingStateId, SGC_RESPONSIBLE_USER_ID); string oldResponsibleUser = finding.ResponsibleUserFullName; finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false); var email = _findingRepository.GetResponsibleUserEmail(this.ReassignedUserID); EmailAddresses.Add(email); EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleFinding()); EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailColaboratorSB()); EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailSectorBoss()); this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "reassign"); this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "reassign", oldResponsibleUser); _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) { AuditWorkflowData auditData = _auditRepository.GetOneByWorkflowId(context.Workflow.Id); auditData.ApproveReportComments = ApproveReportComments; auditData.AuditStateID = _auditStateRepository.GetOneByCode("IAP"); List <string> sectorPlantReferrents = _sectorPlantRepository.GetSectorPlantReferredEmail(auditData.PlantID, auditData.SectorID); EmailAddresses.AddRange(sectorPlantReferrents); _auditRepository.ApproveOrRejectReportAudit(auditData); //If auditor is internal, send email if (!string.IsNullOrEmpty(auditData.AuditorID)) { EmailAddresses.Add(_auditRepository.GetAuditorEmail(auditData.AuditorID)); } //Add responsible of SGC List <string> responsibleSGC = _userWorkflowRepository.GetUsersEmailResponsibleSGC(); EmailAddresses.AddRange(responsibleSGC); auditData = _auditRepository.GetOneByWorkflowId(auditData.WorkflowId); var emailType = "close"; this.EmailSubject = EmailStrings.GetSubjectAudit(auditData.AuditTypeName, emailType); this.EmailMessage = EmailStrings.GetMessageAudit(auditData, _emailSettings.Url, emailType); var findingsWorkFlow = _findingRepository.GetAllByAuditID(auditData.AuditID); foreach (var finding in findingsWorkFlow) { finding.Flow = "Finding"; finding.FlowVersion = 1; _workflowCore.StartFlow(finding); } // _auditStandardAspectRepository. return(ExecutionResult.Next()); }
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()); }
public override ExecutionResult Run(IStepExecutionContext context) { FindingWorkflowData finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id); finding.FinalComment = this.FinalComment; if (State == "Finalizado OK") { finding.FindingStateID = _findingStateRepository.GetOneByCode("FOK"); } else if (State == "Finalizado No OK") { finding.FindingStateID = _findingStateRepository.GetOneByCode("FNK"); } else if (State == "Cerrado") { finding.FindingStateID = _findingStateRepository.GetOneByCode("CER"); } _findingRepository.Update(finding); _findingStatesHistoryRepository.Add(finding.FindingID, finding.FindingStateID, finding.ResponsibleUserID); finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false); // responsible EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.ResponsibleUserID)); //User creator EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.EmitterUserID)); // SGC EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailResponsibleSGC()); // Boss, colaborator EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailSectorBoss()); EmailAddresses.AddRange(_userWorkflowRepository.GetUsersEmailColaboratorSB()); this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "close"); this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "close"); _hub.Clients.All.SendAsync("transferfindingsdata", finding); return(ExecutionResult.Next()); }
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) { var finding = _findingRepository.GetOneByWorkflowId(context.Workflow.Id); var newState = _findingStatesHistoryRepository.GetPreviousState(this.FindingID, finding.FindingStateID); finding.RejectComment = this.RejectComment; finding.FindingStateID = newState; _findingRepository.Update(finding); _reassignmentsFindingHistoryRepository.Add(this.FindingID, this.ReassignedUserID, this.ResponsibleUserId, "Rejected", this.RejectComment); var RESPONSIBLE_SGC_USER_ID = this.ResponsibleUserId; _findingStatesHistoryRepository.Add(this.FindingID, newState, RESPONSIBLE_SGC_USER_ID); EmailAddresses.Add(_findingRepository.GetResponsibleUserEmail(finding.ResponsibleUserID)); this.EmailSubject = EmailStrings.GetSubjectFinding(finding.FindingTypeName, "rejectreassignment"); this.EmailMessage = EmailStrings.GetMessageFinding(finding, _emailSettings.Url, "rejectreassignment"); //Left email of SGC finding = _findingRepository.UpdateIsInProcessWorkflow(finding.FindingID, false); _hub.Clients.All.SendAsync("transferfindingsdata", finding); return(ExecutionResult.Next()); }
public override ExecutionResult Run(IStepExecutionContext context) { AuditWorkflowData auditWorkflowData = new AuditWorkflowData(); auditWorkflowData.PlantID = PlantID; auditWorkflowData.SectorID = SectorID; auditWorkflowData.AuditorID = AuditorID; auditWorkflowData.ExternalAuditor = ExternalAuditor; auditWorkflowData.CreationDate = CreationDate; auditWorkflowData.AuditInitDate = AuditInitDate; auditWorkflowData.AuditTypeID = AuditTypeID; auditWorkflowData.AuditStandard = AuditStandard; auditWorkflowData.AuditStateID = _auditStateRepository.GetOneByCode("PRO"); auditWorkflowData.WorkflowId = context.Workflow.Id; _auditRepository.Add(auditWorkflowData); //Responsible of sector-plant List <string> sectorPlantReferrents = _sectorPlantRepository.GetSectorPlantReferredEmail(PlantID, SectorID); EmailAddresses.AddRange(sectorPlantReferrents); //If auditor is internal, send email if (!string.IsNullOrEmpty(AuditorID)) { EmailAddresses.Add(_auditRepository.GetAuditorEmail(AuditorID)); } auditWorkflowData = _auditRepository.GetOneByWorkflowId(auditWorkflowData.WorkflowId); var emailType = "schedule"; this.EmailSubject = EmailStrings.GetSubjectAudit(auditWorkflowData.AuditTypeName, emailType); this.EmailMessage = EmailStrings.GetMessageAudit(auditWorkflowData, _emailSettings.Url, emailType); return(ExecutionResult.Next()); }