コード例 #1
0
ファイル: Facade.cs プロジェクト: ounata/AK47-2016Source
        private void CheckUnitPermission(AUOperationType opType, string permissionName, AdminUnit unit)
        {
            unit.NullCheck("unit");
            if (unit.Status != SchemaObjectStatus.Normal)
            {
                throw new AUStatusCheckException(unit, opType);
            }

            if (this._NeedCheckPermissions)
            {
                if (unit == null || unit.Status != SchemaObjectStatus.Normal)
                {
                    throw new ArgumentException(string.Format("不存在参数 unit 指定的管理单元", "unit"));
                }

                if (DeluxePrincipal.Current.HasPermissions(permissionName, new string[] { unit.ID }) == false)
                {
                    //如果没有权限,检查是否超级管理员或者拥有架构权限
                    if (AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current) == false)
                    {
                        var schema = unit.GetUnitSchema();
                        if (string.IsNullOrEmpty(schema.MasterRole) || DeluxePrincipal.Current.IsInRole(schema.MasterRole) == false)
                        {
                            throw CreateAclException(opType, unit.Schema, permissionName);
                        }
                    }
                }
            }
        }
コード例 #2
0
        public AUUpdateObjectAclExecutor(AUOperationType opType, SCAclContainer container)
            : base(opType)
        {
            container.NullCheck("container");

            this._Container = container;
        }
コード例 #3
0
		public AUReplaceAclRecursivelyExecutor(AUOperationType opType, ISCAclContainer parent) :
			base(opType)
		{
			parent.NullCheck("parent");

			this._Parent = parent;
			this.AutoStartTransaction = false;
		}
コード例 #4
0
 public AUSchemaExecutor(AUOperationType type, SchemaObjectBase schema)
     : base(type, schema)
 {
     if (type != AUOperationType.AddAdminSchema && type != AUOperationType.RemoveAdminSchema && type != AUOperationType.UpdateAdminSchema)
     {
         throw new NotSupportedException("不支持在此Executor中使用操作" + type);
     }
 }
コード例 #5
0
        public AUObjectExecutor(AUOperationType opType, SchemaObjectBase data)
            : base(opType)
        {
            data.NullCheck("data");

            data.ClearRelativeData();
            this._Data = data;
        }
コード例 #6
0
        public AUReplaceAclRecursivelyExecutor(AUOperationType opType, ISCAclContainer parent) :
            base(opType)
        {
            parent.NullCheck("parent");

            this._Parent = parent;
            this.AutoStartTransaction = false;
        }
コード例 #7
0
		public AUObjectExecutor(AUOperationType opType, SchemaObjectBase data)
			: base(opType)
		{
			data.NullCheck("data");

			data.ClearRelativeData();
			this._Data = data;
		}
コード例 #8
0
 public AURoleMemberExecutor(AUOperationType opType, AUSchemaRole role, AdminUnit unit, SCUser[] users)
     : base(opType)
 {
     role.NullCheck("role");
     users.NullCheck("users");
     unit.NullCheck("unit");
     this.schemaRole = role;
     this.users      = users;
     this.unit       = unit;
 }
コード例 #9
0
		public AURoleMemberExecutor(AUOperationType opType, AUSchemaRole role, AdminUnit unit, SCUser[] users)
			: base(opType)
		{
			role.NullCheck("role");
			users.NullCheck("users");
			unit.NullCheck("unit");
			this.schemaRole = role;
			this.users = users;
			this.unit = unit;
		}
コード例 #10
0
		public AUSchemaRoleExecutor(AUOperationType type, AUSchema schema, AUSchemaRole data)
			: base(type, schema, data)
		{
			switch (type)
			{
				case AUOperationType.AddSchemaRole:
				case AUOperationType.RemoveSchemaRole:
					break;
				default:
					throw new ArgumentOutOfRangeException("type", string.Format("AUSchemaRoleExecutor不支持{0}操作", type));
			}
		}
コード例 #11
0
        public AUSchemaRoleExecutor(AUOperationType type, AUSchema schema, AUSchemaRole data)
            : base(type, schema, data)
        {
            switch (type)
            {
            case AUOperationType.AddSchemaRole:
            case AUOperationType.RemoveSchemaRole:
                break;

            default:
                throw new ArgumentOutOfRangeException("type", string.Format("AUSchemaRoleExecutor不支持{0}操作", type));
            }
        }
コード例 #12
0
		public AUMemberRelativeExecutorBase(AUOperationType opType, SchemaObjectBase container, SchemaObjectBase member)
			: base(opType, member)
		{
			container.NullCheck("container");

			container.ClearRelativeData();

			if (member != null)
				member.ClearRelativeData();

			this._Container = container;
			this._Relation = PrepareRelationObject(container, member);
		}
コード例 #13
0
        public AUMemberRelativeExecutorBase(AUOperationType opType, SchemaObjectBase container, SchemaObjectBase member)
            : base(opType, member)
        {
            container.NullCheck("container");

            container.ClearRelativeData();

            if (member != null)
            {
                member.ClearRelativeData();
            }

            this._Container = container;
            this._Relation  = PrepareRelationObject(container, member);
        }
コード例 #14
0
        public AdminUnitExecutor(AUOperationType opType, AdminUnit parent, AdminUnit child)
            : base(opType, child)
        {
            child.NullCheck("child");
            child.ClearRelativeData();
            if (parent != null)
                parent.ClearRelativeData();

            if (!(opType != AUOperationType.AddAdminUnit | opType != AUOperationType.RemoveAdminUnit))
                throw new ApplicationException("此Executor不支持" + opType + "操作");

            this.inputParent = parent;

            if (this.OperationType == AUOperationType.AddAdminUnit)
                this.aclContainer = PrepareAclContainer(parent, child);
        }
コード例 #15
0
ファイル: Facade.cs プロジェクト: ounata/AK47-2016Source
        private void CheckUpdateAclPermissions(AUOperationType opType, string containerID)
        {
            if (this.NeedCheckPermissionAndCurrentUserIsNotSupervisor)
            {
                AdminUnit unit = null;

                AUCommon.DoDbAction(() =>
                {
                    unit = (AdminUnit)PC.Adapters.SchemaObjectAdapter.Instance.Load(containerID);
                });

                if (unit == null || unit.Status != SchemaObjectStatus.Normal)
                {
                    throw new AUObjectException("指定的管理单元不存在");
                }

                CheckUnitPermission(opType, "EditSubUnitAcl", unit);
            }
        }
コード例 #16
0
ファイル: Facade.cs プロジェクト: ounata/AK47-2016Source
        private SCAclPermissionCheckException CreateAclException(AUOperationType opType, SchemaDefine schemaInfo, string permissionName)
        {
            string opDesp = EnumItemDescriptionAttribute.GetDescription(opType);

            SCAclPermissionItem permissionInfo = schemaInfo.PermissionSet[permissionName];

            string permissionDesp = string.Empty;

            if (permissionInfo != null)
            {
                permissionDesp = permissionInfo.Description;

                if (permissionDesp.IsNullOrEmpty())
                {
                    permissionDesp = permissionInfo.Name;
                }
            }

            return(new SCAclPermissionCheckException(string.Format("不能执行\"{0}\"操作,您没有\"{0}\"权限", opDesp, permissionDesp)));
        }
コード例 #17
0
        public AdminUnitExecutor(AUOperationType opType, AdminUnit parent, AdminUnit child)
            : base(opType, child)
        {
            child.NullCheck("child");
            child.ClearRelativeData();
            if (parent != null)
            {
                parent.ClearRelativeData();
            }

            if (!(opType != AUOperationType.AddAdminUnit | opType != AUOperationType.RemoveAdminUnit))
            {
                throw new ApplicationException("此Executor不支持" + opType + "操作");
            }

            this.inputParent = parent;

            if (this.OperationType == AUOperationType.AddAdminUnit)
            {
                this.aclContainer = PrepareAclContainer(parent, child);
            }
        }
コード例 #18
0
ファイル: Facade.cs プロジェクト: ounata/AK47-2016Source
        private void ExecuteWithActions(AUOperationType operationType, Action action)
        {
            AUCommon.DoDbAction(() =>
            {
                MCS.Library.SOA.DataObjects.Security.Locks.SCDataOperationLockContext.Current.DoAddLockAction(this._AddLock, EnumItemDescriptionAttribute.GetDescription(operationType), () =>
                {
                    if (this._NeedExecuteActions && action != null)
                    {
                        AUObjectOperationActionCollection actions = AUObjectOperationActionSettings.GetConfig().GetActions();

                        actions.BeforeExecute(operationType);

                        action();

                        actions.AfterExecute(operationType);
                    }
                    else
                    {
                        action();
                    }
                });
            });
        }
コード例 #19
0
ファイル: Facade.cs プロジェクト: jerryshi2007/AK47Source
		private void ExecuteWithActions(AUOperationType operationType, Action action)
		{
			AUCommon.DoDbAction(() =>
			{
				MCS.Library.SOA.DataObjects.Security.Locks.SCDataOperationLockContext.Current.DoAddLockAction(this._AddLock, EnumItemDescriptionAttribute.GetDescription(operationType), () =>
				{
					if (this._NeedExecuteActions && action != null)
					{
						AUObjectOperationActionCollection actions = AUObjectOperationActionSettings.GetConfig().GetActions();

						actions.BeforeExecute(operationType);

						action();

						actions.AfterExecute(operationType);
					}
					else
						action();
				});
			});
		}
コード例 #20
0
ファイル: Facade.cs プロジェクト: jerryshi2007/AK47Source
		private void CheckUpdateAclPermissions(AUOperationType opType, string containerID)
		{
			if (this.NeedCheckPermissionAndCurrentUserIsNotSupervisor)
			{
				AdminUnit unit = null;

				AUCommon.DoDbAction(() =>
				{
					unit = (AdminUnit)PC.Adapters.SchemaObjectAdapter.Instance.Load(containerID);
				});

				if (unit == null || unit.Status != SchemaObjectStatus.Normal)
					throw new AUObjectException("指定的管理单元不存在");

				CheckUnitPermission(opType, "EditSubUnitAcl", unit);
			}
		}
コード例 #21
0
ファイル: Facade.cs プロジェクト: jerryshi2007/AK47Source
		private SCAclPermissionCheckException CreateAclException(AUOperationType opType, SchemaDefine schemaInfo, string permissionName)
		{
			string opDesp = EnumItemDescriptionAttribute.GetDescription(opType);

			SCAclPermissionItem permissionInfo = schemaInfo.PermissionSet[permissionName];

			string permissionDesp = string.Empty;

			if (permissionInfo != null)
			{
				permissionDesp = permissionInfo.Description;

				if (permissionDesp.IsNullOrEmpty())
					permissionDesp = permissionInfo.Name;
			}

			return new SCAclPermissionCheckException(string.Format("不能执行\"{0}\"操作,您没有\"{0}\"权限", opDesp, permissionDesp));
		}
コード例 #22
0
ファイル: Facade.cs プロジェクト: jerryshi2007/AK47Source
		private void CheckUnitPermission(AUOperationType opType, string permissionName, AdminUnit unit)
		{
			unit.NullCheck("unit");
			if (unit.Status != SchemaObjectStatus.Normal)
				throw new AUStatusCheckException(unit, opType);

			if (this._NeedCheckPermissions)
			{
				if (unit == null || unit.Status != SchemaObjectStatus.Normal)
					throw new ArgumentException(string.Format("不存在参数 unit 指定的管理单元", "unit"));

				if (DeluxePrincipal.Current.HasPermissions(permissionName, new string[] { unit.ID }) == false)
				{
					//如果没有权限,检查是否超级管理员或者拥有架构权限
					if (AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current) == false)
					{
						var schema = unit.GetUnitSchema();
						if (string.IsNullOrEmpty(schema.MasterRole) || DeluxePrincipal.Current.IsInRole(schema.MasterRole) == false)
							throw CreateAclException(opType, unit.Schema, permissionName);
					}
				}
			}
		}
コード例 #23
0
		public AUUpdateConditionsExecutor(AUOperationType opType, AUAdminScope scope, SCCondition condition)
			: base(opType)
		{
			(this.scope = scope).NullCheck("scope");
			(this.condition = condition).NullCheck("condition");
		}
コード例 #24
0
		/// <summary>
		/// 初始化
		/// </summary>
		/// <param name="opType">操作类型</param>
		/// <param name="obj">要移动的管理单元</param>
		/// <param name="target">目标管理单元 或为 null 表示移动到Schema </param>
		public MoveAUExecutor(AUOperationType opType, AdminUnit obj, AdminUnit target)
			: base(opType)
		{
			(this._Object = obj).NullCheck("obj");
			this._Target = target;
		}
コード例 #25
0
 public AUExecutorBase(AUOperationType opType)
 {
     this.OperationType = opType;
 }
コード例 #26
0
		public AUSchemaExecutor(AUOperationType type, SchemaObjectBase schema)
			: base(type, schema)
		{
			if (type != AUOperationType.AddAdminSchema && type != AUOperationType.RemoveAdminSchema && type != AUOperationType.UpdateAdminSchema)
				throw new NotSupportedException("不支持在此Executor中使用操作" + type);
		}
コード例 #27
0
 public AUMemberRelativeExecutor(AUOperationType opType, SchemaObjectBase container, SchemaObjectBase member)
     : base(opType, container, member)
 {
 }
コード例 #28
0
 /// <summary>
 /// 根据指定的操作类型和执行器初始化<see cref="SchemaObjectOperationContext"/>的新实例。
 /// </summary>
 /// <param name="opType"><see cref="SCOperationType"/>值之一,表示操作的类型</param>
 /// <param name="executor"><see cref="SCExecutorBase"/>对象,表示操作</param>
 public AUObjectOperationContext(AUOperationType opType, AUExecutorBase executor)
 {
     this._OperationType = opType;
     this._Executor      = executor;
 }
コード例 #29
0
 /// <summary>
 /// 执行之后
 /// </summary>
 /// <param name="operationType"></param>
 public void AfterExecute(AUOperationType operationType)
 {
     this.ForEach(action => action.AfterExecute(operationType));
 }
コード例 #30
0
		public AUExecutorBase(AUOperationType opType)
		{
			this.OperationType = opType;
		}
コード例 #31
0
 /// <summary>
 /// 执行之前
 /// </summary>
 /// <param name="obj">一个<see cref="SchemaObjectBase"/>实例</param>
 public void BeforeExecute(AUOperationType operationType)
 {
     this.ForEach(action => action.BeforeExecute(operationType));
 }
コード例 #32
0
		public AUStatusCheckException(SchemaObjectBase originalData, Executors.AUOperationType auOperationType)
			: base(GetMessage(originalData, auOperationType))
		{
			this.originalData = originalData;
			this.auOperationType = auOperationType;
		}
コード例 #33
0
 public AUUpdateConditionsExecutor(AUOperationType opType, AUAdminScope scope, SCCondition condition)
     : base(opType)
 {
     (this.scope = scope).NullCheck("scope");
     (this.condition = condition).NullCheck("condition");
 }
コード例 #34
0
 public AUStatusCheckException(SchemaObjectBase originalData, Executors.AUOperationType auOperationType)
     : base(GetMessage(originalData, auOperationType))
 {
     this.originalData    = originalData;
     this.auOperationType = auOperationType;
 }
コード例 #35
0
		public AUMemberRelativeExecutor(AUOperationType opType, SchemaObjectBase container, SchemaObjectBase member)
			: base(opType, container, member)
		{
		}
コード例 #36
0
 /// <summary>
 /// 初始化
 /// </summary>
 /// <param name="opType">操作类型</param>
 /// <param name="obj">要移动的管理单元</param>
 /// <param name="target">目标管理单元 或为 null 表示移动到Schema </param>
 public MoveAUExecutor(AUOperationType opType, AdminUnit obj, AdminUnit target)
     : base(opType)
 {
     (this._Object = obj).NullCheck("obj");
     this._Target = target;
 }