private SCSimpleRelationBase PrepareRelationObject(SchemaObjectBase container, SchemaObjectBase member) { SCSimpleRelationBase relation = null; AUCommon.DoDbAction(() => { relation = SCMemberRelationAdapter.Instance.Load(container.ID, member.ID); }); if (relation == null) { relation = CreateRelation(container, member); } else { if (relation.Status == SchemaObjectStatus.Normal) { this._RelationExisted = true; } else { relation.Status = SchemaObjectStatus.Normal; } } return(relation); }
protected override void PrepareData(AUObjectOperationContext context) { this._OriginalRelation = this._Object.GetCurrentVeryParentRelation(); if (this._OriginalRelation == null || this._OriginalRelation.Status != SchemaObjectStatus.Normal) { throw new AUObjectValidationException("未找到此管理单元对应的上级关系"); } AUCommon.DoDbAction(() => { this._SourceObject = this._OriginalRelation.Parent; this._ActualTarget = this._Target ?? SchemaObjectAdapter.Instance.Load(this._Object.AUSchemaID); }); if (this._SourceObject == null || this._SourceObject.Status != SchemaObjectStatus.Normal) { throw new AUObjectValidationException("未找到此管理单元对应的上级对象"); } if (this._OriginalRelation.ParentID == this._ActualTarget.ID) { throw new AUObjectValidationException("此管理单元已经属于目标管理单元,无需移动。"); } AUCommon.DoDbAction(() => { this._TargetRelation = PrepareTargetRelation(this._ActualTarget, this._Object); this._NeedGenerateFullPaths = (this._Object is ISCRelationContainer) && (((ISCRelationContainer)this._Object).CurrentChildren.Count > 0); Validate(); }); }
internal static T GetEffectiveObject <T>(string id, bool normalOnly) where T : SchemaObjectBase { if (id == null) { throw new ArgumentNullException("id"); } T result = null; AUCommon.DoDbAction(() => { result = (T)PC.Adapters.SchemaObjectAdapter.Instance.Load(id); }); if (result == null) { throw new ObjectNotFoundException(string.Format("未找到指定ID:{0} 的 {1} 类型的对象。", id, typeof(T).Name)); } if (normalOnly && result.Status != SchemaObjectStatus.Normal) { throw new ObjectNotFoundException(string.Format("{0} 无效,对象为已经删除。", result is SCBase ? (result as SCBase).ToDescription() : result.ID)); } return(result); }
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(); }
/// <summary> /// 生成所有的用户容器下的用户信息快照 /// </summary> public void GenerateAllItemAndContainerSnapshot() { ProcessProgress.Current.MinStep = 0; ProcessProgress.Current.MaxStep = 100; ProcessProgress.Current.CurrentStep = 0; ProcessProgress.Current.StatusText = string.Format("正在加载所有管理范围"); ProcessProgress.Current.Response(); Stopwatch sw = new Stopwatch(); sw.Start(); try { AUCommon.DoDbAction(() => { SchemaObjectCollection containers = AUCommon.DoDbProcess <SchemaObjectCollection>(() => PC.Adapters.SchemaObjectAdapter.Instance.LoadBySchemaType(new string[] { AUCommon.SchemaAUAdminScope }, DateTime.MinValue)); containers.Sort((c1, c2) => string.Compare(c1.SchemaType, c2.SchemaType, true)); ProcessProgress.Current.StatusText = string.Format("加载所有管理范围完成,总共{0}个对象", containers.Count); ProcessProgress.Current.MaxStep = containers.Count; ProcessProgress.Current.Response(); containers.ForEach(c => this.GenerateOneItemAndContainerSnapshot((IAdminScopeItemContainer)c)); }); } finally { sw.Stop(); } ProcessProgress.Current.StatusText = string.Format("计算人员完成,耗时{0:#,##0.00}秒", sw.Elapsed.TotalSeconds); ProcessProgress.Current.Response(); }
public SCAclMemberCollection LoadMembers(IConnectiveSqlClause condition, DateTime timePoint) { ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(condition, timePointBuilder); string sql = string.Format( "SELECT * FROM {0} WHERE {1} ORDER BY SortID", this.GetLoadingTableName(timePoint), connectiveBuilder.ToSqlString(TSqlBuilder.Instance)); SCAclMemberCollection result = new SCAclMemberCollection(); AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName())) { ORMapping.DataReaderToCollection(result, reader); } } }); return(result); }
protected override void CheckStatus() { AUCommon.DoDbAction(() => { List <SchemaObjectBase> dataToBeChecked = new List <SchemaObjectBase>(); if (this.NeedStatusCheck) { dataToBeChecked.Add(this.Data); } if (this.NeedParentStatusCheck && this.inputParent != null) { dataToBeChecked.Add(this.inputParent); } dataToBeChecked.Add(this.schema); CheckObjectStatus(dataToBeChecked.ToArray()); if (this.NeedDuplicateRelationCheck) { var allParentRelations = this.Data.CurrentParentRelations; var relationToSchema = (from r in allParentRelations where r.ParentSchemaType == AUCommon.SchemaAUSchema select r).FirstOrDefault(); var relationToUnit = (from u in allParentRelations where u.ParentSchemaType == AUCommon.SchemaAdminUnit select u).FirstOrDefault(); if (this.inputParent != null) { //添加下级管理单元 if (relationToSchema != null) { throw new SCStatusCheckException(string.Format("对象\"{0}\"已经是顶级管理单元了,不能再添加到别的管理单元中", AUCommon.DisplayNameFor(this.Data))); } else if (relationToUnit != null && (relationToUnit.ID != this.Data.ID || relationToUnit.ParentID != inputParent.ID)) { throw new SCStatusCheckException(string.Format("对象\"{0}\"已经属于另一管理单元{1}了,不能再添加到其他管理单元", AUCommon.DisplayNameFor(this.Data))); } } else { //顶级管理单元 if (relationToSchema != null) { if (relationToSchema.ParentID != schema.ID) { throw new SCStatusCheckException(string.Format("对象\"{0}\"已经是顶级管理单元了,不能再添加到别的管理单元中", AUCommon.DisplayNameFor(this.Data))); } } else if (relationToUnit != null) { throw new SCStatusCheckException(string.Format("对象\"{0}\"已经属于另一管理单元{1}了,不能作为顶级管理单元", AUCommon.DisplayNameFor(this.Data))); } } } }); }
protected override object DoOperation(AUObjectOperationContext context) { if (this._RelationExisted == false) { if (this._OriginalRelation.Status == SchemaObjectStatus.Normal) { this._OriginalRelation.Status = SchemaObjectStatus.Deleted; AUCommon.DoDbAction(() => SchemaRelationObjectAdapter.Instance.UpdateStatus(this._OriginalRelation, SchemaObjectStatus.Deleted)); } AUCommon.DoDbAction(() => SchemaRelationObjectAdapter.Instance.Update(this._TargetRelation)); //if (this.NeedChangeOwner) // SchemaObjectAdapter.Instance.Update(this._Object); if (this._NeedGenerateFullPaths) { AUCommon.DoDbAction(() => SCToDoJobListAdapter.Instance.Insert(SCToDoJob.CreateGenerateFullPathsJob(this._Object))); } } return(this._TargetRelation); }
public AUSchemaCategory LoadByID(string id, DateTime timePoint) { var conditions = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint); WhereSqlClauseBuilder where = new WhereSqlClauseBuilder(); where.AppendItem("ID", id); conditions.Add(where); AUSchemaCategory cate = null; AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { VersionedObjectAdapterHelper.Instance.FillData(ORMapping.GetMappingInfo(typeof(AUSchemaCategory)).TableName, conditions, this.GetConnectionName(), reader => { if (reader.Read()) { cate = new AUSchemaCategory(); ORMapping.DataReaderToObject <AUSchemaCategory>(reader, cate); } }); } }); return(cate); }
/// <summary> /// 生成用户容器下的管理范围信息快照 /// </summary> /// <param name="containers"></param> public void GenerateItemAndContainerSnapshot(IEnumerable <SchemaObjectBase> containers) { ProcessProgress.Current.MinStep = 0; ProcessProgress.Current.MaxStep = containers.Count(); ProcessProgress.Current.CurrentStep = 0; Stopwatch sw = new Stopwatch(); sw.Start(); try { AUCommon.DoDbAction(() => { foreach (IAdminScopeItemContainer container in containers) { this.GenerateOneItemAndContainerSnapshot(container); } }); } finally { sw.Stop(); } ProcessProgress.Current.CurrentStep = ProcessProgress.Current.MaxStep; ProcessProgress.Current.StatusText = string.Format("计算完成,耗时{0:#,##0.00}秒", sw.Elapsed.TotalSeconds); ProcessProgress.Current.Response(); }
protected void SaveClick(object sender, EventArgs e) { this.ClientScript.RegisterClientScriptBlock(this.GetType(), "ResetSubmitButton", "top.SubmitButton.resetAllStates();", true); if (string.IsNullOrWhiteSpace(this.alterKey.Text) == false) { this.Data.ID = this.alterKey.Text; } try { Util.EnsureOperationSafe(); SchemaObjectBase parent = null; if (string.IsNullOrEmpty(this.currentParentID.Value) == false) { AUCommon.DoDbAction(() => parent = SchemaObjectAdapter.Instance.Load(this.currentParentID.Value)); } Facade.InstanceWithPermissions.DoOperation(this.OperationMode, this.Data, parent); WebUtility.ResponseCloseWindowScriptBlock(); ScriptManager.RegisterClientScriptBlock(this.panelContainer, this.GetType(), "master", "top.window.close();", true); } catch (System.Exception ex) { WebUtility.ShowClientError(ex.GetRealException()); } }
/// <summary> /// 根据userID和一组ContainerID,加载该Member所拥有的权限 /// </summary> /// <param name="userID"></param> /// <param name="containerIDs"></param> /// <returns></returns> public SCContainerAndPermissionCollection LoadCurrentContainerAndPermissions(string userID, IEnumerable <string> containerIDs) { var ids = containerIDs.ToArray(); SCContainerAndPermissionCollection result = null; var roleIDs = (from r in new OguUser(userID).Roles.GetAllRoles() select r.ID).ToArray(); if (ids.Length > 0 && roleIDs.Length > 0) { var timeConditon1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("A."); var condition = new WhereSqlClauseBuilder(); condition.AppendItem("A.Status", (int)SchemaObjectStatus.Normal); InSqlClauseBuilder inSql = new InSqlClauseBuilder("A.ContainerID"); inSql.AppendItem(ids); InSqlClauseBuilder inSqlRole = new InSqlClauseBuilder("A.MemberID"); inSqlRole.AppendItem(roleIDs); var sql = string.Format( "SELECT A.* FROM SC.Acl_Current A WHERE {0} ORDER BY SortID ", new ConnectiveSqlClauseCollection(timeConditon1, condition, inSql, inSqlRole).ToSqlString(TSqlBuilder.Instance)); result = new SCContainerAndPermissionCollection(); AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName())) { while (reader.Read()) { string containerID = (string)reader["ContainerID"]; string permission = (string)reader["ContainerPermission"]; if (result.ContainsKey(containerID, permission) == false) { result.Add(new SCContainerAndPermission() { ContainerID = containerID, ContainerPermission = permission }); } } } } }); return(result); } else { result = new SCContainerAndPermissionCollection(); } return(result); }
public static void ClearUp() { AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(AUCommon.DBConnectionName)) { DbHelper.RunSql("EXEC SC.ClearAllData", AUCommon.DBConnectionName); } }); }
protected void GenSchemaTable(object sender, EventArgs e) { SchemaDefineCollection schemas = SchemaExtensions.CreateSchemasDefineFromConfiguration(); AUCommon.DoDbAction(() => { using (TransactionScope scope = TransactionScopeFactory.Create()) { schemas.ForEach(schema => SchemaDefineAdapter.Instance.Update(schema)); scope.Complete(); } }); }
/// <summary> /// 断开容器与成员的关系(不影响成员对象) /// </summary> /// <param name="obj"></param> public void ClearContainer(SchemaObjectBase obj) { AUCommon.DoDbAction(() => { var memberRelations = PC.Adapters.SCMemberRelationAdapter.Instance.LoadByContainerID(obj.ID, DateTime.MinValue); foreach (var item in memberRelations) { if (item.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal) { PC.Adapters.SCMemberRelationAdapter.Instance.UpdateStatus(item, Schemas.SchemaProperties.SchemaObjectStatus.Deleted); } } }); }
private TCollection LoadSchemaObjects<TKey, TCollection>(string sql) where TCollection : SchemaObjectEditableKeyedCollectionBase<TKey, TCollection>, new() where TKey : SchemaObjectBase { TCollection result = new TCollection(); AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { result.LoadFromDataView(DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()).Tables[0].DefaultView); } }); return result; }
private static SchemaObjectBase GetUnitParent(AdminUnit unit, bool allowNull) { SchemaObjectBase parent = null; var parentRelaion = unit.GetCurrentVeryParentRelation(); if (parentRelaion != null) { AUCommon.DoDbAction(() => { parent = parentRelaion.Parent; }); } else if (allowNull == false) { throw new AUObjectException("此管理单元没有任何父级,这可能是数据存在错误或此管理单元未添加到系统。"); } return(parent); }
private SCAclContainer PrepareAclContainer(AdminUnit parent, AdminUnit currentData) { SCAclContainer result = null; if (currentData is ISCAclContainer) { result = new SCAclContainer(currentData); if (parent != null) { AUCommon.DoDbAction(() => result.Members.CopyFrom(AUAclAdapter.Instance.LoadByContainerID(parent.ID, DateTime.MinValue))); } } return(result); }
protected void LoadObject(string id) { AUCommon.DoDbAction(() => { this.Data = SchemaObjectAdapter.Instance.Load(id); }); this.sceneAdapter = PropertyEditorSceneAdapter.Create(this.Data.SchemaType); this.sceneAdapter.ObjectID = this.Data.ID; this.sceneAdapter.Mode = SCObjectOperationMode.Update; this.currentSchemaType.Value = this.Data.SchemaType; // this.CurrentSchemaType = this.Data.SchemaType; this.OperationMode = SCObjectOperationMode.Update; }
protected override void PrepareData(AUObjectOperationContext context) { AUCommon.DoDbAction(() => { actualSchemaRole = (AUSchemaRole)SchemaObjectAdapter.Instance.Load(schemaRole.ID); if (actualSchemaRole.Status != Schemas.SchemaProperties.SchemaObjectStatus.Normal) { throw new AUStatusCheckException(actualSchemaRole, this.OperationType); } this.actualUnit = (AdminUnit)SchemaObjectAdapter.Instance.Load(this.unit.ID); if (this.actualUnit == null || this.actualUnit.Status != Schemas.SchemaProperties.SchemaObjectStatus.Normal) { throw new AUStatusCheckException(actualUnit, this.OperationType); } this.actualUnitRole = Adapters.AUSnapshotAdapter.Instance.LoadAURole(actualSchemaRole.ID, actualUnit.ID, true, DateTime.MinValue); if (actualUnitRole == null || actualUnitRole.Status != Schemas.SchemaProperties.SchemaObjectStatus.Normal) { throw new AUStatusCheckException(actualUnitRole, this.OperationType); } var roleMemberRelations = SCMemberRelationAdapter.Instance.LoadByContainerID(this.actualUnitRole.ID); Dictionary <string, SCUser> userDic = users.ToDictionary(m => m.ID); foreach (var item in roleMemberRelations) { if (item.Status == Schemas.SchemaProperties.SchemaObjectStatus.Normal) { if (userDic.ContainsKey(item.ID)) { userDic.Remove(item.ID); } else { pendingActions.Add(new RemoveRelationAction(item)); } } } foreach (SCUser user in userDic.Values) { pendingActions.Add(new AddRelationAction(this.actualUnitRole, user)); } }); }
protected override void DoValidate(object objectToValidate, object currentObject, string key, ValidationResults validateResults) { string messageTemplate = string.IsNullOrEmpty(this.MessageTemplate) ? "{0}不是有效的管理架构ID。" : this.MessageTemplate; string schemaID = objectToValidate.ToString(); SchemaObjectBase schema = null; AUCommon.DoDbAction(() => { schema = PC.Adapters.SchemaObjectAdapter.Instance.Load(schemaID); }); if (schema == null || schema.Status != Schemas.SchemaProperties.SchemaObjectStatus.Normal) { this.RecordValidationResult(validateResults, string.Format(messageTemplate, objectToValidate), currentObject, key); } }
public AUOperationLogCollection Load(IConnectiveSqlClause sqlClause) { AUOperationLogCollection result = null; AUCommon.DoDbAction(() => { VersionedObjectAdapterHelper.Instance.FillData(GetMappingInfo().TableName, sqlClause, this.GetConnectionName(), (view) => { result = new AUOperationLogCollection(); ORMapping.DataViewToCollection(result, view); }); }); return(result); }
public void UpdateCategory(AUSchemaCategory category) { if (category == null) { throw new ArgumentNullException("category"); } string sql = UpdateBuilder.Instance.ToUpdateSql(category, this.GetMappingInfo()); AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { DateTime point = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName()); category.VersionStartTime = point; } }); }
/// <summary> /// 插入一个新的<see cref="AUOperationLog"/>到数据库中,操作完毕通过其ID属性获取新插入的ID。 /// </summary> /// <param name="log"></param> public void Insert(AUOperationLog log) { log.NullCheck("log"); log.CreateTime = SCActionContext.Current.TimePoint; StringBuilder strB = new StringBuilder(256); strB.Append(ORMapping.GetInsertSql(log, this.GetMappingInfo(), TSqlBuilder.Instance)); strB.Append(TSqlBuilder.Instance.DBStatementSeperator); strB.Append("SELECT SCOPE_IDENTITY()"); AUCommon.DoDbAction(() => { Decimal newID = (Decimal)DbHelper.RunSqlReturnScalar(strB.ToString(), this.GetConnectionName()); log.ID = Decimal.ToInt32(newID); }); }
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); } }
public string GetPinYin(string schemaType, string id, string parentID, string currentValue, bool includingDeleted) { string result = string.Empty; List <string> strPinYin = SCSnapshotAdapter.Instance.GetPinYin(currentValue); AUCommon.DoDbAction(() => { if (strPinYin.Count > 0) { result = strPinYin[0]; if (CodeNameUniqueValidatorFacade.Validate(result, id, schemaType, parentID, includingDeleted == false, false, DateTime.MinValue) == false) { result = GetCodeName(schemaType, id, parentID, result, includingDeleted, 1); } } }); return(result); }
internal static SchemaObjectBase GetEffectiveObject(string id, string message) { SchemaObjectBase result = null; AUCommon.DoDbAction(() => { result = PC.Adapters.SchemaObjectAdapter.Instance.Load(id); }); if (result == null) { throw message != null ? new ObjectNotFoundException(message) : ObjectNotFoundException.CreateForID(id); } else if (result.Status != SchemaObjectStatus.Normal) { throw message != null ? new ObjectNotFoundException(message) : ObjectNotFoundException.CreateForID(id); } return(result); }
/// <summary> /// 得到最后的操作时间。实际上查询了SCOperationSnapshot表。如果没有任何操作,则返回“9999-9-9” /// </summary> /// <returns></returns> public DateTime GetLastestOperationTime() { Dictionary <string, object> context = new Dictionary <string, object>(); string sql = string.Format("SELECT TOP 1 OperateTime FROM {0} ORDER BY OperateTime DESC", GetMappingInfo(context)); object maxTime = null; AUCommon.DoDbAction(() => { maxTime = DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName()); }); if (maxTime == null) { maxTime = MCS.Library.SOA.DataObjects.Security.Adapters.SCConnectionDefine.MaxVersionEndTime; } return((DateTime)maxTime); }
public List <AURoleDisplayItem> LoadAURoleDisplayItems(string unitID, bool normalOnly, DateTime timePoint) { string sql = @"SELECT SR.Name, SR.CodeName, SR.DisplayName, S.ID, S.SchemaRoleID, S.Status FROM SC.AURoleSnapshot S INNER JOIN SC.SchemaMembers R ON S.ID = R.MemberID AND S.SchemaType = R.MemberSchemaType INNER JOIN SC.AUSchemaRoleSnapshot SR ON SR.ID = S.SchemaRoleID WHERE"; WhereSqlClauseBuilder where = new WhereSqlClauseBuilder(); where.AppendCondition("R.ContainerID", unitID).AppendCondition("R.ContainerSchemaType", AUCommon.SchemaAdminUnit); if (normalOnly) { where.NormalFor("R.Status").NormalFor("S.Status").NormalFor("SR.Status"); } var timeCondition1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "S."); var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "SR."); var timeCondition3 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "R."); sql += new ConnectiveSqlClauseCollection(timeCondition1, timeCondition2, timeCondition3, where).ToSqlString(TSqlBuilder.Instance); List <AURoleDisplayItem> result = new List <AURoleDisplayItem>(); AUCommon.DoDbAction(() => { using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName())) { while (dr.Read()) { AURoleDisplayItem item = new AURoleDisplayItem(); ORMapping.DataReaderToObject <AURoleDisplayItem>(dr, item); result.Add(item); } } } }); return(result); }
protected void CheckObjectStatus(params SchemaObjectBase[] objsToCheck) { List <SchemaObjectBase> normalizedObjsToCheck = new List <SchemaObjectBase>(); foreach (SchemaObjectBase obj in objsToCheck) { normalizedObjsToCheck.Add(obj); } InSqlClauseBuilder idBuilder = new InSqlClauseBuilder("ID"); normalizedObjsToCheck.ForEach(o => idBuilder.AppendItem(o.ID)); if (idBuilder.IsEmpty == false) { SchemaObjectCollection originalDataList = null; AUCommon.DoDbAction(() => { originalDataList = SchemaObjectAdapter.Instance.Load(idBuilder); }); string opName = EnumItemDescriptionAttribute.GetDescription(this.OperationType); foreach (SchemaObjectBase objToCheck in normalizedObjsToCheck) { if (originalDataList.ContainsKey(objToCheck.ID) == false) { throw new AUStatusCheckException(string.Format("ID为\"{0}\"的对象不存在,不能执行{1}操作", objToCheck.ID, opName)); } SchemaObjectBase originalData = originalDataList[objToCheck.ID]; if (originalData.Status != SchemaObjectStatus.Normal) { throw new AUStatusCheckException(originalData, this.OperationType); } } } }