예제 #1
0
 public void Param(AppSettings appSettings)
 {
     AppSettingsUtil.Modified(nameof(appSettings.CacheStorage), appSettings.CacheStorage);
     AppSettingsUtil.Modified(nameof(appSettings.RedisReaderPath), appSettings.RedisReaderPath);
     AppSettingsUtil.Modified(nameof(appSettings.RedisWriterPath), appSettings.RedisWriterPath);
     AppSettingsUtil.Modified(nameof(appSettings.IsAuthentication), appSettings.IsAuthentication.ToString());
 }
예제 #2
0
        public async Task <ActionResult> ModifiedParam()
        {
            var api         = Request["ApiAddress"];
            var loginPath   = Request["LoginPath"];
            var requestType = Request["Type"];
            var appSettings = new AppSettings();

            appSettings.CacheStorage     = Request["CacheStorage"];
            appSettings.RedisReaderPath  = Request["RedisReaderPath"];
            appSettings.RedisWriterPath  = Request["RedisWriterPath"];
            appSettings.IsAuthentication = Convert.ToBoolean(Request["IsAuthentication"]);

            var sendTask = new List <Task <Tuple <int, string, string> > >()
            {
                SendAsync($"{api}/api/setting/param", HttpMethod.POST, new Content(appSettings.SerializeObject())),
                SendAsync($"{loginPath}/Login/param", HttpMethod.POST, new Content(appSettings.SerializeObject()))
            };
            var result = await Task.WhenAll(sendTask);

            foreach (var item in result)
            {
                if (item.Item1 != 200)
                {
                    return(Redirect($"~/Setting/Param?error={item.Item2}&type={requestType}"));
                }
            }

            var webCmsAddress = Request["WebCmsAddress"];

            _iConfigParamServices.Param(appSettings);
            AppSettingsUtil.Modified("WebCmsAddress", webCmsAddress);
            AppSettingsUtil.Modified("ApiAddress", api);

            AppSettingsUtil.Modified("LoginPath", loginPath);
            AppSettingsUtil.Modified("UploadExtension", Request["UploadExtension"] ?? string.Empty);
            if (requestType.IsNotNullOrEmpty())
            {
                return(Redirect("~/Index"));
            }
            else
            {
                SetMessage("设置保存成功");
                return(Redirect("~/Setting/Param"));
            }
        }