//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(); } } }
private void bLoad_Click(object sender, EventArgs e) { try { bLoad.Enabled = false; bLoad.Text = "Loading..."; if (cbDataSource.SelectedIndex == 0) { string dataObjectPath = Common.BuildPath(GenericTemplate.moduleParams.DataPath, GenericTemplate.constModuleDataFolder, GenericTemplate.constDataObjectsFolder); string dataObjectName = lbDataObjectList.Items[lbDataObjectList.SelectedIndex].ToString(); dataObjectName += ".xml"; RowCollectionIO rowCollectionIO = new RowCollectionIO(rowCollectionMenager, dataObjectPath + dataObjectName); rowCollectionIO.Load(); } else if (cbDataSource.SelectedIndex == 1) { // Input data from clipboard // new parser will add rows to rowCollection object TextParser textParser = new TextParser(rowCollectionMenager); textParser.AutomaticAddToRowCollectionMenager_ClipboardSource(tbRegexColumnSpliter.Text, tbRegexRowSpliter.Text, cbRegexFirstColumnAsColumnName.Checked); } else if (cbDataSource.SelectedIndex == 2) { // Input data from xml file //XMLParser xmlParser = new XMLParser(rowCollectionMenager, tbSourceFile.Text, int.Parse(tbSourceXMLStartDepth.Text)); XMLParser2 xmlParser = new XMLParser2(rowCollectionMenager, tbSourceFile.Text, tbXPath.Text); } else if (cbDataSource.SelectedIndex == 5) { FolderParser folderParser = new FolderParser(rowCollectionMenager); folderParser.AutomaticAddToRowCollectionMenager_FolderSource(tbFolderInputPath.Text, tbFolderInputFolderMatcher.Text, tbFolderInputColumnRegex.Text, cbFolderInputLookSubfolders.Checked); } else if (cbDataSource.SelectedIndex == 6) { FileParser folderParser = new FileParser(rowCollectionMenager); folderParser.AutomaticAddToRowCollectionMenager_FileSource(tbFileInputFolder.Text, tbFileInputFolderMatcher.Text, tbFileInputFileMatcher.Text, tbFileInputColumnSpliter.Text, cbFileInputSubfolders.Checked); } else { MessageBox.Show("Select data source"); } // save settings SaveSettingsToSettingsMenager(); } catch (Exception ex) { ModuleLog.Write(ex, this, "btnLoad_Click", ModuleLog.LogType.ERROR); } this.Close(); }
private void DestinationObjectData_CompareStrings(string templateHeader, string templateBody, string templateFooter, RowCollectionRow row, int rowID, int rowMax) { TextParser textParser = new TextParser(outputMenagerSettings.rowCollectionMenager); textParser.AutomaticAddToRowCollectionMenager(templateBody, outputMenagerSettings.columnSpliterRegEx, outputMenagerSettings.rowSpliterRegEx); //ObjectRow objectRow = new ObjectRow(new string[] { templateBody }); //outputMenagerSettings.rowCollectionMenager.AddRow(objectRow); }