Example #1
0
 public void Save(bool bRelease)
 {
     if (m_pOleDbDataAdapter != null && m_pDataTable != null)
     {
         try
         {
             OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(m_pOleDbDataAdapter);
             m_pOleDbDataAdapter.Update(m_pDataTable);
             if (bRelease == true)
             {
                 m_pDataTable.Rows.Clear();
                 m_pDataTable.Dispose();
                 //m_pDataSet.Tables.Clear();
                 //m_pDataSet.Dispose();
                 m_pOleDbDataAdapter.Dispose();
                 m_pDataTable = null;
                 //m_pDataSet = null;
                 m_pOleDbDataAdapter = null;
                 //m_pDataTable.Rows.Clear();
             }
         }
         catch (Exception ex)
         {
             LogAPI.WriteErrorLog(ex);
         }
     }
 }
Example #2
0
        public bool DeleteSurplusRows()
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    //删除反向次数为偶数的记录记录
                    string strCommand = "Delete * From " + TableName_TempTable + " Where " + FieldName_LineNodeID
                                        + " in ( Select " + FieldName_LineNodeID + " From ("
                                        + " Select " + FieldName_LineNodeID + ",Count(*) as RowCount From " + TableName_TempTable + " Group by " + FieldName_LineNodeID
                                        + " ) Where RowCount Mod 2=0 )";

                    OleDbCommand oleDbCommand = new OleDbCommand(strCommand, m_pOleDbConnection);
                    oleDbCommand.ExecuteNonQuery();

                    //删除重复记录(只保留一个)
                    strCommand = "Delete * From " + TableName_TempTable + " Where " + FieldName_IndexID
                                 + " in( Select a." + FieldName_IndexID + " From " + TableName_TempTable + " As a," + TableName_TempTable + " As b Where a." + FieldName_LineNodeID + "=b." + FieldName_LineNodeID + " And a." + FieldName_IndexID + "<b." + FieldName_IndexID + ")";

                    oleDbCommand = new OleDbCommand(strCommand, m_pOleDbConnection);
                    oleDbCommand.ExecuteNonQuery();


                    return(true);
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(false);
        }
Example #3
0
        public override bool CreateTable()
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    base.CreateTable();

                    string strCommand = "Create Table " + TableName_TempTable + "("
                                        + FieldName_LineNodeID + " int primary key,"
                                        + FieldName_EntityID + " int,"
                                        + FieldName_FeatureCode + " VARCHAR(16),"
                                        + FieldName_LineType + " int,"
                                        + FieldName_Representation + " VARCHAR(16),"
                                        + FieldName_X1 + " double,"
                                        + FieldName_Y1 + " double,"
                                        + FieldName_X2 + " double,"
                                        + FieldName_Y2 + " double)";

                    OleDbCommand oleDbCommand = new OleDbCommand(strCommand, m_pOleDbConnection);
                    oleDbCommand.ExecuteNonQuery();
                    return(true);
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(false);
        }
Example #4
0
        public DataTable GetTableForAdd()
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    string commandText = "Select * From " + TableName_TempTable + " Where 1>2";
                    m_pOleDbDataAdapter = new OleDbDataAdapter(commandText, m_pOleDbConnection);

                    DataSet m_pDataSet = new DataSet();
                    m_pOleDbDataAdapter.Fill(m_pDataSet);
                    if (m_pDataSet.Tables != null && m_pDataSet.Tables.Count > 0)
                    {
                        m_pDataTable = m_pDataSet.Tables[0];

                        return(m_pDataTable);
                    }

                    return(m_pDataTable);
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(null);
        }
Example #5
0
        public override DataTable GetRecords(string strWhere, string strGroupBy, string strOrderBy)
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    m_nCurrentRowIndex = 0;

                    string commandText = "Select * from "
                                         + "(Select LineNodeID as LineID,X1 as PX1,Y1 as PY1,X2 as PX2,Y2 as PY2,-1 from LineNodeEx Where EntityID=-1 "
                                         + "union Select LineNodeID as LineID,X2 as PX1,Y2 as PY1,X1 as PX2,Y1 as PY2,1 from LineNodeEx Where EntityID=-1) "
                                         + "Order By PX1,PY1,PX2,PY2,LineID";

                    m_pOleDbDataAdapter = new OleDbDataAdapter(commandText, m_pOleDbConnection);


                    OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(m_pOleDbDataAdapter);


                    return(GetNextRecords());
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(null);
        }
Example #6
0
        public DataTable GetRecordsEx(string strWhere, string strGroupBy, string strOrderBy)
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    m_nCurrentRowIndex = 0;

                    /*
                     * Select a.LineNodeID,b.LineNodeID,a.PolygonID,b.PolygonID,a.IsReverse,b.IsReverse,a.EntityID,a.IsFromLine From LineNodeEx as a left join LineNodeEx as b on a.OrtherIndexID=b.LineNodeID Order By a.PolygonID,a.LineIndex
                     * */

                    string commandText = "Select a.LineNodeID as LineNodeID,b.LineNodeID as OtherLineNodeID,a.PolygonID as PolygonID,b.PolygonID as OtherPolygonID,a.IsReverse as IsReverse,b.IsReverse as OtherIsReverse,a.EntityID EntityID,b.EntityID as OtherEntityID,a.LineIndex as LineIndex,b.LineIndex as OtherLineIndex"//,a.IsFromLine as IsFromLine
                                         + " From LineNodeEx as a left join LineNodeEx as b on a.OrtherIndexID=b.LineNodeID"
                                         + " Order By a.PolygonID,a.LineIndex";

                    m_pOleDbDataAdapter = new OleDbDataAdapter(commandText, m_pOleDbConnection);


                    OleDbCommandBuilder commandBuilder = new OleDbCommandBuilder(m_pOleDbDataAdapter);


                    return(GetNextRecords());
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(null);
        }
Example #7
0
		/// <summary>
		/// 创建点实体
		/// </summary>
        /// <param name="pITable">数据表对象</param>
        /// <param name="entinyNode">VCT空间实体节点</param>
        public override void CreateFeature(ITable pITable, EntityNode entinyNode)
        {
            try
            {
                PointNode pPointNode = entinyNode as PointNode;
                if (pPointNode != null)
                {
                    IFeatureClass pFeatureCls = pITable as IFeatureClass;
                    this.Feature = pFeatureCls.CreateFeature();

                    ///标识码赋值
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        this.Feature.set_Value(dBSMIndex, pPointNode.EntityID);

                    ///要素代码赋值
                    int dSYDMIndex = -1;
                    dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                    if (dSYDMIndex != -1)
                        this.Feature.set_Value(dSYDMIndex, pPointNode.FeatureCode);

                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(pPointNode.PointInfoNode.X, pPointNode.PointInfoNode.Y);

                    (this.Feature as IFeature).Shape = pPoint;

                    this.Feature.Store();
                }
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
        }
Example #8
0
 /// <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)
     {
         LogAPI.WriteErrorLog(ex);
     }
 }
Example #9
0
        /// <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);
            }
        }
Example #10
0
 /// <summary>
 /// 初始化xml文档对象
 /// </summary>
 /// <param name="pEnumDBStandard">vct数据文件类型</param>
 /// <param name="pFilterList">过滤层集合</param>
 /// <returns></returns>
 public static bool Initial(EnumDBStandard pEnumDBStandard, List <string> pFilterList)
 {
     try
     {
         if (m_XMLDoc == null)
         {
             m_XMLDoc = new XmlDocument();
         }
         m_XMLDoc.Load(m_strPath);
         if (!InitialConfig(m_XMLDoc, pEnumDBStandard))
         {
             return(false);
         }
         m_pMetaTables = GetMetaTablesByName(m_XMLDoc, pEnumDBStandard, pFilterList);
         if (m_pMetaTables == null)
         {
             return(false);
         }
         return(true);
     }
     catch (Exception ex)
     {
         LogAPI.WriteErrorLog(ex);
         return(false);
     }
 }
Example #11
0
        public override bool CreateTable()
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    base.CreateTable();

                    string strCommand = "Create Table " + TableName_TempTable + "("
                                        + FieldName_LineIndexID + " int,"
                                        + FieldName_LineExIndexID + " int primary key,"
                                        + FieldName_EntityID + " int)";
                    //+ FieldName_EntityID + " int primary key)";

                    OleDbCommand oleDbCommand = new OleDbCommand(strCommand, m_pOleDbConnection);
                    oleDbCommand.ExecuteNonQuery();
                    return(true);
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(false);
        }
Example #12
0
		/// <summary>
		/// 创建空间图层
		/// </summary>
		/// <param name="tableStructureNode">VCT表结构节点</param>
		/// <param name="featureCodeNode">VCT要素编码节点</param>
		private FeatureLayer CreateFeatureLayer(TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                FeatureLayer featureLayer = null;
                ///获取要素集
                IFeatureDataset featureDataset = m_pIDataset as IFeatureDataset;


                //从配置文件读取图形类型
                string sGeometryType = "";
                Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                if (pMetaTalbe != null)
                {
                    sGeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark(pMetaTalbe.Type);
                }
                else
                {
                    LogAPI.WriteLog("未能获取【" + tableStructureNode.TableName + "】的图形类型!");
                    return null;
                }
                ///创建点实体
                if (sGeometryType == "Point")
                {
                    featureLayer = new PointLayer();
                   
                }
                 ///创建线实体
                else if (sGeometryType == "Line")
                {
                    featureLayer = new LineLayer();
                  
                }
                ///创建面实体
                else if (sGeometryType == "Polygon")
                {
                    featureLayer = new PolygonLayer();
                }
                else if (sGeometryType == "Annotation")
                {
                    featureLayer = new AnnotationLayer();
                }

                if (featureLayer != null)
                {
                    featureLayer.StructureNode = tableStructureNode;

                    IFeatureClass pFcls = CreateFeatureClass(featureDataset, tableStructureNode, featureCodeNode);
                    featureLayer.Table = pFcls as ITable;
                    featureLayer.UpdateFieldIndex();
                    return featureLayer;
                }
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
            return null;
        }
Example #13
0
        /// <summary>
        /// 将构面的环分解成线段集合
        /// </summary>
        /// <param name="pRing">构面的环对象IRing</param>
        /// <param name="strFeatureCode">线的要素代码</param>
        /// <param name="strRepresentation">图形表现编码</param>
        /// <param name="nEntityID">面实体索引</param>
        /// <returns>VCT线段对象集合</returns>
        private List<LineNodeEx> GetLineByRing(IRing pRing,string strFeatureCode,string strRepresentation,int nEntityID)
        {
            try
            {
                List<LineNodeEx> pListLine = new List<LineNodeEx>();
               
                ///获取每个环中的线段集合
                ISegmentCollection pExRingSegmentCollection = pRing as ISegmentCollection;

                ///处理集合中的各个线段
                for (int i = 0; i < pExRingSegmentCollection.SegmentCount; i++)
                {
                    ISegment pSegment = pExRingSegmentCollection.get_Segment(i);

                    LineNodeEx pLineNodeEx = new LineNodeEx();//构造VCT线段对象
                    pLineNodeEx.SegmentNodes = new SegmentNodes();//构造线段对应的点集合
                    //pLineNodeEx.IsReverse = bReverse;//设置方向
                    pLineNodeEx.FeatureCode = strFeatureCode;//设置要素代码
                    pLineNodeEx.Representation = strRepresentation;
                    pLineNodeEx.PolygonID = nEntityID;///所属面的标识码


                    BrokenLineNode pBrokenLinNode = new BrokenLineNode();//构造折线
                    pBrokenLinNode.PointInfoNodes = new PointInfoNodes();

                    
                    ILine pLine = pSegment as ILine;
                    if (pLine != null)
                    {
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pLine.FromPoint.X, pLine.FromPoint.Y));
                        pBrokenLinNode.PointInfoNodes.Add(new PointInfoNode(pLine.ToPoint.X, pLine.ToPoint.Y));
                    }
                    

                    //////如果是反向
                    ////if (bReverse)
                    ////{
                    ////    PointInfoNodes tempPointInfoNodes = new PointInfoNodes();
                    ////    foreach (PointInfoNode item in pBrokenLinNode.PointInfoNodes)
                    ////    {
                    ////        tempPointInfoNodes.Add(item);
                    ////    }
                    ////    pBrokenLinNode.PointInfoNodes = tempPointInfoNodes;
                    ////}
                    pLineNodeEx.SegmentNodes.Add(pBrokenLinNode);
                    pListLine.Add(pLineNodeEx);
                }

                return pListLine;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Example #14
0
		/// <summary>
		/// 创建线实体
		/// </summary>
        /// <param name="pITable">数据表对象</param>
        /// <param name="entinyNode">VCT空间实体节点</param>
        public override void CreateFeature(ITable pITable, EntityNode entinyNode)
        {
            try
            {
                IFeatureClass pFeatureCls = pITable as IFeatureClass;
                this.Feature =  pFeatureCls.CreateFeature();
                LineNode pLineNode = entinyNode as LineNode;

                if (pLineNode != null)
                {
                    ///标识码赋值
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        this.Feature.set_Value(dBSMIndex, pLineNode.EntityID);

                    ///要素代码赋值
                    int dSYDMIndex = -1;
                    dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                    if (dSYDMIndex != -1)
                        this.Feature.set_Value(dSYDMIndex, pLineNode.FeatureCode);

                    ///创建空间数据
                    int dLineNodeCount = pLineNode.SegmentNodes.Count;
                    IPointCollection pointCollection = new PolylineClass();
                    for (int i = 0; i < dLineNodeCount; i++)
                    {
                        //11表示折线类型
                        if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("LINETYPE", pLineNode.SegmentNodes[i].SegmentType.ToString()) == "BrokenLine")
                        {
                            BrokenLineNode pBLine = pLineNode.SegmentNodes[i] as BrokenLineNode;
                            foreach (PointInfoNode pPointInfoNode in pBLine.PointInfoNodes)
                            {
                                IPoint pPoint = new PointClass();
                                pPoint.PutCoords(pPointInfoNode.X, pPointInfoNode.Y);
                                object objType = Type.Missing;
                                pointCollection.AddPoint(pPoint, ref objType, ref objType);
                            }
                        }
                        else
                        {
                            //其他类型待后续扩展
                        }
                    }
                    (this.Feature as IFeature).Shape = pointCollection as IGeometry;

                    //feature.set_Value();
                    this.Feature.Store();
                }
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
		}
Example #15
0
 /// <summary>
 /// 获取要素编码节点
 /// </summary>
 public override FeatureCodeNode GetFeatureCodeNode()
 {
     try
     {
         return base.GetFeatureCodeNode();
     }
     catch (Exception ex)
     {
         LogAPI.WriteErrorLog(ex);
         return null;
     }
 }
Example #16
0
		/// <summary>
		/// 创建所有空间图层
		/// </summary>
		/// <param name="tableStructureNodes">VCT表结构节点集合</param>
		/// <param name="featureCodeNodes">VCT要素编码节点集合</param>
        public List<TableLayer> CreateFeatureLayers(List<TableStructureNode> tableStructureNodes, Hashtable featureCodeNodes)
        {
            try
            {
                if (tableStructureNodes == null || featureCodeNodes == null)
                    return null;

                List<TableLayer> arrFeatureLayer = new List<TableLayer>();
                IFeatureDataset featureDataset = this.m_pIDataset as IFeatureDataset;
                ///读取第一个数据集进行处理
                if (featureDataset != null)
                {
                    ////遍历表结构节点进行空间数据表创建
                    foreach (TableStructureNode tableStructureNode in tableStructureNodes)
                    {
                        FeatureCodeNode featureCodeNode = featureCodeNodes[tableStructureNode.TableName] as FeatureCodeNode;

                        //从配置文件读取图形类型
                        string sGeometryType = "";
                        Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                       
                        ///如果当前标准不包含表则不创建
                        if (pMetaTalbe != null)
                        {
                            sGeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark(pMetaTalbe.Type);

                            if (sGeometryType == "NoneGeometry")
                            {
                                ///创建属性数据表
                                TableLayer pTalbeLayer = CreateTableLayer(m_pWorkspace as IFeatureWorkspace, tableStructureNode, featureCodeNode);
                                if (pTalbeLayer != null)
                                    arrFeatureLayer.Add(pTalbeLayer);
                            }
                            else
                            {
                                ///创建空间数据表
                                FeatureLayer featureLayer = CreateFeatureLayer(tableStructureNode, featureCodeNode);
                                if (featureLayer != null)
                                    arrFeatureLayer.Add(featureLayer);
                            }
                        }
                    }
                    return arrFeatureLayer;
                }
                return null;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
		}
Example #17
0
        /// <summary>
        /// 获取要素集中的最大标识码
        /// </summary>
        /// <returns></returns>
        public int GetMaxEntityID()
        {
            try
            {
                int nMaxEntityID = -1;///记录最大标识码
                IEnumDataset pEnumDataset = m_pIDataset.Subsets;
                IDataset pSet = pEnumDataset.Next();
                int nEntityID = -1;
                ///遍历数据集获取各个表中的标识码
                while (pSet != null)
                {
                    ITable pTable = pSet as ITable;

                    ///从配置表中获取标识码字段
                    string sEntityFiled = "";
                    Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.GetMetaTalbleByName(pSet.Name) as Metadata.MetaTable;
                    if (pMetaTable != null)
                    {   
                        sEntityFiled = pMetaTable.EntityIDFiledName;

                        ////仅读取当前标准下的数据
                        ICursor pCursor = pTable.Search(null, true);
                        IRow pRow = pCursor.NextRow();
                        while (pRow != null)
                        {
                            ///获取表中的最大标识码
                            int nIndex = pRow.Fields.FindField(sEntityFiled);
                            if (nIndex != -1)
                            {
                                //if (!VCTFile.ConvertToInt32(pRow.get_Value(nIndex).ToString(), out nEntityID))
                                {

                                    nEntityID = pRow.get_Value(nIndex) == null || pRow.get_Value(nIndex).ToString() == "" ? -1 : Convert.ToInt32(pRow.get_Value(nIndex));
                                }
                                if (nEntityID > nMaxEntityID)
                                    nMaxEntityID = nEntityID;
                            }
                            pRow = pCursor.NextRow();
                        }
                    }
                    pSet = pEnumDataset.Next();
                }
                return nMaxEntityID;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return -1;
            }
        }
Example #18
0
        /// <summary>
        /// 获取实体集合
        /// </summary>
        public override List<FeatureEntity> GetFeatureEntitys()
        {
            try
            {
                IFeatureClass pFeatureCls = this.Table as IFeatureClass;
                IFeatureCursor pCursor = pFeatureCls.Search(null, false);
                IFeature pFeature = pCursor.NextFeature();
                List<FeatureEntity> listFeatureEnty = new List<FeatureEntity>();//保存FeatureEntity
                while (pFeature != null)
                {
                    ///add by 曾平2011-9-7 添加裁切判断
                    ///裁切范围为空表示不进行裁切
                    if (m_CutGeometry != null)
                    {
                        if (!FeatureInCutRegion(pFeature.Shape))
                        {
                            pFeature = pCursor.NextFeature();
                            continue;
                        }
                    }

                    PolygonEntity pPointEntity = new PolygonEntity();
                    pPointEntity.CutGeometry = m_CutGeometry;
                    pPointEntity.IsCut = m_bCut;
                    pPointEntity.Feature = pFeature;
                    ///初始化相关数据
                    //pPointEntity.GetEntityNode();
                    pPointEntity.FeatureCode = this.FeatureCode;
                    int nEntityIDIndex = -1;
                    nEntityIDIndex = pFeature.Fields.FindField(m_strEntityFieldName);
                    if(nEntityIDIndex!=-1)
                        pPointEntity.EntityID =Convert.ToInt32( pFeature.get_Value(nEntityIDIndex));


                    ///设置要素代码和标识码
                    pPointEntity.SetFeatureKeyFieldName(m_strEntityFieldName, m_strSYDMFieldName);


                    listFeatureEnty.Add(pPointEntity);
                    pFeature = pCursor.NextFeature();
                }
                m_FeatureEntys = listFeatureEnty;
                return listFeatureEnty;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Example #19
0
 /// <summary>
 /// 获取VCT表节点
 /// </summary>
 public TableNode GetTableNode()
 {
     try
     {
         TableNode pTableNode = new TableNode();
         pTableNode.TableName = (this.m_pITable as IDataset).Name;
         return(pTableNode);
     }
     catch (Exception ex)
     {
         LogAPI.WriteErrorLog(ex);
         return(null);
     }
 }
Example #20
0
        private List <FieldNode> GetFieldNodes(IFields pFields)
        {
            try
            {
                IFeatureClass    pFeatureCls    = this.m_pITable as IFeatureClass;
                List <FieldNode> pListFieldNode = new List <FieldNode>();

                for (int i = 0; i < pFields.FieldCount; i++)
                {
                    IField itemField = pFields.get_Field(i);
                    ///只保持属性字段
                    if (itemField.Type != esriFieldType.esriFieldTypeGeometry &&
                        itemField.Type != esriFieldType.esriFieldTypeOID &&
                        itemField.Name.ToUpper() != "SHAPE_LENGTH" &&
                        itemField.Name.ToUpper() != "SHAPE_AREA"
                        )
                    {
                        if (pFeatureCls != null && pFeatureCls.FeatureType == esriFeatureType.esriFTAnnotation)
                        {
                            AddAnnotationFieldNode(itemField, pListFieldNode);
                        }
                        else
                        {
                            string sLine = "";
                            if (itemField.Precision != null && itemField.Precision != 0)
                            {
                                sLine = itemField.Name + HeadNode.Separator
                                        + GetVCTFieldType(itemField.Type) + HeadNode.Separator
                                        + itemField.Length + HeadNode.Separator
                                        + itemField.Precision;
                            }
                            else
                            {
                                sLine = itemField.Name + HeadNode.Separator
                                        + GetVCTFieldType(itemField.Type) + HeadNode.Separator
                                        + itemField.Length;
                            }
                            FieldNode pFieldNode = new FieldNode(sLine);
                            pListFieldNode.Add(pFieldNode);
                        }
                    }
                }
                return(pListFieldNode);
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return(null);
            }
        }
Example #21
0
		/// <summary>
		/// 创建注记实体
		/// </summary>
        /// <param name="pITable">数据表对象</param>
        /// <param name="entinyNode">VCT空间实体节点</param>
        public override void CreateFeature(ITable pITable, EntityNode entinyNode)
        {
            try
            {
                AnnotationNode pAnnotationNode = entinyNode as AnnotationNode;
                if (pAnnotationNode != null)
                {
                    IFeatureClass pFeatureCls = pITable as IFeatureClass;
                    this.Feature = pFeatureCls.CreateFeature();

                    ///标识码赋值
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        this.Feature.set_Value(dBSMIndex, pAnnotationNode.EntityID);

                    ///要素代码赋值
                    int dSYDMIndex = -1;
                    dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
                    if (dSYDMIndex != -1)
                        this.Feature.set_Value(dSYDMIndex, pAnnotationNode.FeatureCode);

                    IAnnotationFeature pAnnotationFeature = Feature as IAnnotationFeature;
                    if (pAnnotationFeature != null)
                    {
                        /////注记内容赋值
                        ITextElement pTextElement = new TextElementClass();
                        ITextSymbol pTextSymbol = new TextSymbolClass();
                        pTextSymbol.Angle = pAnnotationNode.Angle;


                        pTextElement.Text = pAnnotationNode.Text;
                        pTextElement.Symbol = pTextSymbol;
                        pAnnotationFeature.Annotation = pTextElement as IElement;
                    }

                    IPoint pPoint = new PointClass();
                    pPoint.PutCoords(pAnnotationNode.PointLocation.X, pAnnotationNode.PointLocation.Y);

                    (this.Feature as IFeature).Shape = pPoint;

                    this.Feature.Store();
                }
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
		}
Example #22
0
		/// <summary>
		/// 获取图层数
		/// </summary>
		public int GetLayerCount()
        {
            //if (m_pIDataset == null)
            //    return 0;
            //else
            //{
            //    ///获取空间数据集合
            //    IEnumDataset pDataSet = m_pIDataset.Subsets;
            //    IDataset set = pDataSet.Next();
            //    int count = 0;
            //    while (set!=null)
            //    {
            //        ///仅处理当前标准下的数据
            //        Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.GetMetaTalbleByName(set.Name) as Metadata.MetaTable;
            //         if (pMetaTable != null)
            //         {
            //             IFeatureClass pFeatureClass = set as IFeatureClass;
            //             if (pFeatureClass != null && (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation
            //                 || pFeatureClass.FeatureType == esriFeatureType.esriFTSimple))
            //                 count++;
            //         }
            //        set = pDataSet.Next();
            //    }
            //    ///获取属性数据集合
            //    IEnumDataset pAttriTalbelDataSet=  m_pIWorkspace.get_Datasets(esriDatasetType.esriDTTable);
            //    IDataset pAttriDataset = pAttriTalbelDataSet.Next();
            //    while (pAttriDataset != null)
            //    {
            //        ///仅处理当前标准下的数据
            //        Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.GetMetaTalbleByName(pAttriDataset.Name) as Metadata.MetaTable;
            //        if (pMetaTable != null)
            //        {
            //            count++;
            //        }
            //        pAttriDataset = pAttriTalbelDataSet.Next();
            //    }
            //    return count;
            //}
            try
            {
                return m_FeatureList.Count;
            }
            catch(Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return 0;
            }
		}
Example #23
0
        /// <summary>
        /// 创建属性表
        /// </summary>
        /// <param name="pFeatureWorkspace"></param>
        /// <param name="tableStructureNode"></param>
        /// <param name="featureCodeNode"></param>
        /// <returns></returns>
        private TableLayer CreateTableLayer(IFeatureWorkspace pFeatureWorkspace, TableStructureNode tableStructureNode, FeatureCodeNode featureCodeNode)
        {
            try
            {
                if (pFeatureWorkspace != null&&tableStructureNode!=null&&featureCodeNode!=null)
                {
                    IObjectClassDescription ocDescription = new ObjectClassDescriptionClass();
                    ///创建数据表字段
                    IFieldChecker fieldChecker = new FieldCheckerClass();
                    IFields validatedFields = CreateFileds(tableStructureNode, featureCodeNode);
                    ///字段信息验证
                    IFields fixFields = null;
                    fieldChecker.ValidateWorkspace = pFeatureWorkspace as IWorkspace;
                    IEnumFieldError enumFieldError = null;
                    fieldChecker.Validate(validatedFields, out enumFieldError, out fixFields);

                    ITable pTable = pFeatureWorkspace.CreateTable(tableStructureNode.TableName, fixFields,
                        ocDescription.InstanceCLSID, null, "");
                    if (pTable != null)
                    {
                        TableLayer pTableLayer = new TableLayer();

                        //从配置文件读取图形类型
                        string sGeometryType = "";
                        Metadata.MetaTable pMetaTalbe = Metadata.MetaDataFile.MetaTabls[tableStructureNode.TableName] as Metadata.MetaTable;
                        if (pMetaTalbe != null)
                        {
                            sGeometryType = pMetaTalbe.Type;
                        }
                        else
                            return null;

                        pTableLayer.GeometryType = sGeometryType;
                        pTableLayer.Table = pTable;
                        pTableLayer.UpdateFieldIndex();
                        return pTableLayer;
                    }
                    return null;
                }
                return null;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
        }
Example #24
0
        /// <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);
            }
        }
Example #25
0
        /// <summary>
        /// 获取VCT表结构节点
        /// </summary>
        private TableStructureNode GetTableStructureNode()
        {
            try
            {
                m_TableStructureNode = new TableStructureNode();
                ///判断当前是否为空间数据表
                if (m_pITable is IFeatureClass)
                {
                    m_TableStructureNode.IsGeometryTable = true;
                    IFeatureClass pFeatureCls = this.m_pITable as IFeatureClass;
                    ///获取表名称
                    m_TableStructureNode.TableName = (m_pITable as IDataset).Name;
                }
                else
                {
                    m_TableStructureNode.IsGeometryTable = false;
                    //m_TableStructureNode.TableName = (m_pITable as IObjectClass).AliasName;
                    m_TableStructureNode.TableName = (m_pITable as IDataset).Name;
                }
                //获取字段信息
                m_TableStructureNode.FieldNodes = GetFieldNodes(m_pITable.Fields);

                ///通过配置获取标识码字段名称
                string sKeyFieldName = "";
                sKeyFieldName = Metadata.MetaDataFile.GetEntityIDFieldName(m_TableStructureNode.TableName);
                if (sKeyFieldName != "")
                {
                    m_strEntityFieldName = sKeyFieldName;
                }

                ///通过配置获取要素代码字段名称
                sKeyFieldName = Metadata.MetaDataFile.GetYSDMFieldName(m_TableStructureNode.TableName);
                if (sKeyFieldName != "")
                {
                    m_strEntityFieldName = sKeyFieldName;
                }
                return(m_TableStructureNode);
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return(null);
            }
        }
Example #26
0
        /// <summary>
        /// 从mdb导出到vct时,初始化空间参考
        /// </summary>
        /// <returns></returns>
        private bool InitialProjection()
        {
            if (m_pIDataset == null)
                return false;
            try
            {
                IGeoDataset geoDataset = (IGeoDataset)m_pIDataset;
                ISpatialReference pSpatialReference = geoDataset.SpatialReference;

                m_Projection = new Projection(pSpatialReference, this.m_pIDataset.Workspace);

                return true;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return false;
            }
        }
Example #27
0
        /// <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)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }

        }
Example #28
0
        public bool ExecuteNonQuery(string commandText)
        {
            if (m_pOleDbConnection != null)
            {
                try
                {
                    OleDbCommand oleDbCommand = new OleDbCommand(commandText, m_pOleDbConnection);

                    oleDbCommand.ExecuteNonQuery();

                    return(true);
                }
                catch (Exception ex)
                {
                    LogAPI.WriteErrorLog(ex);
                }
            }
            return(false);
        }
Example #29
0
        /// <summary>
        /// vct转mdb的时候创建esri数据集
        /// </summary>
        /// <param name="pWorkspace"></param>
        /// <param name="sDatasetName"></param>
        /// <param name="pHeadnode"></param>
        /// <returns></returns>
        public bool CreateESRIDataset(string strDatasetName, HeadNode pHeadnode)
        {
            try
            {
                ISpatialReference pISpatialReference = CreateProjection(pHeadnode);
                if (pISpatialReference != null)
                {
                    IFeatureWorkspace pIFeatureWorkspace = this.m_pIWorkspace as IFeatureWorkspace;
                    this.m_pIDataset = pIFeatureWorkspace.CreateFeatureDataset(strDatasetName, pISpatialReference);
                    return true;
                }

            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
            }
            return false;
        }
Example #30
0
		/// <summary>
		/// 获取VCT注记实体节点
		/// </summary>
		public override EntityNode GetEntityNode()
        {
            try
            {
                AnnotationNode pAnnotationNode = new AnnotationNode();

                //特征类型统一设置为单点注记
                pAnnotationNode.AnnotationType = Convert.ToInt32(Metadata.MetaDataFile.GraphConfig.GetGraphSymbol("ANNOTATIONFEATURETYPE", "SingPointAnnotation"));
                IFeature pFeature = this.Feature as IFeature;
                if (pFeature != null)
                {
                    ///标识码赋值
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        pAnnotationNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex));

                    ///要素代码赋值
                        pAnnotationNode.FeatureCode = this.FeatureCode;

                    ///图形表现赋值 
                     //pAnnotationNode.Representation = pFeature.Class.AliasName;

                    ///注记坐标赋值

                     IGeometry5 pArea = pFeature.Shape as IGeometry5;
                     if (pArea != null)
                     {
                         PointInfoNode pPTInfoNode = new PointInfoNode(pArea.CentroidEx.X, pArea.CentroidEx.Y);
                         pAnnotationNode.PointLocation = pPTInfoNode;
                     }
                    m_AnnotationNode = pAnnotationNode;
                    return pAnnotationNode;
                }
                return null;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return null;
            }
		}