/// <summary> /// Declares that a new ANOTable (anonymous mapping table) should exist in the referenced database. You can call this constructor without first creating the table. If you do /// you should set <see cref="NumberOfIntegersToUseInAnonymousRepresentation"/> and <see cref="NumberOfCharactersToUseInAnonymousRepresentation"/> then <see cref="PushToANOServerAsNewTable"/> /// </summary> /// <param name="repository"></param> /// <param name="externalDatabaseServer"></param> /// <param name="tableName"></param> /// <param name="suffix"></param> public ANOTable(ICatalogueRepository repository, ExternalDatabaseServer externalDatabaseServer, string tableName, string suffix) { if (string.IsNullOrWhiteSpace(tableName)) { throw new NullReferenceException("ANOTable must have a name"); } repository.InsertAndHydrate(this, new Dictionary <string, object> { { "TableName", tableName }, { "Suffix", suffix }, { "Server_ID", externalDatabaseServer.ID } }); }
internal void SetDefaultIfNotExists(ExternalDatabaseServer newServer, PermissableDefaults permissableDefault, bool askYesNo) { var defaults = Activator.RepositoryLocator.CatalogueRepository.GetServerDefaults(); var current = defaults.GetDefaultFor(permissableDefault); if (current == null) { if (!askYesNo || YesNo($"Set as the default {permissableDefault} server?", "Set as default")) { defaults.SetDefault(permissableDefault, newServer); } } }
public void TestRemoteTableAttacher_WithLoadProgress(DatabaseType dbType, bool mismatchProgress) { var db = GetCleanedServer(dbType); var attacher = new RemoteTableAttacher(); //where to go for data var eds = new ExternalDatabaseServer(CatalogueRepository, "ref", null); eds.SetProperties(db); eds.SaveToDatabase(); attacher.RemoteServerReference = eds; RunAttachStageWithLoadProgressJob(attacher, db, mismatchProgress); }
/// <summary> /// Returns the logging server that should be used to audit extraction executions of this <see cref="IExtractionConfiguration"/>. /// </summary> /// <returns></returns> public LogManager GetExplicitLoggingDatabaseServerOrDefault() { ExternalDatabaseServer loggingServer = null; try { loggingServer = GetDistinctLoggingServer(false); } catch (Exception e) { //failed to get a logging server correctly //see if there is a default var defaultGetter = Project.DataExportRepository.CatalogueRepository.GetServerDefaults(); var defaultLoggingServer = defaultGetter.GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID); //there is a default? if (defaultLoggingServer != null) { loggingServer = (ExternalDatabaseServer)defaultLoggingServer; } //no, there is no default or user does not want to use it. throw new Exception("There is no default logging server configured and there was a problem asking Catalogues for a logging server instead. Configure a default logging server via ManageExternalServersUI", e); } var server = DataAccessPortal.GetInstance().ExpectServer(loggingServer, DataAccessContext.Logging); LogManager lm; try { lm = new LogManager(server); if (!lm.ListDataTasks().Contains(ExecuteDatasetExtractionSource.AuditTaskName)) { throw new Exception("The logging database " + server + " does not contain a DataLoadTask called '" + ExecuteDatasetExtractionSource.AuditTaskName + "' (all data exports are logged under this task regardless of dataset/Catalogue)"); } } catch (Exception e) { throw new Exception("Problem figuring out what logging server to use:" + Environment.NewLine + "\t" + e.Message, e); } return(lm); }
public void Join_PatientIndexTable_DoNotUseCacheOnDifferentServer(DatabaseType dbType) { /* * Server1 Server 2 * _____________ _________ * |Biochemistry| → | Cache | (cache is still populated but not used in the resulting join). * * ↓ join ↓ (do not use cache) * _____________________ * | Hospital Admissions| * */ //get the data database var db = GetCleanedServer(dbType); //create the cache on the other server type (doesn't matter what type just as long as it's different). var dbCache = GetCleanedServer(Enum.GetValues(typeof(DatabaseType)).Cast <DatabaseType>().First(t => t != dbType)); ExternalDatabaseServer cache = CreateCache(dbCache); var r = new Random(500); var people = new PersonCollection(); people.GeneratePeople(5000, r); var cic = new CohortIdentificationConfiguration(CatalogueRepository, "cic"); var joinable = SetupPatientIndexTable(db, people, r, cic); cic.CreateRootContainerIfNotExists(); cic.QueryCachingServer_ID = cache?.ID; cic.SaveToDatabase(); var hospitalAdmissions = SetupPatientIndexTableUser(db, people, r, cic, joinable); cic.RootCohortAggregateContainer.AddChild(hospitalAdmissions, 0); var compiler = new CohortCompiler(cic); var runner = new CohortCompilerRunner(compiler, 50000); runner.Run(new CancellationToken()); AssertNoErrors(compiler); Assert.IsTrue(compiler.Tasks.Any(t => t.Key.GetCachedQueryUseCount().Equals("1/1")), "Expected cache to be used only for the final UNION"); }
private PrimaryKeyCollisionIsolationMutilation GetMutilator(DiscoveredDatabase db, params TableInfo[] tableInfoCreated) { //tell the mutilator to resolve the primary key collision on column A by isolating the rows var mutilation = new PrimaryKeyCollisionIsolationMutilation(); mutilation.TablesToIsolate = tableInfoCreated; //tell the mutilator to set up isolation into the provided database var serverPointer = new ExternalDatabaseServer(CatalogueRepository, "Isolation Db", null); serverPointer.SetProperties(db); mutilation.IsolationDatabase = serverPointer; return(mutilation); }
public override void SetDatabaseObject(IActivateItems activator, CohortIdentificationConfiguration databaseObject) { _cic = databaseObject; base.SetDatabaseObject(activator, databaseObject); foreach (var c in _timeoutControls.GetControls()) { CommonFunctionality.Add(c); } _queryCachingServer = _cic.QueryCachingServer; Compiler.CohortIdentificationConfiguration = _cic; CoreIconProvider = activator.CoreIconProvider; RecreateAllTasks(); }
public ExecuteCommandQueryPlatformDatabase(IBasicActivateItems activator, ExternalDatabaseServer eds) : base(activator) { DiscoveredDatabase db; try { db = eds.Discover(DataAccessContext.InternalDataProcessing); } catch (Exception) { SetImpossible("Not a queryable SQL database"); return; } SetTargetDatabase(db); }
public void Join_PatientIndexTable_ThreeServers() { /* * Server1 Server 2 Server 3 * _____________ _________ * |Biochemistry| → (successfully caches joinable bit) | Cache | * * ↘ join ↘ (should crash) * _____________________ * | Hospital Admissions| * */ var server1 = GetCleanedServer(DatabaseType.MySql); var server2 = GetCleanedServer(DatabaseType.MicrosoftSQLServer); var server3 = GetCleanedServer(DatabaseType.Oracle); ExternalDatabaseServer cache = CreateCache(server3); var r = new Random(500); var people = new PersonCollection(); people.GeneratePeople(5000, r); var cic = new CohortIdentificationConfiguration(CatalogueRepository, "cic"); var joinable = SetupPatientIndexTable(server1, people, r, cic); cic.CreateRootContainerIfNotExists(); cic.QueryCachingServer_ID = cache?.ID; cic.SaveToDatabase(); var hospitalAdmissions = SetupPatientIndexTableUser(server2, people, r, cic, joinable); cic.RootCohortAggregateContainer.AddChild(hospitalAdmissions, 0); var compiler = new CohortCompiler(cic); var runner = new CohortCompilerRunner(compiler, 50000); runner.Run(new CancellationToken()); var hospitalAdmissionsTask = compiler.Tasks.Keys.OfType <AggregationTask>().Single(t => t.Aggregate.Equals(hospitalAdmissions)); Assert.AreEqual(CompilationState.Crashed, hospitalAdmissionsTask.State); StringAssert.Contains("is not fully cached and CacheUsageDecision is MustUse", hospitalAdmissionsTask.CrashMessage.ToString()); }
public virtual ExternalDatabaseServer CreateNewPlatformDatabase(ICatalogueRepository catalogueRepository, PermissableDefaults defaultToSet, IPatcher patcher, DiscoveredDatabase db) { if (db == null) { throw new ArgumentException($"Database must be picked before calling {nameof(CreateNewPlatformDatabase)} when using {nameof(BasicActivateItems)}", nameof(db)); } MasterDatabaseScriptExecutor executor = new MasterDatabaseScriptExecutor(db); executor.CreateAndPatchDatabase(patcher, new AcceptAllCheckNotifier()); var eds = new ExternalDatabaseServer(catalogueRepository, "New " + (defaultToSet == PermissableDefaults.None ? "" : defaultToSet.ToString()) + "Server", patcher); eds.SetProperties(db); return(eds); }
public void Setup() { DiscoveredQueryCachingDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(QueryCachingDatabaseName); if (DiscoveredQueryCachingDatabase.Exists()) { DiscoveredQueryCachingDatabase.Drop(); } MasterDatabaseScriptExecutor scripter = new MasterDatabaseScriptExecutor(DiscoveredQueryCachingDatabase); var p = new QueryCachingPatcher(); scripter.CreateAndPatchDatabase(p, new ThrowImmediatelyCheckNotifier()); QueryCachingDatabaseServer = new ExternalDatabaseServer(CatalogueRepository, QueryCachingDatabaseName, p); QueryCachingDatabaseServer.SetProperties(DiscoveredQueryCachingDatabase); }
public void Join_PatientIndexTable_NotOnCacheServer() { /* * Server1 Server 2 * _____________ _________ * |Biochemistry| → | Cache | (cache must first be populated) * * ↘ join ↘ (must use cache) * _____________________ * | Hospital Admissions| * */ var server1 = GetCleanedServer(DatabaseType.MySql); var server2 = GetCleanedServer(DatabaseType.MicrosoftSQLServer); ExternalDatabaseServer cache = CreateCache(server2); var r = new Random(500); var people = new PersonCollection(); people.GeneratePeople(5000, r); var cic = new CohortIdentificationConfiguration(CatalogueRepository, "cic"); var joinable = SetupPatientIndexTable(server1, people, r, cic); cic.CreateRootContainerIfNotExists(); cic.QueryCachingServer_ID = cache?.ID; cic.SaveToDatabase(); var hospitalAdmissions = SetupPatientIndexTableUser(server2, people, r, cic, joinable); cic.RootCohortAggregateContainer.AddChild(hospitalAdmissions, 0); var compiler = new CohortCompiler(cic); var runner = new CohortCompilerRunner(compiler, 50000); runner.Run(new CancellationToken()); AssertNoErrors(compiler); Assert.IsTrue(compiler.Tasks.Any(t => t.Key.GetCachedQueryUseCount().Equals("1/1")), "Expected cache to be used only for the final UNION"); }
public override void SetDatabaseObject(IActivateItems activator, ExternalDatabaseServer databaseObject) { base.SetDatabaseObject(activator, databaseObject); if (_navigationTrack == null) { //what happens when user clicks back/forward _navigationTrack = new NavigationTrack <LogViewerFilter>(f => true, f => { if (f.LoggingTable != LoggingTables.None) { var cmd = new ExecuteCommandViewLoggedData(activator, f); cmd.Execute(); } }); //set the initial filter _navigationTrack.Append(Filter); _back = new ToolStripButton("Back", FamFamFamIcons.Back, (s, e) => _navigationTrack.Back(true)) { DisplayStyle = ToolStripItemDisplayStyle.Image }; } CommonFunctionality.Add(_back); CommonFunctionality.Add(label1); CommonFunctionality.Add(tbContentFilter); CommonFunctionality.Add(label2); CommonFunctionality.Add(tbTop); CommonFunctionality.Add(cbPreferNewer); if (!databaseObject.DiscoverExistence(DataAccessContext.Logging, out string reason)) { activator.KillForm(ParentForm, "Database " + databaseObject + " did not exist:" + reason); return; } LogManager = new LogManager(databaseObject); FetchDataTable(); }
private DiscoveredServer DiscoverServer(ExternalDatabaseServer server) { var builder = new SqlConnectionStringBuilder { DataSource = server.Server }; if (server.Username == null) { builder.IntegratedSecurity = true; } else { builder.UserID = server.Username; builder.Password = server.Password; } return(new DiscoveredServer(builder)); }
/// <summary> /// Creates a new runner for the given <paramref name="compiler"/> which will facilitate running it's Tasks in a sensible order using result caching if possible /// </summary> /// <param name="compiler"></param> /// <param name="timeout">CommandTimeout for each individual command in seconds</param> public CohortCompilerRunner(CohortCompiler compiler, int timeout) { _timeout = timeout; Compiler = compiler; if (Compiler.CohortIdentificationConfiguration == null) { throw new ArgumentException("CohortCompiler must have a CohortIdentificationConfiguration"); } _cic = Compiler.CohortIdentificationConfiguration; if (_cic.QueryCachingServer_ID != null) { _queryCachingServer = _cic.QueryCachingServer; } RunSubcontainers = true; }
protected override Pipeline SetupPipeline() { //create a target server pointer _extractionServer = new ExternalDatabaseServer(CatalogueRepository, "myserver", null); _extractionServer.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; _extractionServer.Username = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExplicitUsernameIfAny; _extractionServer.Password = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExplicitPasswordIfAny; _extractionServer.SaveToDatabase(); //create a pipeline _pipeline = new Pipeline(CatalogueRepository, "Empty extraction pipeline"); //set the destination pipeline var component = new PipelineComponent(CatalogueRepository, _pipeline, typeof(ExecuteFullExtractionToDatabaseMSSql), 0, "MS SQL Destination"); var destinationArguments = component.CreateArgumentsForClassIfNotExists <ExecuteFullExtractionToDatabaseMSSql>().ToList(); IArgument argumentServer = destinationArguments.Single(a => a.Name == "TargetDatabaseServer"); IArgument argumentDbNamePattern = destinationArguments.Single(a => a.Name == "DatabaseNamingPattern"); IArgument argumentTblNamePattern = destinationArguments.Single(a => a.Name == "TableNamingPattern"); Assert.AreEqual("TargetDatabaseServer", argumentServer.Name); argumentServer.SetValue(_extractionServer); argumentServer.SaveToDatabase(); argumentDbNamePattern.SetValue(TestDatabaseNames.Prefix + "$p_$n"); argumentDbNamePattern.SaveToDatabase(); argumentTblNamePattern.SetValue("$c_$d"); argumentTblNamePattern.SaveToDatabase(); AdjustPipelineComponentDelegate?.Invoke(component); var component2 = new PipelineComponent(CatalogueRepository, _pipeline, typeof(ExecuteCrossServerDatasetExtractionSource), -1, "Source"); var arguments2 = component2.CreateArgumentsForClassIfNotExists <ExecuteCrossServerDatasetExtractionSource>().ToArray(); arguments2.Single(a => a.Name.Equals("AllowEmptyExtractions")).SetValue(false); arguments2.Single(a => a.Name.Equals("AllowEmptyExtractions")).SaveToDatabase(); AdjustPipelineComponentDelegate?.Invoke(component2); //configure the component as the destination _pipeline.DestinationPipelineComponent_ID = component.ID; _pipeline.SourcePipelineComponent_ID = component2.ID; _pipeline.SaveToDatabase(); return(_pipeline); }
public void Setup_IdentifierDump() { IdentifierDump_Database = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(IdentifierDump_DatabaseName); if (IdentifierDump_Database.Exists()) { IdentifierDump_Database.Drop(); } var scriptCreate = new MasterDatabaseScriptExecutor(IdentifierDump_Database); var p = new IdentifierDumpDatabasePatcher(); scriptCreate.CreateAndPatchDatabase(p, new ThrowImmediatelyCheckNotifier()); //now create a new reference! IdentifierDump_ExternalDatabaseServer = new ExternalDatabaseServer(CatalogueRepository, IdentifierDump_DatabaseName, p); IdentifierDump_ExternalDatabaseServer.SetProperties(IdentifierDump_Database); CatalogueRepository.GetServerDefaults().SetDefault(PermissableDefaults.IdentifierDumpServer_ID, IdentifierDump_ExternalDatabaseServer); }
protected override void OneTimeSetUp() { base.OneTimeSetUp(); queryCacheDatabase = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase(TestDatabaseNames.Prefix + "QueryCache"); if (queryCacheDatabase.Exists()) { base.DeleteTables(queryCacheDatabase); } MasterDatabaseScriptExecutor executor = new MasterDatabaseScriptExecutor(queryCacheDatabase); var p = new QueryCachingPatcher(); executor.CreateAndPatchDatabase(p, new AcceptAllCheckNotifier()); externalDatabaseServer = new ExternalDatabaseServer(CatalogueRepository, "QueryCacheForUnitTests", p); externalDatabaseServer.SetProperties(queryCacheDatabase); }
public void ServerMissingServerName() { var server = new ExternalDatabaseServer(CatalogueRepository, "Fiction", null); try { var destination = new ExecuteFullExtractionToDatabaseMSSql(); destination.TargetDatabaseServer = server; var tomemory = new ToMemoryCheckNotifier(); destination.Check(tomemory); Assert.AreEqual(CheckResult.Fail, tomemory.Messages[0].Result); Assert.IsTrue(tomemory.Messages[0].Message.StartsWith("TargetDatabaseServer does not have a .Server specified")); } finally { server.DeleteInDatabase(); } }
public ExternalDatabaseServerMenu(RDMPContextMenuStripArgs args, ExternalDatabaseServer server) : base(args, server) { _server = server; if (server.WasCreatedBy(new LoggingDatabasePatcher())) { var viewLogs = new ToolStripMenuItem("View Logs", CatalogueIcons.Logging); Add(new ExecuteCommandViewLoggedData(_activator, new LogViewerFilter(LoggingTables.DataLoadTask)), Keys.None, viewLogs); Add(new ExecuteCommandViewLoggedData(_activator, new LogViewerFilter(LoggingTables.DataLoadRun)), Keys.None, viewLogs); Add(new ExecuteCommandViewLoggedData(_activator, new LogViewerFilter(LoggingTables.FatalError)), Keys.None, viewLogs); Add(new ExecuteCommandViewLoggedData(_activator, new LogViewerFilter(LoggingTables.TableLoadRun)), Keys.None, viewLogs); Add(new ExecuteCommandViewLoggedData(_activator, new LogViewerFilter(LoggingTables.DataSource)), Keys.None, viewLogs); Add(new ExecuteCommandViewLoggedData(_activator, new LogViewerFilter(LoggingTables.ProgressLog)), Keys.None, viewLogs); viewLogs.DropDownItems.Add(new ToolStripSeparator()); viewLogs.DropDownItems.Add(new ToolStripMenuItem("Query with SQL", CatalogueIcons.SQL, ExecuteSqlOnLoggingDatabase)); Items.Add(viewLogs); } }
private void RefreshTasks() { ExternalDatabaseServer liveserver = ddLoggingServer.SelectedItem as ExternalDatabaseServer; var server = DataAccessPortal.GetInstance().ExpectServer(liveserver, DataAccessContext.Logging); if (liveserver != null) { cbxDataLoadTasks.Items.Clear(); try { LogManager lm = new LogManager(server); cbxDataLoadTasks.Items.AddRange(lm.ListDataTasks()); } catch (Exception e) { ExceptionViewer.Show(e); } } }
private void CreateServers() { var defaults = _repositoryLocator.CatalogueRepository.GetServerDefaults(); _edsLogging = new ExternalDatabaseServer(_repositoryLocator.CatalogueRepository, "Logging", new LoggingDatabasePatcher()); _edsLogging.Server = _logging.DataSource; _edsLogging.Database = _logging.InitialCatalog; if (_logging.UserID != null) { _edsLogging.Username = _logging.UserID; _edsLogging.Password = _logging.Password; } _edsLogging.SaveToDatabase(); defaults.SetDefault(PermissableDefaults.LiveLoggingServer_ID, _edsLogging); Console.WriteLine("Successfully configured default logging server"); var edsDQE = new ExternalDatabaseServer(_repositoryLocator.CatalogueRepository, "DQE", new DataQualityEnginePatcher()); edsDQE.Server = _dqe.DataSource; edsDQE.Database = _dqe.InitialCatalog; if (_logging.UserID != null) { edsDQE.Username = _dqe.UserID; edsDQE.Password = _dqe.Password; } edsDQE.SaveToDatabase(); defaults.SetDefault(PermissableDefaults.DQE, edsDQE); Console.WriteLine("Successfully configured default dqe server"); var edsRAW = new ExternalDatabaseServer(_repositoryLocator.CatalogueRepository, "RAW Server", null); edsRAW.Server = _dqe.DataSource; edsRAW.SaveToDatabase(); defaults.SetDefault(PermissableDefaults.RAWDataLoadServer, edsRAW); Console.WriteLine("Successfully configured RAW server"); }
public override void Execute() { base.Execute(); if (_server == null) { if (SelectOne(_available, out ExternalDatabaseServer selected)) { _server = selected; } else { return; } } _loadMetadata.OverrideRAWServer_ID = _server == null ? null : (int?)_server.ID; _loadMetadata.SaveToDatabase(); Publish(_loadMetadata); }
public void ServerDatabaseIsPresentAndCorrectButHasTablesInIt() { var server = new ExternalDatabaseServer(CatalogueRepository, "Fiction", null); server.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; //server.Database = "FictionalDatabase"; Ignored by the extractor! DiscoveredServerICanCreateRandomDatabasesAndTablesOn.CreateDatabase("FictionalDatabase"); var db = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase("FictionalDatabase"); using (var con = db.Server.GetConnection()) { con.Open(); db.Server.GetCommand("CREATE TABLE Bob(name varchar(10))", con).ExecuteNonQuery(); } try { var destination = new ExecuteFullExtractionToDatabaseMSSql(); destination.PreInitialize(_projectStub, new ThrowImmediatelyDataLoadEventListener()); destination.PreInitialize(_commandStub, new ThrowImmediatelyDataLoadEventListener()); destination.TargetDatabaseServer = server; destination.TableNamingPattern = "$d"; destination.DatabaseNamingPattern = "FictionalDatabase"; var tomemory = new ToMemoryCheckNotifier(new ThrowImmediatelyCheckNotifier()); destination.Check(tomemory); Assert.AreEqual(CheckResult.Warning, tomemory.GetWorst()); db.ExpectTable("Bob").Drop(); } finally { server.DeleteInDatabase(); } }
/// <summary> /// Creates a new result for a single <see cref="AggregateConfiguration"/> or <see cref="CohortAggregateContainer"/> /// </summary> /// <param name="cacheServer"></param> /// <param name="childProvider"></param> /// <param name="helper"></param> /// <param name="customise"></param> /// <param name="cancellationToken"></param> public CohortQueryBuilderResult(ExternalDatabaseServer cacheServer, ICoreChildProvider childProvider, CohortQueryBuilderHelper helper, QueryBuilderCustomArgs customise, CancellationToken cancellationToken) { CacheServer = cacheServer; ChildProvider = childProvider; Helper = helper; Customise = customise; CancellationToken = cancellationToken; if (cacheServer != null) { CacheManager = new CachedAggregateConfigurationResultsManager(CacheServer); try { PluginCohortCompilers = new PluginCohortCompilerFactory(cacheServer.CatalogueRepository.MEF).CreateAll(); } catch (Exception ex) { throw new Exception("Failed to build list of IPluginCohortCompilers", ex); } } }
public void CacheIdentifierListWithRunner_WithCaching() { DiscoveredDatabase db; CohortIdentificationConfiguration cic; DataTable dt; SetupCohort(out db, out cic, out dt); MasterDatabaseScriptExecutor e = new MasterDatabaseScriptExecutor(db); var p = new QueryCachingPatcher(); e.CreateAndPatchDatabase(p, new AcceptAllCheckNotifier()); var serverReference = new ExternalDatabaseServer(CatalogueRepository, "Cache", p); serverReference.SetProperties(db); cic.QueryCachingServer_ID = serverReference.ID; cic.SaveToDatabase(); var compiler = new CohortCompiler(cic); var runner = new CohortCompilerRunner(compiler, 5000); runner.Run(new CancellationToken()); Assert.AreEqual(CohortCompilerRunner.Phase.Finished, runner.ExecutionPhase); var rootTask = runner.Compiler.Tasks.Single(t => t.Key is AggregationContainerTask); Assert.IsTrue(rootTask.Value.IsResultsForRootContainer); Assert.IsNull(rootTask.Key.CrashMessage); Assert.AreEqual(CompilationState.Finished, rootTask.Key.State); Assert.IsTrue(runner.Compiler.AreaAllQueriesCached(rootTask.Key)); Assert.AreEqual(dt.Rows.Count, rootTask.Value.Identifiers.Rows.Count); }
protected override void SetUp() { base.SetUp(); _server = new ExternalDatabaseServer(CatalogueRepository, "AliasHandlerTestsServer", null); _server.SetProperties(GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer)); _database = GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer); var s = _database.Server; using (var con = s.GetConnection()) { con.Open(); s.GetCommand("CREATE TABLE AliasHandlerTests (input varchar(50), alias varchar(50))", con).ExecuteNonQuery(); //Two names which are aliases of the same person s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('freddie','craig')", con).ExecuteNonQuery(); s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('craig','freddie')", con).ExecuteNonQuery(); //Three names which are all aliases of the same person s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('peter','paul')", con).ExecuteNonQuery(); s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('peter','pepey')", con).ExecuteNonQuery(); s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('pepey','paul')", con).ExecuteNonQuery(); s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('pepey','peter')", con).ExecuteNonQuery(); s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('paul','pepey')", con).ExecuteNonQuery(); s.GetCommand("INSERT INTO AliasHandlerTests VALUES ('paul','peter')", con).ExecuteNonQuery(); } _handler = new AliasHandler(); _handler.AliasColumnInInputDataTables = "input"; _handler.AliasTableSQL = "select * from AliasHandlerTests"; _handler.DataAccessContext = DataAccessContext.DataLoad; _handler.ResolutionStrategy = AliasResolutionStrategy.CrashIfAliasesFound; _handler.TimeoutForAssemblingAliasTable = 10; _handler.ServerToExecuteQueryOn = _server; }
public static ExternalDatabaseServer CreateNewExternalServer(ICatalogueRepository repository, PermissableDefaults defaultToSet, IPatcher patcher) { CreatePlatformDatabase createPlatform = new CreatePlatformDatabase(patcher); createPlatform.ShowDialog(); var db = createPlatform.DatabaseCreatedIfAny; if (db != null) { var newServer = new ExternalDatabaseServer(repository, db.GetRuntimeName(), patcher); newServer.SetProperties(db); if (defaultToSet != PermissableDefaults.None) { repository.GetServerDefaults().SetDefault(defaultToSet, newServer); } return(newServer); } return(null); }
public override void Execute() { base.Execute(); if (_server == null) { var dialog = new SelectIMapsDirectlyToDatabaseTableDialog(_available, true, false); if (dialog.ShowDialog() == DialogResult.OK) { _server = dialog.Selected as ExternalDatabaseServer; } else { return; } } _loadMetadata.OverrideRAWServer_ID = _server == null ? null : (int?)_server.ID; _loadMetadata.SaveToDatabase(); Publish(_loadMetadata); }
public void ServerDatabaseIsPresentAndCorrect(bool alreadyExists) { var server = new ExternalDatabaseServer(CatalogueRepository, "Fiction", null); server.Server = DiscoveredServerICanCreateRandomDatabasesAndTablesOn.Name; //server.Database = "FictionalDatabase"; Ignored by the extractor! DiscoveredServerICanCreateRandomDatabasesAndTablesOn.CreateDatabase("FictionalDatabase"); Assert.IsTrue(DiscoveredServerICanCreateRandomDatabasesAndTablesOn.ExpectDatabase("FictionalDatabase").Exists()); try { var destination = new ExecuteFullExtractionToDatabaseMSSql(); destination.PreInitialize(_projectStub, new ThrowImmediatelyDataLoadEventListener()); destination.PreInitialize(_commandStub, new ThrowImmediatelyDataLoadEventListener()); destination.TargetDatabaseServer = server; destination.TableNamingPattern = "$d"; if (alreadyExists) { destination.DatabaseNamingPattern = "FictionalDatabase"; //database that exists } else { destination.DatabaseNamingPattern = "Fictional$nDatabase"; //database does not exist (but server does) } var tomemory = new ToMemoryCheckNotifier(new ThrowImmediatelyCheckNotifier()); destination.Check(tomemory); Assert.AreEqual(alreadyExists? CheckResult.Warning: CheckResult.Success, tomemory.GetWorst()); } finally { server.DeleteInDatabase(); } }