Exemplo n.º 1
0
        private void SetActionContext(ActionExecutingContext ctx, HttpContext context)
        {
            var currentUser = !string.IsNullOrWhiteSpace(LoginName)
                ? _controllerProcess.GetCurrentUser(LoginName)
                : _controllerProcess.GetCurrentUser(context);


            if (currentUser == null)
            {
                FormsAuthentication.SignOut();
                ctx.Result = RedirectToAction("Login", "Account");
                return;
            }
            WdContext = new WdContext(currentUser);
            if (!context.Items.Contains("WdContext"))
            {
                context.Items.Add("WdContext", WdContext);
            }
            var userDistricts = ((IList <SysDictionary>)PlatformCaches.GetCache("userDistrict").CacheItem)
                                .Where(obj => obj.ItemKey == currentUser.Id.ToString().ToUpper()).ToList();

            foreach (var userDistrict in userDistricts)
            {
                WdContext.UserContext.Add("district", Guid.Parse(userDistrict.ItemValue));
            }
        }
Exemplo n.º 2
0
        protected override void Initialize(HttpControllerContext controllerContext)
        {
            var currentUser = _controllerProcess.GetCurrentUser("Manager");

            WdContext = new WdContext(currentUser);
            if (!HttpContext.Current.Items.Contains("WdContext"))
            {
                HttpContext.Current.Items.Add("WdContext", WdContext);
            }

            base.Initialize(controllerContext);
        }