Exemple #1
0
        /// <summary>
        /// 高程值检查
        /// </summary>
        /// <param name="pDataCheckClass"></param>
        /// <param name="pFeaDataset"></param>
        /// <param name="pTable"></param>
        /// <param name="ElevMin">最小高程值</param>
        /// <param name="ElevMax">最大高程值</param>
        /// <param name="eError"></param>
        private void ElevValueCheck(DataCheckClass pDataCheckClass, List <IFeatureClass> LstFeaClass, DataTable pTable, string ElevMin, string ElevMax, out Exception eError)
        {
            eError = null;

            if (_AppHk.DataTree == null)
            {
                return;
            }
            _AppHk.DataTree.Nodes.Clear();
            //创建处理树图
            pDataCheckClass.IntialTree(_AppHk.DataTree);
            //设置树节点颜色
            pDataCheckClass.setNodeColor(_AppHk.DataTree);
            _AppHk.DataTree.Tag = false;

            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                string pFeaClsName = pTable.Rows[i]["图层"].ToString().Trim();  //图层名
                string fieldName   = pTable.Rows[i]["字段项"].ToString().Trim(); //高程字段名
                if (pFeaClsName == "")
                {
                    eError = new Exception("图层名为空!");
                    return;
                }
                if (fieldName == "")
                {
                    eError = new Exception("字段名为空!");
                    return;
                }

                //创建树图节点(以图层名作为根结点)
                DevComponents.AdvTree.Node pNode = new DevComponents.AdvTree.Node();
                pNode = (DevComponents.AdvTree.Node)pDataCheckClass.CreateAdvTreeNode(_AppHk.DataTree.Nodes, pFeaClsName, pFeaClsName, _AppHk.DataTree.ImageList.Images[6], true);//图层名节点


                pDataCheckClass.CoutourValueCheck(LstFeaClass, pFeaClsName, fieldName, ElevMin, ElevMax, out eError);
                if (eError != null)
                {
                    return;
                }

                //改变树图运行状态
                pDataCheckClass.ChangeTreeSelectNode(pNode, "完成图层" + pFeaClsName + "高程值检查!", false);
            }
        }
Exemple #2
0
        /// <summary>
        /// 控制点高程注记检查、高程点高程注记检查、等高线高程注记检查
        /// </summary>
        /// <param name="pDataCheckClass"></param>
        /// <param name="pFeaDataset"></param>
        /// <param name="pTable"></param>
        /// <param name="codeName">分类代码名称</param>
        /// <param name="radiu">搜索半径</param>
        /// <param name="precision">精度控制</param>
        /// <param name="eError"></param>
        private void PointAnnoCheck(DataCheckClass pDataCheckClass, List <IFeatureClass> LstFeaClass, DataTable pTable, string codeName, double radiu, long precision, out Exception eError)
        {
            eError = null;

            if (_AppHk.DataTree == null)
            {
                return;
            }
            _AppHk.DataTree.Nodes.Clear();
            //创建处理树图
            pDataCheckClass.IntialTree(_AppHk.DataTree);
            //设置树节点颜色
            pDataCheckClass.setNodeColor(_AppHk.DataTree);
            _AppHk.DataTree.Tag = false;

            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                string FeaClsName = pTable.Rows[i]["图层"].ToString().Trim();  //图层名
                string FieldName  = pTable.Rows[i]["字段项"].ToString().Trim(); //字段名
                string codeValue  = pTable.Rows[i]["检查项"].ToString().Trim(); //检查项
                if ((FeaClsName == "") || (!FeaClsName.Contains(";")))
                {
                    eError = new Exception("图层名为空或配置不正确!");
                    return;
                }
                if ((FieldName == "") || (!FeaClsName.Contains(";")))
                {
                    eError = new Exception("字段名为空!");
                    return;
                }
                string oriCodeValue = "";
                string desCodeValue = "";

                string[] feaNameArr    = FeaClsName.Split(new char[] { ';' });
                string   oriFeaClsName = feaNameArr[0].Trim();       //源要素类名称
                string   desFeaClsName = feaNameArr[1].Trim();       //目标要素类名称
                string[] fieldNameArr  = FieldName.Split(new char[] { ';' });
                string   oriFieldName  = fieldNameArr[0].Trim();     //源高程字段名
                string   desFielsName  = fieldNameArr[1].Trim();     //目标高程字段名

                if (codeValue != "" && codeValue.Contains(";"))
                {
                    string[] codeValueArr = codeValue.Split(new char[] { ';' });
                    oriCodeValue = codeValueArr[0].Trim();        //源要素类分类代码限制条件
                    desCodeValue = codeValueArr[1].Trim();        //目标要素类分类代码限制条件
                }

                //创建树图节点(以图层名作为根结点)
                DevComponents.AdvTree.Node pNode = new DevComponents.AdvTree.Node();
                pNode = (DevComponents.AdvTree.Node)pDataCheckClass.CreateAdvTreeNode(_AppHk.DataTree.Nodes, oriFeaClsName, oriFeaClsName, _AppHk.DataTree.ImageList.Images[6], true);//图层名节点

                pDataCheckClass.ElevAccordanceCheck(LstFeaClass, codeName, oriFeaClsName, oriCodeValue, oriFieldName, desFeaClsName, desCodeValue, desFielsName, radiu, precision, out eError);
                if (eError != null)
                {
                    return;
                }

                //改变树图运行状态
                pDataCheckClass.ChangeTreeSelectNode(pNode, "完成图层" + oriFeaClsName + "高程点注记一致性检查!", false);
            }
        }
        public override void OnClick()
        {
            //执行等高线点线矛盾检查
            //FrmMathematicsCheck mFrmMathematicsCheck = new FrmMathematicsCheck(_AppHk, enumErrorType.等高线点线矛盾);
            //mFrmMathematicsCheck.ShowDialog();

            Exception eError = null;

            #region 错误日志保存
            //错误日志连接信息
            string logPath = TopologyCheckClass.GeoLogPath + "Log" + System.DateTime.Today.Year.ToString() + System.DateTime.Today.Month.ToString() + System.DateTime.Today.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString() + ".xls";;
            if (File.Exists(logPath))
            {
                if (SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "日志文件\n'" + logPath + "'\n已经存在,是否替换?"))
                {
                    File.Delete(logPath);
                }
                else
                {
                    return;
                }
            }
            //生成日志信息EXCEL格式
            SysCommon.DataBase.SysDataBase pSysLog = new SysCommon.DataBase.SysDataBase();
            pSysLog.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + logPath + "; Extended Properties=Excel 8.0;", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
            if (eError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "日志信息表连接失败!");
                return;
            }
            string strCreateTableSQL = @" CREATE TABLE ";
            strCreateTableSQL += @" 错误日志 ";
            strCreateTableSQL += @" ( ";
            strCreateTableSQL += @" 检查功能名 VARCHAR, ";
            strCreateTableSQL += @" 错误类型 VARCHAR, ";
            strCreateTableSQL += @" 错误描述 VARCHAR, ";
            strCreateTableSQL += @" 数据图层1 VARCHAR, ";
            strCreateTableSQL += @" 数据OID1 VARCHAR, ";
            strCreateTableSQL += @" 数据图层2 VARCHAR, ";
            strCreateTableSQL += @" 数据OID2 VARCHAR, ";
            strCreateTableSQL += @" 定位点X VARCHAR , ";
            strCreateTableSQL += @" 定位点Y VARCHAR , ";
            strCreateTableSQL += @" 检查时间 VARCHAR ,";
            strCreateTableSQL += @" 数据文件路径 VARCHAR ";
            strCreateTableSQL += @" ) ";

            pSysLog.UpdateTable(strCreateTableSQL, out eError);
            if (eError != null)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "插入表头出错!");
                pSysLog.CloseDbConnection();
                return;
            }

            DataCheckClass dataCheckCls = new DataCheckClass(_AppHk);
            //将日志表连接信息和表名保存起来
            dataCheckCls.ErrDbCon     = pSysLog.DbConn;
            dataCheckCls.ErrTableName = "错误日志";
            #endregion

            #region 获得要检查的IFeatureClass的集合
            //将Mapcontrol上所有的图层名保存起来
            List <IFeatureClass> LstFeaClass = new List <IFeatureClass>();
            for (int i = 0; i < _AppHk.MapControl.LayerCount; i++)
            {
                ILayer player = _AppHk.MapControl.get_Layer(i);
                if (player is IGroupLayer)
                {
                    ICompositeLayer pComLayer = player as ICompositeLayer;
                    for (int j = 0; j < pComLayer.Count; j++)
                    {
                        ILayer        mLayer        = pComLayer.get_Layer(j);
                        IFeatureLayer mfeatureLayer = mLayer as IFeatureLayer;
                        if (mfeatureLayer == null)
                        {
                            continue;
                        }
                        IFeatureClass pfeaCls = mfeatureLayer.FeatureClass;
                        if (!LstFeaClass.Contains(pfeaCls))
                        {
                            LstFeaClass.Add(pfeaCls);
                        }
                    }
                }
                else
                {
                    IFeatureLayer pfeatureLayer = player as IFeatureLayer;
                    if (pfeatureLayer == null)
                    {
                        continue;
                    }
                    IFeatureClass mFeaCls = pfeatureLayer.FeatureClass;
                    if (!LstFeaClass.Contains(mFeaCls))
                    {
                        LstFeaClass.Add(mFeaCls);
                    }
                }
            }
            #endregion
            try
            {
                SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
                string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + TopologyCheckClass.GeoDataCheckParaPath;
                pSysTable.SetDbConnection(conStr, SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "GIS数据检查配置表连接失败!");
                    pSysLog.CloseDbConnection();
                    return;
                }

                //高程点图层,参数ID为19(还需要改进)
                string pointFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 19, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }
                //等高线图层,参数ID为20
                string lineFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 20, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }
                //高程点高程字段名,参数ID为22
                string pointFieldsname = TopologyCheckClass.GetParaValue(pSysTable, 22, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }
                //等高线高程字段名,参数ID为23
                string lineFieldname = TopologyCheckClass.GetParaValue(pSysTable, 23, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }
                //等高线间距值,参数ID为21
                string intervalValue = TopologyCheckClass.GetParaValue(pSysTable, 21, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }
                //高程点搜索半径,参数ID为38
                string radiu = TopologyCheckClass.GetParaValue(pSysTable, 38, out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }

                if (_AppHk.DataTree == null)
                {
                    return;
                }
                _AppHk.DataTree.Nodes.Clear();
                //创建处理树图
                dataCheckCls.IntialTree(_AppHk.DataTree);
                //设置树节点颜色
                dataCheckCls.setNodeColor(_AppHk.DataTree);
                _AppHk.DataTree.Tag = false;

                //创建树图节点(以图层名作为根结点)
                DevComponents.AdvTree.Node pNode = new DevComponents.AdvTree.Node();
                pNode = (DevComponents.AdvTree.Node)dataCheckCls.CreateAdvTreeNode(_AppHk.DataTree.Nodes, pointFeaclsname, pointFeaclsname, _AppHk.DataTree.ImageList.Images[6], true);//图层名节点


                //执行等高线点线矛盾检查
                dataCheckCls.PointLineElevCheck(LstFeaClass, lineFeaclsname, lineFieldname, pointFeaclsname, pointFieldsname, Convert.ToDouble(intervalValue), out eError);
                if (eError != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "等高线点线矛盾检查失败!" + eError.Message);
                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    return;
                }
                //改变树图运行状态
                dataCheckCls.ChangeTreeSelectNode(pNode, "完成图层" + pointFeaclsname + "等高线点线矛盾检查!", false);

                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据检查完成!");


                pSysLog.CloseDbConnection();
                pSysTable.CloseDbConnection();
                //隐藏进度条
                dataCheckCls.ShowProgressBar(false);
            }
            catch (Exception ex)
            {
                SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
                pSysLog.CloseDbConnection();
                return;
            }
        }