Beispiel #1
0
        public ActionResult Param()
        {
            var method = Request.HttpMethod.ToLower();
            var uuid   = Request.Headers["Authorization"];

            if (method == "get")
            {
                var result = _iConfigParamServices.Param(uuid);
                if (result.Item1 != 200)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
                }

                return(new ContentResult()
                {
                    Content = result.Item2.SerializeObject()
                });
            }
            else if (method == "post")
            {
                var appsetting = _iConfigParamServices.Param(uuid);
                var content    = new StreamReader(Request.InputStream).ReadToEnd();
                var code       = _iConfigParamServices.Param(uuid, content.DeserializeObject <AppSettings>());
                if (code != 200)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized));
                }
                return(new ContentResult()
                {
                    Content = code.ToString()
                });
            }
            return(new HttpStatusCodeResult(HttpStatusCode.MethodNotAllowed));
        }
Beispiel #2
0
        public async Task <ActionResult> Param(string error)
        {
            var apiAddress = WebConfigurationManager.AppSettings["ApiAddress"] ?? string.Empty;
            var loginPath  = WebConfigurationManager.AppSettings["LoginPath"] ?? string.Empty;

            ViewBag.ApiAddress      = apiAddress;
            ViewBag.LoginPath       = loginPath;
            ViewBag.WebCmsAddress   = WebConfigurationManager.AppSettings["WebCmsAddress"] ?? string.Empty;
            ViewBag.UploadExtension = WebConfigurationManager.AppSettings["UploadExtension"] ?? string.Empty;
            ViewBag.CacheStorage    = WebConfigurationManager.AppSettings["MemoryCache"] ?? string.Empty;
            var appsetting = _iConfigParamServices.Param();

            var result = await SendAsync($"{apiAddress}/api/setting/param", HttpMethod.GET);

            if (result.Item1 != 200)
            {
                error = error + result.Item2;
            }

            var apiSetting = result.Item3.DeserializeObject <AppSettings>();

            appsetting.CorsDomains      = apiSetting.CorsDomains;
            appsetting.IsAuthentication = apiSetting.IsAuthentication;
            ViewBag.AppSettings         = appsetting;
            ViewBag.Error = error ?? string.Empty;
            GetMessage();
            return(View());
        }
Beispiel #3
0
        public AppSettings SetParam()
        {
            var result = _iConfigParamServices.Param(Request.Headers.Authorization.ToString());

            if (result.Item1 != 200)
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }
            return(result.Item2);
        }