Beispiel #1
0
        private void ImportFiles(string folderPath)
        {
            RowCollection    rowCollection;
            Regex            regex;
            Match            match;
            RowCollectionRow objectRow;

            string[] fileColumns;
            string[] fileList = Directory.GetFiles(folderPath);

            regex = new Regex(regexFileMatcher, RegexOptions.IgnoreCase);

            foreach (string file in fileList)
            {
                match = regex.Match(file);

                if (match.Length > 0)
                {
                    fileColumns   = SplitRow(file, regexSpliterColumn);
                    rowCollection = rowCollectionMenager.GetRowCollectionObjectFromCellNumber(3 + fileColumns.Length, true);
                    objectRow     = new RowCollectionRow(rowCollection, Common.MargeTwoStringArray(GetDefaultColumns(file), fileColumns));
                    rowCollection.Rows.Add(objectRow);
                }
            }
        }
        private void BrowseFolders(string path)
        {
            RowCollection    rowCollection;
            RowCollectionRow objectRow;
            Regex            regex;
            Match            match;

            string[] folderColumns;
            int      counter = 0;

            string[] folderList = Directory.GetDirectories(path);

            // define regex matcher
            regex = new Regex(regexFolderMatcher, RegexOptions.IgnoreCase);
            foreach (string folder in folderList)
            {
                match = regex.Match(folder);

                if (match.Length > 0)
                {
                    ModuleLog.Write(new string[] { "Folder: " + path, "Match: yes" }, this, "BrowseFolders", ModuleLog.LogType.DEBUG);
                    folderColumns = FolderParser.SplitRow(folder, regexSpliterColumn);
                    // new rowcollection
                    rowCollection = rowCollectionMenager.GetRowCollectionObjectFromCellNumber(2 + folderColumns.Length, true);

                    objectRow = new RowCollectionRow(rowCollection, Common.MargeTwoStringArray(GetDefaultColumns(folder), folderColumns));
                    //rowCollectionMenager.AddRow(objectRow);
                    rowCollection.Rows.Add(objectRow);
                    if (subfolders == true)
                    {
                        BrowseFolders(folder);
                    }
                }
                else
                {
                    // dont import folder but browse childs
                    if (subfolders == true)
                    {
                        ModuleLog.Write(new string[] { "Folder: " + path, "Match: no" }, this, "BrowseFolders", ModuleLog.LogType.DEBUG);
                        BrowseFolders(folder);
                    }
                    else
                    {
                        ModuleLog.Write(new string[] { "Folder: " + path, "Match: skip" }, this, "BrowseFolders", ModuleLog.LogType.DEBUG);
                    }
                }
                if ((counter++ % 1000) == 0)
                {
                    System.Windows.Forms.Application.DoEvents();
                }
            }
        }
Beispiel #3
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();
                }
            }
        }