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) { 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 bool Execute(Domain.CorrectiveAction.CorrectiveAction correctiveAction) { var emailAddress = new List <string>(); var ccEmailAddresses = new List <string>(); var bccEmailAddresses = new List <string>(); var userID = _httpContextAccessor.HttpContext.User.FindFirst("id").Value; var emailSubject = ""; string content = ""; var correctiveAc = _correctiveActionRepository.GetOne(correctiveAction.CorrectiveActionID); string url = $"{_emailSettings.Url}/quality/corrective-actions/{correctiveAction.CorrectiveActionID}/detail"; emailSubject = $"HoshinCloud - Extensión fecha de {(correctiveAction.CorrectiveActionState.Code == "EFP" ? "Planificación de AC" : "Evaluación de AC")}"; content = $"<p>Estimado usuario:</p>"; content += $"<p>Se ha extendido la fecha de vencimiento de {(correctiveAction.CorrectiveActionState.Code == "EFP" ? "Planificación" : "Evaluación")} de una Acción Correctiva" + "</p>"; content += $"<p><b>Id de Acción Correctiva</b>: {correctiveAction.CorrectiveActionID}</p>"; content += $"<p><b>Descripción</b>: {correctiveAction.Description}</p>"; content += $"<p><b>Sector</b>: {correctiveAc.SectorPlantLocationName}</p>"; content += $"<p><b>Responsable Asignado</b>: {correctiveAc.ResponsibleUserFullName}</p>"; content += $"<p><b>Evaluador Asignado</b>: {correctiveAc.ReviewerUserFullName}</p>"; content += $"<p><b>Nueva fecha de vencimiento {(correctiveAction.CorrectiveActionState.Code == "EFP" ? "Planificación" : "Evaluación")}</b>: " + correctiveAction.DeadlineDatePlanification.ToString("dd/MM/yyyy") + "</p>"; content += $"<p>Puede acceder desde aquí: <a href={url}>Ver Acción Correctiva.</a></p>"; content += $"<p>Saludos cordiales.</p>"; correctiveAction.CorrectiveActionStateID = _correctiveActionStateRepository.GetByCode(correctiveAction.CorrectiveActionState.Code == "EFP" ? "ABI" : "TRT"); _correctiveActionStatesHistoryRepository.Add(correctiveAction.CorrectiveActionID, correctiveAction.CorrectiveActionStateID, userID); _correctiveActionRepository.Update(correctiveAction); emailAddress.Add(correctiveAction.ResponisbleUser.Email); emailAddress.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID))); emailAddress.AddRange(_userRepository.GetUsersEmailResponsibleSGC()); _emailSender.SendEmailAsync(emailAddress.ToArray(), ccEmailAddresses.ToArray(), bccEmailAddresses.ToArray(), emailSubject, content, true, MailPriority); return(true); }
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()); }
private void SendEmailAuditRescheduling(CorrectiveAction correctiveAction) { List <string> listMails = new List <string>(); using (var scope = _serviceProvider.CreateScope()) { var _ctx = scope.ServiceProvider.GetService(typeof(SQLHoshinCoreContext)) as SQLHoshinCoreContext; var _emailSender = scope.ServiceProvider.GetService(typeof(IEmailSender)) as IEmailSender; Users newResponsibleUser = _ctx.Users.Where(x => x.Id == correctiveAction.ResponsibleUserID).SingleOrDefault(); Users lastResponsibleUser = _ctx.Users.Where(x => x.Id == correctiveAction.LastResponsibleUserID).SingleOrDefault(); Sectors sector = _ctx.Sectors.Where(x => x.SectorID == correctiveAction.SectorTreatmentID).SingleOrDefault(); listMails.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(Convert.ToInt32(correctiveAction.PlantTreatmentID), Convert.ToInt32(correctiveAction.SectorTreatmentID))); listMails.Add(newResponsibleUser.Email); listMails.Add(lastResponsibleUser.Email); string newResponsibleName = newResponsibleUser.FirstName + " " + newResponsibleUser.Surname; string lastResponsibleName = lastResponsibleUser.FirstName + " " + lastResponsibleUser.Surname; string description = correctiveAction.Description; string sectorName = sector.Name; string estado = correctiveAction.CorrectiveActionState.Name; int correctiveActionID = correctiveAction.CorrectiveActionID; _emailSender.SendEmailAsync(listMails.ToArray(), new string[0], new string[0], $"HoshinCloud – Reasignación de Acción Correctiva", SetMessageEmail(newResponsibleName, lastResponsibleName, description, sectorName, estado, correctiveActionID), true, System.Net.Mail.MailPriority.High); } }
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 async Task <bool> Execute(int auditId, string workflowId) { Domain.Audit.Audit audit = _auditRepository.Get(auditId); List <string> EmailsToNotify = new List <string>(); EmailsToNotify.AddRange(_sectorPlantRepository.GetSectorPlantReferredEmail(audit.PlantID, audit.SectorID)); //Internal Auditr if (audit.Auditor != null) { EmailsToNotify.Add(audit.Auditor.Email); } //LEFT EMAIL OF SGC RESPONSIBLE if (ALLOWED_CODES.Contains(audit.AuditState.Code)) { try { string standards = ""; foreach (AuditStandard normas in audit.AuditStandards) { standards += $"<tr><td>{normas.Standard.Name}</td></tr>"; } var emailSubject = $"HoshinCloud - Auditoría eliminada - {audit.AuditTypeName}"; string content = $"<p><b>Id de Auditoría</b>: {audit.AuditID}</p>"; content += $"<p><b>Tipo de Auditoría</b>: {audit.AuditTypeName}</p>"; content += $"<p><b>Normas</b>: <table>{standards}</table></p>"; content += $"<p><b>Sector</b>: {audit.SectorPlantName}</p>"; content += $"<p><b>Auditor Asignado</b>: {audit.AuditorName}</p>"; content += $"<p><b>Fecha de Inicio</b>: {audit.AuditInitDate.ToString("dd/MM/yyyy")}</p>"; string bodyHtml = $"<html>" + $"<body>" + $"<p>Estimado usuario: </p>" + $"<p>Ha sido reprogramada una auditoría.</p>" + $"{content}" + $"<p></p>" + $"<p>Saludos cordiales.</p>" + $"</body>" + $"</html>"; await _workflowCore.DeleteWorkflowInstance(workflowId); _auditRepository.Delete(auditId); Task.Run(() => _emailSender.SendEmailAsync(EmailsToNotify.ToArray(), new List <string>().ToArray(), new List <string>().ToArray(), emailSubject, bodyHtml, true, System.Net.Mail.MailPriority.High)); return(true); } catch (Exception ex) { throw ex; } } else { throw new InvalidAuditStateException("STATE: " + audit.AuditState.Code); } }
public override ExecutionResult Run(IStepExecutionContext context) { AuditWorkflowData auditData = _auditRepository.GetOneByWorkflowId(context.Workflow.Id); auditData.AuditTeam = AuditTeam; auditData.AuditInitDate = AuditInitDate; auditData.AuditInitTime = AuditInitTime; auditData.AuditFinishDate = AuditFinishDate; auditData.AuditFinishTime = AuditFinishTime; 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(_userWorkflowRepository.GetUsersEmailResponsibleSGC()); //EmailAddresses.AddRange(sectorPlantReferrents); //If auditor is internal, send email //if (!string.IsNullOrEmpty(auditData.AuditorID)) //{ // EmailAddresses.Add(_auditRepository.GetAuditorEmail(auditData.AuditorID)); //} //Left responsible of SGC 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) { 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) { 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()); }