예제 #1
0
        /// <summary>
        ///     载入页面权限树形基础数据
        /// </summary>
        public static void CreatePowerTree()
        {
            var cache = new RoleCache();

            using (var proxy = new RedisProxy(RedisProxy.DbSystem))
            {
                cache.CreatePowerTree(proxy);
            }
        }
예제 #2
0
        static void CacheTask(int roleId)
        {
            using (SystemContextScope.CreateScope())
            {
                using (MySqlDataBaseScope.CreateScope(MySqlDataBase.DefaultDataBase))
                {
                    RoleCache.Cache(roleId);

                    RoleCache cache = new RoleCache();
                    cache.CachePageAuditUser();
                    cache.CacheTypeUser();
                }
            }
        }
        static void CacheTask(int pid)
        {
            var orb = new UserBusinessLogic();

            using (SystemContextScope.CreateScope())
            {
                using (MySqlDataBaseScope.CreateScope(MySqlDataBase.DefaultDataBase))
                {
                    orb.SyncUser(orb._posAccess.First(pid));
                    RoleCache cache = new RoleCache();
                    cache.CachePageAuditUser();
                    cache.CacheTypeUser();
                }
            }
        }
예제 #4
0
        /// <summary>
        /// 载入角色的树形页面权限数据
        /// </summary>
        /// <param name="roleId">角色ID</param>
        /// <returns>树形页面权限数据</returns>
        private List <EasyUiTreeNode> LoadRolePowers(int roleId)
        {
            using (MySqlDataBaseScope.CreateScope(Access.DataBase))
            {
                var pAccess = new RolePowerDataAccess
                {
                    DataBase = Access.DataBase
                };
                var powers = pAccess.All(p => p.RoleId == roleId);

                Dictionary <int, RolePowerData> dictionary;
                try
                {
                    dictionary = powers.ToDictionary(p => p.PageItemId);
                }
                catch// (Exception e)
                {
                    dictionary = new Dictionary <int, RolePowerData>();
                    foreach (var g in powers.GroupBy(p => p.PageItemId))
                    {
                        dictionary.Add(g.Key, g.First());
                        foreach (var item in g.Skip(1))
                        {
                            pAccess.DeletePrimaryKey(item.Id);
                        }
                    }
                }

                var tree = RoleCache.LoadPowerTree();
                SyncPower(tree, dictionary);
                return(new List <EasyUiTreeNode>
                {
                    tree
                });
            }
        }