Ejemplo n.º 1
0
        private static void Send(IRepository <QueuedEmail> _queuedEmailRepo, IUnitOfWork _unitOfWork,
                                 IQueuedEmailService _queuedEmailService)
        {
            var qes = _queuedEmailRepo.FilterBy(k => k.DateSent == null).ToList();

            if (Logger.Log.IsDebugEnabled == true && qes.Count == 0)
            {
                Logger.Log.DebugFormat("there is no emails in the queue");
            }
            else if (qes.Count > 0)
            {
                Logger.Log.InfoFormat("found emails in the queue: {0}", qes.Count);
            }

            foreach (var qe in qes)
            {
                try
                {
                    _queuedEmailService.SendMail(qe.ID);
                    Logger.Log.InfoFormat("Sent email to: {0}, Customer ID: {1}, with OriginalDocument: {2}", qe.To, qe.Customer.ID, qe.OriginalDocument);
                }
                catch (Exception e)
                {
                    Logger.Log.Error(e);
                }
            }
        }