/// <summary>
        /// Initializes a new instance of the <see cref="GlimpseAdomdTransaction"/> class.
        /// </summary>
        /// <param name="innerTransaction">The underlying IDbTransaction.</param>
        /// <param name="connection">The associated AdomdConnection.</param>
        /// <param name="connectionId">The connection identifier.</param>
        /// <param name="messagePublisher">The message publisher.</param>
        internal GlimpseAdomdTransaction(IDbTransaction innerTransaction, IDbConnection connection, Guid connectionId, ITimedMessagePublisher messagePublisher)
        {
            if (innerTransaction == null)
            {
                throw new ArgumentNullException("innerTransaction");
            }
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (messagePublisher == null)
            {
                throw new ArgumentNullException("messagePublisher");
            }
            _innerTransaction = innerTransaction;
            _innerConnection = connection;
            _connectionId = connectionId;
            _messagePublisher = messagePublisher;

            TransactionId = Guid.NewGuid();
            
            _messagePublisher.EmitStartMessage(
                new TransactionBeganMessage(
                    _connectionId,
                    TransactionId,
                    _innerTransaction.IsolationLevel));
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GlimpseAdomdTransaction"/> class.
        /// </summary>
        /// <param name="innerTransaction">The underlying IDbTransaction.</param>
        /// <param name="connection">The associated AdomdConnection.</param>
        /// <param name="connectionId">The connection identifier.</param>
        /// <param name="messagePublisher">The message publisher.</param>
        internal GlimpseAdomdTransaction(IDbTransaction innerTransaction, IDbConnection connection, Guid connectionId, ITimedMessagePublisher messagePublisher)
        {
            if (innerTransaction == null)
            {
                throw new ArgumentNullException("innerTransaction");
            }
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }
            if (messagePublisher == null)
            {
                throw new ArgumentNullException("messagePublisher");
            }
            _innerTransaction = innerTransaction;
            _innerConnection  = connection;
            _connectionId     = connectionId;
            _messagePublisher = messagePublisher;

            TransactionId = Guid.NewGuid();

            _messagePublisher.EmitStartMessage(
                new TransactionBeganMessage(
                    _connectionId,
                    TransactionId,
                    _innerTransaction.IsolationLevel));
        }
        /// <summary>
        /// Handles command start execution.
        /// Publishes a CommandExecutedMessage with command text, command parameters.
        /// </summary>
        private void LogCommandStart()
        {
            var parameters = new List <CommandExecutedParameter>();

            if (_command.Parameters != null && _command.Parameters.Count > 0)
            {
                foreach (IDbDataParameter parameter in _command.Parameters)
                {
                    var parameterName = parameter.ParameterName;
                    if (!parameterName.StartsWith("@"))
                    {
                        parameterName = "@" + parameterName;
                    }
                    parameters.Add(new CommandExecutedParameter {
                        Name = parameterName, Value = parameter.Value
                    });
                }
            }
            _messagePublisher.EmitStartMessage(new CommandExecutedMessage(_command.ConnectionId, _command.CommandId, _command.CommandText, parameters, _command.Transaction != null));
        }
 /// <inheritdoc />
 public void Open()
 {
     _messagePublisher.EmitStartMessage(new ConnectionStartedMessage(_connectionId));
     _innerConnection.Open();
 }