Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Update #283 - Adjusted layout to better show transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
avanderhoorn committed Mar 24, 2013
1 parent b6a0085 commit a862537
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/Glimpse.Ado/AlternateType/GlimpseDbCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private void LogCommandStart(Guid commandId, TimeSpan timerTimeSpan)
}

MessageBroker.Publish(
new CommandExecutedMessage(InnerConnection.ConnectionId, commandId, InnerCommand.CommandText, parameters)
new CommandExecutedMessage(InnerConnection.ConnectionId, commandId, InnerCommand.CommandText, parameters, InnerCommand.Transaction != null)
.AsTimedMessage(timerTimeSpan));
}
}
Expand Down
4 changes: 3 additions & 1 deletion source/Glimpse.Ado/Message/CommandExecutedMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ public class CommandExecutedMessage : AdoCommandMessage
{
public string CommandText { get; protected set; }
public IList<CommandExecutedParamater> Parameters { get; protected set; }
public bool HasTransaction { get; protected set; }

public CommandExecutedMessage(Guid connectionId, Guid commandId, string commandText, IList<CommandExecutedParamater> parameters)
public CommandExecutedMessage(Guid connectionId, Guid commandId, string commandText, IList<CommandExecutedParamater> parameters, bool hasTransaction)
: base(connectionId, commandId)
{
CommandId = commandId;
CommandText = commandText;
Parameters = parameters;
HasTransaction = hasTransaction;
}
}

Expand Down
1 change: 1 addition & 0 deletions source/Glimpse.Ado/Model/CommandMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public CommandMetadata(string id, string connectionId)
public TimeSpan Offset { get; set; }
public IList<CommandParameterMetadata> Parameters { get; private set; }
public int ExecutionIndex { get; set; }
public bool HasTransaction { get; set; }

/// <summary>
/// Gets or sets the head transaction. Set when the command
Expand Down
1 change: 1 addition & 0 deletions source/Glimpse.Ado/Model/MessageAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ private void AggregateCommandExecuted()
command.Command = message.CommandText;
command.StartDateTime = message.StartTime;
command.Offset = message.Offset;
command.HasTransaction = message.HasTransaction;
if(message.Parameters != null)
{
foreach (var parameter in message.Parameters)
Expand Down
21 changes: 12 additions & 9 deletions source/Glimpse.Ado/Tab/Sql.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,25 @@ public override object GetData(ITabContext context)
continue;

var commands = new List<object[]> { new[] { "Transaction Start", "Ordinal", "Command", "Parameters", "Records", "Duration", "Offset", "Transaction End", "Errors" } };
var commandCount = 1;
var commandCount = 1;
foreach (var command in connection.Commands.Values)
{
//Transaction Start
List<object[]> headTransaction = null;
if (command.HeadTransaction != null)
{
headTransaction = new List<object[]> { new[] { "Transaction", "Isolation Level" }, new[] { "Started", command.HeadTransaction.IsolationLevel, !command.HeadTransaction.Committed.HasValue ? "error" : "" } };
headTransaction = new List<object[]> { new[] { "\t▼ Transaction - Started", "Isolation Level - " + command.HeadTransaction.IsolationLevel } };
if (!command.HeadTransaction.Committed.HasValue)
{
headTransaction.Add(new[] { "", "Transaction was never completed", "error" });
}
}

//Transaction Finish
List<object[]> tailTransaction = null;
if (command.TailTransaction != null)
{
tailTransaction = new List<object[]> { new[] { "Transaction", "Committed", "Duration" }, new[] { "Complete", command.TailTransaction.Committed.GetValueOrDefault() ? "Committed" : "Rollbacked", command.TailTransaction.Duration.HasValue ? (object)command.TailTransaction.Duration.Value : null, !command.TailTransaction.Committed.GetValueOrDefault() ? "warn" : "" } };
tailTransaction = new List<object[]> { new[] { "\tTransaction - Finished", "Status - " + (command.TailTransaction.Committed.GetValueOrDefault() ? "Committed" : "Rollbacked") } };
}

//Parameters
Expand All @@ -89,7 +93,7 @@ public override object GetData(ITabContext context)

//Commands
var records = command.RecordsAffected == null || command.RecordsAffected < 0 ? command.TotalRecords : command.RecordsAffected;
commands.Add(new object[] { headTransaction, commandCount++, sanitizer.Process(command.Command, command.Parameters), parameters, records, command.Duration, command.Offset, tailTransaction, errors, errors != null ? "error" : "" });
commands.Add(new object[] { headTransaction, string.Format("{0}{1}", command.HasTransaction ? "\t\t\t" : "", commandCount++), sanitizer.Process(command.Command, command.Parameters), parameters, records, command.Duration, command.Offset, tailTransaction, errors, errors != null ? "error" : "" });
}
connections.Add(new [] { commands, connection.Duration.HasValue ? (object)connection.Duration.Value : null });
}
Expand All @@ -103,7 +107,7 @@ public override object GetData(ITabContext context)
r.Cell(0).DisablePreview().SetLayout(TabLayout.Create().Row(x =>
x.Cell(0).SpanColumns(6).DisablePreview().AsMinimalDisplay().SetLayout(TabLayout.Create().Row(y =>
{
y.Cell(0).WidthInPixels(150).AsKey();
y.Cell(0).WidthInPixels(150);
y.Cell(1);
}))).Row(x =>
{
Expand All @@ -112,7 +116,7 @@ public override object GetData(ITabContext context)
x.Cell(3).WidthInPercent(25).DisablePreview();
x.Cell(4).WidthInPixels(60);
x.Cell(5).WidthInPixels(100).Suffix(" ms").Class("mono");
x.Cell(6).WidthInPixels(70).Prefix("T+ ").Suffix(" ms").Class("mono");
x.Cell(6).WidthInPixels(100).Prefix("T+ ").Suffix(" ms").Class("mono");
}).Row(x =>
x.Cell(8).SpanColumns(6).DisablePreview().AsMinimalDisplay().SetLayout(TabLayout.Create().Row(y =>
{
Expand All @@ -121,9 +125,8 @@ public override object GetData(ITabContext context)
}))).Row(x =>
x.Cell(7).SpanColumns(6).DisablePreview().AsMinimalDisplay().SetLayout(TabLayout.Create().Row(y =>
{
y.Cell(0).WidthInPixels(150).AsKey();
y.Cell(1);
y.Cell(2).WidthInPixels(100).Suffix(" ms").Class("mono");
y.Cell(0).WidthInPixels(150);
y.Cell(1);
}))));
r.Cell(1).WidthInPixels(75).Suffix(" ms").Class("mono");
}).Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,13 @@ private Tuple<int, int> GetTotalAlbumns()
{
using (var command = connection.CreateCommand())
{
command.Transaction = transaction;

command.CommandText = "SELECT COUNT(*) FROM Albums WHERE Title LIKE 'A%'";
command.CommandType = CommandType.Text;
result3 = (int)command.ExecuteScalar();
}
transaction.Commit();
//transaction.Commit();
}

using (var command = connection.CreateCommand())
Expand Down

0 comments on commit a862537

Please sign in to comment.