public async Task InterceptAsync(IMethodInvocation invocation) { if (!CompensableHelper.IsCompensableMethod(invocation.Method)) { await invocation.ProceedAsync(); return; } CompensableMethodContext compensableMethodContext = new CompensableMethodContext(invocation, _serviceProvider); var isTransactionActive = _transactionManager.IsTransactionActive(); if (!TransactionUtils.IsLegalTransactionContext(isTransactionActive, compensableMethodContext)) { throw new TransactionException($"no available compensable transaction, the method {compensableMethodContext.MethodInfo.Name} is illegal"); } switch (compensableMethodContext.GetMethodRole(isTransactionActive)) { case MethodRole.ROOT: await RootMethodProceed(compensableMethodContext); break; case MethodRole.PROVIDER: await ProviderMethodProceed(compensableMethodContext); break; default: await invocation.ProceedAsync(); break; } }
public async Task InterceptAsync(IMethodInvocation invocation) { if (!CompensableHelper.IsCompensableMethod(invocation.Method)) { await invocation.ProceedAsync(); return; } var transaction = _transactionManager.Current; if (transaction != null) { switch (transaction.Status) { case TransactionStatus.TRYING: EnlistParticipant(invocation); break; case TransactionStatus.CONFIRMING: break; case TransactionStatus.CANCELLING: break; } } await invocation.ProceedAsync(); }