Example #1
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);
     }
 }
Example #2
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);
            }
        }
Example #3
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;
 }
Example #4
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);
            }
        }
Example #5
0
 private void LoadDataPlan(DataPlan dataPlan)
 {
     _dataPlan = dataPlan;
     tableTabControl.CurrentDataPlan = _dataPlan;
     SetWindowTitle();
 }
Example #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);
            }
        }
Example #7
0
 public ExportForm(DataPlan dataPlan)
 {
     _dataPlan = dataPlan;
     InitializeComponent();
 }