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); } }
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); } }
public void UpdateAdminSchema(AUSchema schema) { CheckSupervisior(); AUSchemaExecutor executor = new Executors.AUSchemaExecutor(AUOperationType.UpdateAdminSchema, schema); ExecuteWithActions(AUOperationType.UpdateAdminSchema, () => SCActionContext.Current.DoActions(() => { executor.Execute(); })); }
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); } }
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)); } }
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(); })); }
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())); } } } }
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(); })); }
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); }
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; }
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 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())); } }
public AdminUnitsPropertyEditorSceneAdapter(AUSchema schema) { (this.schema = schema).NullCheck("schmea"); }
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; } }