示例#1
0
        private void addWorkGroupUsers(List <RoadFlow.Data.Model.UsersModel> userList, RoadFlow.Data.Model.WorkGroup wg)
        {
            if (wg == null || wg.Members.IsNullOrEmpty())
            {
                return;
            }
            string[]  idArray = wg.Members.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            UsersBLL  busers  = new UsersBLL();
            WorkGroup bwg     = new WorkGroup();

            foreach (var id in idArray)
            {
                if (id.StartsWith(UsersBLL.PREFIX))//人员
                {
                    userList.Add(busers.Get(UsersBLL.RemovePrefix(id).Convert <Guid>()));
                }
                else if (id.IsGuid())//机构
                {
                    userList.AddRange(GetAllUsers(id.Convert <Guid>()));
                }
                else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                {
                    addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).Convert <Guid>()));
                }
            }
        }
示例#2
0
        /// <summary>
        /// 得到一组机构字符串下所有人员
        /// </summary>
        /// <param name="idString"></param>
        /// <returns></returns>
        public List <RoadFlow.Data.Model.UsersModel> GetAllUsers(string idString)
        {
            if (idString.IsNullOrEmpty())
            {
                return(new List <RoadFlow.Data.Model.UsersModel>());
            }
            string[] idArray = idString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            List <RoadFlow.Data.Model.UsersModel> userList = new List <RoadFlow.Data.Model.UsersModel>();
            UsersBLL  busers = new UsersBLL();
            WorkGroup bwg    = new WorkGroup();

            foreach (string id in idArray)
            {
                if (id.StartsWith(UsersBLL.PREFIX))//人员
                {
                    userList.Add(busers.Get(UsersBLL.RemovePrefix(id).Convert <Guid>()));
                }
                else if (id.IsGuid())//机构
                {
                    userList.AddRange(GetAllUsers(id.Convert <Guid>()));
                }
                else if (id.StartsWith(WorkGroup.PREFIX))//工作组
                {
                    addWorkGroupUsers(userList, bwg.Get(WorkGroup.RemovePrefix(id).Convert <Guid>()));
                }
            }
            userList.RemoveAll(p => p == null);
            return(userList.Distinct(new UsersEqualityComparer()).ToList());
        }