/// <summary>
        /// Email seding regrading process
        /// </summary>
        public void SendingMail()
        {
            var pendingEmailQueue = EmailUtility.GetPendingEmailQueue();
            foreach (var queue in pendingEmailQueue)
            {
                queue.EmailContent = GetEmailContent(queue);
                try
                {
                    List<string> to = new List<string>();
                    to.Add(queue.Receiver);

                    Tuple<bool, string> mailResult = EmailUtility.SendEmail(EmailUtility.FromEmail, to.AsEnumerable(), null, null, queue.ProcessName, queue.EmailContent, null);
                    if (mailResult.Item1 == true)
                    {
                        EmailLogVM emailLogVM = new EmailLogVM();
                        emailLogVM.Process = queue.Process;
                        emailLogVM.EmailBody = queue.EmailContent;
                        emailLogVM.Receiver = queue.Receiver;
                        emailLogVM.SentTime = System.DateTime.Now;
                        EmailUtility.SaveEmailLog(emailLogVM, queue.Id);
                    }
                    else
                    {
                        queue.ErrorStatus = mailResult.Item2;
                        EmailUtility.UpdateEmailQueue(queue);
                    }
                }
                catch (Exception ex)
                {
                    queue.ErrorStatus = ex.Message;
                    EmailUtility.UpdateEmailQueue(queue);
                }
            }
        }
        /// <summary>
        /// Saves email log and remove email queue
        /// </summary>
        /// <param name="emailLogVM"></param>
        /// <returns>int</returns>
        public int SaveEmailLog(EmailLogVM emailLogVM, int emailQueueId)
        {
            var emailNotificationServiceBLL = new EmailNotificationServiceBLL();
            Mapper.CreateMap<EmailLogVM, EmailLogBO>();

            var emailLogBO = new EmailLogBO();
            emailLogBO = Mapper.Map<EmailLogVM, EmailLogBO>(emailLogVM);
            return emailNotificationServiceBLL.SaveEmailLog(emailLogBO, emailQueueId);
        }
Beispiel #3
0
 /// <summary>
 /// Save email log 
 /// </summary>
 public static int SaveEmailLog(EmailLogVM emailLogVM, int emailQueueId)
 {
     return ServiceReferences.FPConfigurationProviderServiceClient.SaveEmailLog(emailLogVM, emailQueueId);
 }