Esempio n. 1
0
        /// <summary>
        /// 邮件发送任务列表
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> SendEmailTaskList()
        {
            SendEmailTaskBll sendEmailTaskBll = new SendEmailTaskBll();
            var list = await sendEmailTaskBll.GetList();

            ViewBag.root = "email";
            return(View(list));
        }
Esempio n. 2
0
        /// <summary>
        /// 邮件发送日志
        /// </summary>
        /// <param name="sendEmailTaskId"></param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        public IActionResult SendEmailLogList(int sendEmailTaskId, int pageIndex = 1)
        {
            SendEmailLogBll  sendEmailLogBll  = new SendEmailLogBll();
            int              pageSize         = 35;
            var              tup              = sendEmailLogBll.GetByTaskId(sendEmailTaskId, pageIndex, pageSize);
            SendEmailTaskBll sendEmailTaskBll = new SendEmailTaskBll();
            var              taskinfo         = sendEmailTaskBll.GetById(sendEmailTaskId).Result;

            ViewBag.pageIndex       = pageIndex;
            ViewBag.pageSize        = pageSize;
            ViewBag.count           = tup.Item2;
            ViewBag.sendEmailTaskId = sendEmailTaskId;
            ViewBag.taskinfo        = taskinfo;
            ViewBag.root            = "email";
            return(View(tup.Item1));
        }
Esempio n. 3
0
        public async Task <IActionResult> SaveSendEmailTask()
        {
            SendEmailTask   sendEmailTask   = new SendEmailTask();
            SendEmailLogBll sendEmailLogBll = new SendEmailLogBll();

            sendEmailTask.EmailTempId = Request.Form["EmailTempId"].TryToInt(0);
            sendEmailTask.TaskName    = Request.Form["TaskName"].TryToString();
            sendEmailTask.CreateTime  = DateTime.Now;
            string           Email = Request.Form["Email"].TryToString();
            bool             flag  = Request.Form["sendAll"].TryToString() == "on";
            SendEmailTaskBll bll   = new SendEmailTaskBll();
            int id = await bll.AddAsync(sendEmailTask);

            if (id > 0)
            {
                Task.Run(async() =>
                {
                    if (!Email.IsNull())
                    {
                        SendEmailLog log = new SendEmailLog
                        {
                            SendEmailTaskId = id,
                            Email           = Email,
                            IsRead          = false,
                            IsSend          = false,
                            IsSendOk        = false,
                            Name            = Email,
                            EmailTempId     = sendEmailTask.EmailTempId,
                        };
                        await sendEmailLogBll.AddAsync(log);
                    }
                    if (flag)
                    {
                        TargetEmailBll targetEmailBll = new TargetEmailBll();
                        int pageIndex = 0;
                        int pageSize  = 50;
                        A:
                        pageIndex++;
                        var tup = await targetEmailBll.GetList(pageIndex, pageSize);
                        if (tup.Item1 != null && tup.Item1.Count > 0)
                        {
                            foreach (TargetEmail targetEmail in tup.Item1)
                            {
                                SendEmailLog log1 = new SendEmailLog
                                {
                                    SendEmailTaskId = id,
                                    Email           = targetEmail.Email,
                                    IsRead          = false,
                                    IsSend          = false,
                                    IsSendOk        = false,
                                    Name            = targetEmail.Name,
                                    EmailTempId     = sendEmailTask.EmailTempId,
                                };
                                await sendEmailLogBll.AddAsync(log1);
                            }
                            goto A;
                        }
                    }
                    SendEmailHelper.StartSendEmail(id);
                });
            }
            return(Json(new { code = 1, msg = "OK" }));
        }