Exemplo n.º 1
0
        private void ReadConcentraFile(string file)
        {
            // Concentra document read code is by Doug Cullum.
            StreamReader sr = null;

            try
            {
                sr = File.OpenText(file);
                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++)
                        {
                            //MessageBox.Show(words[i]);
                            words[i] = words[i].TrimEnd(new char[] { ' ', '\"' });
                        }
                        LFNode lf = new LFNode(words);
                        lfList.Add(lf);
                        if (lf.ID != "")
                        {
                            try
                            {
                                lfDict.Add(lf.ID, lf);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.ToString());
                            }
                        }
                        //Add the words array to the data table
                        // xmlTbl.Rows.Add(words);
                        //Console.WriteLine(lf.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 2
0
 public LFTreeNode(LFNode lf)
 {
     this.Text = lf.Text;
 }
Exemplo n.º 3
0
        private void ReadConcentraFileV2(string file)
        {
            /// Code provided by Doug Cullum
            //string firstNodeText = "";
            StreamReader freader = null;

            string[] splitStuff = { "template=\"", "text=\"", "ID=\"", "Log=\"", "ShowCheckBox=\"", "EndLevel2Code=\"", "PID=\"", "Doc_Link=\"", "Tree=\"", "Productline=\"", "Node=\"", "CID=\"", "Book=\"" };
            string   template = "", text = "", id = "", log = "", showCheckBox = "", endLevel2Code = "", pid = "", doc_Link = "", cid = "", tree = "", productLine = "", node = "", book = "";

            try
            {
                freader = File.OpenText(file);

                string text_line;

                string[] words = null;
                // bool firstNode = true;

                while ((text_line = freader.ReadLine()) != null)
                {
                    template      = "";
                    text          = "";
                    id            = "";
                    log           = "";
                    showCheckBox  = "";
                    endLevel2Code = "";
                    pid           = "";
                    doc_Link      = "";
                    book          = "";
                    cid           = "";
                    tree          = "";
                    productLine   = "";
                    node          = "";

                    int endPos = 0;
                    for (int i = 0; i < splitStuff.Length && text_line.StartsWith("<node "); i++)
                    {
                        string[] split = new string[] { splitStuff[i] };

                        words = text_line.Split(split, StringSplitOptions.None);
                        string temp = "";
                        if (words.Length > 1)
                        {
                            endPos = words[1].IndexOf("=\""); //locate the next occurance of the =" string which indicates the next XML attribute
                            if (endPos < 0)                   //When this is less than 0, it means that it hit the end of the text_Line
                            {
                                endPos = words[1].IndexOf("\"  />");
                                temp   = words[1].Substring(0, endPos);
                                //will contain actual needed text, so skip to switch from here
                            }
                            else
                            {
                                temp   = words[1].Substring(0, endPos);
                                endPos = temp.LastIndexOf("\" ");
                            }
                            if (endPos < 0)
                            {
                                endPos = 0;
                            }
                        }
                        else
                        {
                            endPos = 0;
                        }

                        switch (splitStuff[i])
                        {
                        case "template=\"":
                            template = temp.Substring(0, endPos);
                            break;

                        case "text=\"":
                            text = temp.Substring(0, endPos);
                            break;

                        case "ID=\"":
                            id = temp.Substring(0, endPos);
                            break;

                        case "Log=\"":
                            log = temp.Substring(0, endPos);
                            break;

                        case "ShowCheckBox=\"":
                            showCheckBox = temp.Substring(0, endPos);
                            break;

                        case "EndLevel2Code=\"":
                            endLevel2Code = temp.Substring(0, endPos);
                            break;

                        case "PID=\"":
                            pid = temp.Substring(0, endPos);
                            break;

                        case "Doc_Link=\"":
                            doc_Link = temp.Substring(0, endPos);
                            break;

                        case "Book=\"":
                            book = temp.Substring(0, endPos);
                            break;

                        case "CID=\"":
                            cid = temp.Substring(0, endPos);
                            break;

                        case "Tree=\"":
                            tree = temp.Substring(0, endPos);
                            break;

                        case "Productline=\"":
                            productLine = temp.Substring(0, endPos);
                            break;

                        case "Node=\"":
                            node = temp.Substring(0, endPos);
                            break;
                        }
                    }

                    //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 (text_line.Split(splitStuff, StringSplitOptions.RemoveEmptyEntries).Length >= 7)
                    {
                        LFNode lf = new LFNode(template, text, id, log, showCheckBox, endLevel2Code, pid, doc_Link, cid, book, tree, productLine, node);
                        lfList.Add(lf);
                        if (lf.ID != "")
                        {
                            try
                            {
                                lfDict.Add(lf.ID, lf);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.ToString());
                            }
                        }
                    }
                }
            }
            catch (FileLoadException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                // must explicitly close the readers
                freader.Close();
            }
        }
Exemplo n.º 4
0
 public LFTreeNode(LFNode lf)
 {
     this.Text = lf.Text;
 }
Exemplo n.º 5
0
        private void ReadConcentraFileV2(string file)
        {
            /// Code provided by Doug Cullum
            //string firstNodeText = "";
            StreamReader freader = null;
            string[] splitStuff = { "template=\"", "text=\"", "ID=\"", "Log=\"", "ShowCheckBox=\"", "EndLevel2Code=\"", "PID=\"", "Doc_Link=\"", "Tree=\"", "Productline=\"","Node=\"", "CID=\"", "Book=\"" };
            string template = "", text = "", id = "", log = "", showCheckBox = "", endLevel2Code = "", pid = "", doc_Link = "", cid = "", tree = "", productLine = "", node="", book = "";

            try
            {
                freader = File.OpenText(file);

                string text_line;

                string[] words = null;
                // bool firstNode = true;

                while ((text_line = freader.ReadLine()) != null )
                {
                    template = "";
                    text = "";
                    id = "";
                    log = "";
                    showCheckBox = "";
                    endLevel2Code = "";
                    pid = "";
                    doc_Link = "";
                    book = "";
                    cid = "";
                    tree = "";
                    productLine = "";
                    node = "";

                    int endPos = 0;
                    for (int i = 0; i < splitStuff.Length && text_line.StartsWith("<node "); i++)
                    {
                        string[] split = new string[] { splitStuff[i] };

                        words = text_line.Split(split, StringSplitOptions.None);
                        string temp = "";
                        if (words.Length > 1)
                        {
                            endPos = words[1].IndexOf("=\""); //locate the next occurance of the =" string which indicates the next XML attribute
                            if (endPos < 0) //When this is less than 0, it means that it hit the end of the text_Line
                            {
                                endPos = words[1].IndexOf("\"  />");
                                temp = words[1].Substring(0, endPos);
                                //will contain actual needed text, so skip to switch from here
                            }
                            else
                            {
                                temp = words[1].Substring(0, endPos);
                                endPos = temp.LastIndexOf("\" ");
                            }
                            if (endPos < 0)
                            {
                                endPos = 0;
                            }
                        }
                        else
                        {
                            endPos = 0;
                        }

                        switch (splitStuff[i])
                        {
                            case "template=\"":
                                template = temp.Substring(0, endPos);
                                break;
                            case "text=\"":
                                text = temp.Substring(0, endPos);
                                break;
                            case "ID=\"":
                                id = temp.Substring(0, endPos);
                                break;
                            case "Log=\"":
                                log = temp.Substring(0, endPos);
                                break;
                            case "ShowCheckBox=\"":
                                showCheckBox = temp.Substring(0, endPos);
                                break;
                            case "EndLevel2Code=\"":
                                endLevel2Code = temp.Substring(0, endPos);
                                break;
                            case "PID=\"":
                                pid = temp.Substring(0, endPos);
                                break;
                            case "Doc_Link=\"":
                                doc_Link = temp.Substring(0, endPos);
                                break;
                            case "Book=\"":
                                book = temp.Substring(0, endPos);
                                break;
                            case "CID=\"":
                                cid = temp.Substring(0, endPos);
                                break;
                            case "Tree=\"":
                                tree = temp.Substring(0, endPos);
                                break;
                            case "Productline=\"":
                                productLine = temp.Substring(0, endPos);
                                break;
                            case "Node=\"":
                                node = temp.Substring(0, endPos);
                                break;
                        }
                    }

                    //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 (text_line.Split(splitStuff, StringSplitOptions.RemoveEmptyEntries).Length >= 7)
                    {

                        LFNode lf = new LFNode(template, text, id, log, showCheckBox, endLevel2Code, pid, doc_Link, cid, book, tree, productLine, node);
                        lfList.Add(lf);
                        if (lf.ID != "")
                        {
                            try
                            {
                                lfDict.Add(lf.ID, lf);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.ToString());
                            }
                        }
                    }
                }
            }
            catch (FileLoadException ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                // must explicitly close the readers
                freader.Close();
            }
        }
Exemplo n.º 6
0
        private void ReadConcentraFile(string file)
        {
            // Concentra document read code is by Doug Cullum.
            StreamReader sr = null;
            try
            {
                sr = File.OpenText(file);
                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++)
                        {
                            //MessageBox.Show(words[i]);
                            words[i] = words[i].TrimEnd(new char[] { ' ', '\"' });

                        }
                        LFNode lf = new LFNode(words);
                        lfList.Add(lf);
                        if (lf.ID != "")
                        {
                            try
                            {
                                lfDict.Add(lf.ID, lf);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show(e.ToString());
                            }
                        }
                        //Add the words array to the data table
                        // xmlTbl.Rows.Add(words);
                        //Console.WriteLine(lf.ToString());
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }