protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            UserValidator.EnsureValidRoles();

            Response.Expires = -1;
            Response.ContentType = "application/json";
            if(!Request.ContentType.Contains("json"))
            {
                Response.Write("Request does not contain JSON data.");
                Response.End();
                return;
            }

            var streamReader = new StreamReader(Request.InputStream, Encoding.UTF8);
            var jsonString = streamReader.ReadToEnd();
            var jObject = JObject.Parse(jsonString);

            var targetFile = (string)jObject["targetFilename"];
            var patternFile = (string)jObject["patternFilename"];
            PathValidator.EnsureValid(Path.To(targetFile));
            PathValidator.EnsureValid(Path.To(patternFile));

            var languageFileUpdater = new LanguageFileUpdater { NewContent = (JObject)jObject["xmlContent"] };
            languageFileUpdater.ExecuteApplyFor(targetFile, patternFile);
            Response.Write("{\"Status\":\"200 OK\"}");
            Response.End();
        }
示例#2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            UserValidator.EnsureValidRoles();

            Response.Expires     = -1;
            Response.ContentType = "application/json";
            if (!Request.ContentType.Contains("json"))
            {
                Response.Write("Request does not contain JSON data.");
                Response.End();
                return;
            }

            var streamReader = new StreamReader(Request.InputStream, Encoding.UTF8);
            var jsonString   = streamReader.ReadToEnd();
            var jObject      = JObject.Parse(jsonString);

            var targetFile  = (string)jObject["targetFilename"];
            var patternFile = (string)jObject["patternFilename"];

            PathValidator.EnsureValid(Path.To(targetFile));
            PathValidator.EnsureValid(Path.To(patternFile));

            var languageFileUpdater = new LanguageFileUpdater {
                NewContent = (JObject)jObject["xmlContent"]
            };

            languageFileUpdater.ExecuteApplyFor(targetFile, patternFile);
            Response.Write("{\"Status\":\"200 OK\"}");
            Response.End();
        }