Permalink
Browse files

Update #283 - Adjusted layout to better show transactions

  • Loading branch information...
1 parent b6a0085 commit a862537b7546d5e223e9d13825d6ecebfd75abcd @avanderhoorn avanderhoorn committed Mar 24, 2013
@@ -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));
}
}
@@ -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;
}
}
@@ -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
@@ -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)
@@ -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
@@ -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 });
}
@@ -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 =>
{
@@ -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 =>
{
@@ -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();
@@ -129,11 +129,13 @@ private List<Album> GetTopSellingAlbums(int count)
{
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())

0 comments on commit a862537

Please sign in to comment.