Exemple #1
0
        private static void EnumerateColumn(DependencyArguments dependencyArguments, Repository repository)
        {
            ColumnEnumerator enumerator = new ColumnEnumerator();

            if (enumerator.Initialize(repository))
            {
                // nothing to enumerate right now, initialize call should have created the relational types
                // in the repository
            }
        }
Exemple #2
0
        private static void EnumerateDatabase(DependencyArguments dependencyArguments, Repository repository)
        {
            // ToDo: Code the call to DatabaseEnumerator()...
            SQLDBEnumerator enumerator = new SQLDBEnumerator();

            if (enumerator.Initialize(repository))
            {
                foreach (string dbConnection in dependencyArguments.databasesToScan)
                {
                    Console.WriteLine("Enumerating Database metadata for {0}.", dbConnection);
                    enumerator.EnumerateDatabase(dbConnection, dependencyArguments.storeThreePartNames);
                }
            }
        }
Exemple #3
0
        private static Repository InitializeRepository(DependencyArguments dependencyArguments, string commandLineArguments)
        {
            Repository repository = new Repository(dependencyArguments.depDb);

            try
            {
                repository.Open();

                // check if this is a valid repository database
                if (repository.IsValidRepository() == false)
                {
                    repository.CreateRepository();
                }

                if (dependencyArguments.clearDatabase)
                {
                    repository.DeleteExistingRepository();
                }
                else
                {
                    repository.LoadExisingRepository();
                }

                if (commandLineArguments.Length > 512)
                {
                    repository.InitialiseRepository(commandLineArguments.Substring(0, 512));
                }
                else
                {
                    repository.InitialiseRepository(commandLineArguments);
                }
                repository.DatabaseNameOnlyCompare = dependencyArguments.matchDBOnly;

                foreach (string dbPrefix in dependencyArguments.dbPrefix)
                {
                    repository.DatabasePrefixExclusions.Add(dbPrefix);
                }

                return(repository);
            }
            catch (Exception ex)
            {
                log.Error(string.Format("Unable to connect to Dependency Database: {0}", dependencyArguments.depDb));
                log.Error(string.Format("Message: {0}", ex.Message));
                return(null);
            }
        }
Exemple #4
0
        private static void EnumerateSSIS(DependencyArguments dependencyArguments, Repository repository)
        {
            SSISEnumerator enumerator = new SSISEnumerator();

            if (enumerator.Initialize(repository))
            {
                log.Info("Enumerating File System Integration Services metadata.");
                enumerator.EnumerateFileSystemPackages(dependencyArguments.folders, dependencyArguments.recurse, dependencyArguments.storeThreePartNames, dependencyArguments.isPkgPwd);

                if (dependencyArguments.skipSQL == false)
                {
                    log.Info("Enumerating Integration Services metadata.");
                    foreach (string dbServer in dependencyArguments.isDbServer)
                    {
                        if (dbServer.Contains(";"))
                        {
                            String dbUser     = null;
                            String dbPass     = null;
                            String ssisServer = string.Empty;
                            int    posServer  = dbServer.IndexOf("server=", 0, StringComparison.InvariantCultureIgnoreCase) + "server=".Length;
                            int    posUser    = dbServer.IndexOf("user="******"password="******"user="******"password=".Length;
                            dbPass     = dbServer.Substring(posPass, dbServer.Length - posPass);
                            if (String.IsNullOrEmpty(dbUser))
                            {
                                dbUser = null;
                                dbPass = null;
                            }
                            enumerator.EnumerateSqlPackages(ssisServer, dbUser, dbPass, dependencyArguments.ssisFolders, dependencyArguments.storeThreePartNames, dependencyArguments.isPkgPwd);
                        }
                        else
                        {
                            enumerator.EnumerateSqlPackages(dbServer, dependencyArguments.isDbUser, dependencyArguments.isDbPwd, dependencyArguments.ssisFolders, dependencyArguments.storeThreePartNames, dependencyArguments.isPkgPwd);
                        }
                    }
                }
            }
        }
Exemple #5
0
        private static void EnumerateSSRS(DependencyArguments dependencyArguments, Repository repository)
        {
            Console.WriteLine("Enumerating Reporting Services metadata.");
            try
            {
                SSRSEnumerator enumerator = new SSRSEnumerator();

                if (enumerator.Initialize(repository))
                {
                    foreach (string connStr in dependencyArguments.reportURLs)
                    {
                        enumerator.EnumerateReportingServer(connStr, dependencyArguments.recurse, dependencyArguments.storeThreePartNames);
                    }
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(string.Format("Error occurred: {0}", ex.Message));
            }
        }
Exemple #6
0
        private static void EnumerateSSAS(DependencyArguments dependencyArguments, Repository repository)
        {
            log.Info("Enumerating Analysis Services metadata.");
            try
            {
                SSASEnumerator enumerator = new SSASEnumerator();

                if (enumerator.Initialize(repository))
                {
                    foreach (string connStr in dependencyArguments.asCon)
                    {
                        enumerator.EnumerateServer(connStr, dependencyArguments.storeThreePartNames);
                        // Incremental Commit
                        repository.Commit();
                    }
                }
            }
            catch (System.Exception ex)
            {
                log.Error(string.Format("Error occurred: {0}", ex.Message));
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            string commandLineArguments = "";

            foreach (string tmpString in args)
            {
                commandLineArguments += tmpString + " ";
            }
            // parse the command line
            DependencyArguments dependencyArguments = new DependencyArguments();

            if (CommandLine.Parser.ParseArgumentsWithUsage(args, dependencyArguments))
            {
                try
                {
                    if (dependencyArguments.batchMode == false && dependencyArguments.clearDatabase == true)
                    {
                        Console.WriteLine("This tool will delete existing information in the dependency database!");
                        Console.Write("Press any key to begin...");
                        Console.ReadKey(true);
                        Console.WriteLine("started");
                    }

                    // open a connection to the repository
                    Repository repository = InitializeRepository(dependencyArguments, commandLineArguments);

                    if (repository == null)
                    {
                        log.Error(String.Format("Unable to open database on connection string '{0}'.  Exiting...", dependencyArguments.depDb));
                        return;
                    }

                    EnumerateRelational(dependencyArguments, repository);
                    EnumerateFile(dependencyArguments, repository);
                    EnumerateColumn(dependencyArguments, repository);
                    EnumerateReport(dependencyArguments, repository);

                    if (dependencyArguments.databasesToScan != null)
                    {
                        EnumerateDatabase(dependencyArguments, repository);
                    }

                    if (dependencyArguments.skipSSIS == false)
                    {
                        EnumerateSSIS(dependencyArguments, repository);
                    }

                    if (dependencyArguments.skipAS == false)
                    {
                        EnumerateSSAS(dependencyArguments, repository);
                    }

                    if (dependencyArguments.skipReportingServices == false)
                    {
                        EnumerateSSRS(dependencyArguments, repository);
                    }

                    Commit(repository);
                }
                catch (System.Exception ex)
                {
                    log.Error(string.Format("Unexpected error occurred: {0}", ex.Message));
                    log.Error(string.Format("Stack Trace: {0}", ex.StackTrace).Replace(Environment.NewLine, ""));
                }

                if (dependencyArguments.batchMode == false)
                {
                    Console.Write("Press any key to continue...");
                    Console.ReadKey(true);
                    Console.WriteLine("done");
                }
            }
        }