Exemple #1
0
 private void LoadOptions(nDumpOptions options)
 {
     SqlScriptDirTextBox.Text = options.SqlDirectory;
     csvDirTextBox.Text = options.CsvDirectory;
     ApplyFilterCheckBox.Checked = options.ApplyFilters;
     ExportCheckBox.Checked = options.Export;
     ImportCheckBox.Checked = options.Import;
     exportsqlConnection.ConnectionString = options.SourceConnectionString;
     ImportSqlConnection.ConnectionString = options.TargetConnectionString;
     TransformCheckBox.Checked = options.Transform;
 }
Exemple #2
0
 private void ImportIfSelected(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
 {
     if (!nDumpOptions.Import) return;
     try
     {
         var importer = new SqlDataImporter(logger,
                                            new QueryExecutor(nDumpOptions.TargetConnectionString),
                                            new IncrementingNumberSqlScriptFileStrategy(nDumpOptions.SqlDirectory));
         importer.RemoveDataAndImportFromSqlFiles(dataPlan.DataSelects);
     }
     catch (Exception ex)
     {
         throw new nDumpApplicationException("Import Of Sql Failed.",ex);
     }
 }
Exemple #3
0
        private void BulkDeleteIfSelected(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
        {
            if (!nDumpOptions.BulkDelete) return;
            try
            {

                var importer = new CsvDataImporter(logger,
                                                   new QueryExecutor(nDumpOptions.TargetConnectionString),
                                                   nDumpOptions.CsvDirectory, nDumpOptions.Delimiter);
                importer.RemoveDataFromSqlFiles(dataPlan.DataSelects);
            }
            catch (Exception ex)
            {
                throw new nDumpApplicationException("Bulk Delete Of Sql Failed.", ex);
            }
        }
Exemple #4
0
 public int ExecuteDataPlan(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
 {
     try
     {
         ExportIfSelected(nDumpOptions, logger, dataPlan);
         TransformIfSelected(nDumpOptions, logger, dataPlan);
         ImportIfSelected(nDumpOptions, logger, dataPlan);
         BuklInsertIfSelected(nDumpOptions, logger, dataPlan);
     }
     catch (Exception ex)
     {
         logger.Log(ex);
         return -1;
     }
     return 0;
 }
Exemple #5
0
        private void ExportIfSelected(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
        {
            if (!nDumpOptions.Export) return;

            try
            {
                var queryExecutor = new QueryExecutor(nDumpOptions.SourceConnectionString);
                ISelectionFilteringStrategy filteringStrategy =
                    nDumpOptions.ApplyFilters
                        ? (ISelectionFilteringStrategy) new UseFilterIfPresentStrategy(queryExecutor, logger)
                        : new IgnoreFilterStrategy();

                var exporter = new SqlDataExporter(logger, filteringStrategy,
                                                   new CsvGenerator(logger, filteringStrategy, queryExecutor,
                                                                    nDumpOptions.CsvDirectory, nDumpOptions.Delimiter));
                exporter.ExportToCsv(dataPlan.SetupScripts, dataPlan.DataSelects);
            }
            catch (Exception ex)
            {
                throw new nDumpApplicationException("Export To Csv Failed.", ex);
            }
        }
Exemple #6
0
        private void TransformIfSelected(nDumpOptions nDumpOptions, ILogger logger, DataPlan dataPlan)
        {
            if (!nDumpOptions.Transform) return;

            try
            {
                var transformer = new DataTransformer(nDumpOptions.SqlDirectory, nDumpOptions.CsvDirectory,
                                                      logger, nDumpOptions.Delimiter);
                transformer.ConvertCsvToSql(dataPlan.DataSelects);
            }
            catch (Exception ex)
            {
                throw new nDumpApplicationException("Export To Csv Failed.", ex);
            }
        }