Пример #1
0
 void IDbTracingListener.CommandFinished(DbTracingContext context)
 {
     if (onFinished != null)
     {
         onFinished(context);
     }
 }
Пример #2
0
        public override object ExecuteScalar()
        {
            if (!DbTracing.IsEnabled)
            {
                return(command.ExecuteScalar());
            }

            var context = new DbTracingContext(DbTracingType.Scalar, connection, command);

            object result = null;

            DbTracing.FireCommandExecuting(context);
            try
            {
                context.OnStarted();
                result = command.ExecuteScalar();
                context.OnFinished(result);
            }
            catch (Exception ex)
            {
                context.OnFailed(ex);

                DbTracing.FireCommandFailed(context);
                throw;
            }

            DbTracing.FireCommandFinished(context);

            return(result);
        }
Пример #3
0
        internal static void FireCommandFinished(DbTracingContext context)
        {
            if (!enabled)
            {
                return;
            }

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                {
                    listener.CommandFinished(context);
                }
            }
            finally
            {
                rwLock.ExitReadLock();
            }

            if (context.Type != DbTracingType.Reader)
            {
                FireCommandExecuted(context);
            }
        }
Пример #4
0
 void IDbTracingListener.ReaderFinished(DbTracingContext context)
 {
     if (onReaderFinished != null)
     {
         onReaderFinished(context);
     }
 }
Пример #5
0
 void IDbTracingListener.CommandExecuting(DbTracingContext context)
 {
     if (onExecuting != null)
     {
         onExecuting(context);
     }
 }
Пример #6
0
        protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
        {
            if (!DbTracing.IsEnabled)
            {
                return(command.ExecuteReader(behavior));
            }

            var context = new DbTracingContext(DbTracingType.Reader, connection, command);

            DbTracing.FireCommandExecuting(context);
            DbTracingDataReader result = null;

            try
            {
                context.OnStarted();
                result = new DbTracingDataReader(command.ExecuteReader(behavior), context);
                context.OnFinished(result.UnderlyingReader);
            }
            catch (Exception ex)
            {
                context.OnFailed(ex);

                DbTracing.FireCommandFailed(context);
                throw;
            }

            DbTracing.FireCommandFinished(context);

            return(result);
        }
        public DbTracingDataReader(DbDataReader reader, DbTracingContext context)
        {
            if (reader == null)
                throw new ArgumentNullException("reader");
            if (context == null)
                throw new ArgumentNullException("context");
            if (reader is DbTracingDataReader)
                throw new InvalidOperationException("Reader is already wrapped");

            this.reader = reader;
            this.context = context;
        }
Пример #8
0
        public DbTracingDataReader(DbDataReader reader, DbTracingContext context)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (reader is DbTracingDataReader)
            {
                throw new InvalidOperationException("Reader is already wrapped");
            }

            this.reader  = reader;
            this.context = context;
        }
Пример #9
0
        private static void FireCommandExecuted(DbTracingContext context)
        {
            if (!enabled)
            {
                return;
            }

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                {
                    listener.CommandExecuted(context);
                }
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
Пример #10
0
        internal static void FireCommandExecuting(DbTracingContext context)
        {
            if (!enabled)
                return;

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                    listener.CommandExecuting(context);
            }
            finally
            {
                rwLock.ExitReadLock();
            }
        }
Пример #11
0
        internal static void FireCommandFinished(DbTracingContext context)
        {
            if (!enabled)
                return;

            rwLock.EnterReadLock();
            try
            {
                foreach (var listener in listeners)
                    listener.CommandFinished(context);
            }
            finally
            {
                rwLock.ExitReadLock();
            }

            if (context.Type != DbTracingType.Reader)
                FireCommandExecuted(context);
        }
Пример #12
0
 public virtual void CommandFinished(DbTracingContext context)
 {
 }
 public void CommandExecuted(DbTracingContext context)
 {
 }
 public void ReaderFinished(DbTracingContext context)
 {
 }
Пример #15
0
 public virtual void CommandFailed(DbTracingContext context)
 {
 }
 public void CommandFailed(DbTracingContext context)
 {
 }
Пример #17
0
 void IDbTracingListener.ReaderFinished(DbTracingContext context)
 {
     if (onReaderFinished != null)
         onReaderFinished(context);
 }
Пример #18
0
 public virtual void ReaderFinished(DbTracingContext context)
 {
 }
Пример #19
0
 void IDbTracingListener.CommandExecuting(DbTracingContext context)
 {
     if (onExecuting != null)
         onExecuting(context);
 }
Пример #20
0
 public virtual void CommandFinished(DbTracingContext context)
 {
 }
Пример #21
0
 public virtual void CommandExecuting(DbTracingContext context)
 {
 }
 public void CommandFinished(DbTracingContext context)
 {
     Log.Write("-- time: {0}{1}{2}", context.Duration, Environment.NewLine, context.Command.ToTraceString());
 }
Пример #23
0
 void IDbTracingListener.CommandFinished(DbTracingContext context)
 {
     if (onFinished != null)
         onFinished(context);
 }
Пример #24
0
 public virtual void CommandExecuted(DbTracingContext context)
 {
 }