Exemplo n.º 1
0
        public void AssertDBDiagnosticsSerivceReturnsDatabaseTables()
        {
            var dbDiagnosticsService = new DatabaseDiagnosticsService();
            var dbTables             = Task.Run(async() => await dbDiagnosticsService.GetDatabaseTables()).Result;

            Assert.IsNotNull(dbTables);
            Assert.IsTrue(dbTables.Count > 0);
        }
Exemplo n.º 2
0
        public void AssertDBDiagnosticsSerivceReturnsDBSize()
        {
            var dbDiagnosticsService = new DatabaseDiagnosticsService();
            var dbSize = Task.Run(async() => await dbDiagnosticsService.GetDBSize()).Result;

            Assert.IsNotNull(dbSize);
            Assert.IsNotNull(dbSize.Name);
            Assert.IsNotNull(dbSize.Size);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Logs the total size of the database
        /// </summary>
        private void LogDbSize()
        {
            var           dbService = new DatabaseDiagnosticsService();
            var           dataBase  = dbService.GetDBSize().Result;
            StringBuilder sb        = new StringBuilder("Database info:");

            sb.AppendLine();
            sb.AppendLine(string.Format("Database: {0}, Size: {1}, Reserved: {2}, Unallocated: {3}, Data: {4}, Index: {5}, Unused {6}",
                                        dataBase.Name, dataBase.Size, dataBase.Reserved, dataBase.Unallocated, dataBase.Data, dataBase.Index, dataBase.Unused));

            Log.Write(sb.ToString(), System.Diagnostics.TraceEventType.Information);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Logs the size of each database table
        /// </summary>
        private void LogTableSizes()
        {
            var           dbService = new DatabaseDiagnosticsService();
            var           tables    = dbService.GetDatabaseTables().Result;
            StringBuilder sb        = new StringBuilder("Database Tables info:");

            sb.AppendLine();
            foreach (var t in tables)
            {
                sb.AppendLine(string.Format("{0, 35}, {1, 15}, {2, 15}", t.Name, t.Rows, t.Size));
            }

            Log.Write(sb.ToString(), System.Diagnostics.TraceEventType.Information);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Logs the fragmentation ratio of the DB indexes
        /// </summary>
        private void LogIndexFragmentation()
        {
            var           dbService = new DatabaseDiagnosticsService();
            var           indexes   = dbService.GetIndexFragmentation().Result;
            StringBuilder sb        = new StringBuilder("Index info: Database, Table, Index, Fragmentation, Fill Factor: ");

            sb.AppendLine();
            foreach (var idx in indexes)
            {
                sb.AppendLine(string.Format("{0, 35} {1, 35} {2, 35} {3, 10} {4, 10}",
                                            idx.Database, idx.Table, idx.Name, idx.Fragmentation, idx.FillFactor));
            }

            Log.Write(sb.ToString(), System.Diagnostics.TraceEventType.Information);
        }