Beispiel #1
0
        /// <summary>
        /// 注册邮箱
        /// </summary>
        /// <param name="toEmail">接收者邮件</param>
        /// <param name="activateUrl">激活邮件地址</param>
        /// <param name="_result">处理结果</param>
        /// <returns></returns>
        public QssResult QssRegisterEmail(string toEmail, string activateUrl, string code, out string _result)
        {
            var result = QssGetUserByAccount(HttpContext.Current.User.Identity.Name, out User user);

            if (result != QssResult.Success)
            {
                _result = "出现错误!请重试,多次出现该错误请联系管理员.";
                return(QssResult.Fail);
            }
            string body = $"请点击<a href='{activateUrl}'> 此处 </a>来激活你的邮箱,该链接30分钟内有效. 若是链接不能跳转, 请将以下链接复制到浏览器地址栏进行跳转:<br />{activateUrl}";

            if (QssEmailHelper.SendMail(toEmail, "四川农业大学问卷调查与投票系统激活邮件", user.Name, body))
            {
                try
                {
                    // 保存邮箱和激活码
                    user.Email        = toEmail;
                    user.ACode        = code;
                    user.CodeFailTime = DateTime.Now.AddMinutes(30);
                    Update(user);
                    // 提示并跳转
                    _result = "激活邮件已发送,请查收邮件进行邮箱确认!链接30分钟内有效.";
                    return(QssResult.Success);
                }
                catch (Exception exception)
                {
                    // 保存失败
                    QssLogHelper.Log("保存邮箱失败", $"保存用户: {user.Name}({user.Account}) 的邮箱: {toEmail} 失败!失败原因:{exception.Message}", QssLogType.Error, exception);
                    _result = "保存邮箱失败!请重试.";
                    return(QssResult.Fail);
                }
            }
            _result = "发送激活邮件失败!请重试.";
            return(QssResult.Fail);
        }
Beispiel #2
0
        public void Execute(IJobExecutionContext context)
        {
            if (QssEmailHelper.EmailEnqueueCount() == 0)
            {
                return;
            }
            var email = QssEmailHelper.DequeueEmail();

            QssEmailHelper.SendMail(email.ToEmail, email.Subject, email.ToName, email.BodyInfo);
        }
Beispiel #3
0
        /// <summary>
        /// 发送站内信和邮件
        /// </summary>
        /// <param name="message">处理结果信息</param>
        /// <returns></returns>
        public QssResult Send(out string message)
        {
            // 获取信息
            if (GetMessage() != QssResult.Success)
            {
                message = this.message;
                return(QssResult.Fail);
            }

            // 发送邮件
            List <EmailModel> emailList = new List <EmailModel>();

            foreach (var item in receives)
            {
                emailList.Add(new EmailModel {
                    ToEmail = item.Email, ToName = item.Name, Subject = title, BodyInfo = content
                });
            }
            if (currentQvCreator != null)
            {
                emailList.Add(new EmailModel {
                    ToEmail = currentQvCreator.Email, ToName = currentQvCreator.Name, Subject = creatorTitle, BodyInfo = creatorContent
                });
            }
            QssEmailHelper.EnqueueEamil(emailList);

            // 发送站内信
            try
            {
                if (currentQvCreator != null)
                {
                    DbSession.LetterDal.Add(new Letter {
                        Title = creatorTitle, Content = creatorContent, CreateTime = DateTime.Now, Receive = new List <User> {
                            currentQvCreator
                        }
                    });
                }
                DbSession.LetterDal.Add(new Letter {
                    Title = title, Content = content, CreateTime = DateTime.Now, Receive = receives
                });
                DbSession.SaveChanges();
                // 发送成功
                message = $"{qvText} {currentQv.Title} 状态更改成功!";
                return(QssResult.Success);
            }
            catch (Exception exception)
            {
                message = "发送站内信失败!";
                QssLogHelper.Log("发送站内信失败", $"更改{qvText} {currentQv.Title} 状态后,发送站内信失败!失败原因:{exception}", QssLogType.Error);
                return(QssResult.Fail);
            }
        }
        /// <summary>
        /// 发送站内信和邮件
        /// </summary>
        /// <param name="message">处理结果信息</param>
        /// <returns></returns>
        public QssResult Send(out string message)
        {
            if (GetMessage() != QssResult.Success)
            {
                message = this.message;
                return(QssResult.Fail);
            }

            // 发送邮件
            List <EmailModel> emailList = new List <EmailModel>();

            foreach (var item in receives)
            {
                emailList.Add(new EmailModel {
                    ToEmail = item.Email, ToName = item.Name, Subject = title, BodyInfo = content
                });
            }
            QssEmailHelper.EnqueueEamil(emailList);
            // 发送站内信
            try
            {
                DbSession.LetterDal.Add(new Letter()
                {
                    Title = title, Content = content, CreateTime = DateTime.Now, Receive = receives
                });
                DbSession.SaveChanges();

                message = $"组织状态更改成功!";
                return(QssResult.Success);
            }
            catch (Exception exception)
            {
                QssLogHelper.Log("发送站内信失败", "在更新组织状态之后,出现错误! 原因:" + exception.Message, QssLogType.Error);
                message = $"组织状态更改失败!";
                return(QssResult.Success);
            }
        }