private static void RunTable(object sender, ExecutedRoutedEventArgs e) { if (UIContext.Database != null) { BackgroundWorker worker = new BackgroundWorker(); MainWindow mainWindow = (MainWindow)sender; mainWindow.loadingAnimation.Visibility = Visibility.Visible; worker.DoWork += delegate(object s, DoWorkEventArgs args) { object[] data = args.Argument as object[]; IRunService runService = ObjectLocator.GetInstance <IRunService>(); ObfuscationResult result = runService.ObfuscateTable(UIContext.Database.ConnectionString, data[0] as Table); args.Result = result; }; worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args) { mainWindow.loadingAnimation.Visibility = Visibility.Collapsed; ObfuscationResult result = args.Result as ObfuscationResult; MessageBox.Show(mainWindow, string.Format("Finished table obfuscation in {0}", result.TimeElapsed), "Table Obfuscation Finished", MessageBoxButton.OK, MessageBoxImage.Information); IReportService reportService = ObjectLocator.GetInstance <IReportService>(); //string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); //path = path.Replace("file:\\", ""); string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal); path = path + "\\Dafuscator"; if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } path = path + string.Format("\\TableObfuscationReport_{0}_{1}_{2}-{3}_{4}.txt", DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, DateTime.Now.Hour, DateTime.Now.Minute); reportService.GenerateReportForObfucsationResult(result, path); }; worker.RunWorkerAsync(new object[] { mainWindow.ColumnsGrid.SelectedTable }); } else { MessageBox.Show("There is no open database project, cannot obfuscate database.", "Error Saving", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }