public override void Rollback() { try { base.Rollback(); this.Logger.TryLogFail(() => TransactionRolledBack.Fire(this, new TransactionEventArgs(this))); } catch (TransactionException e) { this.Logger.TryLogFail(() => TransactionFailed.Fire(this, new TransactionFailedEventArgs(this, e))); throw; } }
public void Dispose() { if (IsAborted) { return; } if (this == Root) // Root { Root = null; if (IsCompleted) { // Happy scenario: Connections.Do(x => x.Value.Item1.Close()); } else // Root is not completed. { IsAborted = true; Connections.Do(x => x.Value.Item2.Rollback()); Connections.Do(x => x.Value.Item2.Dispose()); Connections.Do(x => x.Value.Item1.Close()); TransactionRolledBack?.Invoke(this, EventArgs.Empty); } } else { Current = Parent; if (IsCompleted) { // A Sub-transaction has been happily completed. // Just wait for the parent. } else { // A sub transaction is not completed. Root?.Dispose(); } } }
private void RolledBackHandler(object sender, TransactionEventArgs e) { TransactionRolledBack.Fire(this, e); }