Пример #1
0
        /// <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);
        }