/// <summary>
        /// 缓存预热,强制重新缓存
        /// </summary>
        /// <returns>影响行数</returns>
        public static int CachePreheating()
        {
            int result = 0;

            // 把所有的组织机构都缓存起来的代码
            BaseOrganizeManager manager = new BaseOrganizeManager();

            using (IDataReader dataReader = manager.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    BaseOrganizeEntity entity = BaseEntity.Create <BaseOrganizeEntity>(dataReader, false);
                    if (entity != null)
                    {
                        BaseOrganizeManager.SetCache(entity);
                        string[] systemCodes = BaseSystemManager.GetSystemCodes();
                        for (int i = 0; i < systemCodes.Length; i++)
                        {
                            // 重置权限缓存数据
                            BaseOrganizePermissionManager.ResetPermissionByCache(systemCodes[i], entity.Id);
                        }
                        result++;
                        System.Console.WriteLine(result.ToString() + " : " + entity.FullName);
                    }
                }
                dataReader.Close();
            }

            return(result);
        }
        public static int RefreshCache(string userId)
        {
            int result = 0;

            // 刷新用户的缓存
            BaseUserEntity userEntity = BaseUserManager.GetObjectByCache(userId, true);

            if (userEntity != null)
            {
                // 刷新用户的登录限制
                BaseUserManager.ResetIPAddressByCache(userId);
                BaseUserManager.ResetMACAddressByCache(userId);
                // 刷新组织机构缓存
                BaseOrganizeManager.GetObjectByCache(userEntity.CompanyId, true);
                // 刷新部门缓存
                BaseDepartmentManager.GetObjectByCache(userEntity.DepartmentId, true);
                // 2016-02-18 吉日嘎拉 刷新拒绝权限(把用户的权限放在一起方便直接移除、刷新)
                string key = "User:IsAuthorized:" + userId;
                using (var redisClient = PooledRedisHelper.GetPermissionClient())
                {
                    redisClient.Remove(key);
                }
                // 每个子系统都可以循环一次
                string[] systemCodes = BaseSystemManager.GetSystemCodes();
                for (int i = 0; i < systemCodes.Length; i++)
                {
                    BaseUserPermissionManager.ResetPermissionByCache(systemCodes[i], userId);
                }
            }

            return(result);
        }
        /// <summary>
        /// 缓存预热,强制重新缓存
        /// </summary>
        /// <returns></returns>
        public static int CachePreheating()
        {
            int result = 0;

            string[] systemCodes = BaseSystemManager.GetSystemCodes();
            for (int i = 0; i < systemCodes.Length; i++)
            {
                GetEntitiesByCache(systemCodes[i], true);
                result += CachePreheating(systemCodes[i]);
            }

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 缓存预热,强制重新缓存
        /// </summary>
        /// <returns></returns>
        public static int CachePreheating()
        {
            var result = 0;

            var systemCodes = BaseSystemManager.GetSystemCodes();

            foreach (var entity in systemCodes)
            {
                GetEntitiesByCache(entity.ItemKey, true);
                result += CachePreheating(entity.ItemKey);
            }

            return(result);
        }
Exemple #5
0
        public static int RefreshCache(string organizeId)
        {
            int result = 0;

            // 2016-02-29 吉日嘎拉 强制刷新缓存
            BaseOrganizeEntity organizeEntity = BaseOrganizeManager.GetObjectByCache(organizeId, true);

            if (organizeEntity != null)
            {
                string[] systemCodes = BaseSystemManager.GetSystemCodes();
                for (int i = 0; i < systemCodes.Length; i++)
                {
                    BaseOrganizePermissionManager.ResetPermissionByCache(systemCodes[i], organizeId);
                }
            }

            return(result);
        }
Exemple #6
0
        /// <summary>
        /// 刷新缓存
        /// </summary>
        /// <param name="systemCode"></param>
        /// <param name="roleId"></param>
        /// <returns></returns>
        public static int RefreshCache(string systemCode, string roleId)
        {
            var result = 0;

            // 2016-02-29 吉日嘎拉 强制刷新缓存
            var roleEntity = GetEntityByCache(systemCode, roleId, true);

            if (roleEntity != null)
            {
                var systemCodes = BaseSystemManager.GetSystemCodes();
                foreach (var entity in systemCodes)
                {
                    GetEntitiesByCache(entity.ItemKey, true);
                    result += CachePreheating(entity.ItemKey);
                }
            }

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// 刷新缓存
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static int RefreshCache(string userId)
        {
            var result = 0;

            // 刷新用户的缓存
            var userEntity = GetEntityByCache(userId, true);

            if (userEntity != null)
            {
                // 刷新用户的登录限制 用户名的限制

                // 刷新用户的登录限制
                ResetIpAddressByCache(userId);
                ResetMacAddressByCache(userId);
                // 刷新组织机构缓存
                BaseOrganizationManager.GetEntityByCache(userEntity.CompanyId.ToString(), true);
                // 2016-02-18 吉日嘎拉 刷新拒绝权限(把用户的权限放在一起方便直接移除、刷新)
                var key = "User:IsAuthorized:" + userId;
                CacheUtil.Remove(key);

                // 2016-05-24 吉日嘎拉 解除登录限制的方法,防止一天都登录不上的问题发生
                //if (!string.IsNullOrEmpty(userEntity.NickName))
                //{
                //    key = "u:" + userEntity.NickName;
                //    PooledRedisHelper.CallLimitRemove(key);
                //}
                //if (!string.IsNullOrEmpty(userEntity.Code))
                //{
                //    key = "u:" + userEntity.Code;
                //    PooledRedisHelper.CallLimitRemove(key);
                //}

                // 每个子系统都可以循环一次
                var systemCodes = BaseSystemManager.GetSystemCodes();
                foreach (var entity in systemCodes)
                {
                    BasePermissionManager.ResetPermissionByCache(entity.ItemKey, userId, null);
                }
            }

            return(result);
        }