コード例 #1
0
ファイル: EngineeringService.cs プロジェクト: sethHome/House
        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);
                    }
                }
            }
        }
コード例 #2
0
ファイル: EngineeringService.cs プロジェクト: sethHome/House
        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);
            }
        }
コード例 #3
0
        private List <int> _GetChildrenMainUsers(BizObject obj, bool IsPermissionUser)
        {
            var result = new List <int>();

            if (!IsPermissionUser || obj.JoinPermissionCheckUser)
            {
                var users = obj.GetMainUsers();

                if (users != null)
                {
                    result.AddRange(users);
                }
            }

            // 如果获取用户是为了参与权限判断且有流程任务的话,流程节点上的用户也算入其中
            if (this.HasTask && IsPermissionUser)
            {
                var tasks = GetTasks();

                foreach (var t in tasks)
                {
                    if (t.UserID > 0)
                    {
                        result.Add(t.UserID);
                    }

                    if (!string.IsNullOrEmpty(t.Users))
                    {
                        result.AddRange(t.Users.Split(',').Select(u => int.Parse(u)));
                    }
                }
            }

            var childrenObjs = obj.GetChildren(null);

            if (childrenObjs != null)
            {
                foreach (var o in childrenObjs)
                {
                    var parentUsers = _GetChildrenMainUsers(o, IsPermissionUser);

                    if (parentUsers != null)
                    {
                        result.AddRange(parentUsers);
                    }
                }
            }

            return(result);
        }