protected T Return <T>(IUserEntity user, MethodBase mi, string description, Func <T> function)
        {
            try
            {
                using (UserHolder.UserSession(user))
                {
                    return(function());
                }
            }
            catch (Exception e)
            {
                e.LogException(el =>
                {
                    el.ControllerName = GetType().Name;
                    el.ActionName     = mi.Name;
                    el.QueryString    = description;
                    el.Version        = Schema.Current.Version.ToString();
                });

                throw;
            }
            finally
            {
                Statics.CleanThreadContextAndAssert();
            }
        }
        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();
            }
        }
示例#3
0
        protected virtual T Return <T>(MethodBase mi, string description, Func <T> function)
        {
            try
            {
                using (CultureFromOperationContext())
                    using (ScopeSessionFactory.OverrideSession(session))
                        using (ExecutionMode.Global())
                        {
                            return(function());
                        }
            }
            catch (Exception e)
            {
                e.LogException(el =>
                {
                    el.ControllerName = GetType().Name;
                    el.ActionName     = mi.Name;
                    el.QueryString    = description;
                });

                throw;
            }
            finally
            {
                Statics.CleanThreadContextAndAssert();
            }
        }
示例#4
0
        protected override T Return <T>(MethodBase mi, string description, Func <T> function)
        {
            try
            {
                string longDescription = mi.Name + description == null ? null : (" " + description);

                using (CultureFromOperationContext())
                    using (TimeTracker.Start(longDescription))
                        using (HeavyProfiler.Log("WCF", () => longDescription))
                            using (ScopeSessionFactory.OverrideSession(session))
                            {
                                return(function());
                            }
            }
            catch (Exception e)
            {
                e.LogException(el =>
                {
                    el.ControllerName = GetType().Name;
                    el.ActionName     = mi.Name;
                    el.QueryString    = description;
                    el.Version        = Schema.Current.Version.ToString();
                });

                throw;
            }
            finally
            {
                Statics.CleanThreadContextAndAssert();
            }
        }
示例#5
0
        protected override T Return <T>(MethodBase mi, string description, Func <T> function)
        {
            try
            {
                using (ScopeSessionFactory.OverrideSession(session))
                {
                    return(function());
                }
            }
            catch (Exception e)
            {
                e.LogException(el =>
                {
                    el.ControllerName = GetType().Name;
                    el.ActionName     = mi.Name;
                    el.QueryString    = description;
                    el.Version        = Schema.Current.Version.ToString();
                });

                throw;
            }
            finally
            {
                Statics.CleanThreadContextAndAssert();
            }
        }
        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()))
                    {
                        //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(actionContext))
                        {
                            using (GetCurrentCultures?.Invoke(actionContext))
                            {
                                if (actionContext.Response != null)
                                {
                                    return(actionContext.Response);
                                }

                                return(await continuation());
                            }
                        }
                    }
                }
            }
            finally
            {
                Statics.CleanThreadContextAndAssert();
            }
        }
示例#7
0
 public void OnResourceExecuted(ResourceExecutedContext context)
 {
     Statics.CleanThreadContextAndAssert();
 }
示例#8
0
 protected void Application_ReleaseRequestState(object sender, EventArgs e)
 {
     Statics.CleanThreadContextAndAssert();
     Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = DefaultCulture;
 }