예제 #1
0
        private string GetInformation(InformationEntry entry)
        {
            if (entry.Title != null)
            {
                if (entry.Text != null)
                {
                    return(String.Format("{0}: {1}", entry.Title, entry.Text));
                }

                return(entry.Title);
            }

            return(entry.Text);
        }
        public void GetEntry_ParsesEachColumn()
        {
            var provider = CreateProvider();
            var row = CreateDataRow();

            row["QueryName"] = "Title";
            row["QueryText"] = "Text";

            var entry = provider.GetEntry(row);

            var expected = new InformationEntry
            {
                Title = "Title",
                Text = "Text"
            };

            var printer = new Stateprinter();
            Assert.AreEqual(printer.PrintObject(expected), printer.PrintObject(entry));
        }
예제 #3
0
        private string GetInformation(InformationEntry entry)
        {
            if (entry.Title != null)
            {
                if (entry.Text != null)
                {
                    return String.Format("{0}: {1}", entry.Title, entry.Text);
                }

                return entry.Title;
            }

            return entry.Text;
        }
예제 #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 }
            });
        }