private void ThenThereIsAProfilingDataTableForEachPaymentFundingLine(params FundingLine[] fundingLines)
        {
            _importContext.Profiling
            .Should()
            .NotBeNull();

            foreach (FundingLine fundingLine in fundingLines)
            {
                _importContext.Profiling.ContainsKey(fundingLine.TemplateLineId)
                .Should()
                .BeTrue();

                IDataTableBuilder <PublishedProviderVersion> dataTableBuilder = _importContext.Profiling[fundingLine.TemplateLineId];

                dataTableBuilder
                .Should()
                .NotBeNull();

                dataTableBuilder
                .DataTable?
                .Rows
                .Count
                .Should()
                .Be(1);
            }
        }
Exemple #2
0
        public IEnumerable<TableInfo> GetTables(OleDbConnection conn, IDataTableBuilder databaseDataTableBuilder)
        {
            var tablePrefix = GetTablePrefix(_projectFile);
            var tables = new List<TableInfo>();

            var defaultTableInfos = GetDefaultTableInfos().ToList();
            tables.AddRange(defaultTableInfos.Where(t => t.OutputTableName == ProjectSettingsName));

            // all columns not nullable
            // no primary keys found with OleDbSchemaGuid.Primary_Keys
            // column flags aren't super helpful (IsLong or IsFixedLength but can tell by char with int maxlen)
            // none of the columns have default values

            var allIndexes = GetAllIndexes(conn);

            foreach (var tableName in GetTableNames(conn).Where(t => t.StartsWith(tablePrefix)))
            {
                _logger.Info("Processing {0} table...", tableName);

                var tableInfo = GetTableInfo(defaultTableInfos, tableName, tablePrefix);
                tableInfo.SetDataTableBuilder(databaseDataTableBuilder);

                tables.Add(tableInfo);

                AddIndexes(tableInfo, allIndexes.DefaultView);

                foreach (var row in GetTableColumns(conn, tableName).AsEnumerable())
                {
                    AddColumn(tableInfo, row);
                }
            }

            return tables;
        }
Exemple #3
0
        public TmgProject(string projectFile, IDataTableBuilder iniFileDataTableBuilder, ILogger logger)
        {
            _logger = logger;
            _iniFileDataTableBuilder = iniFileDataTableBuilder;

            ValidateProjectFile(projectFile);

            _projectFile = projectFile;
        }
Exemple #4
0
        public TmgProject(string projectFile, IDataTableBuilder iniFileDataTableBuilder, ILogger logger)
        {
            _logger = logger;
            _iniFileDataTableBuilder = iniFileDataTableBuilder;

            ValidateProjectFile(projectFile);

            _projectFile = projectFile;
        }
Exemple #5
0
 public TableInfo(string key, string name)
 {
     _dataTableBuilder = null;
     _uniqueColumns = new List<List<string>>();
     _indexes = new List<IndexInfo>();
     _columns = new List<ColumnInfo>();
     Key = key;
     OutputTableName = name;
     _ignoredColumns = new List<string> {"tt", "ispicked"};
     _overriddenDbTypes = new Dictionary<string, OleDbType>();
     _overrideMaxLengths = new Dictionary<string, long>();
 }
Exemple #6
0
 public TableInfo(string key, string name)
 {
     _dataTableBuilder = null;
     _uniqueColumns    = new List <List <string> >();
     _indexes          = new List <IndexInfo>();
     _columns          = new List <ColumnInfo>();
     Key             = key;
     OutputTableName = name;
     _ignoredColumns = new List <string> {
         "tt", "ispicked"
     };
     _overriddenDbTypes  = new Dictionary <string, OleDbType>();
     _overrideMaxLengths = new Dictionary <string, long>();
 }
        public async Task ImportDataTable <T>(IDataTableBuilder <T> dataTableBuilder)
        {
            if (dataTableBuilder.HasNoData)
            {
                return;
            }

            await using SqlConnection connection = NewOpenConnection();
            using SqlBulkCopy bulkCopy           = new SqlBulkCopy(connection)
                  {
                      DestinationTableName = dataTableBuilder.TableName
                  };

            await bulkCopy.WriteToServerAsync(dataTableBuilder.DataTable);
        }
Exemple #8
0
 public TableInfo SetDataTableBuilder(IDataTableBuilder dataTableBuilder)
 {
     _dataTableBuilder = dataTableBuilder;
     return(this);
 }
Exemple #9
0
 public TableInfo SetDataTableBuilder(IDataTableBuilder dataTableBuilder)
 {
     _dataTableBuilder = dataTableBuilder;
     return this;
 }