Exemplo n.º 1
0
        public static bool Insert(ref LogUnit Log)
        {
            if (!CheckDocument())
            {
                return(false);
            }

            XmlElement root = xmlDoc.DocumentElement;
            XmlElement log  = xmlDoc.CreateElement("Log");

            XmlElement id = xmlDoc.CreateElement("id");

            id.InnerText = freeID.ToString();
            Log.id       = freeID;
            freeID       = freeID + 1;
            log.AppendChild(id);

            XmlElement name = xmlDoc.CreateElement("name");

            name.InnerText = Log.message;
            log.AppendChild(name);



            root.AppendChild(log);

            SaveDocument();

            return(true);
        }
Exemplo n.º 2
0
 public static void Fill(XmlNode logNode, ref LogUnit log)
 {
     foreach (XmlNode child in logNode.ChildNodes)
     {
         if (child.Name == "id")
         {
             log.id = int.Parse(child.InnerText);
         }
         if (child.Name == "name")
         {
             log.message = child.InnerText;
         }
     }
 }
Exemplo n.º 3
0
        public static Collection <LogUnit> SelectAll()
        {
            Collection <LogUnit> Logs = new Collection <LogUnit>();

            if (!CheckDocument())
            {
                return(Logs);
            }

            XmlNode     root = xmlDoc.DocumentElement;
            XmlNodeList list = root.SelectNodes("Log");

            foreach (XmlNode logNode in list)
            {
                LogUnit log = new LogUnit();
                Fill(logNode, ref log);

                Logs.Add(log);
            }

            return(Logs);
        }