Example #1
0
        static void Main(string[] args)
        {
            List <LFNode> lfList = new List <LFNode>();
            // Concentra document read code is by Doug Cullum.
            StreamReader sr = null;

            try
            {
                sr = File.OpenText(args[0]);
                string[] delimiterValues = { "<node ", "template=\"", "text=\"", "ID=\"", "Log=\"", "ShowCheckBox=\"", "EndLevel2Code=\"", "PID=\"", "Doc_Link=\"", "CID=\"", "Book=\"", " />" };
                string   text_line;

                string[] words = null;

                while ((text_line = sr.ReadLine()) != null)
                {
                    words = text_line.Split(delimiterValues, StringSplitOptions.RemoveEmptyEntries);

                    //if the row is formatted correctly, add to data table
                    //each row is split into the individual elements then put into their appropriate column within the DataTable

                    if (words.Length >= 7)
                    {
                        for (int i = 0; i < words.Length; i++)
                        {
                            words[i] = words[i].TrimEnd(new char[] { ' ', '\"' });
                            // Console.WriteLine(words[i]);
                        }
                        LFNode lf = new LFNode(words);
                        lfList.Add(lf);
                        //Add the words array to the data table
                        // xmlTbl.Rows.Add(words);
                        //Console.WriteLine(lf.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            Console.WriteLine("Nodes read");
            Console.ReadKey();

            foreach (LFNode l in lfList)
            {
                for (int i = 0; i < lfList.Count(); i++)
                {
                    if (l.PID == lfList[i].ID)
                    {
                        lfList[i].Children.Add(l.ID);
                        Console.Write("Derp.");
                    }
                }
            }

            for (int i = 0; i < lfList.Count(); i++)
            {
                /*
                 * if (lfList[i].ShowCheckBox != "False")
                 * {
                 *  for (int j = 0; j < lfList.Count(); j++)
                 *  {
                 *      if (lfList[j].ID == lfList[i].PID)
                 *      {
                 *          Console.WriteLine(lfList[j].Text);
                 *      }
                 *  }
                 *  Console.WriteLine("-- " + lfList[i].Text);
                 *  Console.WriteLine(lfList[i].ShowCheckBox);
                 * }
                 **/
                if (lfList[i].Children.Count == 0)
                {
                    Console.WriteLine(lfList[i].ToString());
                    foreach (string s in lfList[i].Children)
                    {
                        Console.WriteLine(s);
                    }
                    Console.ReadKey();
                }
            }
            Console.ReadKey();
        }
Example #2
0
        static void Main(string[] args)
        {
            List<LFNode> lfList = new List<LFNode>();
            // Concentra document read code is by Doug Cullum.
            StreamReader sr = null;
            try
            {
                sr = File.OpenText(args[0]);
                string[] delimiterValues = { "<node ", "template=\"", "text=\"", "ID=\"", "Log=\"", "ShowCheckBox=\"", "EndLevel2Code=\"", "PID=\"", "Doc_Link=\"", "CID=\"", "Book=\"", " />" };
                string text_line;

                string[] words = null;

                while ((text_line = sr.ReadLine()) != null)
                {
                    words = text_line.Split(delimiterValues, StringSplitOptions.RemoveEmptyEntries);

                    //if the row is formatted correctly, add to data table
                    //each row is split into the individual elements then put into their appropriate column within the DataTable

                    if (words.Length >= 7)
                    {

                        for (int i = 0; i < words.Length; i++)
                        {
                            words[i] = words[i].TrimEnd(new char[] { ' ', '\"' });
                            // Console.WriteLine(words[i]);

                        }
                        LFNode lf = new LFNode(words);
                        lfList.Add(lf);
                        //Add the words array to the data table
                        // xmlTbl.Rows.Add(words);
                        //Console.WriteLine(lf.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            Console.WriteLine("Nodes read");
            Console.ReadKey();

            foreach (LFNode l in lfList)
            {
                for (int i = 0; i < lfList.Count(); i++)
                {
                    if (l.PID == lfList[i].ID)
                    {
                        lfList[i].Children.Add(l.ID);
                        Console.Write("Derp.");
                    }
                }
            }

            for (int i = 0; i < lfList.Count(); i++)
            {
                /*
                if (lfList[i].ShowCheckBox != "False")
                {
                    for (int j = 0; j < lfList.Count(); j++)
                    {
                        if (lfList[j].ID == lfList[i].PID)
                        {
                            Console.WriteLine(lfList[j].Text);
                        }
                    }
                    Console.WriteLine("-- " + lfList[i].Text);
                    Console.WriteLine(lfList[i].ShowCheckBox);
                }
                 **/
                if (lfList[i].Children.Count == 0)
                {
                    Console.WriteLine(lfList[i].ToString());
                    foreach (string s in lfList[i].Children)
                    {
                        Console.WriteLine(s);
                    }
                    Console.ReadKey();
                }
            }
            Console.ReadKey();
        }