protected override void PrepareData(AUObjectOperationContext context)
        {
            AUCommon.DoDbAction(() =>
            {
                this.schema = (AUSchema)SchemaObjectAdapter.Instance.Load(((AdminUnit)Data).AUSchemaID);

                if (this.schema == null || this.schema.Status != SchemaObjectStatus.Normal)
                {
                    throw new AUObjectValidationException(AUCommon.DisplayNameFor((AdminUnit)this.Data) + "管理单元的SchemaID无效,无法找到对应的Schema。");
                }
            });

            this.PrepareRelationObject();

            base.PrepareData(context);

            var oldObject = (AdminUnit)SCActionContext.Current.OriginalObject;

            if (oldObject != null && oldObject.AUSchemaID != this.schema.ID)
            {
                throw new AUObjectValidationException("一旦创建,不能以任何方式修改AdminUnit的AUSchema属性");
            }

            this.existingSchemaRoles = Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaRoles(schema.ID, false, DateTime.MinValue);
            this.existingUnitRoles   = Adapters.AUSnapshotAdapter.Instance.LoadAURoles(new string[] { this.Data.ID }, new string[0], false, DateTime.MinValue);
            this.existingUnitScopes  = Adapters.AUSnapshotAdapter.Instance.LoadAUScope(this.Data.ID, false, DateTime.MinValue);

            this.pendingActions.Clear();
            PrepareRolesAndScopes();
        }
		private void PrepareScopeItems(AUObjectOperationContext context, AUSchema originalSchema, AUSchema targetSchema)
		{
			var srcArray = originalSchema != null ? originalSchema.Scopes.Split(AUCommon.Spliter, StringSplitOptions.RemoveEmptyEntries) : AUCommon.ZeroLengthStringArray;
			var targetArray = targetSchema.Scopes.Split(AUCommon.Spliter, StringSplitOptions.RemoveEmptyEntries);

			Array.Sort(srcArray);
			Array.Sort(targetArray);

			var toBeAddedScopes = GetToBeAddedScopes(srcArray, targetArray);
			var toBeDeletedScopes = GetToBeRemovedScopes(srcArray, targetArray);
			//角色不在此修改

			this.allCurrentAUs = Adapters.AUSnapshotAdapter.Instance.LoadAUBySchemaID(targetSchema.ID, true, DateTime.MinValue);
			if (allCurrentAUs.Any() && this.Data.Status == SchemaObjectStatus.Deleted)
				throw new InvalidOperationException("必须先删除所有与此管理架构相关的管理单元才可以进行Schema删除。");

			if (toBeAddedScopes.Length > 0 || toBeDeletedScopes.Length > 0)
			{
				if (this.Data.Status == SchemaObjectStatus.Deleted)
					throw new InvalidOperationException("进行删除操作时,不应修改管理范围。");

				PrepareToBeAddedScopes(toBeAddedScopes, pendingActions);

				PrepareToBeDeletedScopes(toBeDeletedScopes, pendingActions);
			}
		}
Esempio n. 3
0
        private void PrepareScopeItems(AUObjectOperationContext context, AUSchema originalSchema, AUSchema targetSchema)
        {
            var srcArray = originalSchema != null?originalSchema.Scopes.Split(AUCommon.Spliter, StringSplitOptions.RemoveEmptyEntries) : AUCommon.ZeroLengthStringArray;

            var targetArray = targetSchema.Scopes.Split(AUCommon.Spliter, StringSplitOptions.RemoveEmptyEntries);

            Array.Sort(srcArray);
            Array.Sort(targetArray);

            var toBeAddedScopes   = GetToBeAddedScopes(srcArray, targetArray);
            var toBeDeletedScopes = GetToBeRemovedScopes(srcArray, targetArray);

            //角色不在此修改

            this.allCurrentAUs = Adapters.AUSnapshotAdapter.Instance.LoadAUBySchemaID(targetSchema.ID, true, DateTime.MinValue);
            if (allCurrentAUs.Any() && this.Data.Status == SchemaObjectStatus.Deleted)
            {
                throw new InvalidOperationException("必须先删除所有与此管理架构相关的管理单元才可以进行Schema删除。");
            }

            if (toBeAddedScopes.Length > 0 || toBeDeletedScopes.Length > 0)
            {
                if (this.Data.Status == SchemaObjectStatus.Deleted)
                {
                    throw new InvalidOperationException("进行删除操作时,不应修改管理范围。");
                }

                PrepareToBeAddedScopes(toBeAddedScopes, pendingActions);

                PrepareToBeDeletedScopes(toBeDeletedScopes, pendingActions);
            }
        }
Esempio n. 4
0
        public void UpdateAdminSchema(AUSchema schema)
        {
            CheckSupervisior();

            AUSchemaExecutor executor = new Executors.AUSchemaExecutor(AUOperationType.UpdateAdminSchema, schema);

            ExecuteWithActions(AUOperationType.UpdateAdminSchema, () => SCActionContext.Current.DoActions(() =>
            {
                executor.Execute();
            }));
        }
Esempio n. 5
0
        protected override void DoValidate(object objectToValidate, object currentObject, string key, ValidationResults validateResults)
        {
            AUSchema schema = (AUSchema)currentObject;
            string   name   = (string)objectToValidate;
            var      target = Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaByName(name, schema.CategoryID, true).GetUniqueNormalObject <AUSchema>();

            if (target != null && schema.ID != target.ID)
            {
                this.RecordValidationResult(validateResults, string.Format("管理架构 {0} 的不唯一名称", AUCommon.DisplayNameFor(schema)), currentObject, key);
            }
        }
Esempio n. 6
0
        private void InitizeTree(string fromUnitID, AUSchema schema)
        {
            tree.Nodes.Clear();

            var root     = AddSchemaToTree(schema, tree.Nodes);
            var subUnits = AU.Adapters.AUSnapshotAdapter.Instance.LoadSubUnits(this.hfSchemaID.Value, this.hfSchemaID.Value, true, DateTime.MinValue);

            foreach (AU.AdminUnit item in subUnits)
            {
                AddUnitToTree(item, root.Nodes);
            }
        }
		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));
			}
		}
Esempio n. 8
0
        public void DeleteAdminSchema(AUSchema schema)
        {
            CheckSupervisior();

            AUSchemaExecutor executor = new Executors.AUSchemaExecutor(AUOperationType.RemoveAdminSchema, schema);

            schema.Status = SchemaObjectStatus.Deleted;

            ExecuteWithActions(AUOperationType.RemoveAdminSchema, () => SCActionContext.Current.DoActions(() =>
            {
                executor.Execute();
            }));
        }
        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));
            }
        }
Esempio n. 10
0
 private void CheckAUSchemaPermission(AUSchema schema)
 {
     if (this._NeedCheckPermissions)
     {
         if (IsSupervisior() == false)
         {
             if (string.IsNullOrEmpty(schema.MasterRole) || DeluxePrincipal.Current.IsInRole(schema.MasterRole) == false)
             {
                 throw new SCAclPermissionCheckException(string.Format("当前用户不属于管理架构 {0} 的管理单元管理员或总管理员,不能添加顶级管理单元", schema.ToDescription()));
             }
         }
     }
 }
Esempio n. 11
0
        public void AddAdminSchemaRole(AUSchemaRole role, AUSchema schema)
        {
            CheckSupervisior();

            AUSchemaRoleExecutor executor = new AUSchemaRoleExecutor(AUOperationType.AddSchemaRole, schema, role)
            {
                SaveTargetData           = true,
                OverrideExistedRelation  = true,
                NeedContainerStatusCheck = true,
            };

            role.Status = SchemaObjectStatus.Normal;

            ExecuteWithActions(AUOperationType.AddSchemaRole, () => SCActionContext.Current.DoActions(() =>
            {
                executor.Execute();
            }));
        }
Esempio n. 12
0
        private static bool CheckAddSubPermission(AUSchema schema, AdminUnit targetUnit)
        {
            bool result = false;

            result = AU.AUPermissionHelper.IsSupervisor(DeluxePrincipal.Current);
            if (result == false)
            {
                if (string.IsNullOrEmpty(schema.MasterRole) == false)
                {
                    result = DeluxePrincipal.Current.IsInRole(schema.MasterRole);

                    if (result == false && targetUnit != null)
                    {
                        var permissions = AU.Adapters.AUAclAdapter.Instance.LoadCurrentContainerAndPermissions(DeluxeIdentity.CurrentUser.ID, new string[] { targetUnit.ID });

                        result = Util.ContainsPermission(permissions, targetUnit.ID, "AddSubUnit");
                    }
                }
            }

            return(result);
        }
Esempio n. 13
0
        private void DeterminPermission(AUSchema schema, AdminUnit unit)
        {
            bool editEnabled = TimePointContext.Current.UseCurrentTime;

            if (editEnabled)
            {
                if (Util.SuperVisiorMode == false)
                {
                    if (string.IsNullOrEmpty(schema.MasterRole) == false)
                    {
                        editEnabled = DeluxePrincipal.Current.IsInRole(schema.MasterRole);

                        if (editEnabled == false)
                        {
                            var permissions = AU.Adapters.AUAclAdapter.Instance.LoadCurrentContainerAndPermissions(DeluxeIdentity.CurrentUser.ID, new string[] { unit.ID });

                            editEnabled = Util.ContainsPermission(permissions, unit.ID, "EditAdminScope");;
                        }
                    }
                }
            }

            this.EditEnabled = editEnabled;
        }
Esempio n. 14
0
        protected override void PrepareData(AUObjectOperationContext context)
        {
            AUCommon.DoDbAction(() =>
            {
                this.schema = (AUSchema)SchemaObjectAdapter.Instance.Load(((AdminUnit)Data).AUSchemaID);

                if (this.schema == null || this.schema.Status != SchemaObjectStatus.Normal)
                    throw new AUObjectValidationException(AUCommon.DisplayNameFor((AdminUnit)this.Data) + "管理单元的SchemaID无效,无法找到对应的Schema。");
            });

            this.PrepareRelationObject();

            base.PrepareData(context);

            var oldObject = (AdminUnit)SCActionContext.Current.OriginalObject;

            if (oldObject != null && oldObject.AUSchemaID != this.schema.ID)
                throw new AUObjectValidationException("一旦创建,不能以任何方式修改AdminUnit的AUSchema属性");

            this.existingSchemaRoles = Adapters.AUSnapshotAdapter.Instance.LoadAUSchemaRoles(schema.ID, false, DateTime.MinValue);
            this.existingUnitRoles = Adapters.AUSnapshotAdapter.Instance.LoadAURoles(new string[] { this.Data.ID }, new string[0], false, DateTime.MinValue);
            this.existingUnitScopes = Adapters.AUSnapshotAdapter.Instance.LoadAUScope(this.Data.ID, false, DateTime.MinValue);

            this.pendingActions.Clear();
            PrepareRolesAndScopes();
        }
Esempio n. 15
0
		private void CheckAUSchemaPermission(AUSchema schema)
		{
			if (this._NeedCheckPermissions)
			{
				if (IsSupervisior() == false)
					if (string.IsNullOrEmpty(schema.MasterRole) || DeluxePrincipal.Current.IsInRole(schema.MasterRole) == false)
						throw new SCAclPermissionCheckException(string.Format("当前用户不属于管理架构 {0} 的管理单元管理员或总管理员,不能添加顶级管理单元", schema.ToDescription()));
			}
		}
Esempio n. 16
0
		public void AddAdminSchemaRole(AUSchemaRole role, AUSchema schema)
		{
			CheckSupervisior();

			AUSchemaRoleExecutor executor = new AUSchemaRoleExecutor(AUOperationType.AddSchemaRole, schema, role)
			{
				SaveTargetData = true,
				OverrideExistedRelation = true,
				NeedContainerStatusCheck = true,
			};

			role.Status = SchemaObjectStatus.Normal;

			ExecuteWithActions(AUOperationType.AddSchemaRole, () => SCActionContext.Current.DoActions(() =>
			{
				executor.Execute();
			}));
		}
Esempio n. 17
0
		public void UpdateAdminSchema(AUSchema schema)
		{
			CheckSupervisior();

			AUSchemaExecutor executor = new Executors.AUSchemaExecutor(AUOperationType.UpdateAdminSchema, schema);

			ExecuteWithActions(AUOperationType.UpdateAdminSchema, () => SCActionContext.Current.DoActions(() =>
			{
				executor.Execute();
			}));
		}
Esempio n. 18
0
		public void DeleteAdminSchema(AUSchema schema)
		{
			CheckSupervisior();

			AUSchemaExecutor executor = new Executors.AUSchemaExecutor(AUOperationType.RemoveAdminSchema, schema);

			schema.Status = SchemaObjectStatus.Deleted;

			ExecuteWithActions(AUOperationType.RemoveAdminSchema, () => SCActionContext.Current.DoActions(() =>
			{
				executor.Execute();
			}));
		}
 public AdminUnitsPropertyEditorSceneAdapter(AUSchema schema)
 {
     (this.schema = schema).NullCheck("schmea");
 }
Esempio n. 20
0
        private static void ValidateName(string name, string codeName, ValidationResult result, AUSchema schema, SchemaObjectBase targetUnit)
        {
            var actualParent = (SchemaObjectBase)targetUnit ?? schema;

            var adminUnit = new AdminUnit()
            {
                ID         = UuidHelper.NewUuidString(),
                CodeName   = codeName,
                Name       = name,
                AUSchemaID = schema.ID
            };

            var validationObjResult = adminUnit.Validate();

            result.ObjectValidationResult = validationObjResult.ResultCount > 0 ? ToMessage(validationObjResult.First()) : "通过";
            result.Passed &= validationObjResult.ResultCount == 0;

            if (result.Passed)
            {
                SCRelationObject relation = new SCRelationObject(actualParent, adminUnit);
                var existedObj            = AU.Adapters.AUSnapshotAdapter.Instance.LoadAUByChildName(name, actualParent.ID, AUCommon.SchemaAdminUnit, true, DateTime.MinValue);
                result.NameValidationResult = existedObj.Count > 0 ? "此名称已经被占用,请使用其他名称" : "通过";
                result.Passed &= existedObj.Count == 0;
            }
        }