Пример #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _securityValidator.EnsureValidUser();

            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"];

            _securityValidator.EnsureValid(_languageLocationService.PathTo(targetFile));
            _securityValidator.EnsureValid(_languageLocationService.PathTo(patternFile));

            _languageFileUpdater.NewContent = (JObject)jObject["xmlContent"];
            _languageFileUpdater.ExecuteApplyFor(targetFile, patternFile);

            Response.Write("{\"Status\":\"200 OK\"}");
            Response.End();
        }
Пример #2
0
        private IEnumerable <string> GetAllFilenamesFrom(string directory)
        {
            _securityValidator.EnsureValid(directory);

            var xmlFilePaths = Directory.GetFiles(directory, "*.xml");

            return(xmlFilePaths.Select(path => path.Split(Path.DirectorySeparatorChar).Last()));
        }