Ejemplo n.º 1
0
        private ExtractionInformation CreateExtractionInformation(ICatalogue catalogue, string name, string columnInfoName, string selectSQL)
        {
            var col = catalogue.GetTableInfoList(false).SelectMany(t => t.ColumnInfos).SingleOrDefault(c => c.GetRuntimeName() == columnInfoName);

            if (col == null)
            {
                throw new Exception("Could not find ColumnInfo called '" + columnInfoName + "' in Catalogue " + catalogue);
            }

            var ci = new CatalogueItem(_repos.CatalogueRepository, catalogue, name);

            ci.ColumnInfo_ID = col.ID;
            ci.SaveToDatabase();

            return(new ExtractionInformation(_repos.CatalogueRepository, ci, col, selectSQL));
        }
Ejemplo n.º 2
0
        protected override void SetUp()
        {
            base.SetUp();

            Database = GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer);

            var rootFolder = new DirectoryInfo(TestContext.CurrentContext.TestDirectory);
            var subdir     = rootFolder.CreateSubdirectory("TestsRequiringADle");

            LoadDirectory = LoadDirectory.CreateDirectoryStructure(rootFolder, subdir.FullName, true);

            Clear(LoadDirectory);

            LiveTable = CreateDataset <Demography>(Database, 500, 5000, new Random(190));
            LiveTable.CreatePrimaryKey(new DiscoveredColumn[] {
                LiveTable.DiscoverColumn("chi"),
                LiveTable.DiscoverColumn("dtCreated"),
                LiveTable.DiscoverColumn("hb_extract")
            });

            TestCatalogue = Import(LiveTable);
            RowsBefore    = 5000;

            TestLoadMetadata = new LoadMetadata(CatalogueRepository, "Loading Test Catalogue");
            TestLoadMetadata.LocationOfFlatFiles = LoadDirectory.RootPath.FullName;
            TestLoadMetadata.SaveToDatabase();


            //make the load load the table
            TestCatalogue.LoadMetadata_ID = TestLoadMetadata.ID;
            TestCatalogue.SaveToDatabase();

            CreateFlatFileAttacher(TestLoadMetadata, "*.csv", TestCatalogue.GetTableInfoList(false).Single(), ",");

            //Get DleRunner to run pre load checks (includes trigger creation etc)
            var runner = new DleRunner(new DleOptions()
            {
                LoadMetadata = TestLoadMetadata.ID, Command = CommandLineActivity.check
            });

            runner.Run(RepositoryLocator, new ThrowImmediatelyDataLoadEventListener(), new AcceptAllCheckNotifier(), new GracefulCancellationToken());
        }