Пример #1
0
        /// <summary>
        /// 发送激活邮件
        /// </summary>
        /// <param name="email"></param>
        /// <returns></returns>
        public Response SendActivateEmail(string email)
        {
            var response = new Response();
            var user     = DbBase.Query <W_Users>().SingleOrDefault(p => p.Email == email);

            if (user == null)
            {
                response.Message = "发送失败,请重新登录后重试.";
                return(response);
            }
            user.EmailConfirmToken = (email + DateTime.Now.Ticks).ToMd5().ToLower();
            var result = DbBase.UpdateMany <W_Users>().OnlyFields(p => p.EmailConfirmToken).Where(p => p.Id == user.Id).Execute(user);

            if (IsUpdateSuccess(result))
            {
                var url  = WebConfigApplicationSettings.GetAppSettings("Domain", "http://www.byr8.top/") + "emailvalidate/" + user.EmailConfirmToken;
                var body = new StringBuilder();
                body.Append("您好:" + user.NickName + "<br/>");
                body.Append("<p>请点击链接激活您的邮箱:");//target=\"_blank\"
                body.Append("<a href=\"" + url + "\"  >" + url + "</a>");
                body.Append("</p>");

                //发送邮件
                new SmtpService().SendMail(email, "(勿回)星座社区激活邮件", body.ToString());

                response.IsSuccess = true;
                response.Message   = "发送成功,请注意查看邮件.";
                return(response);
            }

            response.Message = "发送失败,请重新登录后重试.";
            return(response);
        }
Пример #2
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            IApplicationSettings applicationSettings = new WebConfigApplicationSettings();

            ApplicationSettingsFactory.InitializeApplicationSettingsFactory(applicationSettings);
        }
Пример #3
0
        public Log4NetAdapter()
        {
            XmlConfigurator.Configure();
            var logName = WebConfigApplicationSettings.GetAppSettings("LoggerName");

            logName = logName == null ? "DefaultLog" : logName;
            _log    = LogManager.GetLogger(logName);
        }
Пример #4
0
        public SmtpService()
        {
            _logger = new Log4NetAdapter();
            //配置文件虚拟路径
            var path = WebConfigApplicationSettings.GetAppSettings("EmailConfigPath");

            filePath = HttpContext.Current.Server.MapPath(path == null ? "~/Config/EmailConfig.json" : path);
            try
            {
                var config = FileUtil.Instance.ReadFile(filePath);
                email = JsonConvert.DeserializeObject <EmailAccount>(config);
            }
            catch (Exception ex)
            {
                _logger.Debug("读取配置文件出错,请检查配置文件是否存在!", ex);
            }
        }