public int CompareTo(object obj) { RecordNode objRecordNode = obj as RecordNode; if (this == objRecordNode) return 0; else if (this > objRecordNode) return 1; return -1; }
/// <summary> /// д��VCT���Լ�¼�ڵ� /// </summary> /// <param name="recordNode">VCT���Լ�¼�ڵ�</param> /// <param name="bEndRecord">�Ƿ��DZ�����һ�����Լ�¼</param> public bool WriteRecordNode(RecordNode recordNode, bool bEndRecord) { if (this.m_streamWriter != null) { if(recordNode!=null) this.m_streamWriter.StreamWriterTemp.WriteLine(recordNode); if (bEndRecord == true) this.m_streamWriter.StreamWriterTemp.WriteLine("TableEnd"); this.m_streamWriter.StreamWriterTemp.Flush(); return true; } return false; }
/// <summary> /// ��ȡVCT���Ա��¼�ڵ� /// </summary> private RecordNode ReadRecordNode() { if (this.m_streamReader != null) { string strLine = ""; //��ȡ�������ֻ��� if (m_bFoundTableBegin == false) { ////////////////////////////////////////////////////////////////////////// //VCT����û�С�TableBegin����ǩ��ֻ�С�TableEnd����ǩ /* strLine = this.ReadLine(); //�������Ա�ڵ�Ŀ�ʼ��ǡ�TableBegin�� if (strLine.IndexOf("TableBegin", System.StringComparison.OrdinalIgnoreCase) > -1) {*/ m_bFoundTableBegin = true; //} } if (m_bFoundTableBegin == true) { strLine = this.ReadLine(true); //�������Ա��¼�ڵ�Ľ�����ǡ�TableEnd�� if (strLine.IndexOf("TableEnd", System.StringComparison.OrdinalIgnoreCase) > -1) return null; else { //��ȡ���Լ�¼��Ϣ RecordNode pRecordNode = new RecordNode(); if (pRecordNode.StructRecordNode(strLine) == false) { LogAPI.WriteLog("�������ݱ��¼�����´������ڵ��ļ�������" + m_nReadLineCount + "��"); return null; } return pRecordNode; } } } return null; }
/// <summary> /// 将vct属性表数据插入到对应的属性表中 /// </summary> /// <param name="recordNode"></param> public void InsertAttibuteTableRecord(RecordNode recordNode) { try { IRow pRow = m_pITable.CreateRow(); if (pRow != null) { /////遍历要素的字段集合,除去空间数据相关字段 //List<IField> pListField = new List<IField>(); //for (int i = 0; i < m_pIFeature.Fields.FieldCount; i++) //{ // IField pField = m_pIFeature.Fields.get_Field(i); // if (pField.Type != esriFieldType.esriFieldTypeGeometry // && pField.Type != esriFieldType.esriFieldTypeOID // && pField.Name.ToUpper() != "SHAPE_LENGTH" // && pField.Name.ToUpper() != "SHAPE_AREA") // { // pListField.Add(pField); // } //} /////遍历属性字段集合,进行赋值 //for (int j = 0; j < pListField.Count; j++) //{ // ///查找到对应的字段索引 // int index = m_pIFeature.Fields.FindField(pListField[j].Name); // string sValue = recordNode.FieldValues[j]; // if (index != -1) // m_pIFeature.set_Value(index, sValue); //} ///按照表结构插入数据 for (int i = 0; i < StructureNode.FieldNodes.Count; i++) { FieldNode pFieldNode = StructureNode.FieldNodes[i]; if(pFieldNode.FieldIndex!=-1) pRow.set_Value(pFieldNode.FieldIndex, recordNode.FieldValues[i]); } pRow.Store(); } } catch (Exception ex) { LogAPI.WriteErrorLog(ex); } }
/// <summary> /// 获取属性表数据集合 /// </summary> /// <returns></returns> public List<RecordNode> GetRecordNodes() { try { List<RecordNode> pListNodes = new List<RecordNode>(); ///遍历属性表数据 ICursor pCursor = m_pITable.Search(null,false); IRow pRow = pCursor.NextRow(); while (pRow!=null) { RecordNode pRecordNode = new RecordNode(); pRecordNode.FieldValues = new List<string>(); ///按照表结构中获取到的字段索引添加数据 for (int i = 0; i < StructureNode.FieldNodes.Count; i++) { FieldNode pFieldNode = StructureNode.FieldNodes[i]; if(pFieldNode.FieldIndex!=-1) pRecordNode.FieldValues.Add( pRow.get_Value(pFieldNode.FieldIndex).ToString()); } pListNodes.Add(pRecordNode); pRow = pCursor.NextRow(); } m_RecordNodes = pListNodes; return pListNodes; } catch(Exception ex) { LogAPI.WriteErrorLog(ex); return null; } }
/// <summary> /// ��ȡVCT���Լ�¼�ڵ� /// </summary> public RecordNode GetRecordNode(TableStructureNode pTableStructNode) { try { RecordNode pRecordNode = new RecordNode(); /////��ʶ�븳ֵ //int dBSMIndex = -1; //dBSMIndex = this.Feature.Fields.FindField("BSM"); //if (dBSMIndex != -1) // pRecordNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex)); List<string> sListValues = new List<string>(); for (int i = 0; i < pTableStructNode.FieldNodes.Count; i++) { //IField pField = this.Feature.Fields.get_Field(i); //string sValue = this.Feature.get_Value(i).ToString(); /////ֻ������������ //if (pField.Type != esriFieldType.esriFieldTypeOID // && pField.Type != esriFieldType.esriFieldTypeGeometry // && pField.Name.ToUpper() != "SHAPE_LENGTH" // && pField.Name.ToUpper() != "SHAPE_AREA") //{] FieldNode pFieldNode = pTableStructNode.FieldNodes[i]; if (pFieldNode.FieldName == m_strEntityIDFiled) { sListValues.Insert(0, this.Feature.get_Value(pFieldNode.FieldIndex).ToString()); pRecordNode.EntityID =Convert.ToInt32( this.Feature.get_Value(pFieldNode.FieldIndex)); } else sListValues.Add(this.Feature.get_Value(pFieldNode.FieldIndex).ToString()); //} } pRecordNode.FieldValues = sListValues; return pRecordNode; } catch (Exception ex) { Logger.WriteErrorLog(ex); return null; } }
/// <summary> /// �������� /// </summary> /// <param name="recordNode">������Ϣ</param> public void AttachAttribute(RecordNode recordNode, TableStructureNode pTableStructNode) { try { if (m_pIFeature != null) { if (m_pIFeature is IAnnotationFeature) { ///���ע������ } else { for (int i = 0; i < pTableStructNode.FieldNodes.Count; i++) { FieldNode pFieldNode = pTableStructNode.FieldNodes[i]; string sValue = recordNode.FieldValues[i]; m_pIFeature.set_Value(pFieldNode.FieldIndex, sValue); } m_pIFeature.Store(); } } } catch (Exception ex) { Logger.WriteErrorLog(ex); } }