public void GetGrpIdByAreaId() { GroupName.Clear(); if (AreaId == -1) //全部区域 { GrpVisi = Visibility.Collapsed; } else { GrpVisi = Visibility.Visible; var area = Wlst.Sr.EquipmentInfoHolding.Services.AreaInfoHold.MySlef.GetAreaInfo(AreaId); if (area == null) { return; } var grps = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GrpInfoList(AreaId); GroupName.Add(new GroupInt() { Value = "全部", Key = -1 }); if (grps.Count > 0) { var grpsTmp = (from t in grps orderby t.GroupId select t).ToList(); foreach (var f in grpsTmp) { var grptml = Wlst.Sr.EquipmentInfoHolding.Services.ServicesGrpSingleInfoHold.GetGrpTmlList(AreaId, f.GroupId); if (grptml.Count == 0) { continue; } GroupName.Add(new GroupInt() { Value = f.GroupName, Key = f.GroupId }); } } GroupComboBoxSelected = GroupName[0]; } }
private IGroup CreateGroupInt( UserManagerData userManagerData, string name, string displayName, ID<IUserOrGroup, Guid>? ownerId, ID<IUserOrGroup, Guid> groupId, bool builtIn, bool automatic, GroupType groupType) { name = name.ToLowerInvariant(); if (groupType >= GroupType.Private) this.ThrowExceptionIfDuplicate(userManagerData, name); UserInt owner = null; if (null != ownerId) owner = userManagerData.GetUser(ownerId.Value); var group = new GroupInt() { name = groupType > GroupType.Personal ? name : groupId.ToString(), id = groupId, owner = owner, builtIn = builtIn, automatic = automatic, type = groupType, displayName = displayName }; if (GroupType.Personal == groupType) group.aliases[owner] = name; userManagerData.groups[groupId] = group; if (groupType != GroupType.Personal) userManagerData.byName[name] = group; var groupObj = this.CreateGroupObject(group); IDirectoryHandler usersDirectory = FileHandlerFactoryLocator.FileSystemResolver.ResolveFile("Users").CastFileHandler<IDirectoryHandler>(); string groupFileName = name + ".group"; if (!automatic) { // Decide where the object goes, for personal groups in the user's directory, for system groups in the users directory IDirectoryHandler groupObjectDestinationDirectory; if (groupType == GroupType.Personal) groupObjectDestinationDirectory = usersDirectory.OpenFile(owner.name).CastFileHandler<IDirectoryHandler>(); else groupObjectDestinationDirectory = usersDirectory; INameValuePairsHandler groupDB; try { groupDB = groupObjectDestinationDirectory.CreateFile(groupFileName, "group", ownerId).FileContainer.CastFileHandler<INameValuePairsHandler>(); ; } catch (DuplicateFile) { throw new UserAlreadyExistsException(name + " already exists"); } IUser ownerObj = null; if (null != owner) ownerObj = this.CreateUserObject(owner); groupObjectDestinationDirectory.SetPermission( ownerObj, groupFileName, new ID<IUserOrGroup, Guid>[] { groupId }, FilePermissionEnum.Read, true, true); // Everyone can read a public group if (GroupType.Public == groupType) usersDirectory.SetPermission( ownerObj, groupFileName, new ID<IUserOrGroup, Guid>[] { FileHandlerFactoryLocator.UserFactory.Everybody.Id }, FilePermissionEnum.Read, true, false); groupDB.Set(ownerObj, "GroupId", groupId.Value.ToString()); } log.Info("Created group: " + name); return groupObj; }
/// <summary> /// Creates the group object /// </summary> /// <param name="groupFromDB"></param> /// <returns></returns> private IGroupAndAlias CreateGroupAndAliasObject(GroupInt group, string alias) { return new GroupAndAlias( null != group.owner ? (ID<IUserOrGroup, Guid>?)group.owner.id : (ID<IUserOrGroup, Guid>?)null, group.id, group.name, group.builtIn, group.automatic, group.type, alias, FileHandlerFactoryLocator, group.displayName); }
/// <summary> /// Creates the group object /// </summary> /// <param name="groupFromDB"></param> /// <returns></returns> private IGroup CreateGroupObject(GroupInt group) { return new Group( group.owner != null ? (ID<IUserOrGroup, Guid>?)group.owner.id : (ID<IUserOrGroup, Guid>?)null, group.id, group.name, group.builtIn, group.automatic, group.type, FileHandlerFactoryLocator, group.displayName); }