示例#1
0
        public async Task <VerifyRecordResult> DeleteAsync(long id)
        {
            try
            {
                CleanTrackingHelper.Clean <MailQueue>(context);
                MailQueue item = await context.MailQueue
                                 .AsNoTracking()
                                 .FirstOrDefaultAsync(x => x.Id == id);

                if (item == null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法刪除紀錄));
                }
                else
                {
                    CleanTrackingHelper.Clean <MailQueue>(context);
                    context.Entry(item).State = EntityState.Deleted;
                    await context.SaveChangesAsync();

                    CleanTrackingHelper.Clean <MailQueue>(context);
                    return(VerifyRecordResultFactory.Build(true));
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "刪除記錄發生例外異常");
                return(VerifyRecordResultFactory.Build(false, "刪除記錄發生例外異常", ex));
            }
        }
示例#2
0
        public async Task <VerifyRecordResult> UpdateAsync(MailQueueAdapterModel paraObject)
        {
            try
            {
                MailQueue itemData = Mapper.Map <MailQueue>(paraObject);
                CleanTrackingHelper.Clean <MailQueue>(context);
                MailQueue item = await context.MailQueue
                                 .AsNoTracking()
                                 .FirstOrDefaultAsync(x => x.Id == paraObject.Id);

                if (item == null)
                {
                    return(VerifyRecordResultFactory.Build(false, ErrorMessageEnum.無法修改紀錄));
                }
                else
                {
                    CleanTrackingHelper.Clean <MailQueue>(context);
                    context.Entry(itemData).State = EntityState.Modified;
                    await context.SaveChangesAsync();

                    CleanTrackingHelper.Clean <MailQueue>(context);
                    return(VerifyRecordResultFactory.Build(true));
                }
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "修改記錄發生例外異常");
                return(VerifyRecordResultFactory.Build(false, "修改記錄發生例外異常", ex));
            }
        }
示例#3
0
        public void Execute()
        {
            List <Mail> mailList = new List <Mail>();

            foreach (KeyValuePair <int, MailProvider> item in MailProvider.Providers)
            {
                int standByPeriod = 1;

                MailProvider provider = item.Value;

                if (provider.StandbyPeriod > standByPeriod)
                {
                    standByPeriod = provider.StandbyPeriod;
                }

                SendMailList(MailQueue.Fetch(provider));

                Thread.Sleep(standByPeriod * 1000);
            }

            mailList.AddRange(MailQueue.Fetch());

            SendMailList(mailList);

            mailList.AddRange(MailQueue.Fetch());
        }
示例#4
0
 internal static void QueueMail(MailQueue MailQueue)
 {
     if (MailQueue != null)
     {
         MailQueue.Insert();
     }
 }
示例#5
0
        private static DataTable ConvertMailQueueListToDataTable(List <MailQueue> MailQueues)
        {
            DataTable table = new DataTable();

            table.Columns.Add("MailQueueID", typeof(int));
            table.Columns.Add("ToEmail", typeof(string));
            table.Columns.Add("Subject", typeof(string));
            table.Columns.Add("Content", typeof(string));
            table.Columns.Add("FromName", typeof(string));
            table.Columns.Add("FromEmail", typeof(string));
            table.Columns.Add("ReplyEmail", typeof(string));
            table.Columns.Add("SmtpUniqueId", typeof(int));
            table.Columns.Add("ModuleID", typeof(int));
            table.Columns.Add("Attachment", typeof(string));
            table.Columns.Add("Status", typeof(string));
            table.Columns.Add("RetryDateTime", typeof(DateTime));
            table.Columns.Add("RetryAttempt", typeof(int));
            foreach (MailQueue item in MailQueues)
            {
                MailQueue mq = ProcessMailQueue(item.ModuleID, item.Subject, item.Content, item.ToEmail, null, item.FromName, item.FromEmail, null, item.ReplyEmail);
                if (mq != null)
                {
                    table.Rows.Add(0, mq.ToEmail, mq.Subject, mq.Content, mq.FromName, mq.FromEmail, mq.ReplyEmail, mq.SmtpUniqueId, mq.ModuleID, item.Attachment, mq.Status, mq.RetryDateTime, mq.RetryAttempt);
                }
            }
            return(table);
        }
示例#6
0
        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);
                }
            }
        }
示例#7
0
        public async Task ProcessMailQueueAsync(IEmailProcessor processor)
        {
            IEnumerable <EmailQueue> queue = MailQueue.GetMailInQueue(Catalog).ToList();
            var config = new Config(Catalog);

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

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

                    if (!success)
                    {
                        continue;
                    }

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


                    MailQueue.SetSuccess(this.Catalog, mail.QueueId);
                }
            }
        }
示例#8
0
        public static void SendMail(SmtpClient client, MailQueue mail)
        {
            var msg = new MailMessage
            {
                Subject    = mail.Subject,
                From       = new MailAddress(mail.FromEmail.Trim().ToLower(), mail.FromName.Trim()),
                IsBodyHtml = true,
                Body       = mail.Content
            };

            msg.To.Add(mail.ToEmail.Trim().ToLower());

            if (!string.IsNullOrEmpty(mail.ReplyEmail.Trim().ToLower()))
            {
                msg.ReplyToList.Add(mail.ReplyEmail.Trim().ToLower());
            }

            //msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(mail.Content, null, "text/html"));
            msg.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(ConvertToText(mail.Content), null, "text/plain"));

            if (!string.IsNullOrEmpty(mail.Attachment))
            {
                var attachments = SendAttachment.Attachments(mail.Attachment);

                foreach (var attachment in attachments)
                {
                    msg.Attachments.Add(attachment);
                }
            }

            client.Send(msg);
        }
示例#9
0
        internal static void TestSmtp(SmtpServer smtp, string ToEmail, string FriendlyName, string FromEmail, string FromName, string ReplyTo, ref string SuccessfulMessage, ref string ExceptionsMessage)
        {
            try
            {
                if (smtp != null && !string.IsNullOrEmpty(ToEmail) && !string.IsNullOrEmpty(FromEmail) && !string.IsNullOrEmpty(FromName))
                {
                    SmtpClient client = Connect(smtp.Server, smtp.Port, smtp.Authentication, smtp.Username, smtp.Password, smtp.SSL);

                    var msg = new MailQueue
                    {
                        FromName   = FromEmail,
                        FromEmail  = FromEmail,
                        ToEmail    = ToEmail,
                        ReplyEmail = ReplyTo,
                        Subject    = !string.IsNullOrEmpty(FriendlyName) ? FriendlyName + " Notification Email SMTP Configuration Test" : "Notification Email SMTP Configuration Test",
                    };

                    SendMail(client, msg);

                    SuccessfulMessage = "Email Sent Successfully from " + FromEmail.Trim().ToLower() + " to " + ToEmail.Trim().ToLower();
                }
            }
            catch (Exception ex)
            {
                ExceptionsMessage += "<br />" + ex.Message;
            }
        }
示例#10
0
        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);
                    }
                }
            }
        }
 public PackageService(CourierAppDbContext dbContext, IReviewService reviewService, IGeolocationService gpsService, MailQueue mailService)
 {
     _dbContext     = dbContext;
     _reviewService = reviewService;
     _gpsService    = gpsService;
     _mailService   = mailService;
 }
示例#12
0
        public void Add()
        {
            this.Processor = EmailProcessor.GetDefault(this.Database);
            if (!this.IsEnabled())
            {
                return;
            }

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

            this.Email.ReplyTo     = this.Email.ReplyTo.Or("");
            this.Email.ReplyToName = this.Email.ReplyToName.Or("");

            if (string.IsNullOrWhiteSpace(this.Email.FromName))
            {
                this.Email.FromName = config.FromName;
            }

            if (string.IsNullOrWhiteSpace(this.Email.FromEmail))
            {
                this.Email.FromEmail = config.FromEmail;
            }

            var sysConfig = MessagingConfig.Get(this.Database);

            if (sysConfig.TestMode)
            {
                this.Email.IsTest = true;
            }

            if (this.IsValidEmail(this.Email.FromEmail) && this.IsValidEmail(this.Email.SendTo))
            {
                MailQueue.AddToQueue(this.Database, this.Email);
            }
        }
示例#13
0
        public ActionResult Lock(int paymentClassId)
        {
            Account currentAccount = _unitOfWork.Accounts.GetCurrentUserAccount();

            var beneficiaryIds = currentAccount.Profile.Beneficiaries.Select(b => b.ID).ToArray();

            List <Payment> payments = new List <Payment>();

            if (paymentClassId == -1) //Lock All
            {
                payments = _unitOfWork.Payments.GetPaymentByBeneficiary(beneficiaryIds).ToList();
            }
            else
            {
                payments = _unitOfWork.Payments.GetPaymentByBeneficiary(beneficiaryIds)
                           .Where(p => p.ClassID == paymentClassId).ToList();
            }

            foreach (var payment in payments)
            {
                if (!payment.Locked)
                {
                    payment.Locked      = true;
                    payment.AuditedByID = currentAccount.ID;
                    payment.Tickets     = payment.GenerateTickets();
                    MailQueue mailQueue = new MailQueue(payment);
                    _unitOfWork.MailQueues.Add(mailQueue);
                    _unitOfWork.Payments.Edit(payment);
                    _unitOfWork.Complete();
                }
            }
            return(RedirectToAction("Index"));
        }
示例#14
0
        public void Add()
        {
            if (!IsEnabled())
            {
                return;
            }

            MailQueue.AddToQueue(Catalog, Email);
        }
示例#15
0
        public ActionResult Email(int id)
        {
            Payment   payment   = _unitOfWork.Payments.GetPayment(id);
            MailQueue mailQueue = new MailQueue(payment);

            _unitOfWork.MailQueues.Add(mailQueue);

            return(RedirectToAction("Index"));
        }
示例#16
0
        public ActionResult Resend()
        {
            IEnumerable <Payment> payments = _unitOfWork.Payments.GetLockedPayments();

            foreach (Payment payment in payments)
            {
                MailQueue mailQueue = new MailQueue(payment);
                _unitOfWork.MailQueues.Add(mailQueue);
            }

            return(RedirectToAction("Index"));
        }
示例#17
0
        public async Task <MailQueueAdapterModel> GetAsync(long id)

        {
            MailQueue item = await context.MailQueue
                             .AsNoTracking()
                             .FirstOrDefaultAsync(x => x.Id == id);

            MailQueueAdapterModel result = Mapper.Map <MailQueueAdapterModel>(item);

            await OhterDependencyData(result);

            return(result);
        }
示例#18
0
        public async Task <VerifyRecordResult> AddAsync(MailQueueAdapterModel paraObject)
        {
            try
            {
                MailQueue itemParameter = Mapper.Map <MailQueue>(paraObject);
                CleanTrackingHelper.Clean <MailQueue>(context);
                await context.MailQueue
                .AddAsync(itemParameter);

                await context.SaveChangesAsync();

                CleanTrackingHelper.Clean <MailQueue>(context);
                return(VerifyRecordResultFactory.Build(true));
            }
            catch (Exception ex)
            {
                Logger.LogError(ex, "新增記錄發生例外異常");
                return(VerifyRecordResultFactory.Build(false, "新增記錄發生例外異常", ex));
            }
        }
        public void EmailRole()
        {
            MailQueue queue = new MailQueue();
            EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), null, string.Empty, "*****@*****.**")
                                                      {
                                                          Roles = this.roleList,
                                                          GetUsersFn = this.getUserFn,
                                                          SystemSettings = this.systemSettings
                                                      };

            this.recipientList.Roles.Add("role-2");
            EventResult result = handler.Handle(null, this.action, this.application, new PageList(), this.getApplicationAccessFn);

            Assert.IsTrue(result.Processed);
            MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable;
            Assert.AreEqual(2, message.To.Count);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.To[1].Address);
            Assert.AreEqual("*****@*****.**", message.Sender.Address);
            Assert.AreEqual(this.action.Content, message.Body);
            Assert.AreEqual(this.action.Subject, message.Subject);
        }
示例#20
0
    private MailManager()
    {
        //Get the Mail Section info from config file.
        _mailSection = (MailSection)ConfigurationManager.GetSection("mail");
        //Get whether enable mail sending.
        _enable    = _mailSection.Enable;
        _enableSSL = _mailSection.EnableSSL;
        //Initialize the job timer ------------
        _timer          = new Timer();
        _timer.Interval = _mailSection.Job.SendInterval * 1000 * 60;
        _timer.Enabled  = true;
        _timer.Elapsed += Timer_Elapsed;
        //-------------------------------------

        //Initialize the Mail Queue ----------------
        _queue                  = new MailQueue(_mailSection.Queue);
        _queue.AddingMail      += Queue_AddingMail;
        _queue.AddedMail       += Queue_AddedMail;
        _queue.DeletingMail    += Queue_DeletingMail;
        _queue.DeletedMail     += Queue_DeletedMail;
        _queue.DequeueMail     += Queue_DequeueMail;
        _queue.ExceedQueueSize += Queue_ExceedQueueSize;
        _queue.MailError       += QueueAndJob_MailError;
        //------------------------------------------

        //Initialize the Mail Job -----------------
        _job              = new MailJob(_mailSection.Job, _queue, _enableSSL);
        _job.SendingMail += Job_SendingMail;
        _job.SendedMail  += Job_SendedMail;
        _job.MailError   += QueueAndJob_MailError;
        //------------------------------------------
        //Initialize the Event Receiver -------
        if (string.IsNullOrEmpty(_mailSection.EventReceiver) == false)
        {
            Type tp = Type.GetType(_mailSection.EventReceiver);
            _mailEventReceiver = (MailEvent)Activator.CreateInstance(tp, false);
            //-------------------------------------
        }
    }
示例#21
0
        public void SetUp()
        {
            var tsDir = new TsDir();

            _tsOption = new TsOption(tsDir);
            _tsOption.Set("FOLDER", "MailBox", "dir", string.Format("{0}\\MailBox", tsDir.Src));
            //user1,user2,user3
            _tsOption.Set("DAT", "MailBox", "user", "user1\tpass\buser2\tpass\buser3\tpass");

            var kernel    = new Kernel(null, null, null, null);
            var logger    = new Logger(kernel, "LOG", false, null);
            var manageDir = tsDir.Src + "\\TestDir";

            //MailQueue
            _mailQueue = new MailQueue(tsDir.Src + "\\MailQueue");
            var oneOption = kernel.ListOption.Get("MailBox");

            _mailBox = new MailBox(kernel, oneOption);

            var mailSave = new MailSave(kernel, _mailBox, logger, _mailQueue, "", _domainList);//モック

            var memberList = new Dat();

            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER1", "*****@*****.**", false, true, true, ""));  //一般・読者・投稿
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER2", "*****@*****.**", false, true, false, "")); //一般・読者・×
            memberList.Add(true, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER3", "*****@*****.**", false, false, true, "")); //一般・×・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "USER6" , "*****@*****.**" , false, false, true, ""));//一般・×・投稿 (Disable)
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN" , "*****@*****.**" , true, false, true, "123"));//管理者・×・投稿
            //memberList.Add(true,  string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN2", "*****@*****.**", true, true, true, "456"));//管理者・読者・投稿
            //memberList.Add(false, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}", "ADMIN3", "*****@*****.**", true, true, true, "789"));//管理者・読者・投稿 (Disable)
            var        docs             = (from object o in Enum.GetValues(typeof(MLDocKind)) select "").ToList();
            const int  maxSummary       = 10;
            const int  getMax           = 10;
            const bool autoRegistration = true;
            const int  titleKind        = 1;
            var        mlOption         = new MlOption(maxSummary, getMax, autoRegistration, titleKind, docs, manageDir, memberList);

            _ml = new Ml(kernel, logger, mailSave, mlOption, _mlName, _domainList);
        }
示例#22
0
 private EF.MailQueue ConvertToEF(MailQueue mailQueue)
 {
     return(new EF.MailQueue(mailQueue.PaymentID, mailQueue.To));
 }
        public void SingleFieldRecipientInRepeater()
        {
            MailQueue queue = new MailQueue();
            EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), null, string.Empty, "*****@*****.**")
                                                      {
                                                          Roles = this.roleList,
                                                          GetUsersFn = this.getUserFn,
                                                          SystemSettings = this.systemSettings
                                                      };

            ApplicationData data = new ApplicationData();

            Dictionary<string, object>[] repeater = new Dictionary<string, object>[1];
            repeater[0] = new Dictionary<string, object>();
            repeater[0]["Email"] = "*****@*****.**";
            data.Add("Repeater1", repeater);
            this.application.ApplicationData = data;

            this.recipientList.FormFields.Add("Repeater1[0].Email");

            EventResult result = handler.Handle(null, this.action, this.application, new PageList(), this.getApplicationAccessFn);

            Assert.IsTrue(result.Processed);
            MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable;
            Assert.AreEqual(1, message.To.Count);

            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.Sender.Address);
            Assert.AreEqual(this.action.Content, message.Body);
            Assert.AreEqual(this.action.Subject, message.Subject);
        }
        public void EmailUserWithPdf()
        {
            MailQueue queue = new MailQueue();
            EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), new ApplicationPdfWriter(), string.Format("{0}/iapply.pdf", System.IO.Path.GetTempPath()), "*****@*****.**")
                                                      {
                                                          Roles = this.roleList,
                                                          GetUsersFn = this.getUserFn,
                                                          SystemSettings = this.systemSettings
                                                      };

            this.action.AttachPdf = true;
            this.application.ApplicationData.Add("Test", "Test");
            this.recipientList.Users.Add("user-1");

            ControlList controlList = new ControlList();
            TextControl textControl = new TextControl
                                      {
                                          Name = "Test",
                                          Label = "Test"
                                      };
            controlList.Add(textControl);

            PageList pages = new PageList
                             {
                                 new UserPage
                                 {
                                     Controls = controlList
                                 }
                             };
            EventResult result = handler.Handle(null, this.action, this.application, pages, this.getApplicationAccessFn);

            Assert.IsTrue(result.Processed);
            MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable;
            Assert.AreEqual(1, message.To.Count);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.Sender.Address);
            Assert.AreEqual(1, message.Attachments.Count);
            Assert.AreEqual(this.action.Subject, message.Subject);
        }
示例#25
0
        public override bool Publish()
        {
            try
            {
                string exceptionDetail = string.Empty;
                string exceptionData   = string.Empty;
                string fileName        = string.Empty;

                this.Message = Nhea.Text.HtmlHelper.ReplaceNewLineWithHtml(this.Message);

                if (this.Exception != null)
                {
                    ExceptionDetailBuilder.Build(this.Exception, out exceptionDetail, out exceptionData, out fileName);

                    if (!string.IsNullOrEmpty(exceptionDetail))
                    {
                        exceptionDetail = string.Format("<b>Exception Detail:</b>{1}{0}{1}", Nhea.Text.HtmlHelper.ReplaceNewLineWithHtml(exceptionDetail), HtmlNewLine);
                    }

                    if (!string.IsNullOrEmpty(exceptionData))
                    {
                        exceptionData = string.Format("<b>Exception Data:</b>{1}{0}{1}", Nhea.Text.HtmlHelper.ReplaceNewLineWithHtml(exceptionData), HtmlNewLine);
                    }

                    if (string.IsNullOrEmpty(this.Message))
                    {
                        this.Message = this.Exception.Message;
                    }
                }

                string detail = "<b>Message:</b> " + Message + HtmlNewLine;
                detail += "<b>Log Level:</b> " + Level.ToString() + HtmlNewLine;
                detail += "<b>Date:</b> " + DateTime.Now.ToString() + HtmlNewLine;
                detail += "<b>Username:</b> " + UserName + HtmlNewLine;

                string aspnetCoreEnvironmentVariable = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

                if (!string.IsNullOrEmpty(aspnetCoreEnvironmentVariable))
                {
                    detail += "<b>Environment:</b> " + aspnetCoreEnvironmentVariable + HtmlNewLine;
                }
                else
                {
                    detail += "<b>Environment:</b> " + Nhea.Configuration.Settings.Application.EnvironmentType.ToString() + HtmlNewLine;
                }

                detail += "<b>OSVersion:</b> " + System.Environment.OSVersion + HtmlNewLine;

                //var version = System.Environment.Version;
                //var appContextFrameworkName = System.AppContext.TargetFrameworkName;
                string frameworkName = null;

                try
                {
                    frameworkName = Assembly.GetEntryAssembly()?.GetCustomAttribute <TargetFrameworkAttribute>()?.FrameworkName;
                }
                catch
                { }

                if (string.IsNullOrEmpty(frameworkName))
                {
                    frameworkName = System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
                }

                detail += "<b>Framework:</b> " + frameworkName + HtmlNewLine;

                detail += "<b>OSArchitecture:</b> " + System.Runtime.InteropServices.RuntimeInformation.OSArchitecture.ToString() + HtmlNewLine;

                detail += "<b>ProcessArchitecture:</b> " + System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture.ToString() + HtmlNewLine;

                //detail += "Is64BitOperatingSystem : " + System.Environment.Is64BitOperatingSystem.ToString() + HtmlNewLine;
                //detail += "Is64BitProcess : " + System.Environment.Is64BitProcess.ToString() + HtmlNewLine;

                detail += "<b>Source:</b> " + Source + HtmlNewLine;

                if (!string.IsNullOrEmpty(fileName))
                {
                    detail += "<b>File Name:</b> " + fileName + HtmlNewLine;
                }

                detail += HtmlNewLine + HtmlNewLine;

                if (!string.IsNullOrEmpty(exceptionData))
                {
                    detail += exceptionData;
                }

                if (!string.IsNullOrEmpty(exceptionDetail))
                {
                    detail += exceptionDetail;
                }

                detail += "<b>----------------------------------end----------------------------------</b>";

                string subject = String.Empty;

                if (string.IsNullOrEmpty(Settings.Log.MailList))
                {
                    subject = Settings.Log.InformSubject;
                }
                else
                {
                    subject = this.Message;
                }

                string mailFrom = string.Empty;

                if (!string.IsNullOrEmpty(Settings.Log.MailFrom))
                {
                    mailFrom = Settings.Log.MailFrom;
                }

                MailQueue.Add(mailFrom, Settings.Log.MailList, subject, detail);

                return(true);
            }
            catch (Exception ex)
            {
                Logger.Log(LogLevel.Error, PublishTypes.File, null, null, ex.Message, ex, false);
                Logger.Log(LogLevel.Error, PublishTypes.File, this.Source, this.UserName, this.Message, this.Exception, false);

                return(false);
            }
        }
示例#26
0
 public async Task AddMailToQueueAsync(MailQueueViewModel model)
 {
     MailQueue mailQueue = _mapper.Map <MailQueueViewModel, MailQueue>(model);
     await _context.MailQueues.AddAsync(mailQueue);
 }
示例#27
0
 public void Add(MailQueue mailQueue)
 {
     _raisinsDb.MailQueues.Add(mailQueue);
 }
示例#28
0
        public Initialization2()
        {
            var tsDir = new TsDir();
            //var tsOption = new TsOption(tsDir);
            //var manageDir = tsDir.Src + "\\TestDir";

            //TmpDir2 = string.Format("{0}/../../TestDir", Directory.GetCurrentDirectory());
            var optionDef = tsDir.Src + "\\Option.def";


            //Docs
            Docs = new List <string>();
            var lines = File.ReadAllLines(optionDef, Encoding.GetEncoding(932));

            foreach (MlDocKind docKind in Enum.GetValues(typeof(MlDocKind)))
            {
                var  tag = string.Format("MEMO=Ml\b{0}Document=", docKind.ToString().ToLower());
                bool hit = false;
                foreach (var l in lines)
                {
                    if (l.IndexOf(tag) == 0)
                    {
                        Docs.Add(l.Substring(tag.Length));
                        hit = true;
                        break;
                    }
                }
                if (!hit)
                {
                    Docs.Add("");
                }
            }

            Kernel     = new Kernel(null, null, null, null);
            Logger     = Kernel.CreateLogger("LOG", true, null);
            domainList = new List <string>()
            {
                "example.com"
            };
            MlAddr = new MlAddr(mlName, domainList);
            var mailQueue = new MailQueue(tsDir.Src + "TestDir");
            var oneOption = new Option(Kernel, "", "");
            var mailBox   = new MailBox(Kernel, oneOption);

            MailSave = new MailSave(Kernel, mailBox, Logger, mailQueue, "", domainList);
            MlOption = CreateMlOption();
            //MlUserList = CreateMlUsers();

            Ml = new Ml(Kernel, Logger, MailSave, MlOption, mlName, domainList);
            //30件のメールを保存
            for (int i = 0; i < 30; i++)
            {
                var mail = new Mail(null);
                mail.Init(Encoding.ASCII.GetBytes("\r\n"));  //区切り行(ヘッダ終了)
                mail.AddHeader("subject", string.Format("[{0}:{1:D5}]TITLE", mlName, i + 1));
                mail.Init(Encoding.ASCII.GetBytes("1\r\n")); //本文
                mail.Init(Encoding.ASCII.GetBytes("2\r\n")); //本文
                mail.Init(Encoding.ASCII.GetBytes("3\r\n")); //本文

                Ml.Save(mail);
            }
        }
示例#29
0
 public void Add(MailQueue mailQueue)
 {
     _context.MailQueues.Add(ConvertToEF((mailQueue)));
     _context.SaveChanges();
 }
示例#30
0
        private static MailQueue ProcessMailQueue(int ModuleID, string Subject, string Content, string ToEmail, List <Data.Entities.Attachment> Attachments, string FromName, string FromEmail, string FromEmailPrefix, string ReplyEmail)
        {
            MailQueue mailQueue = null;

            if (!string.IsNullOrEmpty(Subject) && !string.IsNullOrEmpty(Content) && !string.IsNullOrEmpty(ToEmail))
            {
                mailQueue = new MailQueue
                {
                    ModuleID      = ModuleID,
                    Subject       = Subject,
                    Content       = Content,
                    SmtpUniqueId  = -1,
                    Status        = "Queue",
                    RetryAttempt  = 0,
                    RetryDateTime = DateTime.UtcNow
                };

                List <Setting> Settings = SettingFactory.GetSettings(ModuleID, AppFactory.Identifiers.admin_notifications_email.ToString());

                if (Settings.Count > 0)
                {
                    try
                    {
                        if (Settings.Where(s => s.Name == "DNNHostSetting").FirstOrDefault() != null && Settings.Where(s => s.Name == "DNNHostSetting").FirstOrDefault().Value.ToLower() == "false")
                        {
                            if (Settings.Where(s => s.Name == "ReplyFromDisplayName").FirstOrDefault() != null)
                            {
                                mailQueue.FromName = Settings.Where(s => s.Name == "ReplyFromDisplayName").FirstOrDefault().Value;
                            }

                            if (Settings.Where(s => s.Name == "ReplyFromEmail").FirstOrDefault() != null)
                            {
                                mailQueue.FromEmail = Settings.Where(s => s.Name == "ReplyFromEmail").FirstOrDefault().Value;
                            }

                            if (Settings.Where(s => s.Name == "ReplyTo").FirstOrDefault() != null)
                            {
                                mailQueue.ReplyEmail = Settings.Where(s => s.Name == "ReplyTo").FirstOrDefault().Value;
                            }
                        }
                        else
                        {
                            mailQueue.FromName   = Host.HostEmail;
                            mailQueue.FromEmail  = Host.HostEmail;
                            mailQueue.ReplyEmail = Host.HostEmail;
                        }
                    }
                    catch { }
                }

                if (!string.IsNullOrEmpty(FromName))
                {
                    mailQueue.FromName = FromName;
                }

                if (!string.IsNullOrEmpty(FromEmail))
                {
                    mailQueue.FromEmail = FromEmail;
                }

                if (!string.IsNullOrEmpty(ReplyEmail))
                {
                    mailQueue.ReplyEmail = ReplyEmail;
                }

                if (string.IsNullOrEmpty(mailQueue.ReplyEmail))
                {
                    mailQueue.ReplyEmail = mailQueue.FromEmail;
                }

                mailQueue.ToEmail = ToEmail;

                if (Attachments != null && Attachments.Count > 0)
                {
                    mailQueue.Attachment = Newtonsoft.Json.JsonConvert.SerializeObject(Attachments);
                }
                else
                {
                    mailQueue.Attachment = "";
                }

                //Fix for 50310 and 50294  auto-no-reply-helpdesk@
                if (!string.IsNullOrEmpty(FromEmailPrefix) && !string.IsNullOrEmpty(mailQueue.FromEmail))
                {
                    mailQueue.FromEmail = FromEmailPrefix + mailQueue.FromEmail.Split('@')[1];
                }
            }

            return(mailQueue);
        }
示例#31
0
 public void AddToQueue(MailQueue mail)
 {
     MailQueueRepository.Add(mail);
 }
示例#32
0
 internal static List <MailQueue> GetMailQueue(int moduleId)
 {
     return(MailQueue.Query("Where ModuleID=@0", moduleId).Where(m => m.Status == "Queue" || (m.Status == "Retry" && m.RetryDateTime < DateTime.Now && m.RetryAttempt <= 3)).ToList());
 }
示例#33
0
 public ApplicationUserService(UserManager <ApplicationUser> userManager, ICourierManagementService courierService, MailQueue mailService)
 {
     _userManager    = userManager;
     _courierService = courierService;
     _mailService    = mailService;
 }