Пример #1
0
 internal void SetConnectionString(EDbType dbType, string dataSource, string user, string password)
 {
     if (!ConnectionStringRegistry.Instance().HasDbType(dbType))
     {
         IConnectionString oraConnect;
         if (_connectionStringsLoaded.ContainsKey(dataSource))
         {
             oraConnect = _connectionStringsLoaded[dataSource];
         }
         else
         {
             oraConnect = new OracleConnectionString(dataSource, user, password)
             {
                 ConnectionPooling = true
             };
         }
         ConnectionStringRegistry.Instance().Add(dbType, oraConnect);
     }
 }
Пример #2
0
        public void Configure()
        {
            var dbMode = ConnectionStringRegistry.Instance().DatabaseMode;

            if (dbMode != EDatabaseMode.Unkown)
            {
                var databaseTypesLoader = new DatabaseTypesLoader();
                var dbTypes             = databaseTypesLoader.Load();

                string databaseId = dbTypes.GetDatabaseId(EDbType.MainDb, dbMode);

                if (databaseId != null)
                {
                    var connectionStringLoader = new ConnectionStringLoader();
                    var connectionStrings      = connectionStringLoader.Load();

                    ConnectionStringRegistry.Instance().Add(EDbType.MainDb, connectionStrings[databaseId]);
                }
            }
        }
Пример #3
0
        public void Configure()
        {
            bool connectionStringFromCmdLineExists = false;
            bool connectionStringFromXmlFileExists = false;

            if (!string.IsNullOrEmpty(_user) &&
                !string.IsNullOrEmpty(_password))
            {
                connectionStringFromCmdLineExists = true;
            }

            var loader            = new ConnectionStringLoader();
            var connectionStrings = loader.Load();

            if (connectionStrings != null &&
                connectionStrings.Count > 0)
            {
                connectionStringFromXmlFileExists = true;
            }

            OracleConnectionString connectString;

            if (connectionStringFromCmdLineExists)
            {
                connectString = new OracleConnectionString(_dataSource, _user, _password);
            }
            else if (connectionStringFromXmlFileExists)
            {
                connectString = connectionStrings[_dataSource] as OracleConnectionString;

                Debug.Assert(connectString != null, "connectString != null");
                if (connectString.HasProxyUserAndPassword)
                {
                    connectString.User     = WindowsIdentity.GetCurrent().NameWithoutDomain();
                    connectString.Password = null;
                }
                Debug.Assert(connectString != null, "ConnectionString not of type OracleConnectionString?");
            }
            else
            {
                throw new ConnectionStringRegistryException(
                          "No Database ConnectionString configuration found. Please use command-line or xml-config.");
            }

            if (DbType == EDbType.Unkown && DbMode == EDatabaseMode.Unkown)
            {
                var databaseTypesLoader = new DatabaseTypesLoader();
                var dbTypes             = databaseTypesLoader.Load();
                DbType = dbTypes.GetDbType(_dataSource);
                DbMode = dbTypes.GetDbMode(_dataSource);
            }

            if (DbType == EDbType.Unkown)
            {
                throw new ConnectionStringRegistryException(string.Format("Unkown database type [{0}]", _dataSource));
            }
            if (DbMode == EDatabaseMode.Unkown)
            {
                throw new ConnectionStringRegistryException(string.Format("Unkown database mode [{0}]", _dataSource));
            }

            connectString.ConnectionPooling = true;
            ConnectionStringRegistry.Instance().DatabaseMode = DbMode;
            ConnectionStringRegistry.Instance().Add(DbType, connectString);
        }
Пример #4
0
        /// <summary>
        /// Returns debug information that will be sent to the Glimpse client.
        /// </summary>
        /// <param name="context">The tab context.</param>
        /// <returns>An object with debug information that the Glimpse client can display.</returns>
        public override object GetData(ITabContext context)
        {
            var connectionStringRegistry = new ConnectionStringRegistry();
            var entryFactory = new EntryFactory(connectionStringRegistry);
            var requestMetadataProvider = new RequestMetadataProvider(entryFactory);
            var requestMetadata = requestMetadataProvider.GetRequestMetadata(SqlDebug.CurrentRequestLog);

            var items = new List<object[]>
            {
                new object[] {"Ordinal", "Information", "Text", "Result", "Received", "Sent", "Duration", "Stack trace"}
            };

            var nextOrdinal = 1;
            foreach (var entry in requestMetadata.Entries)
            {
                CommandEntry commandEntry = entry as CommandEntry;
                if (commandEntry != null)
                {
                    items.Add(new object[] {
                        String.Format(CultureInfo.InvariantCulture, "{0:N0}", nextOrdinal++),
                        GetInformation(commandEntry),
                        GetText(commandEntry),
                        GetResult(commandEntry),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesReceived, GetBytesReceivedChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesSent, GetBytesSentChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} ms {1}!", commandEntry.Duration.TotalMilliseconds, GetDurationChart(requestMetadata, commandEntry)),
                        commandEntry.StackTrace,
                        commandEntry.IsDuplicate ? "warn" : String.Empty
                    });
                    continue;
                }

                ConnectionEntry connectionEntry = entry as ConnectionEntry;
                if (connectionEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(connectionEntry),
                        String.Empty,
                        null,
                        null,
                        null,
                        null,
                        connectionEntry.StackTrace,
                        "quiet"
                    });
                    continue;
                }

                InformationEntry informationEntry = entry as InformationEntry;
                if (informationEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(informationEntry),
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        "info"
                    });
                    continue;
                }
            }

            var statictics = new object[] {
                new object[] { "Name", "Value" },
                new object[] { "Queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalCommands) },
                new object[] { "Duplicate queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalDuplicateCommands) },
                new object[] { "Duration", String.Format(CultureInfo.InvariantCulture, "{0:N0} ms", requestMetadata.Statistics.TotalDuration.TotalMilliseconds) },
                new object[] { "Received", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesReceived) },
                new object[] { "Sent", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesSent) }
            };

            return new Dictionary<string, object>
            {
                { SECTION_KEY_STATISTICS, statictics },
                { SECTION_KEY_QUERIES, items }
            };
        }
Пример #5
0
        /// <summary>
        /// Returns debug information that will be sent to the Glimpse client.
        /// </summary>
        /// <param name="context">The tab context.</param>
        /// <returns>An object with debug information that the Glimpse client can display.</returns>
        public override object GetData(ITabContext context)
        {
            var connectionStringRegistry = new ConnectionStringRegistry();
            var entryFactory             = new EntryFactory(connectionStringRegistry);
            var requestMetadataProvider  = new RequestMetadataProvider(entryFactory);
            var requestMetadata          = requestMetadataProvider.GetRequestMetadata(SqlDebug.CurrentRequestLog);

            var items = new List <object[]>
            {
                new object[] { "Ordinal", "Information", "Text", "Result", "Received", "Sent", "Duration", "Stack trace" }
            };

            var nextOrdinal = 1;

            foreach (var entry in requestMetadata.Entries)
            {
                CommandEntry commandEntry = entry as CommandEntry;
                if (commandEntry != null)
                {
                    items.Add(new object[] {
                        String.Format(CultureInfo.InvariantCulture, "{0:N0}", nextOrdinal++),
                        GetInformation(commandEntry),
                        GetText(commandEntry),
                        GetResult(commandEntry),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesReceived, GetBytesReceivedChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} B {1}!", commandEntry.BytesSent, GetBytesSentChart(requestMetadata, commandEntry)),
                        String.Format(CultureInfo.InvariantCulture, "!{0:N0} ms {1}!", commandEntry.Duration.TotalMilliseconds, GetDurationChart(requestMetadata, commandEntry)),
                        commandEntry.StackTrace,
                        commandEntry.IsDuplicate ? "warn" : String.Empty
                    });
                    continue;
                }

                ConnectionEntry connectionEntry = entry as ConnectionEntry;
                if (connectionEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(connectionEntry),
                        String.Empty,
                        null,
                        null,
                        null,
                        null,
                        connectionEntry.StackTrace,
                        "quiet"
                    });
                    continue;
                }

                InformationEntry informationEntry = entry as InformationEntry;
                if (informationEntry != null)
                {
                    items.Add(new object[] {
                        String.Empty,
                        GetInformation(informationEntry),
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        "info"
                    });
                    continue;
                }
            }

            var statictics = new object[] {
                new object[] { "Name", "Value" },
                new object[] { "Queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalCommands) },
                new object[] { "Duplicate queries", String.Format(CultureInfo.InvariantCulture, "{0:N0}", requestMetadata.Statistics.TotalDuplicateCommands) },
                new object[] { "Duration", String.Format(CultureInfo.InvariantCulture, "{0:N0} ms", requestMetadata.Statistics.TotalDuration.TotalMilliseconds) },
                new object[] { "Received", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesReceived) },
                new object[] { "Sent", String.Format(CultureInfo.InvariantCulture, "{0:N0} B", requestMetadata.Statistics.TotalBytesSent) }
            };

            return(new Dictionary <string, object>
            {
                { SECTION_KEY_STATISTICS, statictics },
                { SECTION_KEY_QUERIES, items }
            });
        }