protected override void PrepareData(SchemaObjectOperationContext context) { base.PrepareData(context); this.ownerObj = (SCBase)SchemaObjectAdapter.Instance.Load(this._Owner.OwnerID); if (ownerObj == null || ownerObj.Status != SchemaObjectStatus.Normal) throw new SCStatusCheckException("指定条件容器对象不存在。"); }
protected override void PrepareData(SchemaObjectOperationContext context) { base.PrepareData(context); this._ContainerObject = (SCBase)SchemaObjectAdapter.Instance.Load(this._Container.ContainerID); if (this._ContainerObject == null || this._ContainerObject.Status != SchemaObjectStatus.Normal) throw new SCStatusCheckException("ACL容器对象无效"); if ((this._ContainerObject is ISCAclContainer) == false) throw new SCStatusCheckException(string.Format("ACL容器对象无效:{0}不实现ISCAclContainer接口", this._ContainerObject.ToDescription())); }
protected override void PrepareData(SchemaObjectOperationContext context) { base.PrepareData(context); this.ownerObj = (SCBase)SchemaObjectAdapter.Instance.Load(this._Owner.OwnerID); if (ownerObj == null || ownerObj.Status != SchemaObjectStatus.Normal) { throw new SCStatusCheckException("指定条件容器对象不存在。"); } }
protected override void PrepareData(SchemaObjectOperationContext context) { PrepareCandidatesRecursively(this._Parent); if (this._Candidates.Count > 0) { ProcessProgress.Current.MinStep = 0; ProcessProgress.Current.MaxStep = this._Candidates.Count; ProcessProgress.Current.CurrentStep = 0; } }
protected override object DoOperation(SchemaObjectOperationContext context) { using (TransactionScope scope = TransactionScopeFactory.Create()) { SCConditionAdapter.Instance.UpdateConditions(this.Owner.OwnerID, this.Owner.Type, this.Owner.Conditions); scope.Complete(); } return this._Owner; }
protected override void PrepareData(SchemaObjectOperationContext context) { CheckStatus(); this._Object.Properties.ContainsKey("OwnerID").FalseThrow("对象{0}不具备OwnerID属性", this._Object.ToDescription()); this._Object.CurrentParents.ContainsKey(_TargetOrganization.ID).FalseThrow("修改对象{0}的所有者错误,目标对象{1}不是{0}的父对象", this._Object.ToDescription(), this._TargetOrganization.ToDescription()); this._Object.Properties.SetValue("OwnerID", this._TargetOrganization.ID); this._Object.Properties.SetValue("OwnerName", this._TargetOrganization.Properties.GetValue("Name", string.Empty)); }
/// <summary> /// 处理相关数据 /// </summary> /// <param name="context"></param> protected void DoRelativeDataOperation(SchemaObjectOperationContext context) { if (this._ObjectNameChanged) { if (context.ContainsKey("parentRelations")) { UpdateRelations((IEnumerable <SCRelationObject>)context["parentRelations"]); } } if (this._NeedDeleteRelations) { if (context.ContainsKey("childrenRelations")) { UpdateRelationsStatus((IEnumerable <SCRelationObject>)context["childrenRelations"]); } if (context.ContainsKey("parentRelations")) { UpdateRelationsStatus((IEnumerable <SCRelationObject>)context["parentRelations"]); } } if (context.ContainsKey("containersRelations")) { UpdateMembersRelationsStatus((IEnumerable <SCSimpleRelationBase>)context["containersRelations"]); } if (context.ContainsKey("membersRelations")) { UpdateMembersRelationsStatus((IEnumerable <SCSimpleRelationBase>)context["membersRelations"]); } if (context.ContainsKey("aclMembers")) { SCAclAdapter.Instance.UpdateStatus(((SCAclContainerOrMemberCollectionBase)context["aclMembers"]), SchemaObjectStatus.Deleted); } if (context.ContainsKey("aclContainers")) { SCAclAdapter.Instance.UpdateStatus(((SCAclContainerOrMemberCollectionBase)context["aclContainers"]), SchemaObjectStatus.Deleted); } if (this._NeedGenerateFullPaths) { SCToDoJobListAdapter.Instance.Insert(SCToDoJob.CreateGenerateFullPathsJob(this.Data)); } if (this._NeedDeleteConditions && this.Data is ISCUserContainerWithConditionObject && this.Data.Status != SchemaObjectStatus.Normal) { SCConditionAdapter.Instance.DeleteByOwner(this.Data.ID, "Default"); } }
protected override object DoOperation(SchemaObjectOperationContext context) { using (TransactionScope scope = TransactionScopeFactory.Create()) { SchemaObjectAdapter.Instance.Update(Data); DoRelativeDataOperation(context); scope.Complete(); } return(this.Data); }
protected override object DoOperation(SchemaObjectOperationContext context) { if (OverrideExistedRelation || this.RelationExisted == false) { SCMemberRelationAdapter.Instance.Update(this.Relation); } if (SaveTargetData) { SchemaObjectAdapter.Instance.Update(Data); } return(this.Relation); }
protected override void PrepareOperationLog(SchemaObjectOperationContext context) { SCOperationLog log = SCOperationLog.CreateLogFromEnvironment(); log.ResourceID = this._Owner.OwnerID; log.SchemaType = this.ownerObj.SchemaType; log.OperationType = this.OperationType; log.Category = this.ownerObj.Schema.Category; log.Subject = string.Format("{0}: {1}", EnumItemDescriptionAttribute.GetDescription(this.OperationType), this.ownerObj.Name); log.SearchContent = this.ownerObj.ToFullTextString(); context.Logs.Add(log); }
protected override void PrepareOperationLog(SchemaObjectOperationContext context) { SCOperationLog log = SCOperationLog.CreateLogFromEnvironment(); log.ResourceID = this._Object.ID; log.SchemaType = this._Object.SchemaType; log.OperationType = this.OperationType; log.Category = this._Object.Schema.Category; log.Subject = string.Format("{0}: {1}", EnumItemDescriptionAttribute.GetDescription(this.OperationType), ((SCBase)this._Object).Name); log.SearchContent = this._Object.ToFullTextString(); context.Logs.Add(log); }
protected override void PrepareData(SchemaObjectOperationContext context) { base.PrepareData(context); this._ContainerObject = (SCBase)SchemaObjectAdapter.Instance.Load(this._Container.ContainerID); if (this._ContainerObject == null || this._ContainerObject.Status != SchemaObjectStatus.Normal) { throw new SCStatusCheckException("ACL容器对象无效"); } if ((this._ContainerObject is ISCAclContainer) == false) { throw new SCStatusCheckException(string.Format("ACL容器对象无效:{0}不实现ISCAclContainer接口", this._ContainerObject.ToDescription())); } }
protected override object DoOperation(SchemaObjectOperationContext context) { int deletedCount = 0; foreach (SCDeleteCandidate candidate in this._Candidates) { string objName = candidate.Object.Properties.GetValue("Name", string.Empty); try { SCObjectOperations.Instance.DoOperation(SCObjectOperationMode.Delete, candidate.Object, candidate.Parent, candidate.DeletedByContainer); ProcessProgress.Current.StatusText = string.Format("已删除\"{0}\"", objName); ProcessProgress.Current.Increment(); ProcessProgress.Current.Response(); if (SCDataOperationLockContext.Current.Lock != null && (deletedCount) % 5 == 0) { SCDataOperationLockContext.Current.ExtendLock(); } deletedCount++; } catch (System.Exception ex) { throw new ApplicationException(string.Format("删除对象{0}({1})出错: {2}", objName, candidate.Object.ID, ex.Message)); } } SCOperationLog log = SCOperationLog.CreateLogFromEnvironment(); log.ResourceID = this._Parent.ID; log.SchemaType = this._Parent.SchemaType; log.OperationType = this.OperationType; log.Category = this._Parent.Schema.Category; log.Subject = string.Format("{0}: 总计应删除{1}中的 {2:#,##0} 个对象,实际删除{3:#,##0}个对象", EnumItemDescriptionAttribute.GetDescription(this.OperationType), this._Parent.Name, this._Candidates.Count.ToString(), deletedCount); log.SearchContent = this._Parent.ToFullTextString(); context.Logs.Add(log); ProcessProgress.Current.StatusText = string.Format("总共删除了{0:#,##0}个对象", deletedCount); ProcessProgress.Current.Response(); return(this._Parent); }
protected override void PrepareData(SchemaObjectOperationContext context) { CheckObjectStatus(this._Parent); foreach (SchemaObjectBase sourceObj in this._OriginalObjectsToDelete) { PrepareCandidatesRecursively(sourceObj); AddCandidates(this._Parent, false, sourceObj); } ProcessProgress.Current.MinStep = 0; ProcessProgress.Current.MaxStep = this._Candidates.Count; ProcessProgress.Current.CurrentStep = 0; ProcessProgress.Current.Response(); }
protected override void PrepareOperationLog(SchemaObjectOperationContext context) { SCOperationLog log = SCOperationLog.CreateLogFromEnvironment(); log.ResourceID = this._Role.ID; log.SchemaType = this._Role.SchemaType; log.OperationType = this.OperationType; log.Category = this._Role.Schema.Category; log.Subject = string.Format("{0}: 替角色 {1} {2} 权限 {3}", EnumItemDescriptionAttribute.GetDescription(this.OperationType), this._Role.Name, (this._Relation.Status == SchemaObjectStatus.Normal ? "赋予" : "解除"), this._Permission.Name); log.SearchContent = this._Role.ToFullTextString() + " " + this._Permission.ToFullTextString(); context.Logs.Add(log); }
protected override object DoOperation(SchemaObjectOperationContext context) { using (TransactionScope scope = TransactionScopeFactory.Create()) { if (_Image == null || _Image.IsEmpty()) { _Object.Properties[this._PropertyName].StringValue = ""; } else { ImagePropertyAdapter.Instance.UpdateWithContent(this._Image); _Object.Properties[this._PropertyName].StringValue = JSONSerializerExecute.Serialize(this._Image); } SchemaObjectAdapter.Instance.Update(this._Object); scope.Complete(); } return(this._Object); }
protected override object DoOperation(SchemaObjectOperationContext context) { using (TransactionScope scope = TransactionScopeFactory.Create()) { if (_Image == null || _Image.IsEmpty()) { _Object.Properties[this._PropertyName].StringValue = ""; } else { ImagePropertyAdapter.Instance.UpdateWithContent(this._Image); _Object.Properties[this._PropertyName].StringValue = JSONSerializerExecute.Serialize(this._Image); } SchemaObjectAdapter.Instance.Update(this._Object); scope.Complete(); } return this._Object; }
protected override void PrepareOperationLog(SchemaObjectOperationContext context) { if (this.RelationExisted == false) { SCOperationLog log = SCOperationLog.CreateLogFromEnvironment(); log.ResourceID = this._Object.ID; log.SchemaType = this._Object.SchemaType; log.OperationType = this.OperationType; log.Category = this._Object.Schema.Category; log.Subject = string.Format("{0}: {1} 从 {2} 至 {3}", EnumItemDescriptionAttribute.GetDescription(this.OperationType), this._Object.Name, this._OriginalOrganization.Name, this._TargetOrganization.Name); log.SearchContent = this._Object.ToFullTextString() + " " + this._OriginalOrganization.ToFullTextString() + " " + this._TargetOrganization.ToFullTextString(); context.Logs.Add(log); } else { SCOperationLog log = SCOperationLog.CreateLogFromEnvironment(); log.ResourceID = this._Object.ID; log.SchemaType = this._Object.SchemaType; log.OperationType = this.OperationType; log.Category = this._Object.Schema.Category; log.Subject = string.Format("{0}: {1} 从 {2} 至 {3}(跳过已经存在的关系)", EnumItemDescriptionAttribute.GetDescription(this.OperationType), this._Object.Name, this._OriginalOrganization.Name, this._TargetOrganization.Name); log.SearchContent = this._Object.ToFullTextString() + " " + this._OriginalOrganization.ToFullTextString() + " " + this._TargetOrganization.ToFullTextString(); context.Logs.Add(log); } }
protected override void PrepareOperationLog(SchemaObjectOperationContext context) { context.Logs.Add(this.Data.ToOperationLog(this.OperationType)); }
protected override object DoOperation(SchemaObjectOperationContext context) { SCAclAdapter.Instance.Update(this.Container); return(this.Container); }
protected override void PrepareData(SchemaObjectOperationContext context) { SCActionContext.Current.OriginalObject = SchemaObjectAdapter.Instance.Load(this.Data.ID); SCActionContext.Current.CurrentObject = this.Data; string originalName = SCActionContext.Current.OriginalObject != null?SCActionContext.Current.OriginalObject.Properties.GetValue("Name", string.Empty) : string.Empty; string currentName = SCActionContext.Current.OriginalObject != null?SCActionContext.Current.CurrentObject.Properties.GetValue("Name", string.Empty) : string.Empty; this._ObjectNameChanged = originalName != currentName; //是否是关系容器 ISCRelationContainer rContainer = this.Data as ISCRelationContainer; if (this._ObjectNameChanged) { this._NeedGenerateFullPaths = (rContainer != null && rContainer.CurrentChildren.Count > 0); this.Data.CurrentParentRelations.ForEach(relation => { if (relation.FullPath.IsNotEmpty()) { int index = relation.FullPath.LastIndexOf(originalName); if (index >= 0) { relation.FullPath = relation.FullPath.Substring(0, index) + currentName; } } }); context["parentRelations"] = this.Data.CurrentParentRelations; } this.Validate(); if (this._NeedDeleteRelations) { //加载关系对象,然后为了统一删除和打标志。 if (rContainer != null) { context["childrenRelations"] = rContainer.CurrentChildrenRelations; } context["parentRelations"] = this.Data.CurrentParentRelations; } if (this._NeedDeleteMemberRelations) { if (this.Data is ISCMemberObject) { context["containersRelations"] = ((ISCMemberObject)this.Data).GetCurrentMemberOfRelations(); } if (this.Data is ISCContainerObject) { context["membersRelations"] = ((ISCContainerObject)this.Data).GetCurrentMembersRelations(); } } if (this.Data.Status != SchemaObjectStatus.Normal) { if (this.Data is ISCAclContainer) { context["aclMembers"] = ((ISCAclContainer)this.Data).GetAclMembers(); } if (this.Data is ISCAclMember) { context["aclContainers"] = ((ISCAclMember)this.Data).GetAclContainers(); } } base.PrepareData(context); }
protected override object DoOperation(SchemaObjectOperationContext context) { if (OverrideExistedRelation || this.RelationExisted == false) SchemaRelationObjectAdapter.Instance.Update(this.Relation); return this.Relation; }
protected override object DoOperation(SchemaObjectOperationContext context) { if (OverrideExistedRelation || this.RelationExisted == false) SCMemberRelationAdapter.Instance.Update(this.Relation); if (SaveTargetData) SchemaObjectAdapter.Instance.Update(Data); return this.Relation; }
protected override void PrepareData(SchemaObjectOperationContext context) { if (this.NeedChangeOwner) { this._Object.Properties.SetValue("OwnerID", this._TargetOrganization.ID); this._Object.Properties.SetValue("OwnerName", this._TargetOrganization.Properties.GetValue("Name", string.Empty)); } Validate(); }
protected override void PrepareData(SchemaObjectOperationContext context) { }
protected override object DoOperation(SchemaObjectOperationContext context) { //需要考虑默认关系的情况 if (this._TargetParentRelations != null) { //如果是插入或更新 if (this.Relation.Status == SchemaObjectStatus.Normal) { if (this._OverrideDefault) { this._TargetParentRelations.ForEach(r => { if (r.Default == true && r.ParentID != this.Relation.ParentID) { r.Default = false; SchemaRelationObjectAdapter.Instance.Update(r); } } ); } else { if (this._TargetParentRelations.Exists(r => r.Default == true && r.ParentID != this.Relation.ParentID)) { this.Relation.Default = false; } } } else { if (this.Relation.Default == true) { SCRelationObject firstNotDefaultRelation = this._TargetParentRelations.Find(r => r.Default == false && r.ParentID != this.Relation.ParentID); if (firstNotDefaultRelation != null) { firstNotDefaultRelation.Default = true; SchemaRelationObjectAdapter.Instance.Update(firstNotDefaultRelation); } } } } //当不是删除操作,且需要修改关系时 if (this.Data.Status == SchemaObjectStatus.Normal && (OverrideExistedRelation || this.RelationExisted == false)) { SchemaRelationObjectAdapter.Instance.Update(this.Relation); } if (SaveTargetData) { SchemaObjectAdapter.Instance.Update(Data); this.DoRelativeDataOperation(context); } if (this._AclContainer != null) { SCAclAdapter.Instance.Update(this._AclContainer); } return(this.Relation); }
protected override object DoOperation(SchemaObjectOperationContext context) { SCAclAdapter.Instance.Update(this.Container); return this.Container; }
protected override void PrepareData(SchemaObjectOperationContext context) { SCActionContext.Current.OriginalObject = SchemaObjectAdapter.Instance.Load(this.Data.ID); SCActionContext.Current.CurrentObject = this.Data; string originalName = SCActionContext.Current.OriginalObject != null ? SCActionContext.Current.OriginalObject.Properties.GetValue("Name", string.Empty) : string.Empty; string currentName = SCActionContext.Current.OriginalObject != null ? SCActionContext.Current.CurrentObject.Properties.GetValue("Name", string.Empty) : string.Empty; this._ObjectNameChanged = originalName != currentName; //是否是关系容器 ISCRelationContainer rContainer = this.Data as ISCRelationContainer; if (this._ObjectNameChanged) { this._NeedGenerateFullPaths = (rContainer != null && rContainer.CurrentChildren.Count > 0); this.Data.CurrentParentRelations.ForEach(relation => { if (relation.FullPath.IsNotEmpty()) { int index = relation.FullPath.LastIndexOf(originalName); if (index >= 0) relation.FullPath = relation.FullPath.Substring(0, index) + currentName; } }); context["parentRelations"] = this.Data.CurrentParentRelations; } this.Validate(); if (this._NeedDeleteRelations) { //加载关系对象,然后为了统一删除和打标志。 if (rContainer != null) context["childrenRelations"] = rContainer.CurrentChildrenRelations; context["parentRelations"] = this.Data.CurrentParentRelations; } if (this._NeedDeleteMemberRelations) { if (this.Data is ISCMemberObject) context["containersRelations"] = ((ISCMemberObject)this.Data).GetCurrentMemberOfRelations(); if (this.Data is ISCContainerObject) context["membersRelations"] = ((ISCContainerObject)this.Data).GetCurrentMembersRelations(); } if (this.Data.Status != SchemaObjectStatus.Normal) { if (this.Data is ISCAclContainer) context["aclMembers"] = ((ISCAclContainer)this.Data).GetAclMembers(); if (this.Data is ISCAclMember) context["aclContainers"] = ((ISCAclMember)this.Data).GetAclContainers(); } base.PrepareData(context); }
protected override object DoOperation(SchemaObjectOperationContext context) { using (TransactionScope scope = TransactionScopeFactory.Create()) { SchemaObjectAdapter.Instance.Update(Data); DoRelativeDataOperation(context); scope.Complete(); } return this.Data; }
private void PersistOperationLog(SchemaObjectOperationContext context) { using (TransactionScope scope = TransactionScopeFactory.Create()) { context.Logs.ForEach(log => SCOperationLogAdapter.Instance.Insert(log)); scope.Complete(); } }
protected override void PrepareData(SchemaObjectOperationContext context) { base.PrepareData(context); CheckObjectStatus(this._Object); }
private object InternalExecute() { SchemaObjectOperationContext context = new SchemaObjectOperationContext(this.OperationType, this); ExecutionWrapper("PrepareData", () => PrepareData(context)); ExecutionWrapper("PrepareOperationLog", () => PrepareOperationLog(context)); object result = null; if (this.AutoStartTransaction) { using (TransactionScope scope = TransactionScopeFactory.Create()) { ExecutionWrapper("DoOperation", () => result = DoOperation(context)); ExecutionWrapper("PersistOperationLog", () => PersistOperationLog(context)); scope.Complete(); } } else { ExecutionWrapper("DoOperation", () => result = DoOperation(context)); ExecutionWrapper("PersistOperationLog", () => PersistOperationLog(context)); } return result; }
protected override object DoOperation(SchemaObjectOperationContext context) { if (this._RelationExisted == false) { if (this._OriginalRelation.Status == SchemaObjectStatus.Normal) { this._OriginalRelation.Status = SchemaObjectStatus.Deleted; SchemaRelationObjectAdapter.Instance.Update(this._OriginalRelation); } SchemaRelationObjectAdapter.Instance.Update(this._TargetRelation); if (this.NeedChangeOwner) SchemaObjectAdapter.Instance.Update(this._Object); if (this._NeedGenerateFullPaths) SCToDoJobListAdapter.Instance.Insert(SCToDoJob.CreateGenerateFullPathsJob(this._Object)); } return this._TargetRelation; }
protected abstract object DoOperation(SchemaObjectOperationContext context);
protected override void PrepareData(SchemaObjectOperationContext context) { base.PrepareData(context); if (NeedStatusCheck) CheckObjectStatus(this._Role, this._Permission); }
protected virtual void PrepareOperationLog(SchemaObjectOperationContext context) { }
protected override object DoOperation(SchemaObjectOperationContext context) { //需要考虑默认关系的情况 if (this._TargetParentRelations != null) { //如果是插入或更新 if (this.Relation.Status == SchemaObjectStatus.Normal) { if (this._OverrideDefault) { this._TargetParentRelations.ForEach(r => { if (r.Default == true && r.ParentID != this.Relation.ParentID) { r.Default = false; SchemaRelationObjectAdapter.Instance.Update(r); } } ); } else { if (this._TargetParentRelations.Exists(r => r.Default == true && r.ParentID != this.Relation.ParentID)) this.Relation.Default = false; } } else { if (this.Relation.Default == true) { SCRelationObject firstNotDefaultRelation = this._TargetParentRelations.Find(r => r.Default == false && r.ParentID != this.Relation.ParentID); if (firstNotDefaultRelation != null) { firstNotDefaultRelation.Default = true; SchemaRelationObjectAdapter.Instance.Update(firstNotDefaultRelation); } } } } //当不是删除操作,且需要修改关系时 if (this.Data.Status == SchemaObjectStatus.Normal && (OverrideExistedRelation || this.RelationExisted == false)) SchemaRelationObjectAdapter.Instance.Update(this.Relation); if (SaveTargetData) { SchemaObjectAdapter.Instance.Update(Data); this.DoRelativeDataOperation(context); } if (this._AclContainer != null) { SCAclAdapter.Instance.Update(this._AclContainer); } return this.Relation; }
/// <summary> /// 处理相关数据 /// </summary> /// <param name="context"></param> protected void DoRelativeDataOperation(SchemaObjectOperationContext context) { if (this._ObjectNameChanged) { if (context.ContainsKey("parentRelations")) UpdateRelations((IEnumerable<SCRelationObject>)context["parentRelations"]); } if (this._NeedDeleteRelations) { if (context.ContainsKey("childrenRelations")) UpdateRelationsStatus((IEnumerable<SCRelationObject>)context["childrenRelations"]); if (context.ContainsKey("parentRelations")) UpdateRelationsStatus((IEnumerable<SCRelationObject>)context["parentRelations"]); } if (context.ContainsKey("containersRelations")) UpdateMembersRelationsStatus((IEnumerable<SCSimpleRelationBase>)context["containersRelations"]); if (context.ContainsKey("membersRelations")) UpdateMembersRelationsStatus((IEnumerable<SCSimpleRelationBase>)context["membersRelations"]); if (context.ContainsKey("aclMembers")) SCAclAdapter.Instance.UpdateStatus(((SCAclContainerOrMemberCollectionBase)context["aclMembers"]), SchemaObjectStatus.Deleted); if (context.ContainsKey("aclContainers")) SCAclAdapter.Instance.UpdateStatus(((SCAclContainerOrMemberCollectionBase)context["aclContainers"]), SchemaObjectStatus.Deleted); if (this._NeedGenerateFullPaths) SCToDoJobListAdapter.Instance.Insert(SCToDoJob.CreateGenerateFullPathsJob(this.Data)); if (this._NeedDeleteConditions && this.Data is ISCUserContainerWithConditionObject && this.Data.Status != SchemaObjectStatus.Normal) SCConditionAdapter.Instance.DeleteByOwner(this.Data.ID, "Default"); }