예제 #1
0
        public IActionResult SmtpConfig()
        {
            Config           cfg  = Config.GetSystemConfig();
            SMTPConfigEntity smtp = cfg.SMTPConfigEntity;

            Admin.WriteLogActions("查看SMTP配置;");
            return(View(smtp));
        }
예제 #2
0
        public IActionResult SmtpConfig(SMTPConfigEntity model)
        {
            //验证
            if (!Utils.IsValidEmail(model.SmtpEmail))
            {
                tip.Message = "SMTP帐号格式错误!请输入正确的Email!";
                return(Json(tip));
            }
            if (string.IsNullOrEmpty(model.SmtpHost))
            {
                tip.Message = "请输入SMTP服务器地址!";
                return(Json(tip));
            }
            if (!Utils.IsInt(model.SmtpProt))
            {
                tip.Message = "请输入正确的端口号!";
                return(Json(tip));
            }
            string json = JsonConvert.SerializeObject(model);

            OtherConfig oc = OtherConfig.Find(OtherConfig._.ConfigName == "smtp");

            if (oc == null)//如果不存在
            {
                oc                = new OtherConfig();
                oc.ConfigName     = "smtp";
                oc.ConfigValue    = JsonConvert.SerializeObject(model);
                oc.LastUpdateTime = DateTime.Now;
                oc.Insert();
            }
            else
            {
                oc.ConfigValue    = JsonConvert.SerializeObject(model);
                oc.LastUpdateTime = DateTime.Now;
                oc.Update();
            }
            Admin.WriteLogActions("修改SMTP设置;");

            tip.Status  = JsonTip.SUCCESS;
            tip.Message = "修改站点SMTP配置成功";

            return(Json(tip));
        }