private void OutputWorkspaceSqlToolStripMenuItemOnClick(object sender, EventArgs e) { if (!PromptToSaveWorkspace()) { return; } using (var dumpWorkspaceDlg = new DumpWorkspaceDlg()) { if (dumpWorkspaceDlg.ShowDialog(TopLevelControl) == DialogResult.Cancel) { return; } Settings.Default.Reload(); using (var fileDialog = new SaveFileDialog { Title = "Export Workspace SQL", Filter = "SQL Files (*.sql)|*.sql|All Files|*.*", FileName = Path.GetFileNameWithoutExtension(Workspace.DatabasePath) + ".sql", InitialDirectory = Settings.Default.ExportResultsDirectory, }) { if (fileDialog.ShowDialog(this) == DialogResult.Cancel) { return; } Settings.Default.ExportResultsDirectory = Path.GetDirectoryName(fileDialog.FileName); Settings.Default.Save(); var workspace = new Workspace(Workspace.DatabasePath); try { Workspace = null; using (var longWaitDialog = new LongWaitDialog(TopLevelControl, "Exporting SQL")) { var databaseDumper = new DatabaseDumper(workspace, dumpWorkspaceDlg.DatabaseTypeEnum, fileDialog.FileName); new LongOperationBroker(databaseDumper.Run, longWaitDialog).LaunchJob(); } } finally { Workspace = OpenWorkspace(workspace.DatabasePath); } } } }
static void Main(string [] args) { var db = TestDatabase.CreateTestDatabase("./test-data"); Console.Write(DatabaseDumper.DumpDatabase(db)); }