示例#1
0
 public RoundhousETask(DbConnectionInfo connectionInfo, string scriptsLocation, string environmentName, RoundhousEMode roundhouseMode, DatabaseRecoveryMode recoveryMode, string restorePath, int restoreTimeout, string restoreCustomOptions, string repositoryPath, string versionFile, string versionXPath, int commandTimeout, int commandTimeoutAdmin, string functionsFolderName, string sprocsFolderName, string viewsFolderName, string upFolderName, string versionTable, string scriptsRunTable, string scriptsRunErrorTable, bool? warnOnOneTimeScriptChanges, string outputPath, 
     string alterDatabaseFolderName, string runAfterCreateDatabaseFolderName, string runBeforeUpFolderName, string runFirstAfterUpFolderName, string indexesFolderName, string runAfterOtherAnyTimeScriptsFolderName, string permissionsFolderName)
 {
     _connectionInfo = connectionInfo;
     _scriptsLocation = scriptsLocation;
     _environmentName = environmentName;
     _recoveryMode = recoveryMode;
     _roundhouseMode = roundhouseMode;
     _restorePath = restorePath;
     _restoreTimeout = restoreTimeout;
     _restoreCustomOptions = restoreCustomOptions;
     _repositoryPath = repositoryPath;
     _versionFile = versionFile;
     _versionXPath = versionXPath;
     _commandTimeout = commandTimeout;
     _commandTimeoutAdmin = commandTimeoutAdmin;
     _alterDatabaseFolderName = alterDatabaseFolderName;
     _runAfterCreateDatabaseFolderName = runAfterCreateDatabaseFolderName;
     _runBeforeUpFolderName = runBeforeUpFolderName;
     _upFolderName = upFolderName;
     _runFirstAfterUpFolderName = runFirstAfterUpFolderName;
     _functionsFolderName = functionsFolderName;
     _viewsFolderName = viewsFolderName;
     _sprocsFolderName = sprocsFolderName;
     _indexesFolderName = indexesFolderName;
     _runAfterOtherAnyTimeScriptsFolderName = runAfterOtherAnyTimeScriptsFolderName;
     _permissionsFolderName = permissionsFolderName;
     _versionTable = versionTable;
     _scriptsRunTable = scriptsRunTable;
     _scriptsRunErrorTable = scriptsRunErrorTable;
     _warnOnOneTimeScriptChanges = warnOnOneTimeScriptChanges;
     _outputPath = outputPath;
 }
示例#2
0
 public RoundhousETask(DbConnectionInfo connectionInfo, string scriptsLocation, string environmentName, RoundhousEMode roundhouseMode, DatabaseRecoveryMode recoveryMode, string restorePath, int restoreTimeout, string restoreCustomOptions, string repositoryPath, string versionFile, string versionXPath, int commandTimeout, int commandTimeoutAdmin, string functionsFolderName, string sprocsFolderName, string viewsFolderName, string upFolderName, string versionTable, string scriptsRunTable, string scriptsRunErrorTable, bool?warnOnOneTimeScriptChanges, string outputPath)
 {
     _connectionInfo             = connectionInfo;
     _scriptsLocation            = scriptsLocation;
     _environmentName            = environmentName;
     _recoveryMode               = recoveryMode;
     _roundhouseMode             = roundhouseMode;
     _restorePath                = restorePath;
     _restoreTimeout             = restoreTimeout;
     _restoreCustomOptions       = restoreCustomOptions;
     _repositoryPath             = repositoryPath;
     _versionFile                = versionFile;
     _versionXPath               = versionXPath;
     _commandTimeout             = commandTimeout;
     _commandTimeoutAdmin        = commandTimeoutAdmin;
     _functionsFolderName        = functionsFolderName;
     _sprocsFolderName           = sprocsFolderName;
     _viewsFolderName            = viewsFolderName;
     _upFolderName               = upFolderName;
     _versionTable               = versionTable;
     _scriptsRunTable            = scriptsRunTable;
     _scriptsRunErrorTable       = scriptsRunErrorTable;
     _warnOnOneTimeScriptChanges = warnOnOneTimeScriptChanges;
     _outputPath = outputPath;
 }
示例#3
0
 public RoundhousETask(string connectionString, string scriptsLocation, string environmentName, RoundhousEMode roundhouseMode, DatabaseRecoveryMode recoveryMode, string restorePath, string repositoryPath, string versionFile, string versionXPath)
 {
     _connectionString = connectionString;
     _scriptsLocation = scriptsLocation;
     _environmentName = environmentName;
     _recoveryMode = recoveryMode;
     _roundhouseMode = roundhouseMode;
     _restorePath = restorePath;
     _repositoryPath = repositoryPath;
     _versionFile = versionFile;
     _versionXPath = versionXPath;
 }
示例#4
0
 public RoundhousETask(string connectionString, string scriptsLocation, string environmentName, RoundhousEMode roundhouseMode, DatabaseRecoveryMode recoveryMode, string restorePath, int restoreTimeout, string restoreCustomOptions, string repositoryPath, string versionFile, string versionXPath,int commandTimeout, int commandTimeoutAdmin)
 {
     _connectionString = connectionString;
     _scriptsLocation = scriptsLocation;
     _environmentName = environmentName;
     _recoveryMode = recoveryMode;
     _roundhouseMode = roundhouseMode;
     _restorePath = restorePath;
     _restoreTimeout = restoreTimeout;
     _restoreCustomOptions = restoreCustomOptions;
     _repositoryPath = repositoryPath;
     _versionFile = versionFile;
     _versionXPath = versionXPath;
     _commandTimeout = commandTimeout;
     _commandTimeoutAdmin = commandTimeoutAdmin;
 }
示例#5
0
 public RoundhousETask(string connectionString, string scriptsLocation, string environmentName, RoundhousEMode roundhouseMode, DatabaseRecoveryMode recoveryMode, string restorePath, int restoreTimeout, string restoreCustomOptions, string repositoryPath, string versionFile, string versionXPath, int commandTimeout, int commandTimeoutAdmin, string functionsFolderName, string sprocsFolderName, string viewsFolderName, string upFolderName, string versionTable, string scriptsRunTable, string scriptsRunErrorTable, bool? warnOnOneTimeScriptChanges)
 {
     _connectionString = connectionString;
     _scriptsLocation = scriptsLocation;
     _environmentName = environmentName;
     _recoveryMode = recoveryMode;
     _roundhouseMode = roundhouseMode;
     _restorePath = restorePath;
     _restoreTimeout = restoreTimeout;
     _restoreCustomOptions = restoreCustomOptions;
     _repositoryPath = repositoryPath;
     _versionFile = versionFile;
     _versionXPath = versionXPath;
     _commandTimeout = commandTimeout;
     _commandTimeoutAdmin = commandTimeoutAdmin;
     _functionsFolderName = functionsFolderName;
     _sprocsFolderName = sprocsFolderName;
     _viewsFolderName = viewsFolderName;
     _upFolderName = upFolderName;
     _versionTable = versionTable;
     _scriptsRunTable = scriptsRunTable;
     _scriptsRunErrorTable = scriptsRunErrorTable;
     _warnOnOneTimeScriptChanges = warnOnOneTimeScriptChanges;
 }
        public void _3_Exam_Servers()
        {
            var list = SqlServers.OrderByVersionDesc().ToList();

            Debug.WriteLine($"Exam {list.Count} sql servers:{Environment.NewLine}{list.AsBullets()}");
            Debug.WriteLine("");

            int                    alive = 0, sysadmin = 0;
            Stopwatch              startAt      = Stopwatch.StartNew();
            StringBuilder          timingReport = new StringBuilder();
            ConcurrentBag <string> errorServers = new ConcurrentBag <string>();
            ParallelOptions        opts         = new ParallelOptions()
            {
                MaxDegreeOfParallelism = Math.Max(list.Count, 2)
            };

            Parallel.For(0, list.Count, opts, (i) =>
            {
                var sqlRef = list[i];
                // if (Debugger.IsAttached && sqlRef.DataSource.IndexOf("Ubuntu-16.04-LTS", StringComparison.InvariantCultureIgnoreCase) >= 0) Debugger.Break();
                string cs            = sqlRef.ConnectionString;
                string v             = sqlRef.Version == null ? "N/A" : sqlRef.Version.ToString();
                StringBuilder report = new StringBuilder();
                report.AppendLine($"SERVER {sqlRef}");
                try
                {
                    using (SqlConnection con = new SqlConnection(cs))
                    {
                        var man = con.Manage();
                        var ver = man.ShortServerVersion;
                        if (sqlRef.Version == null)
                        {
                            sqlRef.Version = ver;
                        }
                        alive++;
                        report.AppendLine("Version (4 bytes) ........: " + ver);
                        report.AppendLine("Version (string) .........: " + man.ProductVersion);
                        report.AppendLine("Product Level ............: " + man.ProductLevel);
                        report.AppendLine("Update Level .............: " + man.ProductUpdateLevel);
                        report.AppendLine("Edition ..................: " + man.ServerEdition);
                        report.AppendLine("Engine Edition ...........: " + man.EngineEdition);
                        report.AppendLine("Host Platform ............: " + man.HostPlatform);
                        report.AppendLine("Security Mode ............: " + man.SecurityMode);
                        report.AppendLine("Is LocalDB ...............: " + man.IsLocalDB);
                        var transport = man.NetTransport;
                        transport    += ", " + (man.IsConnectionEncrypted ? "Encrypted" : "Without Encryption");
                        report.AppendLine("Transport ................: " + transport);
                        report.AppendLine("Server Collation .........: " + man.ServerCollation);
                        var roles       = man.FixedServerRoles;
                        var isSysAdmin  = (roles & FixedServerRoles.SysAdmin) != 0;
                        var rolesString = isSysAdmin ? "Sys Admin" : roles.ToString();
                        report.AppendLine("Built-in Roles ...........: " + rolesString);
                        var dbList = man.DatabaseSizes;
                        report.AppendLine("Databases ................: " + dbList.Count + " (" + dbList.Sum(x => x.Value) + " Kb)");
                        if (isSysAdmin)
                        {
                            sysadmin++;
                        }
                        var paths = man.DefaultPaths;
                        report.AppendLine("Default Data .............: " + paths.DefaultData);
                        report.AppendLine("Default Log ..............: " + paths.DefaultLog);
                        report.AppendLine("Default Backup ...........: " + paths.DefaultBackup);

                        // DB Options demo
                        var currentDatabase = man.CurrentDatabaseName;
                        var dbOptions       = man.Databases[currentDatabase];
                        report.Append("Connected DB Info ........: [" + currentDatabase + "]" + Environment.NewLine);
                        dbOptions.WriteDigest(report, intent: 1);

                        report.AppendLine("Long Version .............: " + man.LongServerVersion);


                        if (man.IsAzure && Debugger.IsAttached)
                        {
                            Debugger.Break();
                        }
                        if (!man.IsAzure)
                        {
                            var prevRecovery = dbOptions.RecoveryMode;
                            DatabaseRecoveryMode newRecovery =
                                prevRecovery == DatabaseRecoveryMode.Bulk_Logged
                                    ? DatabaseRecoveryMode.Simple
                                    : DatabaseRecoveryMode.Bulk_Logged;

                            dbOptions.RecoveryMode = newRecovery;
                            dbOptions.RecoveryMode = prevRecovery;
                        }

                        man.IsFullTextSearchInstalled.ToString();
                    }
                }
                catch (Exception ex)
                {
                    report.AppendLine("Exception ................: " + ex.GetExeptionDigest());
                    errorServers.Add(sqlRef.DataSource);
                }

                lock (timingReport)
                    timingReport
                    .AppendFormat($" {sqlRef} examined in {(startAt.ElapsedMilliseconds / 1000m):0.00} secs")
                    .AppendLine();

                Debug.WriteLine(report);
            });

            Debug.WriteLine($"Done:{Environment.NewLine}{timingReport}");
            Debug.WriteLine($"Alive Servers: {alive}. SysAdmins Permissions: {sysadmin}.");
            if (errorServers.Count > 0)
            {
                Debug.WriteLine(string.Format(
                                    "Warning! Some sql servers have fails. See details above: {0}{1}",
                                    Environment.NewLine,
                                    string.Join(Environment.NewLine, errorServers.OrderBy(x => x).Select(x => " * " + x))
                                    ));
            }
        }
示例#7
0
 public RoundhousEOptions WithDatabaseRecoveryMode(DatabaseRecoveryMode recoveryMode)
 {
     _recoveryMode = recoveryMode;
     return this;
 }
 public RoundhousEOptions WithDatabaseRecoveryMode(DatabaseRecoveryMode recoveryMode)
 {
     _recoveryMode = recoveryMode;
     return(this);
 }