private static SameContainerItemAndContainerSnapshotCollection GetUpdateData(string containerID, string containerSchemaType, SameContainerItemAndContainerSnapshotCollection existedData, SchemaObjectCollection users) { SameContainerItemAndContainerSnapshotCollection updatedInfo = new SameContainerItemAndContainerSnapshotCollection(); foreach (ItemAndContainerSnapshot uacs in existedData) { if (users.ContainsKey(uacs.ItemID)) { //原来是已删除的,现在改为Normal if (uacs.Status != SchemaObjectStatus.Normal) { uacs.Status = SchemaObjectStatus.Normal; updatedInfo.Add(uacs); } } else { //现在不存在了,状态需要改为已删除 uacs.Status = SchemaObjectStatus.Deleted; updatedInfo.Add(uacs); } } return(updatedInfo); }
private static SameContainerItemAndContainerSnapshotCollection GetInsertData(string containerID, string containerSchemaType, SameContainerItemAndContainerSnapshotCollection existedData, SchemaObjectCollection items) { SameContainerItemAndContainerSnapshotCollection newInfo = new SameContainerItemAndContainerSnapshotCollection(); foreach (SchemaObjectBase item in items) { if (existedData.ContainsKey(item.ID) == false && newInfo.ContainsKey(item.ID) == false) { ItemAndContainerSnapshot uacs = new ItemAndContainerSnapshot(); uacs.ContainerID = containerID; uacs.ContainerSchemaType = containerSchemaType; uacs.ItemID = item.ID; uacs.ItemSchemaType = item.SchemaType; uacs.Status = SchemaObjectStatus.Normal; newInfo.Add(uacs); } } return(newInfo); }
/// <summary> /// 根据Container来加载ItemAndContainerSnapshot的信息 /// </summary> /// <param name="containerID"></param> /// <param name="timePoint"></param> /// <returns></returns> public SameContainerItemAndContainerSnapshotCollection LoadByContainerID(string containerID, DateTime timePoint) { containerID.CheckStringIsNullOrEmpty("containerID"); ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint); WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); whereBuilder.AppendItem("ContainerID", containerID); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(whereBuilder, timePointBuilder); string sql = string.Format("SELECT * FROM {0} WHERE {1}", this.GetLoadingTableName(timePoint), connectiveBuilder.ToSqlString(TSqlBuilder.Instance)); SameContainerItemAndContainerSnapshotCollection result = new SameContainerItemAndContainerSnapshotCollection(); using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName())) { while (reader.Read()) { ItemAndContainerSnapshot item = new ItemAndContainerSnapshot(); ORMapping.DataReaderToObject(reader, item); if (result.ContainsKey(item.ItemID) == false) { result.Add(item); } } } } return(result); }
private static SameContainerItemAndContainerSnapshotCollection GetUpdateData(string containerID, string containerSchemaType, SameContainerItemAndContainerSnapshotCollection existedData, SchemaObjectCollection users) { SameContainerItemAndContainerSnapshotCollection updatedInfo = new SameContainerItemAndContainerSnapshotCollection(); foreach (ItemAndContainerSnapshot uacs in existedData) { if (users.ContainsKey(uacs.ItemID)) { //原来是已删除的,现在改为Normal if (uacs.Status != SchemaObjectStatus.Normal) { uacs.Status = SchemaObjectStatus.Normal; updatedInfo.Add(uacs); } } else { //现在不存在了,状态需要改为已删除 uacs.Status = SchemaObjectStatus.Deleted; updatedInfo.Add(uacs); } } return updatedInfo; }
private static SameContainerItemAndContainerSnapshotCollection GetInsertData(string containerID, string containerSchemaType, SameContainerItemAndContainerSnapshotCollection existedData, SchemaObjectCollection items) { SameContainerItemAndContainerSnapshotCollection newInfo = new SameContainerItemAndContainerSnapshotCollection(); foreach (SchemaObjectBase item in items) { if (existedData.ContainsKey(item.ID) == false && newInfo.ContainsKey(item.ID) == false) { ItemAndContainerSnapshot uacs = new ItemAndContainerSnapshot(); uacs.ContainerID = containerID; uacs.ContainerSchemaType = containerSchemaType; uacs.ItemID = item.ID; uacs.ItemSchemaType = item.SchemaType; uacs.Status = SchemaObjectStatus.Normal; newInfo.Add(uacs); } } return newInfo; }
/// <summary> /// 根据Container来加载ItemAndContainerSnapshot的信息 /// </summary> /// <param name="containerID"></param> /// <param name="timePoint"></param> /// <returns></returns> public SameContainerItemAndContainerSnapshotCollection LoadByContainerID(string containerID, DateTime timePoint) { containerID.CheckStringIsNullOrEmpty("containerID"); ConnectiveSqlClauseCollection timePointBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint); WhereSqlClauseBuilder whereBuilder = new WhereSqlClauseBuilder(); whereBuilder.AppendItem("ContainerID", containerID); ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(whereBuilder, timePointBuilder); string sql = string.Format("SELECT * FROM {0} WHERE {1}", this.GetLoadingTableName(timePoint), connectiveBuilder.ToSqlString(TSqlBuilder.Instance)); SameContainerItemAndContainerSnapshotCollection result = new SameContainerItemAndContainerSnapshotCollection(); using (DbContext context = DbContext.GetContext(this.GetConnectionName())) { using (IDataReader reader = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName())) { while (reader.Read()) { ItemAndContainerSnapshot item = new ItemAndContainerSnapshot(); ORMapping.DataReaderToObject(reader, item); if (result.ContainsKey(item.ItemID) == false) result.Add(item); } } } return result; }