Ejemplo n.º 1
0
        public List <User> GetAllUsers(string idString)
        {
            if (idString.IsNullOrEmpty())
            {
                return(new List <User>());
            }
            string[] idArray  = idString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            var      userList = new List <User>();

            foreach (string id in idArray)
            {
                if (id.StartsWith(MemberPerfix.UserPREFIX))//人员
                {
                    var user = _userRepository.Get(MemberPerfix.RemovePrefix(id).ToLong());
                    userList.Add(user);
                }
                else if (id.IsLong())//机构
                {
                    userList.AddRange(GetAllUsersById(id.ToLong()));
                }
                else if (id.StartsWith(MemberPerfix.DepartmentPREFIX)) //部门领导
                {
                    var leader = GetLeaderById(MemberPerfix.RemovePrefix(id).ToLong());
                    userList.AddRange(leader);
                }
                else if (id.StartsWith(MemberPerfix.DepartmentFGLeaderPREFIX)) //部门分管领导
                {
                    var chargleader = GetChargeLeaderById(MemberPerfix.RemovePrefix(id).ToLong());
                    userList.AddRange(chargleader);
                }
                else if (id.StartsWith(MemberPerfix.DepartmentMemberPREFIX)) //部门直属成员
                {
                    var users = GetAllByOrganizeIDArray(new long[] { MemberPerfix.RemovePrefix(id).ToLong() });
                    userList.AddRange(users);
                }
                else if (id.StartsWith(MemberPerfix.AllUserPREFIX)) //部门直属成员
                {
                    var users = GetAllUsersById(MemberPerfix.RemovePrefix(id).ToLong());
                    userList.AddRange(users.Distinct());
                }
                else if (id.StartsWith(MemberPerfix.WorkGroupPREFIX))//角色组
                {
                    //角色组暂未实现
                }
                else if (id.StartsWith(MemberPerfix.PostPREFIX))
                {
                    var users = GetAbpUsersByOrgPostIds(id);
                    userList.AddRange(users.Distinct());
                }
            }
            userList.RemoveAll(p => p == null);
            return(userList.Distinct(new UsersEqualityComparer()).ToList());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 用户是否是部门领导
 /// </summary>
 /// <param name="flowID"></param>
 /// <param name="groupID"></param>
 /// <returns></returns>
 public bool IsChargerLeader(long userId, long orgId)
 {
     try
     {
         var orgModel = _organizationUnitRepository.Get(orgId);
         if (MemberPerfix.RemovePrefix(orgModel.ChargeLeader).ToLong() == userId)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Ejemplo n.º 3
0
        public List <User> GetAbpUsersByOrgPostIds(string orgPostIds)
        {
            if (orgPostIds.IsNullOrWhiteSpace())
            {
                return(new List <User>());
            }
            var orgPostIdArry = orgPostIds.Split(',').ToList();

            for (int i = 0; i < orgPostIdArry.Count(); i++)
            {
                orgPostIdArry[i] = MemberPerfix.RemovePrefix(orgPostIdArry[i]);
            }
            var query = from userpost in _userPostRepository.GetAll()
                        join u in _userRepository.GetAll() on userpost.UserId equals u.Id
                        where orgPostIdArry.Contains(userpost.OrgPostId.ToString())
                        select u;

            return(query.ToList());
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取一个部门的部门领导
        /// </summary>
        /// <param name="userID"></param>
        /// <returns></returns>
        public List <User> GetLeaderById(long orgId)
        {
            var ret = new List <User>();
            var org = _organizationUnitRepository.Get(orgId);

            if (!org.Leader.IsNullOrWhiteSpace())
            {
                var leaderAarry = org.Leader.Split(",");
                foreach (var item in leaderAarry)
                {
                    var user = _userRepository.Get(MemberPerfix.RemovePrefix(item).ToLong());
                    ret.Add(user);
                }
            }
            else
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该部门未设置部门领导。");
            }
            return(ret);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 用户是否是分管领导
 /// </summary>
 /// <param name="flowID"></param>
 /// <param name="groupID"></param>
 /// <returns></returns>
 public bool IsChargerLeader(long userId)
 {
     try
     {
         var orgModel = GetDeptByUserID(userId);
         if (!string.IsNullOrEmpty(orgModel.ChargeLeader))
         {
             var leaders = orgModel.ChargeLeader.Split(",");
             foreach (var item in leaders)
             {
                 if (!string.IsNullOrEmpty(item) && MemberPerfix.RemovePrefix(item).ToLong() == userId)
                 {
                     return(true);
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 根据ID得到名称(有前缀的情况)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetName(string id, out string code, out string orgid)
        {
            code  = "";
            orgid = "";
            using (_unitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))
            {
                string name = string.Empty;
                if (id.IsLong())//机构
                {
                    var org = _organizationUnitRepository.Get(id.ToLong());
                    code  = org.Code;
                    orgid = org.Id.ToString();
                    return(org.DisplayName);
                }
                else if (id.StartsWith(MemberPerfix.UserPREFIX))//用户
                {
                    var user = _userRepository.Get(MemberPerfix.RemovePrefix(id).ToLong());
                    var orgs = UserManager.GetOrganizationUnitsAsync(user).Result.Where(ite => ite.IsDeleted == false);
                    if (orgs != null)
                    {
                        code  = string.Join(",", orgs.Select(ite => ite.Code));
                        orgid = string.Join(",", orgs.Select(ite => ite.Id));
                    }
                    return(user.Name);
                }
                else if (id.StartsWith(MemberPerfix.DepartmentPREFIX))//部门-领导
                {
                    string uid = id.Replace(MemberPerfix.DepartmentPREFIX, "");
                    long   deptID;
                    if (!uid.IsLong(out deptID))
                    {
                        return("");
                    }
                    else
                    {
                        var org   = _organizationUnitRepository.Get(deptID);
                        var users = GetLeaderById(deptID);
                        return(org.DisplayName + $"[领导:{string.Join(",", users.Select(r => r.Name))}]");
                    }
                }
                else if (id.StartsWith(MemberPerfix.DepartmentFGLeaderPREFIX))//部门-分管领导
                {
                    string uid = id.Replace(MemberPerfix.DepartmentFGLeaderPREFIX, "");
                    long   deptID;
                    if (!uid.IsLong(out deptID))
                    {
                        return("");
                    }
                    else
                    {
                        var org   = _organizationUnitRepository.Get(deptID);
                        var users = GetChargeLeaderById(deptID);
                        return(org.DisplayName + $"[分管领导:{string.Join(",", users.Select(r => r.Name))}]");
                    }
                }

                else if (id.StartsWith(MemberPerfix.DepartmentMemberPREFIX))//部门直属人
                {
                    string uid = id.Replace(MemberPerfix.DepartmentMemberPREFIX, "");
                    long   deptID;
                    if (!uid.IsLong(out deptID))
                    {
                        return("");
                    }
                    else
                    {
                        var org = _organizationUnitRepository.Get(deptID);
                        code  = org.Code;
                        orgid = org.Id.ToString();
                        return(org.DisplayName + "[直属成员]");
                    }
                }

                else if (id.StartsWith(MemberPerfix.DepartmentIdPREFIX))//部门直属人
                {
                    string uid = id.Replace(MemberPerfix.DepartmentIdPREFIX, "");
                    long   deptID;
                    if (!uid.IsLong(out deptID))
                    {
                        return("");
                    }
                    else
                    {
                        var org = _organizationUnitRepository.Get(deptID);
                        code  = org.Code;
                        orgid = org.Id.ToString();
                        return(org.DisplayName);
                    }
                }
                else if (id.StartsWith(MemberPerfix.UserIdPREFIX))//用户
                {
                    var user = _userRepository.Get(MemberPerfix.RemovePrefix(id).ToLong());
                    var orgs = UserManager.GetOrganizationUnitsAsync(user).Result.Where(ite => ite.IsDeleted == false);
                    if (orgs != null)
                    {
                        code  = string.Join(",", orgs.Select(ite => ite.Code));
                        orgid = string.Join(",", orgs.Select(ite => ite.Id));
                    }
                    return(user.Name);
                }
                else if (id.StartsWith(MemberPerfix.AllUserPREFIX))
                {
                    var torgid = long.Parse(id.Replace(MemberPerfix.AllUserPREFIX, ""));
                    var org    = _organizationUnitRepository.FirstOrDefault(torgid);
                    if (org == null)
                    {
                        return("[该部门已被删除]");
                    }
                    code  = org.Code;
                    orgid = org.Id.ToString();
                    return(org.DisplayName + "[所有人员]");
                }
                else if (id.StartsWith(MemberPerfix.PostPREFIX))
                {
                    var orgpostid       = Guid.Parse(id.Replace(MemberPerfix.PostPREFIX, ""));
                    var postInfoService = AbpBootstrapper.Create <Abp.Modules.AbpModule>().IocManager.IocContainer.Resolve <IPostInfoAppService>();
                    return(postInfoService.GetUserNameByOrgPostId(orgpostid));
                }

                //else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                //{
                //    string uid = WorkGroup.RemovePrefix(id);
                //    Guid wid;
                //    if (!uid.IsGuid(out wid))
                //    {
                //        return "";
                //    }
                //    else
                //    {
                //        return new WorkGroup().GetName(wid);
                //    }
                //}

                return("");
            }
        }