Пример #1
0
		public void RemoveUserFromRole(SCUser user, AdminUnit unit, AUSchemaRole role)
		{
			CheckUnitPermission(AUOperationType.RemoveUserFromRole, "EditRoleMembers", unit);

			SchemaObjectBase r = Adapters.AUSnapshotAdapter.Instance.LoadAURole(role.ID, unit.ID, true, DateTime.MinValue);
			if (r == null)
				throw new AUObjectValidationException("没有找到此管理单元的角色,请尝试重新添加此角色");

			AUMemberRelativeExecutor executor = new AUMemberRelativeExecutor(AUOperationType.RemoveUserFromRole, r, user)
			{
				OverrideExistedRelation = true,
				SaveTargetData = false,
				NeedStatusCheck = false,
				NeedContainerStatusCheck = this.NeedValidationAndStatusCheck,
			};

			executor.Relation.Status = SchemaObjectStatus.Deleted;

			SCMemberRelation result = null;

			ExecuteWithActions(AUOperationType.RemoveUserFromRole, () => SCActionContext.Current.DoActions(() => result = (SCMemberRelation)executor.Execute()));
		}
Пример #2
0
		public void RemoveObjectFromScope(AUAdminScopeItem item, AUAdminScope scope)
		{
			AdminUnit unit = scope.GetOwnerUnit();
			CheckUnitPermission(AUOperationType.AddAdminUnit, "EditAdminScope", unit);

			AUMemberRelativeExecutor executor = new AUMemberRelativeExecutor(AUOperationType.AddAUScopeItem, scope, item)
			{
				SaveTargetData = false,
				NeedValidation = this.NeedValidationAndStatusCheck,
				NeedContainerStatusCheck = this.NeedValidationAndStatusCheck,
			};

			executor.Data.Status = SchemaObjectStatus.Deleted;
			executor.Relation.Status = SchemaObjectStatus.Deleted;

			ExecuteWithActions(AUOperationType.AddAUScopeItem, () => SCActionContext.Current.DoActions(() =>
			{
				executor.Execute();
			}));
		}