public async Task <HttpResponseMessage> ExecuteAuthorizationFilterAsync(HttpActionContext actionContext, CancellationToken cancellationToken, Func <Task <HttpResponseMessage> > continuation)
        {
            string action = ProfilerActionSplitterAttribute.GetActionDescription(actionContext);

            try
            {
                using (TimeTracker.Start(action))
                {
                    using (HeavyProfiler.Log("Web.API " + actionContext.Request.Method, () => actionContext.Request.RequestUri.ToString()))
                    {
                        var user = (IUserEntity)GetProp(actionContext, SignumAuthenticationFilterAttribute.UserKey);
                        using (user != null ? UserHolder.UserSession(user) : null)
                        {
                            var culture = SignumAuthenticationFilterAttribute.GetCurrentCultures?.Invoke(actionContext);
                            using (culture != null ? CultureInfoUtils.ChangeBothCultures(culture) : null)
                            {
                                var result = await continuation();

                                return(result);
                            }
                        }
                    }
                }
            }
            finally
            {
                Statics.CleanThreadContextAndAssert();
            }
        }
        public async Task <HttpResponseMessage> ExecuteAuthorizationFilterAsync(HttpActionContext actionContext, CancellationToken cancellationToken, Func <Task <HttpResponseMessage> > continuation)
        {
            string action = ProfilerActionSplitterAttribute.GetActionDescription(actionContext);

            using (TimeTracker.Start(action))
            {
                using (HeavyProfiler.Log("Web.API " + actionContext.Request.Method, () => actionContext.Request.RequestUri.ToString()))
                {
                    //if (ProfilerLogic.SessionTimeout != null)
                    //{
                    //    IDisposable sessionTimeout = Connector.CommandTimeoutScope(ProfilerLogic.SessionTimeout.Value);
                    //    if (sessionTimeout != null)
                    //        actionContext.Request.RegisterForDispose(sessionTimeout);
                    //}

                    actionContext.Request.Properties[SavedRequestKey] = await actionContext.Request.Content.ReadAsStringAsync();

                    using (Authenticate == null ? null : Authenticate(actionContext))
                    {
                        if (actionContext.Response != null)
                        {
                            return(actionContext.Response);
                        }

                        return(await continuation());
                    }
                }
            }
        }
Exemple #3
0
        public override IDisposable GetResource(ResourceExecutingContext context)
        {
            string action = ProfilerActionSplitterAttribute.GetActionDescription(context);

            return(TimeTracker.Start(action));
        }