public static void Process(ProcessingValues processingValues) { foreach (string path in processingValues.MdbFilePaths.DefaultCollectionIfEmpty()) { MdbToTextProcessor.ProcessMdb(processingValues, path); } }
private static void WriteFileForDataTable(ProcessingValues processingValues, DataTable newDataTable) { if (processingValues.OutputFormat.Has(OutputFormat.Xml)) { MdbToTextProcessor.WriteXmlForDataTable(processingValues, newDataTable); } if (processingValues.OutputFormat.Has(OutputFormat.Text)) { MdbToTextProcessor.WriteTextForDataTable(processingValues, newDataTable); } }
private static void WriteOneBigFile(ProcessingValues processingValues, string path, DataSet allTables) { string mdbName = Path.GetFileNameWithoutExtension(path); if (processingValues.OutputFormat.Has(OutputFormat.Xml)) { MdbToTextProcessor.WriteXmlForDataSet(processingValues, allTables, mdbName); } if (processingValues.OutputFormat.Has(OutputFormat.Text)) { MdbToTextProcessor.WriteTextForDataSet(processingValues, allTables, mdbName); } }
private void Process() { if (!this.ValidateInput()) { return; } MdbToTextProcessor.ProcessingValues values = new MdbToTextProcessor.ProcessingValues() { MdbFilePaths = this.GetFilePathsForProcessing(), MdbPath = this.MdbPath, OutputFormat = this.OutputFormat, OutputPath = this.OutputPath, OutputType = this.OutputType, }; MdbToTextProcessor.Process(values); MessageBox.Show(FormMessageStrings.OutputComplete, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private static void ProcessMdb(ProcessingValues processingValues, string path) { using (OleDbConnection connection = new OleDbConnection(string.Format(ProcessingStrings.OledbConnectionStringFormat, path))) { connection.Open(); DataSet allTables = new DataSet(); DataTable schema = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, ProcessingStrings.TableSchemaIdentifier }); foreach (DataRow row in schema.Rows) { DataTable newDataTable = new DataTable(row[ProcessingStrings.TableNameSchemaValue].ToString()); OleDbDataAdapter adapter = new OleDbDataAdapter(string.Format(ProcessingStrings.SqlSelectTableValuesFormat, newDataTable.TableName), connection); adapter.Fill(newDataTable); /* If processing individual files, don't both filling the DataSet with table info. Just process and * move to the next. No need to take up memory holding on to it. */ if (processingValues.OutputType == OutputType.IndividualFiles) { MdbToTextProcessor.WriteFileForDataTable(processingValues, newDataTable); } else { /* REFACTOR: Rather than storing the DataSet in memory and outputting all at the end, I should just append * to an existing file as I loop over the rows. */ allTables.Tables.Add(newDataTable); } } if (processingValues.OutputType == OutputType.OneBigFile) { MdbToTextProcessor.WriteOneBigFile(processingValues, path, allTables); } } }