示例#1
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="requestContext"/>
        protected override void Initialize(RequestContext requestContext)
        {
            this.CurrentUser = UserHelper.GetCurrentUser();

            //核对用户信息和安全信息 / 登录是否有效 / 缓存用户数据 / 记录日志 / 异常返回信息定义(和前台约定页面跳转)
            if (CurrentUser != null)
            {
                requestContext.HttpContext.User = (IPrincipal)this.CurrentUser;
                this.CurrentUserFullInfo        = (UserBackFullInfo)(requestContext.HttpContext.Session[this.CurrentUser.LoginName]);
                //把组织机构全部数据放入缓存,如果取不到值(没有设置或者过期)
                var orgdata = RedisHelper.Get <List <Org_Organization> >("GGNCenterOrgs");
                if (orgdata == null || orgdata.Count == 0)
                {
                    Org_OrganizationDal oobll = new Org_OrganizationDal();
                    var orgall = oobll.GetAll().ToList();
                    RedisHelper.Set("GGNCenterOrgs", orgall, new TimeSpan(3650, 0, 0, 0, 0)); //失效时间3650天,10年
                }
                //把全部员工数据放入缓存,如果取不到值(没有设置或者过期)
                var allorguserdata = RedisHelper.Get <List <View_UserOrgInfo> >("GGNCenterOrgAllPersons");
                if (allorguserdata == null || allorguserdata.Count == 0)
                {
                    Org_UserDal orguserbll = new Org_UserDal();
                    var         orguserall = orguserbll.GetAllUserInfos();
                    RedisHelper.Set("GGNCenterOrgAllPersons", orguserall, new TimeSpan(3650, 0, 0, 0, 0)); //失效时间3650天,10年
                }
            }
            base.Initialize(requestContext);
        }
        private void Initialize()
        {
            this.CurrentUser = UserHelper.GetCurrentUser();

            //核对用户信息和安全信息 / 登录是否有效 / 缓存用户数据 / 记录日志 / 异常返回信息定义(和前台约定页面跳转)
            if (CurrentUser != null)
            {
                GlobalHttpContext.Current.User = this.CurrentUser;
                this.CurrentUserFullInfo       = GlobalHttpContext.Current.Session.Get <UserBackFullInfo>(this.CurrentUser.LoginName);
                //把组织机构全部数据放入缓存,如果取不到值(没有设置或者过期)
                var orgdata = RedisHelper.Get <List <Org_Organization> >("CMPOrgs");
                if (orgdata == null || orgdata.Count == 0)
                {
                    Org_OrganizationDal oobll = new Org_OrganizationDal();
                    var orgall = oobll.GetAll().ToList();
                    RedisHelper.Set("CMPOrgs", orgall, new TimeSpan(3650, 0, 0, 0, 0)); //失效时间3650天,10年
                }
                //把全部员工数据放入缓存,如果取不到值(没有设置或者过期)
                var allorguserdata = RedisHelper.Get <List <View_UserOrgInfo> >("CMPOrgAllPersons");
                if (allorguserdata == null || allorguserdata.Count == 0)
                {
                    Org_UserDal orguserbll = new Org_UserDal();
                    var         orguserall = orguserbll.GetAllUserInfos();
                    RedisHelper.Set("CMPOrgAllPersons", orguserall, new TimeSpan(3650, 0, 0, 0, 0)); //失效时间3650天,10年
                }
            }
        }