Пример #1
0
        private void InitializeUserSession(ActionExecutingContext filterContext)
        {
            Logger.Debug("Session_Start", "Begin");

            Logger.Debug("Session_Start", "var userSessionContext = new UserSessionContext(new HttpContextWrapper(HttpContext.Current));");

            var userSessionContext = new UserSessionContext(filterContext.HttpContext);

            Logger.Debug("Session_Start", "LessonBusiness businessManager = new LessonBusiness();");
            LessonBusiness businessManager = new LessonBusiness(_dbcontext);

            Logger.Debug("Session_Start", "userSessionContext.CurrentUser = businessManager.GetCurrentUser();");
            userSessionContext.CurrentUser = businessManager.GetCurrentUser();

            if (!string.IsNullOrWhiteSpace(Utility.SafeGetAppConfigSetting("Debug_UserPermission", "")))
            {
                Enumerations.Role debugPrivilege = (Enumerations.Role)Enum.Parse(typeof(Enumerations.Role), Utility.SafeGetAppConfigSetting("Debug_UserPermission", "User"));
                if (userSessionContext.CurrentUser == null)
                {
                    if (bool.Parse(Utility.SafeGetAppConfigSetting("Debug_PopulateFakeUsers", "false")))
                    {
                        userSessionContext.CurrentUser = new Data.RoleUser
                        {
                            LastName  = "User",
                            FirstName = "Debug",
                            Sid       = "S-1-5-21-861617734-1335137780-1834409622-8391"
                        };
                    }
                }

                if (userSessionContext.CurrentUser != null)
                {
                    userSessionContext.CurrentUser.RoleId = (int)debugPrivilege;
                }
            }
        }