Esempio n. 1
0
        public static Match MatchCubeToDatabase(List <Database> databases, Cube cube)
        {
            //
            // Summary:
            //      Based on the connection strings and their initial
            //      catalog values found in the cube, the corresponding
            //      databases are matched and returned to the caller.
            //

            Match match = new Match(cube);

            Console.WriteLine($"Comparing for cube {cube._cubeName}...");

            foreach (DataSource ds in cube._cubeDs)
            {
                Database db = new Database();
                // Compare based on Initial Catalog because
                // databases have no connection string

                db = databases.Find(x =>
                                    x._databaseDs._dsInitCatalog.Equals(ds._dsInitCatalog));

                if (db == null)
                {
                    MatchException matchException = new MatchException($"The cube " +
                                                                       $"{cube._cubeName} has no corresponding databases.");
                    throw matchException;
                }

                Console.WriteLine($"The cube {cube._cubeName} connects to database " +
                                  $"{db._databaseDs._dsInitCatalog}");
                match.MatchedDatabases.Add(db);
            }
            return(match);
        }
Esempio n. 2
0
        public void CheckForTables(Match match)
        {
            //
            // Summary:
            //      Checks for each cube table
            //      if it is represented in the
            //      corresponding database. If not
            //      it will generate warnings and
            //      throw an exception.
            //
            string checkName = "100. Cube vs Database table test";

            Console.WriteLine($"Running check {checkName}: \nChecking if all cube tables have " +
                              $"corresponding database tables.");

            List <CubeTable> nonMatchedTables = new List <CubeTable>();

            foreach (CubeTable cubeTable in match.MatchingCube._cubeTables)
            {
                foreach (Database db in match.MatchedDatabases)
                {
                    // See if the cubeTable is found in the database table list
                    Boolean isTable = db._databaseTables.Any(x => x.TableName.ToLower() == cubeTable.TableName.ToLower());

                    // See if the cubeTable is found in the database view list
                    Boolean isView = db._databaseViews.Any(x => x.TableName.ToLower() == cubeTable.TableName.ToLower());

                    // If the cube table is not within the database table or view
                    // list, add it to the non matched table list.
                    if (!(isTable || isView))
                    {
                        nonMatchedTables.Add(cubeTable);
                    }
                }
            }

            // If there are non matched tables, write
            // out their names to the console. Else
            // write out success.
            if (nonMatchedTables.Count > 0)
            {
                MatchException matchException = new MatchException($"Error: One or more cube " +
                                                                   $"tables cannot be found in the dacpac. Checkname: {checkName}");
                Console.WriteLine($"For cube {match.MatchingCube._cubeName} the following " +
                                  $"tables cannot be found in the dacpacs:");
                foreach (Table table in nonMatchedTables)
                {
                    Console.WriteLine($"\n{table.TableName}");
                }

                // TODO: opnieuw aanzetten exception. Staat nu uit voor debugging.
                //throw matchException;
            }
            else
            {
                WriteTestSuccess(checkName);
            }
        }