Example #1
0
 public Transaction(IConnection connection, ITransactionResourceHandler resourceHandler = null, ILogger logger = null, Bookmark bookmark = null) : base(logger)
 {
     _connection      = new TransactionConnection(this, connection);
     _protocol        = _connection.BoltProtocol;
     _resourceHandler = resourceHandler;
     Bookmark         = bookmark;
 }
Example #2
0
        private async Task CloseAsync()
        {
            try
            {
                if (_state == State.MarkedSuccess)
                {
                    await CommitTxAsync().ConfigureAwait(false);
                }
                else if (_state == State.MarkedFailed || _state == State.Active)
                {
                    await RollbackTxAsync().ConfigureAwait(false);
                }
            }
            finally
            {
                await _connection.CloseAsync().ConfigureAwait(false);

                if (_resourceHandler != null)
                {
                    await _resourceHandler.OnTransactionDisposeAsync().ConfigureAwait(false);

                    _resourceHandler = null;
                }
            }
        }
Example #3
0
 protected override void Dispose(bool isDisposing)
 {
     if (!isDisposing)
     {
         return;
     }
     try
     {
         if (_state == State.MarkedSuccess)
         {
             CommitTx();
         }
         else if (_state == State.MarkedFailed || _state == State.Active)
         {
             RollbackTx();
         }
     }
     finally
     {
         _connection.Close();
         if (_resourceHandler != null)
         {
             _resourceHandler.OnTransactionDispose();
             _resourceHandler = null;
         }
         base.Dispose(true);
     }
 }
Example #4
0
        public Transaction(IConnection connection, ITransactionResourceHandler resourceHandler = null, ILogger logger = null, Bookmark bookmark = null) : base(logger)
        {
            _connection      = new TransactionConnection(this, connection);
            _resourceHandler = resourceHandler;
            IDictionary <string, object> parameters = bookmark?.AsBeginTransactionParameters();

            _connection.Run(Begin, parameters);
        }
Example #5
0
 public Transaction(IConnection connection, ITransactionResourceHandler resourceHandler = null, IDriverLogger logger = null, Bookmark bookmark = null)
 {
     _connection      = new TransactionConnection(this, connection);
     _protocol        = _connection.BoltProtocol;
     _resourceHandler = resourceHandler;
     _bookmark        = bookmark;
     _logger          = logger;
 }
 public AsyncTransaction(IConnection connection, ITransactionResourceHandler resourceHandler,
                         ILogger logger = null, string database = null, Bookmark bookmark = null, bool reactive = false,
                         long fetchSize = Config.Infinite)
 {
     _connection      = new TransactionConnection(this, connection);
     _protocol        = _connection.BoltProtocol;
     _resourceHandler = resourceHandler ?? throw new ArgumentNullException(nameof(resourceHandler));
     _bookmark        = bookmark;
     _logger          = logger;
     _reactive        = reactive;
     _database        = database;
     _fetchSize       = fetchSize;
 }
Example #7
0
        protected override void Dispose(bool isDisposing)
        {
            if (!isDisposing)
            {
                return;
            }
            try
            {
                if (_state == State.MarkedSuccess)
                {
                    try
                    {
                        CommitTx();
                    }
                    catch (Exception)
                    {
                        // if we ever failed to commit, then we rollback the tx
                        try
                        {
                            RollbackTx();
                        }
                        catch (Exception)
                        {
                            // ignored
                        }

                        throw;
                    }
                }
                else if (_state == State.MarkedFailed || _state == State.Active)
                {
                    RollbackTx();
                }
            }
            finally
            {
                _connection.Close();
                if (_resourceHandler != null)
                {
                    _resourceHandler.OnTransactionDispose();
                    _resourceHandler = null;
                }
                base.Dispose(true);
            }
        }
Example #8
0
        private async Task CloseAsync()
        {
            try
            {
                if (_state == State.MarkedSuccess)
                {
                    try
                    {
                        await CommitTxAsync().ConfigureAwait(false);
                    }
                    catch (Exception)
                    {
                        // if we ever failed to commit, then we rollback the tx
                        try
                        {
                            await RollbackTxAsync().ConfigureAwait(false);
                        }
                        catch (Exception)
                        {
                            // ignored
                        }
                        throw;
                    }
                }
                else if (_state == State.MarkedFailed || _state == State.Active)
                {
                    await RollbackTxAsync().ConfigureAwait(false);
                }
            }
            finally
            {
                await _connection.CloseAsync().ConfigureAwait(false);

                if (_resourceHandler != null)
                {
                    await _resourceHandler.OnTransactionDisposeAsync().ConfigureAwait(false);

                    _resourceHandler = null;
                }
            }
        }