コード例 #1
0
ファイル: Organize.cs プロジェクト: greatPurpose/bizprocess
        private void addWorkGroupUsers(List <BizProcess.Data.Model.Users> userList, BizProcess.Data.Model.WorkGroup wg)
        {
            if (wg == null || wg.Members.IsNullOrEmpty())
            {
                return;
            }
            string[]  idArray = wg.Members.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            Users     busers  = new Users();
            WorkGroup bwg     = new WorkGroup();

            foreach (var id in idArray)
            {
                if (id.StartsWith(Users.PREFIX))//人员
                {
                    userList.Add(busers.Get(Users.RemovePrefix(id).ToGuid()));
                }
                else if (id.IsGuid())//机构
                {
                    userList.AddRange(GetAllUsers(id.ToGuid()));
                }
                else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                {
                    addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).ToGuid()));
                }
            }
        }
コード例 #2
0
ファイル: Organize.cs プロジェクト: greatPurpose/bizprocess
        /// <summary>
        /// 得到一组机构字符串下所有人员
        /// </summary>
        /// <param name="idString"></param>
        /// <returns></returns>
        public List <BizProcess.Data.Model.Users> GetAllUsers(string idString)
        {
            if (idString.IsNullOrEmpty())
            {
                return(new List <BizProcess.Data.Model.Users>());
            }
            string[] idArray = idString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <BizProcess.Data.Model.Users> userList = new List <BizProcess.Data.Model.Users>();
            Users     busers = new Users();
            WorkGroup bwg    = new WorkGroup();

            foreach (string id in idArray)
            {
                if (id.StartsWith(Users.PREFIX))//人员
                {
                    userList.Add(busers.Get(Users.RemovePrefix(id).ToGuid()));
                }
                else if (id.IsGuid())//机构
                {
                    userList.AddRange(GetAllUsers(id.ToGuid()));
                }
                else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                {
                    addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).ToGuid()));
                }
            }
            userList.RemoveAll(p => p == null);
            return(userList.Distinct(new UsersEqualityComparer()).ToList());
        }
コード例 #3
0
ファイル: Organize.cs プロジェクト: greatPurpose/bizprocess
        /// <summary>
        /// 根据ID得到名称(有前缀的情况)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetName(string id)
        {
            string name = string.Empty;

            if (id.IsGuid())//机构
            {
                return(GetName(id.ToGuid()));
            }
            else if (id.StartsWith(Users.PREFIX))//用户
            {
                string uid = Users.RemovePrefix(id);
                Guid   userID;
                if (!uid.IsGuid(out userID))
                {
                    return("");
                }
                else
                {
                    return(new Users().GetName(userID));
                }
            }
            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("");
        }