示例#1
0
        public SisulizerProject(string filename, string language)
        {
            var importProject = new XmlDocument();

            importProject.Load(filename);

            // iterate sources
            foreach (XmlElement rowNode in importProject.SelectNodes("//document/source/node/node/row"))
            {
                var context = GetContextOfNode(rowNode);
                foreach (XmlElement langNode in rowNode.SelectNodes($"lang[@id='{language}']"))
                {
                    var langRow = new LangRow
                    {
                        Id          = langNode.Attributes.GetValueOrDefault("id"),
                        Date        = langNode.Attributes.GetValueOrDefault("date"),
                        Status      = langNode.Attributes.GetValueOrDefault("status"),
                        Content     = langNode.InnerText,
                        Invalidated = langNode.Attributes.GetValueOrDefault("invalidated") == "1",
                    };
                    this.content.Add(context, langRow);
                }

                ////Console.WriteLine(context);
            }
        }
示例#2
0
        private static void UpdateNode(XmlNode xmlNode, LangRow langRow, ILogger logger)
        {
            ////var langRowDate = DateTime.ParseExact(langRow.Date, "yyyyMMddhhmmss", CultureInfo.InvariantCulture);
            ////var sourceDate = DateTime.ParseExact(xmlNode.Attributes["date"].Value, "yyyyMMddhhmmss", CultureInfo.InvariantCulture);

            xmlNode.SetOrUpdateAttribute("date", langRow.Date, logger);
            xmlNode.SetOrUpdateAttribute("status", langRow.Status, logger);
            xmlNode.SetOrUpdateAttribute("invalidated", langRow.Invalidated ? "1" : "", logger);

            if (xmlNode.InnerText != langRow.Content)
            {
                logger?.Update("content", xmlNode.InnerText, langRow.Content);
                xmlNode.InnerText = langRow.Content;
            }
        }