Esempio n. 1
0
        public override void OnClick()
        {
            //FrmMathematicsCheck mFrmMathematicsCheck = new FrmMathematicsCheck(_AppHk, enumErrorType.线长度逻辑性);
            //mFrmMathematicsCheck.ShowDialog();

            Exception eError = null;

            FrmLineLengthCheck pFrmLineLengthCheck = new FrmLineLengthCheck();

            if (pFrmLineLengthCheck.ShowDialog() == DialogResult.OK)
            {
                #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;
                    }

                    //分类代码字段名
                    string codeName = TopologyCheckClass.GetCodeName(pSysTable, out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                        pSysLog.CloseDbConnection();
                        pSysTable.CloseDbConnection();
                        return;
                    }

                    DataTable mTable = TopologyCheckClass.GetParaValueTable(pSysTable, 3, out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                        pSysLog.CloseDbConnection();
                        pSysTable.CloseDbConnection();
                        return;
                    }
                    if (mTable.Rows.Count == 0)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未进行线长度检查配置!");
                        pSysLog.CloseDbConnection();
                        pSysTable.CloseDbConnection();
                        return;
                    }
                    //执行线长度逻辑性检查
                    double pmax = pFrmLineLengthCheck.MaxValue;
                    double pmin = pFrmLineLengthCheck.MinValue;
                    LineLogicCheck(dataCheckCls, LstFeaClass, mTable, codeName, pmin.ToString(), pmax.ToString(), out eError);
                    if (eError != null)
                    {
                        SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "线长度逻辑性检查失败。" + eError.Message);
                        pSysLog.CloseDbConnection();
                        pSysTable.CloseDbConnection();
                        return;
                    }
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据检查完成!");

                    pSysLog.CloseDbConnection();
                    pSysTable.CloseDbConnection();
                    //隐藏进度条
                    dataCheckCls.ShowProgressBar(false);
                }
                catch (Exception ex)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message);
                    pSysLog.CloseDbConnection();
                    return;
                }
            }
        }
Esempio n. 2
0
        public void OnDataCheck()
        {
            Exception eError = null;

            if (Hook == null)
            {
                return;
            }
            IArcgisDataCheckParaSet dataCheckParaSet = Hook.DataCheckParaSet as IArcgisDataCheckParaSet;

            if (dataCheckParaSet == null)
            {
                return;
            }
            if (dataCheckParaSet.Workspace == null)
            {
                return;
            }

            //实现代码
            SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable();
            pSysTable.DbConn    = dataCheckParaSet.DbConnPara;
            pSysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            pSysTable.DBType    = SysCommon.enumDBType.ACCESS;

            //分类代码字段名
            string codeName = TopologyCheckClass.GetCodeName(pSysTable, out eError);

            if (eError != null)
            {
                //eError=new Exception(eError.Message);
                return;
            }

            //等高线注记检查,参数ID为31
            DataTable mTable = TopologyCheckClass.GetParaValueTable(pSysTable, 31, out eError);

            if (eError != null)
            {
                //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
                return;
            }
            if (mTable.Rows.Count == 0)
            {
                //eError = new Exception("未进行等高线注记一致性检查参数配置!");
                return;
            }
            //等高线注记检查搜索半径,参数ID为34
            string paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 34, out eError);

            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            double serchRadiu3 = Convert.ToDouble(paraValue3);

            //等高线注记检查精度控制,参数ID为37
            paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 37, out eError);
            if (eError != null)
            {
                eError = new Exception("读取数据减配置表失败。" + eError.Message);
                return;
            }
            long precision3 = Convert.ToInt64(paraValue3);

            SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            List <IDataset>             LstFeaClass   = sysGisDataSet.GetAllFeatureClass();

            if (LstFeaClass.Count == 0)
            {
                return;
            }

            //执行等高线注记检查
            PointAnnoCheck(Hook, LstFeaClass, mTable, codeName, serchRadiu3, precision3, out eError);
            if (eError != null)
            {
                eError = new Exception("等高线注记检查失败。" + eError.Message);
                return;
            }

            #region 分类代码字段名
            //string codeName = TopologyCheckClass.GetCodeName(pSysTable, out eError);
            //if (eError != null)
            //{
            //    //eError=new Exception(eError.Message);
            //    return;
            //}

            ////获取所有数据集
            //SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace);
            //List<string> featureDatasetNames = sysGisDataSet.GetAllFeatureDatasetNames();
            //if (featureDatasetNames.Count == 0) return;
            //foreach (string name in featureDatasetNames)
            //{
            //    IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError);
            //    if (eError != null) continue;


            //    //等高线注记检查,参数ID为31
            //    DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 31, out eError);
            //    if (eError != null)
            //    {
            //        //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message);
            //        return;
            //    }
            //    if (mTable.Rows.Count == 0)
            //    {
            //        continue;
            //    }
            //    //等高线注记检查搜索半径,参数ID为34
            //    string paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 34, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    double serchRadiu3 = Convert.ToDouble(paraValue3);
            //    //等高线注记检查精度控制,参数ID为37
            //    paraValue3 = TopologyCheckClass.GetParaValue(pSysTable, 37, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("读取数据减配置表失败。" + eError.Message);
            //        return;
            //    }
            //    long precision3 = Convert.ToInt64(paraValue3);
            //    //执行等高线注记检查
            //    PointAnnoCheck(Hook, featureDataset, mTable, codeName, serchRadiu3, precision3, out eError);
            //    if (eError != null)
            //    {
            //        eError = new Exception("等高线注记检查失败。" + eError.Message);
            //        return;
            //    }
            //}
            #endregion
        }