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);
        }
Пример #2
0
        public List <CorrectiveActionStateOutput> Execute()
        {
            List <CorrectiveActionState> correctiveActionStates = _correctiveActionStateRepository.GetAll();

            return(_mapper.Map <List <CorrectiveActionState>, List <CorrectiveActionStateOutput> >(correctiveActionStates));
        }