Ejemplo n.º 1
0
        private bool checkPermission(ObjectViewLevel viewLevl, int currentUser, BizObject obj)
        {
            var users = obj.GetParentMainUsers();

            users.AddRange(obj.GetChildrenMainUsers(true));

            switch (viewLevl)
            {
            case ObjectViewLevel.全部:
                return(true);

            case ObjectViewLevel.部门:
                foreach (var u in users)
                {
                    if (_DeptUsers.Contains(u))
                    {
                        return(true);
                    }
                }
                return(false);

            case ObjectViewLevel.个人:
                foreach (var u in users)
                {
                    if (currentUser == u)
                    {
                        return(true);
                    }
                }
                return(false);

            default:
                return(false);
            }
        }
Ejemplo n.º 2
0
        private bool checkPermission(ObjectViewLevel viewLevl, int currentUser, params int[] users)
        {
            switch (viewLevl)
            {
            case ObjectViewLevel.全部:
                return(true);

            case ObjectViewLevel.部门:
                foreach (var u in users)
                {
                    if (_DeptUsers.Contains(u))
                    {
                        return(true);
                    }
                }
                return(false);

            case ObjectViewLevel.个人:
                foreach (var u in users)
                {
                    if (currentUser == u)
                    {
                        return(true);
                    }
                }
                return(false);

            default:
                return(false);
            }
        }
Ejemplo n.º 3
0
        private void setChildren(BizObject obj, PageQueryParam pageParam, bool hasPermission, ObjectViewLevel viewLevel, int currentUser, int currentDeep, int MaxDeep)
        {
            var children = obj.GetChildren(pageParam);

            if (children != null)
            {
                foreach (var item in children)
                {
                    if (!hasPermission)
                    {
                        // 验证子对象有没有权限
                        hasPermission = checkPermission(viewLevel, currentUser, item);
                    }

                    if (currentDeep < MaxDeep)
                    {
                        setChildren(item, pageParam, hasPermission, viewLevel, currentUser, currentDeep + 1, MaxDeep);
                    }

                    if (hasPermission || (item.Children != null && item.Children.Count > 0))
                    {
                        if (obj.Children == null)
                        {
                            obj.Children = new List <BizObject>();
                        }

                        obj.Children.Add(item);
                    }
                }
            }
        }