private static void PerformUow(IInvocation invocation, bool isTransactional) { using (var unitOfWork = IocHelper.ResolveAsDisposable <IUnitOfWork>()) { try { UnitOfWorkScope.Current = unitOfWork.Object; UnitOfWorkScope.Current.Initialize(isTransactional); UnitOfWorkScope.Current.Begin(); try { invocation.Proceed(); UnitOfWorkScope.Current.End(); } catch { try { UnitOfWorkScope.Current.Cancel(); } catch { } //Hide exceptions on cancelling throw; } } finally { UnitOfWorkScope.Current = null; } } }
/// <summary> /// Create a new unit of work scope. /// </summary> public UnitOfWorkScope(bool isTransactional) { //There is already a uow, do nothing if (Current != null) { return; } //this scope started the uow _isStartedByThisScope = true; _unitOfWorkWrapper = IocHelper.ResolveAsDisposable <IUnitOfWork>(); Current = _unitOfWorkWrapper.Object; try { Current.Initialize(isTransactional); Current.Begin(); } catch { Current = null; _unitOfWorkWrapper.Dispose(); throw; } }
public IHttpController Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType) { var controllerWrapper = IocHelper.ResolveAsDisposable <IHttpController>(controllerType); request.RegisterForDispose(controllerWrapper); return(controllerWrapper.Object); }
/// <summary> /// Intercepts a method. /// </summary> /// <param name="invocation">Method invocation arguments</param> public void Intercept(IInvocation invocation) { //If there isalready a running transaction (or no need to a db connection), just run the method if (UnitOfWorkScope.CurrentUow != null || !UnitOfWorkHelper.ShouldPerformUnitOfWork(invocation.MethodInvocationTarget)) { invocation.Proceed(); return; } using (var unitOfWork = IocHelper.ResolveAsDisposable <IUnitOfWork>()) { try { UnitOfWorkScope.CurrentUow = unitOfWork.Object; UnitOfWorkScope.CurrentUow.BeginTransaction(); try { invocation.Proceed(); UnitOfWorkScope.CurrentUow.Commit(); } catch (Exception ex) { try { UnitOfWorkScope.CurrentUow.Rollback(); } catch { } throw; } } finally { UnitOfWorkScope.CurrentUow = null; } } }
/// <summary> /// Create a new unit of work scope. /// </summary> public UnitOfWorkScope() { _unitOfWorkWrapper = IocHelper.ResolveAsDisposable <IUnitOfWork>(); CurrentUow = _unitOfWorkWrapper.Object; try { CurrentUow.BeginTransaction(); } catch { CurrentUow = null; } }
public void Authorize(IInvocation invocation) { if (!invocation.MethodInvocationTarget.IsDefined(typeof(AbpAuthorizeAttribute), true)) { return; } var authorizeAttributes = invocation.MethodInvocationTarget.GetCustomAttributes(typeof(AbpAuthorizeAttribute), true); using (var authorizationAttributeHelper = IocHelper.ResolveAsDisposable <AuthorizeAttributeHelper>()) { authorizationAttributeHelper.Object.Authorize(authorizeAttributes.Cast <IAbpAuthorizeAttribute>()); } }
protected override bool AuthorizeCore(System.Web.HttpContextBase httpContext) { if (!base.AuthorizeCore(httpContext)) { return(false); } try { using (var authorizationAttributeHelper = IocHelper.ResolveAsDisposable <AuthorizeAttributeHelper>()) { authorizationAttributeHelper.Object.Authorize(this); } return(true); } catch (AbpAuthorizationException ex) { LogHelper.Logger.Warn(ex.Message, ex); return(false); } }