/// <summary>
        /// 迭代加载菜单导航
        /// </summary>
        /// <param name="oldlist">源数据</param>
        /// <param name="newlist">新数据</param>
        /// <param name="parentId"></param>
        private void GetChilds(List<Navigations.Navigation> oldlist, Permission permission, int parentId)
        {
            Func<Navigations.Navigation, bool> predicate = n => n.ParentId == parentId;
            if (parentId == 0)
            {
                predicate = n => n.ParentId == null || n.ParentId == parentId;
            }

            var subs = oldlist
            .Where(predicate)
            .OrderBy(n => n.SortId)
            .ToList();

            //循环
            foreach (var item in subs)
            {
                var subPermission = permission.CreateChildPermission(
                    item.PermissionName,
                    L(item.LocalizableString),
                    multiTenancySides: item.MultiTenancySide.HasValue
                    ? item.MultiTenancySide.Value
                    : (MultiTenancySides.Host | MultiTenancySides.Tenant));
                //迭代
                GetChilds(oldlist, subPermission, item.Id);
            }
        }
 /// <summary>
 /// 递归加载所有权限
 /// </summary>
 /// <param name="rootPermission"></param>
 /// <param name="permission"></param>
 private void AddPermissions(PermissionInfo rootPermission, Permission permission)
 {
     var permissions = PermissionInfos.Where(p => p.ParentName == rootPermission.Name);
     foreach (PermissionInfo permissionInfo in permissions)
     {
         var childernPermission = permission.CreateChildPermission(permissionInfo.Name,
               new FixedLocalizableString(permissionInfo.DisplayName), permissionInfo.IsGrantedByDefault);
         AddPermissions(permissionInfo, childernPermission);
     }
 }
Beispiel #3
0
        private void CreateChildPermissions(List <PermissionDefinition> dbPermissions, Abp.Authorization.Permission permission)
        {
            var dbChildPermissions = dbPermissions.Where(x => x.Parent == permission.Name).ToList();

            foreach (var dbChildPermission in dbChildPermissions)
            {
                var childPermission =
                    permission.CreateChildPermission(dbChildPermission.Name, dbChildPermission.DisplayName.L(), dbChildPermission.Description.L());
                CreateChildPermissions(dbPermissions, childPermission);
                dbPermissions.Remove(dbChildPermission);
            }
        }
Beispiel #4
0
        private void CreateChildPermi(Abp.Authorization.Permission permission, long id)
        {
            var childPermission = _permissions.Where(s => s.ParentId == id);

            if (childPermission.Count() > 0)
            {
                childPermission.ToList().ForEach(z =>
                {
                    var grandPermi = permission.CreateChildPermission(z.Name, L(z.DisplayName));
                    CreateChildPermi(grandPermi, z.Id);
                });
            }
        }