Пример #1
0
        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 async void ExecuteAsync(Domain.CorrectiveAction.CorrectiveAction correctiveAction, string observation, DateTime overdueTime, int correctiveActionID)
        {
            var userID       = _httpContextAccessor.HttpContext.User.FindFirst("id").Value;
            var correctiveAc = _correctiveActionRepository.GetOne(correctiveAction.CorrectiveActionID);
            var users        = _userReopository.GetAll();
            //var idUser = "";
            //foreach (var u in users)
            //{
            //    var roles = u.Roles;
            //    foreach (var r in roles)
            //    {
            //        if (r == "Aprobador de AC")
            //        {
            //            idUser = u.Id;
            //        }
            //    }
            //}

            string        url            = $"{_emailSettings.Url}/quality/corrective-actions/{correctiveAction.CorrectiveActionID}/detail";
            List <string> EmailsToNotify = new List <string>();

            EmailsToNotify.AddRange(_userWorkflowRepository.GetUsersEmailCorrectiveActionApprover());
            int ACid = 0;

            string emailSubject = "HoshinCloud - Solicitud extensión fecha de Evaluación de AC.";
            string content      = $"<html>" +
                                  $"<body>" +
                                  $"<p>Estimado usuario: </p>" +
                                  $"<p>Se solicita la extensión de la fecha de Evaluación de la Acción Correctiva:</p>" +
                                  $"<p><b>Id de Acción Correctiva: </b> {correctiveAction.CorrectiveActionID}</p>" +
                                  $"<p><b>Descripción: </b> {correctiveAc.Description}</p>" +
                                  $"<p><b>Sector: </b> {correctiveAc.SectorPlantTreatmentName}</p>" +
                                  $"<p><b>Responsable asignado: </b> {correctiveAc.ResponsibleUserFullName}</p>" +
                                  $"<p><b>Evaluador asignado: </b>{correctiveAc.ReviewerUserFullName}</p>" +
                                  $"<p><b>Fecha vencimiento de Evaluación: </b>{correctiveAc.DeadlineDateEvaluation.ToString("dd/MM/yyyy")}</p>" +
                                  $"<p><b>Estado :</b>{correctiveAc.CorrectiveActionStateName}</p>" +
                                  $"<p><b>Fecha vencimiento Evaluación solicitada: </b>{overdueTime.ToString("dd/MM/yyyy")}</p>" +
                                  $"<p>Puede acceder desde aquí: <a href={url}>Ver Acción Correctiva.</a></p>" +
                                  $"<p></p>" +
                                  $"<p>Saludos cordiales.</p>" +
                                  $"</body>" +
                                  $"</html>";


            await _emailSender.SendEmailAsync(EmailsToNotify.ToArray(), new List <string>().ToArray(), new List <string>().ToArray(), emailSubject, content, true, System.Net.Mail.MailPriority.High);

            var allACstates = _CorrectiveActionStateRepository.GetAll();

            foreach (var s in allACstates)
            {
                if (s.Code == "EFE")
                {
                    ACid = s.CorrectiveActionStateID;
                }
            }
            correctiveAc.CorrectiveActionStateID = ACid;
            _correctiveActionStatesHistoryRepository.Add(correctiveAc.CorrectiveActionID, correctiveAc.CorrectiveActionStateID, userID);
            _correctiveActionRepository.Update(correctiveAc);
        }
Пример #3
0
        public CorrectiveActionOutput Execute(int id)
        {
            var correctiveAction = _correctiveActionRepository.GetOne(id);

            var a = _mapper.Map <Domain.CorrectiveAction.CorrectiveAction, CorrectiveActionOutput>(correctiveAction);

            return(a);
        }
        public async Task Execute(int correctiveActionId)
        {
            var correctiveAction      = _correctiveActionRepository.GetOne(correctiveActionId);
            var correctiveActionTasks = _taskRepository.GetAllForCorrectiveActionWithOutStates(correctiveActionId);
            var taskStateCompletedId  = _taskStateRepository.GetIdByCode("COM");
            var quantityWithoutFinish = correctiveActionTasks.Where(t => t.TaskStateID != taskStateCompletedId).ToList().Count;

            if (quantityWithoutFinish == 0)
            {
                await _workflowCore.ExecuteEvent("FinishedTasks", correctiveAction.WorkflowId, new CorrectiveActionWorkflowData());
            }
        }
        public void Execute(int id)
        {
            var correctiveAction = _correctiveActionRepository.GetOne(id);

            if (correctiveAction != null)
            {
                _correctiveActionRepository.Delete(correctiveAction);
            }
            else
            {
                throw new EntityNotFoundException(Convert.ToString(id), "No se encontró una acción correctiva con ese ID");
            }
        }
        public bool Execute(Task task)
        {
            var emailAddress      = new List <string>();
            var ccEmailAddresses  = new List <string>();
            var bccEmailAddresses = new List <string>();
            var emailSubject      = "Extensión fecha de vencimiento de tarea de AC.";
            var userID            = _httpContextAccessor.HttpContext.User.FindFirst("id").Value;
            var correctiveAction  = _correctiveActionRepository.GetOne(task.EntityID);

            if (task.ImplementationPlannedDate > correctiveAction.MaxDateImplementation)
            {
                var previousMaxdateImplementation = correctiveAction.MaxDateImplementation;
                correctiveAction.MaxDateImplementation = Convert.ToDateTime(task.ImplementationPlannedDate);

                int correctiveActionStateID = _correctiveActionStateRepository.GetByCode("PLN");
                correctiveAction.CorrectiveActionStateID = correctiveActionStateID;
                _correctiveActionStatesHistoryRepository.Add(correctiveAction.CorrectiveActionID, correctiveAction.CorrectiveActionStateID, userID);
                double days = (correctiveAction.MaxDateImplementation - previousMaxdateImplementation).TotalDays;
                correctiveAction.MaxDateEfficiencyEvaluation = correctiveAction.MaxDateEfficiencyEvaluation.AddDays(days);
                correctiveAction.DeadlineDateEvaluation      = correctiveAction.DeadlineDateEvaluation.AddDays(days);
                _correctiveActionRepository.Update(correctiveAction);
                emailAddress.Add(correctiveAction.ResponisbleUser.Email);
            }
            int taskStateID = _taskStateRepository.GetIdByCode("ECU");

            task.TaskStateID = taskStateID;
            _taskRepository.Update(task);
            var userTask = _userRepository.Get(task.ResponsibleUserID);

            emailAddress.Add(userTask.Email);
            var url          = $"{_emailSettings.Url}/quality/corrective-actions/{correctiveAction.CorrectiveActionID}/detail";
            var emailMessage = $"<html>" +
                               $"<body>" +
                               $"<p>Estimado Usuario: </p>" +
                               $"<p>Se ha extendido la fecha de vencimiento de una tarea de AC: </p>" +

                               $"<p><b>Id tarea: </b>{task.TaskID}.</p>" +
                               $"<p><b>Id de Acción Correctiva: </b>{correctiveAction.CorrectiveActionID}.</p>" +
                               $"<p><b>Descripción de la tarea: </b>{task.Description}.</p>" +
                               $"<p><b>Responsable asignado a la tarea: </b>{userTask.FullName}.</p>" +
                               $"<p><b>Nueva fecha vencimiento de la tarea: </b>{task.ImplementationPlannedDate.ToString("dd/MM/yyyy")}.</p>" +
                               $"<p><b>Fecha de implementación total de la AC: </b>{correctiveAction.MaxDateImplementation.ToString("dd/MM/yyyy")}.</p>" +
                               $"<p>Puede acceder desde aquí: <a href={url}>Ver tarea de Acción Correctiva</a>.</p>" +
                               $"<p></p>" +
                               $"<p>Saludos cordiales.</p>" +
                               $"</body>" +
                               $"</html>";

            _emailSender.SendEmailAsync(emailAddress.ToArray(), ccEmailAddresses.ToArray(), bccEmailAddresses.ToArray(), emailSubject, emailMessage, true, MailPriority);
            return(true);
        }
Пример #7
0
 public async Task <CorrectiveActionOutput> Execute(Domain.CorrectiveAction.CorrectiveAction correctiveAction, IFormFile[] Evidences, List <string> filesToDelete)
 {
     filesToDelete.RemoveAll(string.IsNullOrWhiteSpace);
     try
     {
         if (Evidences != null)
         {
             await InsertFiles(Evidences, correctiveAction);
         }
         if (filesToDelete != null)
         {
             await DeleteFiles(filesToDelete, correctiveAction);
         }
         _correctiveActionEvidenceRepository.Update(correctiveAction.CorrectiveActionID, correctiveAction.NewEvidencesUrls, correctiveAction.DeleteEvidencesUrls);
         return(_mapper.Map <Domain.CorrectiveAction.CorrectiveAction, CorrectiveActionOutput>(_correctiveActionRepository.GetOne(correctiveAction.CorrectiveActionID)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }