public void RoundTripComparisonTest() { var sw = new Stopwatch(); Debug.WriteLine("Starting Test:"); sw.Start(); var importFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "FolderDTC"); var importDts = new FolderDataTableSet(importFolder) { Id = "Import DataSet", TableList = TableList }; var connStr = DataSerTestHelper.DataDiffConnectionString; Debug.WriteLine(string.Format("Starting import... elpased: {0}", sw.Elapsed)); var importResult = importDts.ImportTables(connStr); Debug.WriteLine(string.Format("Import complete: {0}", sw.Elapsed)); DataSerTestHelper.AssertResult(importResult); Debug.WriteLine(string.Format("Starting export... elpased: {0}", sw.Elapsed)); var exportFolder = TestHelper.ResetFolder("Export"); var exportDts = new DatabaseDataTableSet(connStr) { Id = "Export DataSet", TableList = TableList }; var exportResult = exportDts.ExportTables(exportFolder); Debug.WriteLine(string.Format("export complete: {0}", sw.Elapsed)); DataSerTestHelper.AssertResult(exportResult); Debug.WriteLine("Asserting exported files are the same as the originals..."); AssertFolderContentsAreEqual(importFolder, exportFolder); Debug.WriteLine(string.Format("Total time: {0}", sw.Elapsed)); }
private void cmdOk_Click(object sender, System.EventArgs e) { UiWrap(() => { if (string.IsNullOrEmpty(txtConnectionString.Text)) return; var dts = new DatabaseDataTableSet(txtConnectionString.Text); if (tlvTables.CheckedItems.Count > 0) { dts.TableList = tlvTables.CheckedItems.Cast<ListViewItem>().Select(lvi => lvi.Text).ToList(); } dts.SaveConfig(DtsConfigPath); }, "Ok clicked"); }
public DataValueSearcher(DatabaseDataTableSet databaseDataTableSet) { _databaseDataTableSet = databaseDataTableSet; }
private ReturnValue<DatabaseDataTableSet> GetSource() { var selectedTableNames = lvCompareResults.CheckedItems.Cast<ListViewItem>().Select(lvi => lvi.Text).ToArray(); if (!selectedTableNames.Any()) { return ReturnValue<DatabaseDataTableSet>.FailResult("No tables selected to migrate."); } var source = new DatabaseDataTableSet(txtSourceDb.Text) ; Contract.Assert(source != null); source.TableList = selectedTableNames.ToList(); return ReturnValue<DatabaseDataTableSet>.SuccessResult(source); }
private ReturnValue<string> ExportToWorkingFolder(DatabaseDataTableSet source) { var workingFolder = txtWorkingFolder.Text; return ReturnValue<string>.Wrap(() => { if (!Directory.Exists(workingFolder)) ReturnValue.Abort(string.Format("The working folder '{0}' does not exist.", txtWorkingFolder)); var msg = string.Format("Exporting tables to '{0}'...", workingFolder); ShowStatus(msg); ShowStatus(source.ExportTables(workingFolder), msg); return workingFolder; }, string.Format("Exporting DatatableSet to '{0}.", workingFolder)); }
public static ReturnValue<DataTableSet> FromConfigFile(string fileName, bool loadOnOpen = true) { try { var config = XDocument.Load(fileName); string type = config.Root.Element("Type").Value; DataTableSet dtSet; if (type == "Database") { string connStr = config.Root.Element("ConnectionString").Value; dtSet = new DatabaseDataTableSet(connStr); dtSet.Id = connStr; } else if (type == "Folder") { string folderPath = config.Root.Element("FolderPath").Value; dtSet = new FolderDataTableSet(folderPath); dtSet.Id = folderPath; } else { return ReturnValue<DataTableSet>.FailResult(string.Format("Invalid Type in configration file: {0}", type)); } var dataTablesElement = config.Root.Element("Tables"); if (dataTablesElement != null) { dtSet.TableList = dataTablesElement.Elements("Table").Select(e => e.Value).ToList(); } if (loadOnOpen) { var loadResult = dtSet.Load(); if (!loadResult.Success) return ReturnValue<DataTableSet>.Cascade(loadResult, "Failed to load tables."); } return ReturnValue<DataTableSet>.SuccessResult(dtSet); } catch (Exception ex) { return ReturnValue<DataTableSet>.FailResult(string.Format("Error trying to create DataTableSet from file: {0}", fileName), ex); } }