Exemplo n.º 1
0
        //#################################################################################################
        private static Classes.FList GetFiltersFromXml(XmlDocument doc)
        {
            var     flist   = new Classes.FList();
            XmlNode filters = doc.SelectSingleNode("filters");

            foreach (XmlNode node in filters.SelectNodes("filter"))
            {
                if (node.SelectSingleNode("name") == null)
                {
                    continue;
                }

                var filter = new Classes.Filter();
                filter.name = node.SelectSingleNode("name").InnerText;

                if (node.SelectSingleNode("value") != null)
                {
                    filter.value = node.SelectSingleNode("value").InnerText;
                }

                flist.Add(filter);
            }

            return(flist);
        }
Exemplo n.º 2
0
        public static void WriteToXml(Classes.FList flist)
        {
            try
            {
                string XmlPath = @"Sessions\LastSession.xml";
                if (!Directory.Exists(Path.Join(XmlPath, "..")))
                {
                    Directory.CreateDirectory(Path.Join(XmlPath, ".."));
                }
                if (File.Exists(XmlPath))
                {
                    File.Delete(XmlPath);
                }
                XmlWriter xmlWriter = XmlWriter.Create(XmlPath); //@"..\Sessions\LastSession.xml"

                xmlWriter.WriteStartDocument();
                xmlWriter.WriteStartElement("filters");

                foreach (var item in flist.flist)
                {
                    xmlWriter.WriteStartElement("filter");

                    xmlWriter.WriteStartElement("name");
                    xmlWriter.WriteString(item.name);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteStartElement("value");
                    xmlWriter.WriteString(item.value);
                    xmlWriter.WriteEndElement();

                    xmlWriter.WriteEndElement();
                }

                xmlWriter.WriteEndDocument();
                xmlWriter.Close();
            }
            catch (Exception ex)
            {
                Controllers.LogController.LogError(String.Format(Controllers.HelperController.GetMessage("File.Err.WriteToXml").txt, ex.ToString()));
                throw;
            }
        }
Exemplo n.º 3
0
 //#################################################################################################
 public static void SaveSession(Classes.FList flist)
 {
     Controllers.FileController.WriteToXml(flist);
 }