예제 #1
0
        public void LogConnection(DbConnection connection,
                                  DbConnectionContext interceptionConnectionContext,
                                  CommandConnectionType type)
        {
            var commandConnection = new CommandConnection
            {
                IsAsync          = interceptionConnectionContext.IsAsync,
                Type             = type,
                IsCanceled       = interceptionConnectionContext.IsCanceled,
                ConnectionString = connection.ConnectionString,
                Exception        = interceptionConnectionContext.Exception != null ? interceptionConnectionContext.Exception.Message : "",
                StackTrace       = new CallingMethod {
                    AssembliesToExclude = AssembliesToExclude
                }.GetCallingMethodInfo()
            };

            setBaseInfo(interceptionConnectionContext, commandConnection);

            if (commandConnection.ConnectionId == null)
            {
                commandConnection.ConnectionId = UniqueIdExtensions <DbConnection> .GetUniqueId(connection).ToInt();
            }

            _baseInfoQueue.Enqueue(commandConnection);
        }
 public static DbConnectionContext GetLoggedDbConnection(DbConnection connection)
 {
     var context = new DbConnectionContext
     {
         IsAsync = false,
         IsCanceled = false,
         Exception = null,
         ConnectionString = connection.ConnectionString,
         ObjectContextId = SessionIdLoggingContext.SessionId.GetUniqueId(),
         ObjectContextName = SessionId,
         ConnectionId = UniqueIdExtensions<DbConnection>.GetUniqueId(connection).ToInt()
     };
     return context;
 }
 public static DbConnectionContext GetLoggedDbConnection(ProfiledDbTransaction interceptionContext, int connectionId)
 {
     var context = new DbConnectionContext
     {
         IsAsync = false,
         IsCanceled = false,
         Exception = null,
         ConnectionString = interceptionContext.Connection.ConnectionString,
         TransactionId =
             interceptionContext.InnerTransaction == null
                 ? (int?)null
                 : UniqueIdExtensions<DbTransaction>.GetUniqueId(interceptionContext.InnerTransaction).ToInt(),
         IsolationLevel = interceptionContext.IsolationLevel,
         ObjectContextId = SessionIdLoggingContext.SessionId.GetUniqueId(),
         ObjectContextName = SessionId,
         ConnectionId = connectionId
     };
     return context;
 }
예제 #4
0
        public void TransactionBegan(DbConnection connection, DbConnectionContext context)
        {
            var commandTransaction = new CommandTransaction
            {
                IsAsync         = context.IsAsync,
                TransactionType = CommandTransactionType.Began,
                IsCanceled      = context.IsCanceled,
                Exception       = context.Exception != null ? context.Exception.Message : "",
                StackTrace      = new CallingMethod {
                    AssembliesToExclude = AssembliesToExclude
                }.GetCallingMethodInfo()
            };

            setBaseInfo(context, commandTransaction);

            commandTransaction.TransactionId  = context.TransactionId;
            commandTransaction.IsolationLevel = context.IsolationLevel;

            _baseInfoQueue.Enqueue(commandTransaction);
        }
예제 #5
0
 public void ConnectionOpened(DbConnection connection, DbConnectionContext context)
 {
     LogConnection(connection, context, CommandConnectionType.Opened);
 }
예제 #6
0
 public void ConnectionDisposing(DbConnection connection, DbConnectionContext context)
 {
     LogConnection(connection, context, CommandConnectionType.Disposed);
 }