Ejemplo n.º 1
0
        public DataTableViewerUI(IDataAccessPoint source, string sql, string caption)
        {
            InitializeComponent();

            try
            {
                using (DbConnection con = DataAccessPortal.GetInstance().ExpectServer(source, DataAccessContext.DataExport).GetConnection())
                {
                    con.Open();

                    using (var cmd = DatabaseCommandHelper.GetCommand(sql, con))
                        using (var da = DatabaseCommandHelper.GetDataAdapter(cmd))
                        {
                            DataTable dt = new DataTable();
                            da.Fill(dt);
                            dataGridView1.DataSource = dt;
                        }
                }
            }
            catch (Exception e)
            {
                ExceptionViewer.Show("Failed to connect to source " + source + " and execute SQL: " + Environment.NewLine + sql, e);
            }

            this.Text = caption;
        }
Ejemplo n.º 2
0
        public void TestGettingConnectionStrings()
        {
            foreach (TableInfo tbl in CatalogueRepository.GetAllObjects <TableInfo>().Where(table => table.Name.ToLower().Equals("bob")))
            {
                tbl.DeleteInDatabase();
            }

            foreach (var c in CatalogueRepository.GetAllObjects <DataAccessCredentials>().Where(cred => cred.Name.ToLower().Equals("bob")))
            {
                c.DeleteInDatabase();
            }

            //test it with TableInfos
            TableInfo t = new TableInfo(CatalogueRepository, "Bob");

            try
            {
                t.Server   = "fish";
                t.Database = "bobsDatabase";
                t.SaveToDatabase();

                //t has no credentials
                var server = DataAccessPortal.GetInstance().ExpectServer(t, DataAccessContext.InternalDataProcessing);

                Assert.AreEqual(typeof(SqlConnectionStringBuilder), server.Builder.GetType());
                Assert.AreEqual("fish", ((SqlConnectionStringBuilder)server.Builder).DataSource);
                Assert.AreEqual("bobsDatabase", ((SqlConnectionStringBuilder)server.Builder).InitialCatalog);
                Assert.AreEqual(true, ((SqlConnectionStringBuilder)server.Builder).IntegratedSecurity);

                var creds = new DataAccessCredentials(CatalogueRepository, "Bob");
                try
                {
                    t.SetCredentials(creds, DataAccessContext.InternalDataProcessing, true);
                    creds.Username = "******";
                    creds.Password = "******";
                    creds.SaveToDatabase();


                    ////t has some credentials now
                    server = DataAccessPortal.GetInstance().ExpectServer(t, DataAccessContext.InternalDataProcessing);

                    Assert.AreEqual(typeof(SqlConnectionStringBuilder), server.Builder.GetType());
                    Assert.AreEqual("fish", ((SqlConnectionStringBuilder)server.Builder).DataSource);
                    Assert.AreEqual("bobsDatabase", ((SqlConnectionStringBuilder)server.Builder).InitialCatalog);
                    Assert.AreEqual("frank", ((SqlConnectionStringBuilder)server.Builder).UserID);
                    Assert.AreEqual("bobsPassword", ((SqlConnectionStringBuilder)server.Builder).Password);
                    Assert.AreEqual(false, ((SqlConnectionStringBuilder)server.Builder).IntegratedSecurity);
                }
                finally
                {
                    var linker = new TableInfoCredentialsManager(CatalogueRepository);
                    linker.BreakAllLinksBetween(creds, t);
                    creds.DeleteInDatabase();
                }
            }
            finally
            {
                t.DeleteInDatabase();
            }
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        public DiscoveredServer GetDistinctLiveDatabaseServer()
        {
            HashSet <ITableInfo> normalTables = new HashSet <ITableInfo>();
            HashSet <ITableInfo> lookupTables = new HashSet <ITableInfo>();

            foreach (ICatalogue catalogue in this.GetAllCatalogues())
            {
                List <ITableInfo> normal;
                List <ITableInfo> lookup;
                catalogue.GetTableInfos(out normal, out lookup);

                foreach (ITableInfo n in normal)
                {
                    normalTables.Add(n);
                }
                foreach (ITableInfo l in lookup)
                {
                    lookupTables.Add(l);
                }
            }

            if (normalTables.Any())
            {
                return(DataAccessPortal.GetInstance().ExpectDistinctServer(normalTables.ToArray(), DataAccessContext.DataLoad, true));
            }

            if (lookupTables.Any())
            {
                return(DataAccessPortal.GetInstance().ExpectDistinctServer(lookupTables.ToArray(), DataAccessContext.DataLoad, true));
            }

            throw new Exception("LoadMetadata " + this + " has no TableInfos configured (or possibly the tables have been deleted resulting in MISSING ColumnInfos?)");
        }
Ejemplo n.º 4
0
        protected override Releaseability GetSpecificAssessment(IExtractionResults extractionResults)
        {
            var _extractDir = Configuration.GetProject().ExtractionDirectory;

            ExtractDirectory = new ExtractionDirectory(_extractDir, Configuration).GetDirectoryForDataset(DataSet);

            var externalServerId = int.Parse(extractionResults.DestinationDescription.Split('|')[0]);
            var externalServer   = _repositoryLocator.CatalogueRepository.GetObjectByID <ExternalDatabaseServer>(externalServerId);
            var dbName           = extractionResults.DestinationDescription.Split('|')[1];
            var tblName          = extractionResults.DestinationDescription.Split('|')[2];
            var server           = DataAccessPortal.GetInstance().ExpectServer(externalServer, DataAccessContext.DataExport, setInitialDatabase: false);
            var database         = server.ExpectDatabase(dbName);

            if (!database.Exists())
            {
                return(Releaseability.ExtractFilesMissing);
            }
            var foundTable = database.ExpectTable(tblName);

            if (!foundTable.Exists())
            {
                return(Releaseability.ExtractFilesMissing);
            }

            return(Releaseability.Undefined);
        }
Ejemplo n.º 5
0
        private void TestWithParameterValueThatRowsAreReturned()
        {
            var p = _tvfTableInfo.GetAllParameters().Single();

            p.Value = "5";
            p.SaveToDatabase();

            var qb = new QueryBuilder("", "");

            qb.AddColumnRange(_tvfCatalogue.GetAllExtractionInformation(ExtractionCategory.Any));

            var sql = qb.SQL;

            var db = DataAccessPortal.GetInstance().ExpectDatabase(_tvfTableInfo, DataAccessContext.InternalDataProcessing);

            using (var con = db.Server.GetConnection())
            {
                con.Open();
                var r = db.Server.GetCommand(sql, con).ExecuteReader();

                int rowsReturned = 0;

                while (r.Read())
                {
                    rowsReturned++;
                    Assert.NotNull(r["chi"]);
                    Assert.NotNull(r["definitionID"]);
                }

                Assert.AreEqual(rowsReturned, 5);
            }
        }
        public void NullsAreDropped()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("MyCol");
            dt.Rows.Add("0101010101");
            dt.Rows.Add(DBNull.Value);
            dt.Rows.Add("0101010102");

            _manager.CommitResults(new CacheCommitIdentifierList(_config, "select * from fish", dt, _myColSpecification, 30));

            var resultTable = _manager.GetLatestResultsTable(_config, AggregateOperation.IndexedExtractionIdentifierList, "select * from fish");

            var dt2 = new DataTable();

            using (var con = DataAccessPortal.GetInstance().ExpectServer(QueryCachingDatabaseServer, DataAccessContext.InternalDataProcessing).GetConnection())
            {
                con.Open();

                SqlDataAdapter da = new SqlDataAdapter("Select * from " + resultTable.GetFullyQualifiedName(),
                                                       (SqlConnection)con);
                da.Fill(dt2);
            }

            Assert.AreEqual(2, dt2.Rows.Count);
            Assert.IsTrue(dt2.Rows.Cast <DataRow>().Any(r => (string)r[0] == "0101010101"));
            Assert.IsTrue(dt2.Rows.Cast <DataRow>().Any(r => (string)r[0] == "0101010102"));
        }
Ejemplo n.º 7
0
        public ExitCodeType Mutilate(IDataLoadJob job)
        {
            var db = DataAccessPortal.GetInstance().ExpectDatabase(DatabaseToBackup, DataAccessContext.DataLoad);

            db.CreateBackup("DataLoadEngineBackup");
            return(ExitCodeType.Success);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Connects to the live database referenced by this <seealso cref="ColumnInfo"/> and discovers the column returning the
        /// live state of the column.
        /// <para>If the database/table/column doesn't exist or is inaccessible then this method will throw</para>
        /// </summary>
        /// <param name="context">Determines which credentials (if any) to use to perform the connection operation</param>
        /// <returns>The live state of the column</returns>
        public DiscoveredColumn Discover(DataAccessContext context)
        {
            var ti = TableInfo;
            var db = DataAccessPortal.GetInstance().ExpectDatabase(ti, context);

            return(db.ExpectTable(ti.GetRuntimeName()).DiscoverColumn(GetRuntimeName()));
        }
        public void BasicCase()
        {
            var ex = Assert.Throws <ArgumentException>(() => _manager.CommitResults(new CacheCommitExtractableAggregate(_config, "I've got a lovely bunch of coconuts", new DataTable(), 30)));


            Assert.IsTrue(ex.Message.StartsWith("The DataTable that you claimed was an ExtractableAggregateResults had zero columns and therefore cannot be cached"));

            DataTable dt = new DataTable();

            dt.Columns.Add("Col1");
            dt.Rows.Add("fishy!");

            var ex2 = Assert.Throws <NotSupportedException>(() => _manager.CommitResults(new CacheCommitExtractableAggregate(_config, "I've got a lovely bunch of coconuts", dt, 30)));

            Assert.IsTrue(
                ex2.Message.StartsWith(
                    "Aggregate ExtractableAggregateCachingTests is not marked as IsExtractable therefore cannot be cached"));



            _config.IsExtractable = true;
            _config.SaveToDatabase();


            //make the underlying column an is extraction identifier
            _extractionInformation.IsExtractionIdentifier = true;
            _extractionInformation.SaveToDatabase();

            AggregateDimension dim = new AggregateDimension(CatalogueRepository, _extractionInformation, _config);

            _config.ClearAllInjections();

            var ex3 = Assert.Throws <NotSupportedException>(() => _manager.CommitResults(new CacheCommitExtractableAggregate(_config, "I've got a lovely bunch of coconuts", dt, 30)));

            Assert.IsTrue(
                ex3.Message.StartsWith(
                    "Aggregate ExtractableAggregateCachingTests contains dimensions marked as IsExtractionIdentifier or HashOnDataRelease (Col1)"));

            _extractionInformation.IsExtractionIdentifier = false;
            _extractionInformation.SaveToDatabase();
            _config.ClearAllInjections();

            Assert.DoesNotThrow(() => _manager.CommitResults(new CacheCommitExtractableAggregate(_config, "I've got a lovely bunch of coconuts", dt, 30)));

            dim.DeleteInDatabase();


            using (var con = DataAccessPortal.GetInstance().ExpectServer(QueryCachingDatabaseServer, DataAccessContext.InternalDataProcessing).GetConnection())
            {
                IHasFullyQualifiedNameToo table = _manager.GetLatestResultsTableUnsafe(_config, AggregateOperation.ExtractableAggregateResults);

                con.Open();
                using (var cmd = DatabaseCommandHelper.GetCommand("Select * from " + table.GetFullyQualifiedName(), con))
                    using (var r = cmd.ExecuteReader())
                    {
                        Assert.IsTrue(r.Read());
                        Assert.AreEqual("fishy!", r["Col1"]);
                    }
            }
        }
Ejemplo n.º 10
0
        public void Check(ICheckNotifier notifier)
        {
            if (string.IsNullOrWhiteSpace(Server))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("No Server set", CheckResult.Warning));
            }
            else
            if (string.IsNullOrWhiteSpace(Database))
            {
                notifier.OnCheckPerformed(new CheckEventArgs("No Database set", CheckResult.Warning));
            }
            else
            {
                try
                {
                    DataAccessPortal.GetInstance().ExpectServer(this, DataAccessContext.InternalDataProcessing).TestConnection();
                    notifier.OnCheckPerformed(new CheckEventArgs("Successfully connected to server", CheckResult.Success));
                }
                catch (Exception exception)
                {
                    notifier.OnCheckPerformed(new CheckEventArgs("Failed to connect to server", CheckResult.Fail, exception));
                    return;
                }
            }

            //if it's a logging server run logging checks
            if (WasCreatedBy(new LoggingDatabasePatcher()))
            {
                new LoggingDatabaseChecker(this).Check(notifier);
            }
        }
Ejemplo n.º 11
0
        private void RefreshUIFromDatabase()
        {
            try
            {
                _server = DataAccessPortal.GetInstance()
                          .ExpectServer(_collection.GetDataAccessPoint(), DataAccessContext.InternalDataProcessing);

                string sql = _collection.GetSql();
                _originalSql = sql;
                //update the editor to show the user the SQL
                _scintilla.Text = sql;

                _server.TestConnection();

                LoadDataTableAsync(_server, sql);
            }
            catch (QueryBuildingException ex)
            {
                ragSmiley1.SetVisible(true);
                ragSmiley1.Fatal(ex);
            }
            catch (Exception ex)
            {
                ragSmiley1.SetVisible(true);
                ragSmiley1.Fatal(ex);
            }
        }
        public void Begin()
        {
            Task = new Task(() =>
            {
                var server = DataAccessPortal.GetInstance().ExpectDatabase(Source, DataAccessContext.DataExport).Server;
                using (var con = server.GetConnection())
                {
                    con.Open();
                    using (var cmd = server.GetCommand(Source.GetCountsDataTableSql(), con))
                    {
                        cmd.CommandTimeout = 120; //give it up to 2 minutes
                        server.GetDataAdapter(cmd).Fill(DataTable);
                    }
                }
            });

            Task.ContinueWith(s =>
            {
                if (Finished != null)
                {
                    Finished();
                }
            });

            Task.Start();
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Synchronizes the TableInfo against the underlying database to ensure the Catalogues understanding of what columns exist, what are primary keys,
        /// collation types etc match the reality.  Pass in an alternative
        /// </summary>
        /// <param name="tableToSync"></param>
        public TableInfoSynchronizer(TableInfo tableToSync)
        {
            _tableToSync = tableToSync;
            _repository  = _tableToSync.CatalogueRepository;

            _toSyncTo = DataAccessPortal.GetInstance().ExpectServer(tableToSync, DataAccessContext.InternalDataProcessing);
        }
Ejemplo n.º 14
0
        private void GetWhitelist(IDataLoadEventListener listener)
        {
            _whitelist = new HashSet <string>();

            var db     = DataAccessPortal.GetInstance().ExpectDatabase(PatientIdWhitelistColumnInfo.TableInfo, DataAccessContext.DataLoad);
            var server = db.Server;

            var qb = new QueryBuilder("distinct", null);

            qb.AddColumn(new ColumnInfoToIColumn(new MemoryRepository(), PatientIdWhitelistColumnInfo));

            var sql = qb.SQL;

            listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "Downloading Whitelist with SQL:" + sql));

            using (var con = server.GetConnection())
            {
                con.Open();
                var r = server.GetCommand(sql, con).ExecuteReader();

                while (r.Read())
                {
                    var o = r[PatientIdWhitelistColumnInfo.GetRuntimeName()];
                    if (o == null || o == DBNull.Value)
                    {
                        continue;
                    }

                    _whitelist.Add(o.ToString());
                }
            }

            listener.OnNotify(this, new NotifyEventArgs(_whitelist.Count == 0 ? ProgressEventType.Error : ProgressEventType.Information, "Whitelist contained " + _whitelist.Count + " identifiers"));
        }
        private void WriteBundleContents(IExtractableDatasetBundle datasetBundle, IDataLoadEventListener job, GracefulCancellationToken cancellationToken)
        {
            var rootDir             = _request.GetExtractionDirectory();
            var supportingSQLFolder = new DirectoryInfo(Path.Combine(rootDir.FullName, SupportingSQLTable.ExtractionFolderName));
            var lookupDir           = rootDir.CreateSubdirectory("Lookups");

            //extract the documents
            foreach (SupportingDocument doc in datasetBundle.Documents)
            {
                datasetBundle.States[doc] = TryExtractSupportingDocument(rootDir, doc, job)
                    ? ExtractCommandState.Completed
                    : ExtractCommandState.Crashed;
            }

            //extract supporting SQL
            foreach (SupportingSQLTable sql in datasetBundle.SupportingSQL)
            {
                datasetBundle.States[sql] = TryExtractSupportingSQLTable(supportingSQLFolder, _request.Configuration, sql, job, _dataLoadInfo)
                    ? ExtractCommandState.Completed
                    : ExtractCommandState.Crashed;
            }

            //extract lookups
            foreach (BundledLookupTable lookup in datasetBundle.LookupTables)
            {
                try
                {
                    job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "About to extract lookup " + lookup));

                    var server = DataAccessPortal.GetInstance().ExpectServer(lookup.TableInfo, DataAccessContext.DataExport);

                    Stopwatch sw = new Stopwatch();
                    sw.Start();

                    //extracts all of them
                    var extractTableVerbatim = new ExtractTableVerbatim(server, new [] { lookup.TableInfo.Name }, lookupDir, _request.Configuration.Separator, DateFormat);
                    int linesWritten         = extractTableVerbatim.DoExtraction();
                    sw.Stop();
                    job.OnProgress(this, new ProgressEventArgs("Lookup " + lookup, new ProgressMeasurement(linesWritten, ProgressType.Records), sw.Elapsed));

                    if (_request is ExtractDatasetCommand)
                    {
                        var result             = (_request as ExtractDatasetCommand).CumulativeExtractionResults;
                        var supplementalResult = result.AddSupplementalExtractionResult("SELECT * FROM " + lookup.TableInfo.Name, lookup.TableInfo);
                        supplementalResult.CompleteAudit(this.GetType(), extractTableVerbatim.OutputFilename, linesWritten);
                    }

                    datasetBundle.States[lookup] = ExtractCommandState.Completed;
                }
                catch (Exception e)
                {
                    job.OnNotify(this, new NotifyEventArgs(ProgressEventType.Error, "Error occurred trying to extract lookup " + lookup + " on server " + lookup.TableInfo.Server, e));

                    datasetBundle.States[lookup] = ExtractCommandState.Crashed;
                }
            }

            haveWrittenBundleContents = true;
        }
Ejemplo n.º 16
0
        /// <inheritdoc/>
        public DiscoveredServer GetDistinctLiveDatabaseServer(DataAccessContext context, bool setInitialDatabase, out IDataAccessPoint distinctAccessPoint)
        {
            var tables = GetTableInfosIdeallyJustFromMainTables();

            distinctAccessPoint = tables.FirstOrDefault();

            return(DataAccessPortal.GetInstance().ExpectDistinctServer(tables, context, setInitialDatabase));
        }
Ejemplo n.º 17
0
        public ANOTransformer(ANOTable anoTable, IDataLoadEventListener listener = null)
        {
            _externalDatabaseServer = anoTable.Server;

            _server = DataAccessPortal.GetInstance().ExpectServer(_externalDatabaseServer, DataAccessContext.DataLoad);

            _anoTable = anoTable;
            _listener = listener;
        }
Ejemplo n.º 18
0
        public override void ShowData(IViewSQLAndResultsCollection collection)
        {
            var point = collection.GetDataAccessPoint();
            var db    = DataAccessPortal.GetInstance().ExpectDatabase(point, DataAccessContext.InternalDataProcessing);

            var toRun = new ExtractTableVerbatim(db.Server, collection.GetSql(), Console.OpenStandardOutput(), ",", null);

            toRun.DoExtraction();
        }
Ejemplo n.º 19
0
        private void CheckTableInfo(TableInfo tableInfo, ICheckNotifier notifier)
        {
            //get all columns
            ColumnInfo[] columnInfos;
            ColumnInfo[] columnInfosWhichArePrimaryKeys;

            //check whether the live database and staging databases have appropriate columns and triggers etc on them
            DiscoveredDatabase staging = _databaseConfiguration.DeployInfo[LoadBubble.Staging];
            DiscoveredDatabase live    = DataAccessPortal.GetInstance().ExpectDatabase(tableInfo, DataAccessContext.DataLoad);

            var liveTable = live.ExpectTable(tableInfo.GetRuntimeName(LoadBubble.Live, _databaseConfiguration.DatabaseNamer), tableInfo.Schema);
            var liveCols  = liveTable.DiscoverColumns();

            CheckTableInfoSynchronization(tableInfo, notifier);

            CheckTableHasColumnInfosAndPrimaryKeys(live, tableInfo, out columnInfos, out columnInfosWhichArePrimaryKeys, notifier);

            try
            {
                //if trigger is created as part of this check then it is likely to have resulted in changes to the underlying table (e.g. added hic_validFrom field) in which case we should resynch the TableInfo to pickup these new columns
                bool runSynchronizationAgain;
                CheckTriggerIntact(liveTable, notifier, out runSynchronizationAgain);

                if (runSynchronizationAgain)
                {
                    CheckTableInfoSynchronization(tableInfo, notifier);
                }

                if (!_databaseConfiguration.RequiresStagingTableCreation)
                {
                    //Important:
                    //Regarding this if block: None of the current loading systems in RDMP have RequiresStagingTableCreation as false but in theory you could build some kind of multi threaded horror
                    //which had multiple simultaneous loads all populating a single STAGING bubble therefore this code is left in the codebase, it probably works ok but you will need a
                    //fair bit of work if you want to realise such a monstrosity (for one cleanup on each run probably cleans up STAGING on exit)

                    //live can have additional hic_ columns which do not appear in staging (lookups cannot)
                    var stagingTable = staging.ExpectTable(tableInfo.GetRuntimeName(LoadBubble.Staging, _databaseConfiguration.DatabaseNamer));

                    if (!stagingTable.Exists())
                    {
                        notifier.OnCheckPerformed(new CheckEventArgs("RequiresStagingTableCreation is false but staging does not exist, this flag should indicate that you anticipate STAGING to be already setup before you kick off the load", CheckResult.Fail));
                    }

                    var stagingCols = stagingTable.DiscoverColumns();

                    ConfirmStagingAndLiveHaveSameColumns(tableInfo.GetRuntimeName(), stagingCols, liveCols, false, notifier);

                    CheckStagingToLiveMigrationForTable(stagingTable, stagingCols, liveTable, liveCols, notifier);
                }
            }
            catch (Exception e)
            {
                notifier.OnCheckPerformed(new CheckEventArgs("Load Checks Crashed " + tableInfo, CheckResult.Fail, e));
            }
        }
        private DiscoveredDatabase GetDestinationDatabase(IDataLoadEventListener listener)
        {
            //tell user we are about to inspect it
            listener.OnNotify(this, new NotifyEventArgs(ProgressEventType.Information, "About to open connection to " + TargetDatabaseServer));

            var databaseName = GetDatabaseName();

            var discoveredServer = DataAccessPortal.GetInstance().ExpectServer(TargetDatabaseServer, DataAccessContext.DataExport, setInitialDatabase: false);

            return(discoveredServer.ExpectDatabase(databaseName));
        }
Ejemplo n.º 21
0
        /// <inheritdoc/>
        public DiscoveredTable Discover(DataAccessContext context)
        {
            var db = DataAccessPortal.GetInstance().ExpectDatabase(this, context);

            if (IsTableValuedFunction)
            {
                return(db.ExpectTableValuedFunction(GetRuntimeName(), Schema));
            }

            return(db.ExpectTable(GetRuntimeName(), Schema, IsView?TableType.View : TableType.Table));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Runs the query described in <paramref name="collection"/> and extracts the data into <paramref name="toFile"/>
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="toFile"></param>
        /// <param name="context">Determines which access credentials (if any) are used to run the query</param>
        public static void ExtractDataToFile(IViewSQLAndResultsCollection collection, FileInfo toFile, DataAccessContext context = DataAccessContext.InternalDataProcessing)
        {
            var point = collection.GetDataAccessPoint();
            var db    = DataAccessPortal.GetInstance().ExpectDatabase(point, context);

            using (var fs = File.OpenWrite(toFile.FullName))
            {
                var toRun = new ExtractTableVerbatim(db.Server, collection.GetSql(), fs, ",", null);
                toRun.DoExtraction();
            }
        }
Ejemplo n.º 23
0
        private void DeleteANOEndpoint()
        {
            var remnantEndpointANOTable = DataAccessPortal.GetInstance()
                                          .ExpectDatabase(ANOStore_ExternalDatabaseServer, DataAccessContext.InternalDataProcessing)
                                          .ExpectTable("ANOCondition");

            if (remnantEndpointANOTable.Exists())
            {
                remnantEndpointANOTable.Drop();
            }
        }
Ejemplo n.º 24
0
        public void TestDistinctCredentials_DatabaseMixedCapitalization_NotAllowed()
        {
            List <TestAccessPoint> testPoints = new List <TestAccessPoint>();

            testPoints.Add(new TestAccessPoint("frank", "bob", null, null));
            testPoints.Add(new TestAccessPoint("frank", "BOB", null, null));

            var ex = Assert.Throws <ExpectedIdenticalStringsException>(() => DataAccessPortal.GetInstance().ExpectDistinctServer(testPoints.ToArray(), DataAccessContext.InternalDataProcessing, true));

            StringAssert.Contains("All data access points must be into the same database, access points 'frankbob' and 'frankBOB' are into different databases", ex.Message);
        }
Ejemplo n.º 25
0
        public void TestDistinctCredentials_ServerMixedCapitalization_Allowed()
        {
            List <TestAccessPoint> testPoints = new List <TestAccessPoint>();

            testPoints.Add(new TestAccessPoint("frank", "bob", null, null));
            testPoints.Add(new TestAccessPoint("FRANK", "bob", null, null));

            var server = DataAccessPortal.GetInstance().ExpectDistinctServer(testPoints.ToArray(), DataAccessContext.InternalDataProcessing, true);

            Assert.AreEqual("frank", server.Name);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Gets the <see cref="LogManager"/> for logging load events related to this Catalogue / it's LoadMetadata (if it has one).  This will throw if no
        /// logging server has been configured.
        /// </summary>
        /// <returns></returns>
        public LogManager GetLogManager()
        {
            if (LiveLoggingServer_ID == null)
            {
                throw new Exception("No live logging server set for Catalogue " + this.Name);
            }

            var server = DataAccessPortal.GetInstance().ExpectServer(LiveLoggingServer, DataAccessContext.Logging);

            return(new LogManager(server));
        }
Ejemplo n.º 27
0
        private void ddExternalDatabaseServer_SelectedIndexChanged(object sender, EventArgs e)
        {
            var server = ddExternalDatabaseServer.SelectedItem as ExternalDatabaseServer;

            if (server == null)
            {
                return;
            }

            ANOTransformer.ConfirmDependencies(DataAccessPortal.GetInstance().ExpectDatabase(server, DataAccessContext.DataLoad), checksUI1);
        }
Ejemplo n.º 28
0
        /// <inheritdoc cref="GetDistinctLoggingDatabase()"/>
        public DiscoveredServer GetDistinctLoggingDatabase(out IExternalDatabaseServer serverChosen)
        {
            var loggingServers = GetLoggingServers();

            var loggingServer = loggingServers.FirstOrDefault();

            //get distinct connection
            var toReturn = DataAccessPortal.GetInstance().ExpectDistinctServer(loggingServers, DataAccessContext.Logging, true);

            serverChosen = (IExternalDatabaseServer)loggingServer;
            return(toReturn);
        }
Ejemplo n.º 29
0
        public void TestDistinctCredentials_UsernamePasswordAreNull()
        {
            List <TestAccessPoint> testPoints = new List <TestAccessPoint>();

            testPoints.Add(new TestAccessPoint("frank", "bob", null, null));
            testPoints.Add(new TestAccessPoint("frank", "bob", "username", "mydifferentPass"));

            //call this
            var ex = Assert.Throws <Exception>(() => DataAccessPortal.GetInstance().ExpectDistinctServer(testPoints.ToArray(), DataAccessContext.InternalDataProcessing, true));

            StringAssert.Contains("collection could not agree whether to use Credentials", ex.Message);
        }
Ejemplo n.º 30
0
        public void TestDistinctCredentials_WrappedDatabaseName()
        {
            List <TestAccessPoint> testPoints = new List <TestAccessPoint>();

            testPoints.Add(new TestAccessPoint("frank", "[bob's Database]", "username", "mypas"));
            testPoints.Add(new TestAccessPoint("frank", "bob's Database", "username", "mypas"));
            //call this
            var result = DataAccessPortal.GetInstance().ExpectDistinctServer(testPoints.ToArray(), DataAccessContext.InternalDataProcessing, true);

            //test result
            Assert.AreEqual("bob's Database", result.Builder["Initial Catalog"]);
        }