Пример #1
0
        public static void AddWordLog(string word, WordLogType type)
        {
            GenerateWordLog();
            //Console.WriteLine(word + "  " + type.ToString());
            string        wordLogPath = GetWordLogPath(DateTime.Now);
            List <string> list        = GetWordLog(wordLogPath, type);

            if (list.Contains(word))
            {
                Console.WriteLine("列表包含");
            }
            else
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(wordLogPath);
                XmlElement root = xdoc.DocumentElement;
                XmlNode    node = xdoc.CreateElement("word");
                node.InnerText = word;
                foreach (XmlElement xelm in root.ChildNodes)
                {
                    //Console.WriteLine(xelm.Name);
                    if (xelm.Name == type.ToString())
                    {
                        xelm.AppendChild(node);
                    }
                }
                xdoc.Save(wordLogPath);
            }
        }
Пример #2
0
 public static int[] GetWorkLoad(int count, WordLogType type)
 {
     //string wordLogPath = GetWordLogPath(DateTime.Now);
     int[] result = new int[count];
     for (int i = 0; i < count; i++)
     {
         List <string> wordlist = GetWordLog(GetWordLogPath(DateTime.Now.AddDays(-(count - i - 1))), type);
         result[i] = wordlist.Count;
     }
     return(result);
 }
Пример #3
0
        public static List <string> GetWordLog(string wordLogPath, WordLogType type)
        {
            List <string> result = new List <string>();

            if (File.Exists(wordLogPath))
            {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(wordLogPath);
                XmlElement root = xdoc.DocumentElement;
                foreach (XmlElement xelm in root.ChildNodes)
                {
                    if (xelm.Name == type.ToString())
                    {
                        foreach (XmlElement xe in xelm.ChildNodes)
                        {
                            result.Add(xe.InnerText);
                        }
                    }
                }
            }
            return(result);
        }