Ejemplo n.º 1
0
        public GroupInfo Create(string operationUserId, GroupCreateInfo createInfo)
        {
            User  opUser = this.OrganizationManager.UserManager.GetUserById(operationUserId);
            Group group  = this.OrganizationManager.GroupManager.Create(opUser, createInfo);

            return(group.MapGroupInfo());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 创建用户组
        /// </summary>
        /// <param name="group">用户组</param>
        /// <returns>用户组</returns>
        public Group Create(User operationUser, GroupCreateInfo createInfo)
        {
            lock (this._updateLockObject)
            {
                if (operationUser == null)
                {
                    throw new ArgumentNullException("operationUser");
                }
                if (createInfo == null)
                {
                    throw new ArgumentNullException("groupInfo");
                }

                if (createInfo.GroupType == GroupType.Group)
                {
                    if (this._Groups.Exists(x => x.GroupType != GroupType.Personal && x.Name == createInfo.Name))
                    {
                        throw new GroupNameReapeatException();
                    }
                }
                else if (createInfo.GroupType == GroupType.Personal)
                {
                    if (this._Groups.Exists(x => x.GroupType == GroupType.Personal && x.Creator == operationUser && x.Name == createInfo.Name))
                    {
                        throw new GroupNameReapeatException();
                    }
                }
                List <Group> groups = this._Groups;
                if (this.Creating != null)
                {
                    this.Creating(this, createInfo);
                }

                Group group = new Group(Guid.NewGuid().ToString(), createInfo.Name, DateTime.Now, operationUser, createInfo.Remark, GroupType.Group, this._orgMnger);

                List <Group> tempGroup = groups.ToList();
                tempGroup.Add(group);
                this._groups = tempGroup;

                if (this.Created != null)
                {
                    this.Created(this, group);
                }

                return(group);
            }
        }