Beispiel #1
0
        private void ProcessXML(XmlNodeList xmlNodeList, UberTools.Modules.GenericTemplate.RowCollectionNS.RowCollection parentRowCollection)
        {
            RowCollection    rowCollection = null;
            RowCollectionRow objectRow;
            string           rowCollectionName = null;

            foreach (XmlNode node in xmlNodeList)
            {
                if (node.NodeType == XmlNodeType.Element)
                {
                    rowCollectionName = FindXPath(node);
                    rowCollection     = rowCollectionMenager[rowCollectionName];
                    if (rowCollection == null)
                    {
                        rowCollection = rowCollectionMenager.CreateRowCollection(node.Attributes.Count, rowCollectionName);
                    }

                    // check if parent row collection is not null, only first call is null
                    if (parentRowCollection != null)
                    {
                        // add this row collection to parent chilld list
                        parentRowCollection.AddChild(rowCollection);
                    }

                    // make new instance of ObjectRow object
                    objectRow = new RowCollectionRow(rowCollection, GetAllAttribites(node));
                    // if node have inner text
                    if (node.InnerText != "")
                    {
                        // add extra columnt to objectRow object
                        objectRow.AddColl(new RowCollectionColumn(node.InnerText));
                    }
                    // add new row to row collection
                    rowCollection.Rows.Add(objectRow);

                    //ModuleLog.Write(GetAllAttribites(node), this, "ProcessXML", ModuleLog.LogType.INFO);

                    // recurse chilld
                    ProcessXML(node.ChildNodes, rowCollection);
                }
            }
        }
Beispiel #2
0
        //public void AutomaticAddToRowCollectionMenager_ClipboardSource(string regexSpliterColumn, string regexSpliterRow)
        //{
        //    int counter = 0;
        //    string[] lineList = TextParser.SplitRow(System.Windows.Forms.Clipboard.GetText(), regexSpliterRow);

        //    if (System.Windows.Forms.Clipboard.ContainsText())
        //    {
        //        foreach (string line in lineList)
        //        {
        //            rowCollectionMenager.AddRow(new ObjectRow(null, TextParser.SplitRow(line, regexSpliterColumn)));
        //            if ((counter++ % 1000) == 0)
        //            {
        //                System.Windows.Forms.Application.DoEvents();
        //            }
        //        }
        //    }
        //}

        public void AutomaticAddToRowCollectionMenager_ClipboardSource(string regexSpliterColumn, string regexSpliterRow, bool firstRowAsColumnName)
        {
            RowCollection    rowCollection;
            RowCollectionRow row;

            string[] lineList;
            string[] columnList;
            int      counter = 0;

            // Get array of rows
            lineList = TextParser.SplitRow(System.Windows.Forms.Clipboard.GetText(), regexSpliterRow);

            // If row list is null then exit
            if (lineList == null)
            {
                return;
            }

            // Go through all rows
            foreach (string line in lineList)
            {
                // Split row in array of columns
                columnList = TextParser.SplitRow(line, regexSpliterColumn);
                // get rowCollection object
                rowCollection = rowCollectionMenager.GetRowCollectionObjectFromCellNumber(columnList.Length, false);
                // check if rowCollection is null
                if (rowCollection == null)
                {
                    // create new rowCollecion object
                    //rowCollection = new RowCollection(columnList.Length, RowCollection.const_prefix + columnList.Length.ToString());
                    rowCollection = rowCollectionMenager.CreateRowCollection(columnList.Length);

                    // define column names
                    if (firstRowAsColumnName == true)
                    {
                        for (int i = 0; i < columnList.Length; i++)
                        {
                            rowCollection.Columns[i] = columnList[i];
                        }
                    }
                    else
                    {
                        // create new row object from column array
                        row = new RowCollectionRow(rowCollection, columnList);
                        // add row to rowCollection
                        rowCollection.Rows.Add(row);
                    }
                }
                else
                {
                    // create new row object from column array
                    row = new RowCollectionRow(rowCollection, columnList);
                    // add row to rowCollection
                    rowCollection.Rows.Add(row);
                }
                //rowCollectionMenager.AddRow(new ObjectRow(null, TextParser.SplitRow(line, regexSpliterColumn)));
                if ((counter++ % 1000) == 0)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
        }