private static void WriteDelHistoryLine(IFeature ifeature_0, IFeature ifeature_1, int int_0, System.DateTime dateTime_0) { string[] array = (ZDEditTools.ZDFeatureClass as IDataset).Name.Split(new char[] { '.' }); ZDHistoryTable zDHistoryTable = new ZDHistoryTable(); IRow row = ZDEditTools.ZDChangeHisInfoTable.CreateRow(); RowOperator.SetFieldValue(row, zDHistoryTable.ChageDateFieldName, dateTime_0); RowOperator.SetFieldValue(row, zDHistoryTable.ChangeTypeFieldName, int_0); RowOperator.SetFieldValue(row, zDHistoryTable.OrigineZDOIDName, ifeature_0.OID); RowOperator.SetFieldValue(row, zDHistoryTable.NewZDOIDName, -1); if (ifeature_1 != null) { RowOperator.SetFieldValue(row, zDHistoryTable.HisZDOIDName, ifeature_1.OID); } else { RowOperator.SetFieldValue(row, zDHistoryTable.HisZDOIDName, -1); } RowOperator.SetFieldValue(row, zDHistoryTable.ZDFeatureClassName, array[array.Length - 1]); RowOperator.SetFieldValue(row, zDHistoryTable.ZDRegisterGuidName, ZDRegister.GetRegisterZDGuid(ZDEditTools.ZDFeatureClass)); row.Store(); }
public bool CanUndo(IFeatureClass ifeatureClass_0) { string text = (ifeatureClass_0 as IDataset).Name; string[] array = text.Split(new char[] { '.' }); text = array[array.Length - 1]; if (text.Length > 4) { string a = text.Substring(text.Length - 4).ToLower(); if (a == "_his") { text = text.Substring(0, text.Length - 4); } } string registerZDGuid = ZDRegister.GetRegisterZDGuid(ifeatureClass_0); bool result; if (this.ChageType == ZDEditType.Delete) { result = true; } else { ZDHistoryTable zDHistoryTable = new ZDHistoryTable(); string whereClause = string.Format("{0}='{1}' and {2} in ({3})", new object[] { zDHistoryTable.ZDRegisterGuidName, registerZDGuid, zDHistoryTable.OrigineZDOIDName, this.NewOIDs }); IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = whereClause; IWorkspace workspace = AppConfigInfo.GetWorkspace(); ITable table = (workspace as IFeatureWorkspace).OpenTable(zDHistoryTable.TableName); int num = table.RowCount(queryFilter); result = (num == 0); } return(result); }
public void LoadParent() { this.IsLoad = true; try { ZDHistoryTable zDHistoryTable = new ZDHistoryTable(); string text = (this.Feature.Class as IDataset).Name; string[] array = text.Split(new char[] { '.' }); text = array[array.Length - 1]; if (text.Length > 4) { string a = text.Substring(text.Length - 4).ToLower(); if (a == "_his") { text = text.Substring(0, text.Length - 4); } } string historyZDFeatureName = ZDRegister.GetHistoryZDFeatureName(this.Feature.Class as IFeatureClass); string registerZDGuid = ZDRegister.GetRegisterZDGuid(this.Feature.Class as IFeatureClass); IFeatureClass ifeatureClass_ = ((this.Feature.Class as IDataset).Workspace as IFeatureWorkspace).OpenFeatureClass( historyZDFeatureName); string whereClause = string.Format("{0}='{1}' and {2}={3}", new object[] { zDHistoryTable.ZDRegisterGuidName, registerZDGuid, zDHistoryTable.NewZDOIDName, this.OID }); IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = whereClause; IWorkspace workspace = AppConfigInfo.GetWorkspace(); ITable table = (workspace as IFeatureWorkspace).OpenTable(zDHistoryTable.TableName); ICursor cursor = table.Search(queryFilter, false); for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow()) { ZDChangeHistoryInfo zDChangeHistoryInfo = new ZDChangeHistoryInfo(); object fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.ChangeTypeFieldName); if (this.ChageType == ZDEditType.Unknown) { this.ChageType = (ZDEditType)System.Convert.ToInt32(fieldValue); } fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.ChageDateFieldName); this.ChangeDate = System.Convert.ToDateTime(fieldValue); fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.OrigineZDOIDName); int oID = System.Convert.ToInt32(fieldValue); zDChangeHistoryInfo.Feature = ZDChangeHistory.GetHisFeat(ifeatureClass_, oID); zDChangeHistoryInfo.OID = oID; zDChangeHistoryInfo.TopFeat = this.Feature; zDChangeHistoryInfo.SouceInfos = new System.Collections.Generic.List <ZDChangeHistoryInfo>(); this.SouceInfos.Add(zDChangeHistoryInfo); } ComReleaser.ReleaseCOMObject(cursor); } catch (System.Exception) { } }
public static System.Collections.Generic.List <ZDChangeHistoryInfo2> GetZDChangeHistory( IFeatureClass ifeatureClass_0) { System.Collections.Generic.List <ZDChangeHistoryInfo2> list = new System.Collections.Generic.List <ZDChangeHistoryInfo2>(); ZDHistoryTable zDHistoryTable = new ZDHistoryTable(); string text = (ifeatureClass_0 as IDataset).Name; string[] array = text.Split(new char[] { '.' }); text = array[array.Length - 1]; if (text.Length > 4) { string a = text.Substring(text.Length - 4).ToLower(); if (a == "_his") { text = text.Substring(0, text.Length - 4); } } string registerZDGuid = ZDRegister.GetRegisterZDGuid(ifeatureClass_0); string whereClause = string.Format("{0}='{1}' ", zDHistoryTable.ZDRegisterGuidName, registerZDGuid); IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = whereClause; (queryFilter as IQueryFilterDefinition).PostfixClause = string.Format(" ORDER BY {0} desc ", zDHistoryTable.ChageDateFieldName); try { using (ComReleaser comReleaser = new ComReleaser()) { IWorkspace workspace = AppConfigInfo.GetWorkspace(); ITable table = (workspace as IFeatureWorkspace).OpenTable(zDHistoryTable.TableName); ICursor cursor = table.Search(queryFilter, true); comReleaser.ManageLifetime(cursor); IRow row = cursor.NextRow(); SortedList <int, ZDChangeHistoryInfo2> sortedList = new SortedList <int, ZDChangeHistoryInfo2>(); SortedList <int, ZDChangeHistoryInfo2> sortedList2 = new SortedList <int, ZDChangeHistoryInfo2>(); while (row != null) { try { object fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.ChangeTypeFieldName); ZDEditType zDEditType = (ZDEditType)System.Convert.ToInt32(fieldValue); fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.ChageDateFieldName); System.DateTime changeDate = System.Convert.ToDateTime(fieldValue); fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.OrigineZDOIDName); int num = System.Convert.ToInt32(fieldValue); fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.NewZDOIDName); int num2 = System.Convert.ToInt32(fieldValue); fieldValue = RowOperator.GetFieldValue(row, zDHistoryTable.HisZDOIDName); int num3 = System.Convert.ToInt32(fieldValue); if (num2 != -1) { ZDChangeHistoryInfo2 zDChangeHistoryInfo; if (zDEditType == ZDEditType.Split) { if (sortedList2.ContainsKey(num)) { zDChangeHistoryInfo = sortedList2[num]; } else { zDChangeHistoryInfo = new ZDChangeHistoryInfo2(); sortedList2.Add(num, zDChangeHistoryInfo); zDChangeHistoryInfo.Add(num); zDChangeHistoryInfo.AddHis(num3); zDChangeHistoryInfo.ChangeDate = changeDate; zDChangeHistoryInfo.ChageType = zDEditType; list.Add(zDChangeHistoryInfo); } zDChangeHistoryInfo.AddNew(num2); } else if (zDEditType == ZDEditType.Union) { if (sortedList.ContainsKey(num2)) { zDChangeHistoryInfo = sortedList[num2]; } else { zDChangeHistoryInfo = new ZDChangeHistoryInfo2(); sortedList.Add(num2, zDChangeHistoryInfo); zDChangeHistoryInfo.AddNew(num2); zDChangeHistoryInfo.ChangeDate = changeDate; zDChangeHistoryInfo.ChageType = zDEditType; list.Add(zDChangeHistoryInfo); } zDChangeHistoryInfo.Add(num); zDChangeHistoryInfo.AddHis(num3); } else { zDChangeHistoryInfo = new ZDChangeHistoryInfo2(); zDChangeHistoryInfo.Add(num); zDChangeHistoryInfo.AddNew(num2); zDChangeHistoryInfo.AddHis(num3); zDChangeHistoryInfo.ChangeDate = changeDate; zDChangeHistoryInfo.ChageType = zDEditType; list.Add(zDChangeHistoryInfo); } zDChangeHistoryInfo.HisOID = num3; } else if (num != -1 && zDEditType == ZDEditType.Delete) { ZDChangeHistoryInfo2 zDChangeHistoryInfo = new ZDChangeHistoryInfo2(); zDChangeHistoryInfo.Add(num); zDChangeHistoryInfo.AddNew(num2); zDChangeHistoryInfo.AddHis(num3); zDChangeHistoryInfo.ChangeDate = changeDate; zDChangeHistoryInfo.ChageType = zDEditType; list.Add(zDChangeHistoryInfo); } } catch (System.Exception) { } row = cursor.NextRow(); } } } catch (System.Exception) { } return(list); }
public bool UnDoChange(IFeatureClass ifeatureClass_0) { bool result; if (this.CanUndo(ifeatureClass_0)) { string text = (ifeatureClass_0 as IDataset).Name; string[] array = text.Split(new char[] { '.' }); text = array[array.Length - 1]; if (text.Length > 4) { string a = text.Substring(text.Length - 4).ToLower(); if (a == "_his") { text = text.Substring(0, text.Length - 4); } } string registerZDGuid = ZDRegister.GetRegisterZDGuid(ifeatureClass_0); ZDHistoryTable zDHistoryTable = new ZDHistoryTable(); string whereClause; if (this.ChageType == ZDEditType.Create) { whereClause = string.Format("{0}='{1}' and {2} in ({3})", new object[] { zDHistoryTable.ZDRegisterGuidName, registerZDGuid, zDHistoryTable.NewZDOIDName, this.NewOIDs }); } else { whereClause = string.Format("{0}='{1}' and {2} in ({3})", new object[] { zDHistoryTable.ZDRegisterGuidName, registerZDGuid, zDHistoryTable.OrigineZDOIDName, this.OriginOIDs }); } IQueryFilter queryFilter = new QueryFilter(); queryFilter.WhereClause = whereClause; IWorkspace workspace = AppConfigInfo.GetWorkspace(); ITable table = (workspace as IFeatureWorkspace).OpenTable(zDHistoryTable.TableName); table.DeleteSearchedRows(queryFilter); string historyZDFeatureName = ZDRegister.GetHistoryZDFeatureName(ifeatureClass_0); IFeatureClass featureClass = ((ifeatureClass_0 as IDataset).Workspace as IFeatureWorkspace).OpenFeatureClass(historyZDFeatureName); string[] array2 = this.HisOIDs.Split(new char[] { ',' }); try { if (this.ChageType != ZDEditType.Delete) { queryFilter = new QueryFilter(); whereClause = string.Format("{0} in ({1}) ", ifeatureClass_0.OIDFieldName, this.NewOIDs); queryFilter.WhereClause = whereClause; (ifeatureClass_0 as ITable).DeleteSearchedRows(queryFilter); } } catch (System.Exception) { } int index = featureClass.FindField("OriginOID_"); int index2 = table.FindField(zDHistoryTable.NewZDOIDName); string[] array3 = array2; for (int i = 0; i < array3.Length; i++) { string text2 = array3[i]; if (text2 != "-1") { IFeature feature = ifeatureClass_0.CreateFeature(); IFeature feature2 = featureClass.GetFeature(System.Convert.ToInt32(text2)); int num = System.Convert.ToInt32(feature2.get_Value(index)); RowOperator.CopyFeatureToFeatureEx(feature2, feature); feature2.Delete(); whereClause = string.Format("{0}='{1}' and {2} ={3}", new object[] { zDHistoryTable.ZDRegisterGuidName, registerZDGuid, zDHistoryTable.NewZDOIDName, num }); queryFilter.WhereClause = whereClause; ICursor cursor = table.Search(queryFilter, false); for (IRow row = cursor.NextRow(); row != null; row = cursor.NextRow()) { row.set_Value(index2, feature.OID); row.Store(); } ComReleaser.ReleaseCOMObject(cursor); } } result = true; } else { result = false; } return(result); }