/// <summary>
        /// 加载特定用户的模块
        /// TODO:这里会加载用户及用户角色的所有模块,“为用户分配模块”功能会给人一种混乱的感觉,但可以接受
        /// </summary>
        /// <param name="userId">The user unique identifier.</param>
        public IEnumerable <Module> LoadForUser(string userId)
        {
            var roleIds   = _revelanceApp.Get(Define.USERROLE, true, userId);
            var moduleIds = UnitWork.Find <Relevance>(
                u =>
                (u.FirstId == userId && u.Key == Define.USERMODULE) ||
                (u.Key == Define.ROLEMODULE && roleIds.Contains(u.FirstId))).Select(u => u.SecondId);

            return(UnitWork.Find <Module>(u => moduleIds.Contains(u.Id)).OrderBy(u => u.SortNo));
        }
Exemple #2
0
        /// <summary>
        /// 寻找该节点执行人
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private string GetNodeMakers(FlowNode node)
        {
            string makerList = "";

            if (node.setInfo != null)
            {
                if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
                {
                    makerList = "1";
                }
                else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
                {
                    makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);
                }
                else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_ROLE)  //指定角色
                {
                    var users = _revelanceApp.Get(Define.USERROLE, false, node.setInfo.NodeDesignateData.roles);
                    makerList = GenericHelpers.ArrayToString(users, makerList);
                }
            }
            else  //如果没有设置节点信息,默认所有人都可以审核
            {
                makerList = "1";
            }
            return(makerList);
        }
Exemple #3
0
        /// <summary>
        /// 寻找该节点执行人
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private string GetNodeMarkers(FlowNode node, string flowinstanceCreateUserId = "")
        {
            string makerList = "";

            if (node.type == FlowNode.START && (!string.IsNullOrEmpty(flowinstanceCreateUserId))) //如果是开始节点,通常情况下是驳回到开始了
            {
                makerList = flowinstanceCreateUserId;
            }
            else if (node.setInfo != null)
            {
                if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
                {
                    makerList = "1";
                }
                else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
                {
                    makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);
                }
                else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_ROLE)  //指定角色
                {
                    var users = _revelanceApp.Get(Define.USERROLE, false, node.setInfo.NodeDesignateData.roles);
                    makerList = GenericHelpers.ArrayToString(users, makerList);
                }
            }
            else  //如果没有设置节点信息,默认所有人都可以审核
            {
                makerList = "1";
            }
            return(makerList);
        }
Exemple #4
0
        /// <summary>
        /// 寻找下一步的执行人
        /// 一般用于本节点审核完成后,修改流程实例的当前执行人,可以做到通知等功能
        /// </summary>
        /// <returns></returns>
        private string GetNextMakers(FlowRuntime wfruntime, NodeDesignateReq request = null)
        {
            string makerList = "";

            if (wfruntime.nextNodeId == "-1")
            {
                throw (new Exception("无法寻找到下一个节点"));
            }

            if (wfruntime.nextNodeType == 0) //如果是会签节点
            {
                makerList = GetForkNodeMakers(wfruntime, wfruntime.nextNodeId);
            }
            else if (wfruntime.nextNode.setInfo.NodeDesignate == Setinfo.RUNTIME_SPECIAL_ROLE)
            { //如果是运行时指定角色
                if (wfruntime.nextNode.setInfo.NodeDesignate != request.NodeDesignateType)
                {
                    throw new Exception("前端提交的节点权限类型异常,请检查流程");
                }
                var users = _revelanceApp.Get(Define.USERROLE, false, request.NodeDesignates);
                makerList = GenericHelpers.ArrayToString(users, makerList);
            }
            else if (wfruntime.nextNode.setInfo.NodeDesignate == Setinfo.RUNTIME_SPECIAL_USER)
            {  //如果是运行时指定用户
                if (wfruntime.nextNode.setInfo.NodeDesignate != request.NodeDesignateType)
                {
                    throw new Exception("前端提交的节点权限类型异常,请检查流程");
                }
                makerList = GenericHelpers.ArrayToString(request.NodeDesignates, makerList);
            }
            else
            {
                makerList = GetNodeMarkers(wfruntime.nextNode);
                if (string.IsNullOrEmpty(makerList))
                {
                    throw (new Exception("无法寻找到节点的审核者,请查看流程设计是否有问题!"));
                }
            }

            return(makerList);
        }
        public IEnumerable <ModuleElement> LoadMenusForRole(string moduleId, string roleId)
        {
            var elementIds = _revelanceApp.Get(Define.ROLEELEMENT, true, roleId);
            var query      = UnitWork.Find <ModuleElement>(u => elementIds.Contains(u.Id));

            if (!string.IsNullOrEmpty(moduleId))
            {
                query = query.Where(u => u.ModuleId == moduleId);
            }

            return(query);
        }
Exemple #6
0
        /// <summary>
        /// 加载当前登录用户可访问的一个部门及子部门全部用户
        /// </summary>
        public TableData Load(QueryUserListReq request)
        {
            var loginUser = _auth.GetCurrentUser();

            string cascadeId = ".0.";

            if (!string.IsNullOrEmpty(request.orgId))
            {
                var org = loginUser.Orgs.SingleOrDefault(u => u.Id == request.orgId);
                cascadeId = org.CascadeId;
            }

            IQueryable <User> query = UnitWork.Find <User>(null);

            if (!string.IsNullOrEmpty(request.key))
            {
                query = UnitWork.Find <User>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
            }

            var ids     = loginUser.Orgs.Where(u => u.CascadeId.Contains(cascadeId)).Select(u => u.Id).ToArray();
            var userIds = _revelanceApp.Get(Define.USERORG, false, ids);

            var users = query.Where(u => userIds.Contains(u.Id))
                        .OrderBy(u => u.Name)
                        .Skip((request.page - 1) * request.limit)
                        .Take(request.limit);

            var records = query.Count(u => userIds.Contains(u.Id));


            var userviews = new List <UserView>();

            foreach (var user in users.ToList())
            {
                UserView uv   = user;
                var      orgs = _orgManagerApp.LoadForUser(user.Id);
                uv.Organizations   = string.Join(",", orgs.Select(u => u.Name).ToList());
                uv.OrganizationIds = string.Join(",", orgs.Select(u => u.Id).ToList());
                userviews.Add(uv);
            }

            return(new TableData
            {
                count = records,
                data = userviews,
            });
        }
Exemple #7
0
        /// <summary>
        /// 加载当前登录用户可访问的一个部门及子部门全部角色
        /// </summary>
        public TableData Load(QueryRoleListReq request)
        {
            var loginUser = _auth.GetCurrentUser();

            string cascadeId = ".0.";

            if (!string.IsNullOrEmpty(request.orgId))
            {
                var org = loginUser.Orgs.SingleOrDefault(u => u.Id == request.orgId);
                cascadeId = org.CascadeId;
            }

            var ids     = loginUser.Orgs.Where(u => u.CascadeId.Contains(cascadeId)).Select(u => u.Id).ToArray();
            var roleIds = _revelanceApp.Get(Define.ROLEORG, false, ids);

            var roles = UnitWork.Find <Role>(u => roleIds.Contains(u.Id))
                        .OrderBy(u => u.Name)
                        .Skip((request.page - 1) * request.limit)
                        .Take(request.limit);

            var records = Repository.GetCount(u => roleIds.Contains(u.Id));


            var roleViews = new List <RoleView>();

            foreach (var role in roles.ToList())
            {
                RoleView uv   = role;
                var      orgs = LoadByRole(role.Id);
                uv.Organizations   = string.Join(",", orgs.Select(u => u.Name).ToList());
                uv.OrganizationIds = string.Join(",", orgs.Select(u => u.Id).ToList());
                roleViews.Add(uv);
            }

            return(new TableData
            {
                count = records,
                data = roleViews,
            });
        }
        /// <summary>
        /// 寻找该节点执行人
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        private string GetMakerList(FlowNode node, string processId)
        {
            string makerList = "";

            if (node.setInfo == null)
            {
                makerList = "-1";
            }
            else
            {
                if (node.setInfo.NodeDesignate == Setinfo.ALL_USER)//所有成员
                {
                    makerList = "1";
                }
                else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_USER)//指定成员
                {
                    makerList = GenericHelpers.ArrayToString(node.setInfo.NodeDesignateData.users, makerList);

                    if (makerList == "")
                    {
                        makerList = "-1";
                    }
                }
                else if (node.setInfo.NodeDesignate == Setinfo.SPECIAL_ROLE)  //指定角色
                {
                    var users = RevelanceManagerApp.Get(Define.USERROLE, false, node.setInfo.NodeDesignateData.roles);
                    makerList = GenericHelpers.ArrayToString(users, makerList);

                    if (makerList == "")
                    {
                        makerList = "-1";
                    }
                }
            }
            return(makerList);
        }
Exemple #9
0
 //获取角色可访问的模块字段
 public IEnumerable <string> LoadPropertiesForRole(string roleId, string moduleCode)
 {
     return(_revelanceApp.Get(Define.ROLEDATAPROPERTY, roleId, moduleCode));
 }
        public IEnumerable <Resource> LoadForRole(string appId, string roleId)
        {
            var elementIds = _revelanceApp.Get(Define.ROLERESOURCE, true, roleId);

            return(UnitWork.Find <Resource>(u => elementIds.Contains(u.Id) && (appId == null || appId == "" || u.AppId == appId)));
        }
Exemple #11
0
        public IEnumerable <Resource> LoadForUser(string appId, string userId)
        {
            var elementIds = _revelanceApp.Get(Define.USERRESOURCE, true, userId);

            return(UnitWork.Find <Resource>(u => elementIds.Contains(u.Id) && (appId == "" || u.AppId == appId)));
        }