Exemple #1
0
        public IActionResult Save(SysSetting info)
        {
            CommonResult result = new CommonResult();

            info.LocalPath = _hostingEnvironment.WebRootPath;
            SysSetting sysSetting = XmlConverter.Deserialize <SysSetting>("xmlconfig/sys.config");

            sysSetting = info;
            //对关键信息加密
            if (!string.IsNullOrEmpty(info.Email))
            {
                sysSetting.Email = DEncrypt.Encrypt(info.Email);
            }
            if (!string.IsNullOrEmpty(info.Emailsmtp))
            {
                sysSetting.Emailsmtp = DEncrypt.Encrypt(info.Emailsmtp);
            }
            if (!string.IsNullOrEmpty(info.Emailpassword))
            {
                sysSetting.Emailpassword = DEncrypt.Encrypt(info.Emailpassword);
            }
            if (!string.IsNullOrEmpty(info.Smspassword))
            {
                sysSetting.Smspassword = DEncrypt.Encrypt(info.Smspassword);
            }
            if (!string.IsNullOrEmpty(info.Smsusername))
            {
                sysSetting.Smsusername = DEncrypt.Encrypt(info.Smsusername);
            }
            string uploadPath = _hostingEnvironment.WebRootPath + "/" + sysSetting.Filepath;

            if (!Directory.Exists(uploadPath))
            {
                Directory.CreateDirectory(uploadPath);
            }
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();

            if (yuebonCacheHelper.Exists("SysSetting"))
            {
                yuebonCacheHelper.Replace("SysSetting", sysSetting);
            }
            else
            {
                //写入缓存
                yuebonCacheHelper.Add("SysSetting", sysSetting);
            }
            XmlConverter.Serialize <SysSetting>(sysSetting, "xmlconfig/sys.config");
            result.ErrCode = ErrCode.successCode;
            return(ToJsonContent(result));
        }