Example #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();
        }
Example #2
0
        private void SaveLanguageFileChangesFor(string filename)
        {
            var targetFilePath = _languageLocationService.PathTo(filename);

            using (var xmlTextWriter = new XmlTextWriter(targetFilePath, Encoding.UTF8))
            {
                xmlTextWriter.Formatting = Formatting.Indented;
                PatternXmlDocument.Save(xmlTextWriter);
            }
        }
Example #3
0
        private void InitEditFor(string filename)
        {
            hfPatternFilename.Value = filename;
            var filePath = _languageLocationService.PathTo(filename);

            _securityValidator.EnsureValid(filePath);

            var xmlDocument = new XmlDocument();

            using (var fileStream = new FileStream(filePath, FileMode.Open))
            {
                xmlDocument.Load(fileStream);
            }

            csEditableTree.XmlDeclaration = xmlDocument.FirstChild as XmlDeclaration;
            xmlDocument.RemoveChild(xmlDocument.FirstChild);
            csEditableTree.DataSource = xmlDocument.ChildNodes;
            csEditableTree.DataBind();
        }