예제 #1
0
        private static void PerformTask(Options options)
        {
            if (!String.IsNullOrEmpty(options.ProjectFile))
            {
                IDatabaseProjectService databaseProjectService = ObjectLocator.GetInstance <IDatabaseProjectService>();
                IEventAggregator        eventAggregator        = ObjectLocator.GetInstance <IEventAggregator>();

                Console.WriteLine(string.Format("Loading the Dafuscator project: {0}", options.ProjectFile));
                Database         db = databaseProjectService.GetDatabaseProject(options.ProjectFile);
                ConnectionString connetionString;

                if (!String.IsNullOrEmpty(options.ConnectionString))
                {
                    connetionString = new ConnectionString(options.ConnectionString);
                }
                else
                {
                    connetionString = db.ConnectionString;
                }
                db.ConnectionString = connetionString;
                eventAggregator.AddListener <StatusUpdateEvent>(e => Console.WriteLine(string.Format("{0}: {1}", DateTime.Now, e.Message)));

                if (!String.IsNullOrEmpty(options.ExportFile))
                {
                    Console.WriteLine(string.Format("Started exporting the Dafuscator project to {0}", options.ExportFile));
                    IExportService exportService = ObjectLocator.GetInstance <IExportService>();
                    exportService.ExportTables(db.Tables, options.ExportFile, connetionString);

                    Console.WriteLine("Finished exporting the Dafuscator project.");
                }
                else
                {
                    Console.WriteLine(string.Format("Started the obfuscation of the {0} database.", db.ConnectionString.DatabaseName));

                    IRunService    runService    = ObjectLocator.GetInstance <IRunService>();
                    IReportService reportService = ObjectLocator.GetInstance <IReportService>();

                    ObfuscationResult result = runService.ObfuscateDatabase(db);

                    string path = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                    path = path + "\\Dafuscator";

                    if (Directory.Exists(path) == false)
                    {
                        Directory.CreateDirectory(path);
                    }

                    path = path +
                           string.Format("\\DatabaseObfuscationReport_{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);

                    Console.WriteLine("Finished the obfuscation process in {0}", result.TimeElapsed);
                }
            }
        }
예제 #2
0
        private static void SaveProject(object sender, ExecutedRoutedEventArgs e)
        {
            if (UIContext.Database != null)
            {
                BackgroundWorker worker = new BackgroundWorker();

                SaveFileDialog dialog = new SaveFileDialog();
                dialog.DefaultExt = ".daf";
                dialog.Filter     = "Dafsucator Projects (.daf)|*.daf";

                bool?result = dialog.ShowDialog();
                if (result == true)
                {
                    MainWindow mainWindow = (MainWindow)sender;
                    mainWindow.loadingAnimation.Visibility = Visibility.Visible;

                    worker.DoWork += delegate(object s, DoWorkEventArgs args)
                    {
                        IDatabaseProjectService databaseProjectService = ObjectLocator.GetInstance <IDatabaseProjectService>();
                        string filePath = args.Argument as string;

                        databaseProjectService.SaveDatabaseProject(UIContext.Database, filePath);
                    };

                    worker.RunWorkerCompleted += delegate(object s, RunWorkerCompletedEventArgs args)
                    {
                        mainWindow.loadingAnimation.Visibility = Visibility.Collapsed;
                    };

                    worker.RunWorkerAsync(dialog.FileName);
                }
            }
            else
            {
                MessageBox.Show("There is no open database project, cannot save.", "Error Saving", MessageBoxButton.OK,
                                MessageBoxImage.Exclamation);
            }
        }
예제 #3
0
        private static void OpenProject(object sender, ExecutedRoutedEventArgs e)
        {
            OpenFileDialog dialog = new OpenFileDialog();

            dialog.DefaultExt = ".daf";
            dialog.Filter     = "Dafsucator Projects (.daf)|*.daf";

            bool?result = dialog.ShowDialog();

            if (result == true)
            {
                string filePath = dialog.FileName;

                IDatabaseProjectService databaseProjectService = ObjectLocator.GetInstance <IDatabaseProjectService>();

                Database db = databaseProjectService.GetDatabaseProject(filePath);
                UIContext.Database = db;

                MainWindow mainWindow = (MainWindow)sender;
                mainWindow.RefreshData();
                mainWindow.ColumnsGrid.Visibility = Visibility.Visible;
            }
        }