mirror of https://github.com/abpframework/abp.git
committed by
GitHub
3 changed files with 0 additions and 59 deletions
@ -1,42 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.SignalR; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Microsoft.Extensions.Options; |
|
||||
using Volo.Abp.Uow; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.SignalR.Uow; |
|
||||
|
|
||||
public class AbpUowHubFilter : IHubFilter |
|
||||
{ |
|
||||
public virtual async ValueTask<object> InvokeMethodAsync(HubInvocationContext invocationContext, Func<HubInvocationContext, ValueTask<object>> next) |
|
||||
{ |
|
||||
object result = null; |
|
||||
|
|
||||
var options = await CreateOptionsAsync(invocationContext); |
|
||||
|
|
||||
var unitOfWorkManager = invocationContext.ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
|
||||
|
|
||||
using (var uow = unitOfWorkManager.Begin(options)) |
|
||||
{ |
|
||||
result = await next(invocationContext); |
|
||||
await uow.CompleteAsync(); |
|
||||
} |
|
||||
|
|
||||
return result; |
|
||||
} |
|
||||
|
|
||||
private async Task<AbpUnitOfWorkOptions> CreateOptionsAsync(HubInvocationContext invocationContext) |
|
||||
{ |
|
||||
var options = new AbpUnitOfWorkOptions(); |
|
||||
|
|
||||
var defaultOptions = invocationContext.ServiceProvider.GetRequiredService<IOptions<AbpUnitOfWorkDefaultOptions>>().Value; |
|
||||
var uowHubFilterOptions = invocationContext.ServiceProvider.GetRequiredService<IOptions<AbpUowHubFilterOptions>>().Value; |
|
||||
options.IsTransactional = defaultOptions.CalculateIsTransactional( |
|
||||
autoValue: invocationContext.ServiceProvider.GetRequiredService<IUnitOfWorkTransactionBehaviourProvider>().IsTransactional |
|
||||
?? await uowHubFilterOptions.IsTransactional(invocationContext) |
|
||||
); |
|
||||
|
|
||||
return options; |
|
||||
} |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
using System; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.SignalR; |
|
||||
|
|
||||
namespace Volo.Abp.AspNetCore.SignalR.Uow; |
|
||||
|
|
||||
public class AbpUowHubFilterOptions |
|
||||
{ |
|
||||
public Func<HubInvocationContext, Task<bool>> IsTransactional { get; set; } |
|
||||
|
|
||||
public AbpUowHubFilterOptions() |
|
||||
{ |
|
||||
IsTransactional = context => Task.FromResult<bool>(true); |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue