public async Task Execute(Domain.CorrectiveAction.CorrectiveAction correctiveAction, IFormFile[] Evidences)
        {
            try
            {
                if (Evidences != null)
                {
                    await InsertFiles(Evidences, correctiveAction);
                }

                var workflowId = _correctiveActionRepository.GetWorkflowId(correctiveAction.CorrectiveActionID);

                var correctiveActionWorkflow = new CorrectiveActionWorkflowData();

                correctiveActionWorkflow.WorkflowId           = workflowId;
                correctiveActionWorkflow.isEffective          = correctiveAction.isEffective;
                correctiveActionWorkflow.EvidencesUrl         = correctiveAction.NewEvidencesUrls;
                correctiveActionWorkflow.EvaluationCommentary = correctiveAction.EvaluationCommentary;

                await _workflowCore.ExecuteEvent("ReviewedCorrectiveAction", workflowId, correctiveActionWorkflow);
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
        }
Example #2
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);
        }
Example #4
0
        private async Task DeleteFiles(List <string> filesToDelete, Domain.CorrectiveAction.CorrectiveAction correctiveAction)
        {
            foreach (var fe in filesToDelete)
            {
                var fileToDelete = new Evidence();
                fileToDelete.FileName = fe;
                fileToDelete.Url      = await _azureStorageRepository.DeleteFileAzureStorage(fileToDelete, _azureStorageSettings.ContainerCorrectiveActionName);

                correctiveAction.DeleteEvidencesUrls.Add(fileToDelete.Url);
            }
        }
Example #5
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;
     }
 }
Example #6
0
        private async Task InsertFiles(IFormFile[] findingEvidences, Domain.CorrectiveAction.CorrectiveAction correctiveAction)
        {
            foreach (var fe in findingEvidences)
            {
                var fileToAdd = new Evidence();

                using (var memoryStream = new MemoryStream())
                {
                    await fe.CopyToAsync(memoryStream);

                    fileToAdd.Bytes = memoryStream.ToArray();
                }

                fileToAdd.FileName = fe.FileName;
                fileToAdd.IsInsert = true;
                fileToAdd.IsDelete = false;

                fileToAdd.Url = await _azureStorageRepository.InsertFileAzureStorage(fileToAdd, TypeData.Byte, _azureStorageSettings.ContainerCorrectiveActionName);

                correctiveAction.NewEvidencesUrls.Add(fileToAdd.Url);
            }
        }
 public CorrectiveActionOutput Execute(Domain.CorrectiveAction.CorrectiveAction correctiveAction)
 {
     return(_mapper.Map <Domain.CorrectiveAction.CorrectiveAction, CorrectiveActionOutput>(_correctiveActionRepository.Update(correctiveAction)));
 }