public override void OnClick() { Exception eError = null; //FrmMathematicsCheck mFrmMathematicsCheck = new FrmMathematicsCheck(_AppHk, enumErrorType.数学基础正确性); //mFrmMathematicsCheck.ShowDialog(); FrmMathCheck pFrmMathCheck = new FrmMathCheck(); if (pFrmMathCheck.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 if (_AppHk.DataTree == null) { return; } _AppHk.DataTree.Nodes.Clear(); //创建处理树图 IntialTree(_AppHk.DataTree); //设置树节点颜色 setNodeColor(_AppHk.DataTree); _AppHk.DataTree.Tag = false; string prjStr = pFrmMathCheck.PRJFNAME; if (prjStr == "") { return; } try { ISpatialReferenceFactory spatialRefFac = new SpatialReferenceEnvironmentClass(); ISpatialReference standardSpatialRef = spatialRefFac.CreateESRISpatialReferenceFromPRJFile(prjStr); for (int i = 0; i < LstFeaClass.Count; i++) { IFeatureClass pFeatureClass = LstFeaClass[i]; string pFeaClsNameStr = "";//图层名 pFeaClsNameStr = (pFeatureClass as IDataset).Name.Trim(); //创建树图节点(以图层名作为根结点) DevComponents.AdvTree.Node pNode = new DevComponents.AdvTree.Node(); pNode = (DevComponents.AdvTree.Node)CreateAdvTreeNode(_AppHk.DataTree.Nodes, pFeaClsNameStr, pFeaClsNameStr, _AppHk.DataTree.ImageList.Images[6], true);//图层名节点 //显示进度条 ShowProgressBar(true); int tempValue = 0; ChangeProgressBar((_AppHk as Plugin.Application.IAppFormRef).ProgressBar, 0, 1, tempValue); dataCheckCls.MathematicsCheck(pFeatureClass, standardSpatialRef, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数学基础性正确检查失败。" + eError.Message); pSysLog.CloseDbConnection(); return; } tempValue += 1;//进度条的值加1 ChangeProgressBar((_AppHk as Plugin.Application.IAppFormRef).ProgressBar, -1, -1, tempValue); //改变树图运行状态 ChangeTreeSelectNode(pNode, "完成图层" + pFeaClsNameStr + "的数据基础性正确检查", false); } SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据检查完成!"); pSysLog.CloseDbConnection(); //隐藏进度条 ShowProgressBar(false); } catch (Exception ex) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", ex.Message); pSysLog.CloseDbConnection(); return; } } }
/// <summary> /// 单击开始检查时 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_enter_Click(object sender, EventArgs e) { Exception eError = null; if (txtRange.Text == "") { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择接边范围数据库!"); return; } SysCommon.Gis.SysGisDataSet pRangeGisDB = new SysCommon.Gis.SysGisDataSet(); pRangeGisDB.SetWorkspace(txtRange.Text.ToString().Trim(), SysCommon.enumWSType.PDB, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边范围数据库连接失败!"); return; } if (ShowException()) { #region 错误日志连接信息 string logPath = txtLog.Text; if (logPath.Trim() == string.Empty) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择日志输出路径!"); return; } if (File.Exists(logPath)) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据文件已存在!\n" + logPath); } //生成日志信息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("提示", "插入表头出错!"); return; } #endregion double AreaValue = Convert.ToDouble(txt_area.Text); //范围容差 double SearchValue = Convert.ToDouble(txt_search.Text); //搜索容差 DataCheckClass JoinChecks = new DataCheckClass(_AppHk); //将日志表连接信息和表名保存起来 JoinChecks.ErrDbCon = pSysLog.DbConn; JoinChecks.ErrTableName = "错误日志"; JoinChecks.AREAValue = AreaValue; JoinChecks.SEARCHValue = SearchValue; 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数据检查配置表连接失败!"); return; } //获得接边范围的图层名和字段名 DataTable mTable = GetParaValueTable(pSysTable, 39, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "查询GIS数据检察配置表失败!"); return; } if (mTable.Rows.Count == 0) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未进行接边检查参数的配置!"); return; } string rangeLayerName = mTable.Rows[0]["图层"].ToString().Trim(); string rangeFieldName = mTable.Rows[0]["字段项"].ToString().Trim(); if (rangeFieldName == "" || rangeLayerName == "") { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "接边检查参数配置不完整!"); return; } //设置界面上初始显示的属性表 TreeLayer.Nodes[Convert.ToInt32(dataGridViewX1.Tag)].Name = ""; for (int d = 0; d < dataGridViewX1.Rows.Count; d++) { if (Convert.ToBoolean(dataGridViewX1.Rows[d].Cells[0].Value) == true) { string temp = dataGridViewX1.Rows[d].Cells[1].Value.ToString(); TreeLayer.Nodes[Convert.ToInt32(dataGridViewX1.Tag)].Name += temp + " "; } } if (!JoinChecks.Initialize_Tree(pRangeGisDB, rangeLayerName, rangeFieldName, _AppHk.DataTree, TreeLayer, _AppHk, out eError)) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "初始化树图失败!"); return; } //int Pur = PurviewState();//验证是管理员还是作业员 ///说明:作业员以图幅去进行接边处理,管理员以任务区范围去接边处理 //if (Pur == 1) //{ ////管理员 ////初始化数据处理树图 //if (!JoinChecks.Initialize_Tree("任务区范围", "CASE_NAME", _AppHk.DataTree, TreeLayer, _AppHk)) //{ // return; //} //} //else if(Pur == 0) //{ // //作业员 // //初始化数据处理树图 // if (!JoinChecks.Initialize_Tree("图幅范围", "MAP_ID", _AppHk.DataTree, TreeLayer, _AppHk)) // { // return; // } //} this.Close(); //数据接边检查 //用线程做速度会很慢主要体现在要素空间查询时 //System.Threading.ParameterizedThreadStart parstart = new System.Threading.ParameterizedThreadStart(JoinChecks.DoJoinCheck); //Thread aThread = new Thread(parstart); //_AppHk.CurrentThread = aThread; //aThread.Priority = ThreadPriority.Highest; //aThread.Start(_AppHk as object);, Pur int Pur = 0; //以图幅进行接边 JoinChecks.DoJoinCheck(_AppHk as object, Pur); } }
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; } } }
public override void OnClick() { Exception eError = null; #region 初始化错误列表,并绑定到DataGrid上面 //_ResultTable = new DataTable(); //_ResultTable.Columns.Add("要素类名称", typeof(string)); //_ResultTable.Columns.Add("OBJECTID", typeof(string)); //_ResultTable.Columns.Add("错误名", typeof(string)); //_ResultTable.Columns.Add("具体描述", typeof(string)); //_ResultTable.Columns.Add("检查时间", typeof(string)); //_AppHk.DataCheckGrid.DataSource = null; //_AppHk.DataCheckGrid.DataSource = _ResultTable; //_AppHk.DataCheckGrid.Visible = true; //_AppHk.DataCheckGrid.ReadOnly = true; //_AppHk.DataCheckGrid.SelectionMode = DataGridViewSelectionMode.FullRowSelect; //for (int j = 0; j < _AppHk.DataCheckGrid.Columns.Count; j++) //{ // _AppHk.DataCheckGrid.Columns[j].Width = (_AppHk.DataCheckGrid.Width - 15) / _AppHk.DataCheckGrid.Columns.Count; //} //_AppHk.DataCheckGrid.RowHeadersWidth = 20; #endregion #region 获得要检查的IFeatureLayer的集合 //将Mapcontrol上所有的图层名保存起来 List <IFeatureLayer> LstFeaLayer = new List <IFeatureLayer>(); for (int i = 0; i < _AppHk.MapControl.LayerCount; i++) { ILayer player = _AppHk.MapControl.get_Layer(i); if (player is IGroupLayer) { if (player.Name == "范围") { continue; } 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) { return; } if (!LstFeaLayer.Contains(mfeatureLayer)) { LstFeaLayer.Add(mfeatureLayer); } } } else { IFeatureLayer pfeatureLayer = player as IFeatureLayer; if (pfeatureLayer == null) { return; } if (!LstFeaLayer.Contains(pfeatureLayer)) { LstFeaLayer.Add(pfeatureLayer); } } } #endregion string path = TopologyCheckClass.GeoDataCheckParaPath;// Application.StartupPath + "\\..\\Res\\checker\\GeoCheckPara.mdb"; Plugin.Application.IAppFormRef pAppForm = _AppHk as Plugin.Application.IAppFormRef; #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 //_CodeErrorPro = new clsCodeCheckProccess(); ClsCodeCheck CodeErrerCheck = new ClsCodeCheck(_AppHk, path, LstFeaLayer); CodeErrerCheck.ErrDbCon = pSysLog.DbConn; CodeErrerCheck.ErrTableName = "错误日志"; //CodeErrerCheck.FindErr += new GOGISErrorChecker.EventHandle(CodeErrerCheck_FindErr); //CodeErrerCheck.ProgressStep += new GOGISErrorChecker.ProgressHandle(CodeErrerCheck_ProgressStep); pAppForm.ProgressBar.Visible = true; CodeErrerCheck.ExcuteCheck(); pAppForm.ProgressBar.Visible = false; pSysLog.CloseDbConnection(); //_CodeErrorPro.Dispose(); }
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; } }
private void buttonX2_Click(object sender, EventArgs e) { Exception eError = null; //等高线方向 string orient = cmbOrient.SelectedItem.ToString().Trim(); //错误日志连接信息 string logPath = txtLog.Text; if (logPath.Trim() == string.Empty) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择日志输出路径!"); return; } if (File.Exists(logPath)) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "数据文件已存在!\n" + logPath); } #region 生成日志信息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; } #endregion DataCheckClass dataCheckCls = new DataCheckClass(_AppHk); //将日志表连接信息和表名保存起来 dataCheckCls.ErrDbCon = pSysLog.DbConn; dataCheckCls.ErrTableName = "错误日志"; #region 连接GIS数据检察配置表 ,并获取相关参数 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为20 string pFeaClsName = GetParaValue(pSysTable, 20, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message); pSysLog.CloseDbConnection(); pSysTable.CloseDbConnection(); return; } //等高线要素类 IFeatureClass pFeaCls = GetLineFeaCls(pFeaClsName); if (pFeaCls == null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在等高线图层,图层名为:" + pFeaClsName); pSysLog.CloseDbConnection(); pSysTable.CloseDbConnection(); return; } //等高线高程字段名,参数ID23 string pFieldName = GetParaValue(pSysTable, 23, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message); pSysLog.CloseDbConnection(); pSysTable.CloseDbConnection(); return; } //等高线高程间距参数值,参数ID为21 string paraValue = GetParaValue(pSysTable, 21, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "读取数据减配置表失败。" + eError.Message); pSysLog.CloseDbConnection(); pSysTable.CloseDbConnection(); return; } double intevalValue = Convert.ToDouble(paraValue); //执行等高线高程值检查 dataCheckCls.LineIntervalCheck(pFeaCls, pFieldName, m_PolyLine, intevalValue, orient, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "等高线高程值检查失败。" + eError.Message); pSysLog.CloseDbConnection(); pSysTable.CloseDbConnection(); return; } #endregion pSysLog.CloseDbConnection(); pSysTable.CloseDbConnection(); this.Close(); }
private void btnOk_Click(object sender, EventArgs e) { string logPath = txtLog.Text; if (logPath.Trim() == string.Empty) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "请选择日志输出路径!"); return; } if (File.Exists(logPath)) { if (SysCommon.Error.ErrorHandle.ShowFrmInformation("是", "否", "数据文件已存在!\n" + logPath)) { File.Delete(logPath); } else { return; } } GeoDataChecker.DoDispose(); Exception errEx = null; //连接配置参数信息 SysDB = new SysCommon.DataBase.SysDataBase(); SysDB.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + TopologyCheckClass.GeoDataCheckParaPath, SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out errEx); //SysDB.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + GeoDataChecker.GeoCheckParaPath, SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out errEx); if (SysDB.DbConn == null) { return; } if (!File.Exists(GeoDataChecker.DBSchemaPath)) { return; } if (!File.Exists(GeoDataChecker.GeoCheckXmlPath)) { return; } //生成日志信息EXCEL格式 SysDataBaseLog = new SysCommon.DataBase.SysDataBase(); SysDataBaseLog.SetDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + logPath + "; Extended Properties=Excel 8.0;", SysCommon.enumDBConType.OLEDB, SysCommon.enumDBType.ACCESS, out errEx); if (SysDataBaseLog.DbConn == null) { 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 += @" ) "; SysDataBaseLog.UpdateTable(strCreateTableSQL, out errEx); if (errEx != null) { SysDataBaseLog.CloseDbConnection(); return; } # region 库体结构检查 foreach (ListViewItem aItem in listViewEx.CheckedItems)