private void convertDb2() { try { LogText.Text = ""; ConvertButton.IsEnabled = false; DB2Converter converter = new DB2Converter(MappingFileText.Text, InputDirectoryText.Text, Db2Settings.Database, Db2Settings.Username, Db2Settings.Password, Db2Settings.MoveDirectory, SchemaFileText.Text, SchematronFileText.Text); converter.LogEvent += delegate(string logText) { Dispatcher.Invoke(() => { LogText.Text += logText + "\n"; }); }; converter.ConversionComplete += delegate() { Dispatcher.Invoke(() => { MessageBox.Show("Done!"); EnableConvertButton(); }); }; Thread thr = new Thread(new ThreadStart(converter.Convert)); thr.Start(); } catch (Exception ex) { LogText.Text += "ERROR: " + ex.Message; } }
static void Main(string[] args) { var result = Parser.Default.ParseArguments <XLSXOptions, MDBOptions, DB2Options>(args) .WithParsed <XLSXOptions>(o => { XlsxConverter xlsxConverter = new XlsxConverter(o.MappingConfig, o.InputDirectory, o.OutputDirectory, o.MoveDirectory, o.SchemaPath, o.SchematronPath); xlsxConverter.LogEvent += delegate(string logText) { Console.WriteLine(logText); }; xlsxConverter.Convert(); }) .WithParsed <MDBOptions>(o => { MSAccessConverter mdbConverter = new MSAccessConverter(o.MappingConfig, o.InputDirectory, o.OutputDirectory, o.MoveDirectory, o.SchemaPath, o.SchematronPath); mdbConverter.LogEvent += delegate(string logText) { Console.WriteLine(logText); }; mdbConverter.Convert(); }) .WithParsed <DB2Options>(o => { DB2Converter db2Converter = new DB2Converter(o.MappingConfig, o.InputDirectory, o.Database, o.Username, o.Password, o.MoveDirectory, o.SchemaPath, o.SchematronPath); db2Converter.LogEvent += delegate(string logText) { Console.WriteLine(logText); }; db2Converter.Convert(); }); #if DEBUG Console.WriteLine("Press <enter> to continue..."); Console.ReadLine(); #endif }