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; }
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; } } }
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); } }
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); }
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; }
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); } }
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; } } }