コード例 #1
0
ファイル: MailQueueManager.cs プロジェクト: evisional1/mixerp
        public async Task ProcessQueueAsync(IEmailProcessor processor, bool deleteAttachments = false)
        {
            var queue = await MailQueue.GetMailInQueueAsync(this.Database).ConfigureAwait(false);

            var config = new EmailConfig(this.Database, this.Processor);

            this.Processor = processor;

            if (this.IsEnabled())
            {
                foreach (var mail in queue)
                {
                    var message     = EmailHelper.GetMessage(config, mail);
                    var attachments = mail.Attachments?.Split(',').ToArray();

                    await processor.SendAsync(message, deleteAttachments, attachments).ConfigureAwait(false);

                    if (message.Status == Status.Completed)
                    {
                        mail.Delivered   = true;
                        mail.DeliveredOn = DateTimeOffset.UtcNow;

                        await MailQueue.SetSuccessAsync(this.Database, mail.QueueId).ConfigureAwait(false);
                    }
                }
            }
        }
コード例 #2
0
ファイル: MailQueueManager.cs プロジェクト: makhalaf/frapid
        public async Task ProcessMailQueueAsync(IEmailProcessor processor)
        {
            var queue = await MailQueue.GetMailInQueueAsync(this.Database).ConfigureAwait(false);

            var config = new Config(this.Database, this.Processor);

            if (this.IsEnabled())
            {
                foreach (var mail in queue)
                {
                    var message     = EmailHelper.GetMessage(config, mail);
                    var attachments = mail.Attachments?.Split(',').ToArray();

                    bool success = await processor.SendAsync(message, false, attachments).ConfigureAwait(false);

                    if (!success)
                    {
                        continue;
                    }

                    mail.Delivered   = true;
                    mail.DeliveredOn = DateTimeOffset.UtcNow;


                    await MailQueue.SetSuccessAsync(this.Database, mail.QueueId).ConfigureAwait(false);
                }
            }
        }