/// <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);
        }
示例#2
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);
        }