public override async Task Befor(IAOPContext context) { _container = context.ServiceProvider.GetService <TransactionContainer>(); if (!_container.TransactionOpened) { _container.TransactionOpened = true; await _container.BeginTransactionAsync(_isolationLevel); } }
public override async Task After(IAOPContext context) { _container = context.ServiceProvider.GetService <TransactionContainer>(); try { if (_container.TransactionOpened) { _container.CommitTransaction(); } } catch (Exception ex) { _container.RollbackTransaction(); throw new Exception("系统异常", ex); } if (_container.TransactionOpened) { _container.TransactionOpened = false; } await Task.CompletedTask; }