/// <summary> /// 获得错误列表,等高线点线矛盾 /// </summary> /// <param name="pFeatureDataset"></param> /// <param name="pFeatureCls"></param> /// <param name="feaClsname"></param> /// <param name="pFeature"></param> /// <param name="eErrorID"></param> /// <param name="eError"></param> private void GetErrorList(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, IFeatureClass pOriFeatureCls, IFeature pOriFeature, IFeatureClass pDesFeatureCls, IFeature pDesFeature, int eErrorID, string eErrorDes, out Exception eError) { eError = null; try { double pMapx = 0.0; double pMapy = 0.0; IPoint pPoint = null; //高程值不在给定的高程范围内,将错误结果保存下来 if (pOriFeatureCls.ShapeType != esriGeometryType.esriGeometryPoint) { pPoint = TopologyCheckClass.GetPointofFeature(pOriFeature); } else { pPoint = pOriFeature.Shape as IPoint; } pMapx = pPoint.X; pMapy = pPoint.Y; List <object> ErrorLst = new List <object>(); ErrorLst.Add("要素属性检查"); //功能组名称 ErrorLst.Add("等高线点线矛盾检查"); //功能名称 if (pFeatureDataset == null) { ErrorLst.Add(""); //数据文件名 } else { ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名 } ErrorLst.Add(eErrorID); //错误id; ErrorLst.Add(eErrorDes); //错误描述 ErrorLst.Add(pMapx); //... ErrorLst.Add(pMapy); //... ErrorLst.Add((pOriFeatureCls as IDataset).Name); ErrorLst.Add(pOriFeature.OID); ErrorLst.Add((pDesFeatureCls as IDataset).Name); ErrorLst.Add(pDesFeature.OID); ErrorLst.Add(false); ErrorLst.Add(System.DateTime.Now.ToString()); //传递错误日志 IDataErrInfo dataErrInfo = new DataErrInfo(ErrorLst); DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo); DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent); } catch (Exception ex) { eError = ex; } }
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; //获取所有数据集 SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace); List <string> featureDatasetNames = sysGisDataSet.GetAllFeatureDatasetNames(); if (featureDatasetNames.Count == 0) { return; } //设置进度条 ProgressChangeEvent eInfo = new ProgressChangeEvent(); eInfo.Max = featureDatasetNames.Count; int pValue = 0; //遍历数据集,并进行检查 foreach (string name in featureDatasetNames) { IFeatureDataset featureDataset = sysGisDataSet.GetFeatureDataset(name, out eError); if (eError != null) { continue; } //线线重合检查,参数为45 DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 45, out eError); if (eError != null) { //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); return; } if (mTable.Rows.Count == 0) { continue; } AreaTopoCheck2(Hook, featureDataset, mTable, esriTopologyRuleType.esriTRTLineCoveredByLineClass, out eError); if (eError != null) { eError = new Exception("线线重合检查失败!" + eError.Message); return; } //进度条加1 pValue++; eInfo.Value = pValue; GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo); } }
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; } } }
/// <summary> /// 注记高程值一致性检查 /// </summary> /// <param name="hook"></param> /// <param name="feaClsLst"></param> /// <param name="codeName">分类代码字段名</param> /// <param name="oriFeaClsName">源要素类名称</param> /// <param name="oriCodeValue">源要素类分类代码值</param> /// <param name="oriElevFieldName">源高程值字段名</param> /// <param name="desFeaClsName">目标要素类名称</param> /// <param name="desCodeValue">目标要素类分类代码值</param> /// <param name="labelFieldName">目标要素类高程值</param> /// <param name="radius">搜索半径</param> /// <param name="precision">精度控制</param> /// <param name="outError"></param> public void ElevAccordanceCheck(IArcgisDataCheckHook hook, List <IDataset> feaClsLst, string codeName, string oriFeaClsName, string oriCodeValue, string oriElevFieldName, string desFeaClsName, string desCodeValue, string labelFieldName, double radius, long precision, out Exception outError) { outError = null; try { //源要素类 IFeatureClass pOriFeaCls = null;// (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(oriFeaClsName); foreach (IDataset pDT in feaClsLst) { string tempName = pDT.Name; if (tempName.Contains(".")) { tempName = tempName.Substring(tempName.IndexOf('.') + 1); } if (tempName == oriFeaClsName) { pOriFeaCls = pDT as IFeatureClass; break; } } if (pOriFeaCls == null) { return; } //源要素类高程字段索引值 int oriEleIndex = pOriFeaCls.Fields.FindField(oriElevFieldName); if (oriEleIndex == -1) { outError = new Exception("要素类" + oriFeaClsName + "字段" + oriElevFieldName + "不存在!"); return; } //目标要素类 IFeatureClass pDesFeaCls = null;// (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(desFeaClsName); foreach (IDataset pDT in feaClsLst) { string tempName = pDT.Name; if (tempName.Contains(".")) { tempName = tempName.Substring(tempName.IndexOf('.') + 1); } if (tempName == desFeaClsName) { pDesFeaCls = pDT as IFeatureClass; break; } } if (pDesFeaCls == null) { return; } //目标要素类高程字段索引值 int desElevIndex = pDesFeaCls.Fields.FindField(labelFieldName); if (desElevIndex == -1) { outError = new Exception("要素类" + desFeaClsName + "字段" + labelFieldName + "不存在!"); return; } //查找源要素类中符合分类代码限制条件的要素 string whereStr = ""; if (oriCodeValue != "") { whereStr = codeName + " ='" + oriCodeValue + "'"; } IQueryFilter pFilter = new QueryFilterClass(); pFilter.WhereClause = whereStr; IFeatureCursor pCursor = pOriFeaCls.Search(pFilter, false); if (pCursor == null) { return; } IFeature pOriFea = pCursor.NextFeature(); //遍历源要素,进行比较 while (pOriFea != null) { #region 进行检查 string oriElevValue = pOriFea.get_Value(oriEleIndex).ToString(); //根据原高程值求出精度允许的高程值用于比较 if (oriElevValue.Contains(".")) { //原高程值包含小数点 int oriDotIndex = oriElevValue.IndexOf('.'); if (precision == 0) { oriElevValue = oriElevValue.Substring(0, oriDotIndex); } else if (oriElevValue.Substring(oriDotIndex + 1).Length > precision && precision > 0) { //原高程值的小数点位数大于精度控制 int oriLen = oriDotIndex + 1 + Convert.ToInt32(precision); oriElevValue = oriElevValue.Substring(0, oriLen); } } IFeature desFeature = GetNearestFeature(pDesFeaCls, codeName, desCodeValue, pOriFea, radius, out outError); if (outError != null) { return; } if (desFeature == null) { pOriFea = pCursor.NextFeature(); continue; } string desElevValue = desFeature.get_Value(desElevIndex).ToString(); if (desElevValue.Contains(".")) { //目标高程值包含小数点 int desDotIndex = desElevValue.IndexOf('.'); if (precision == 0) { desElevValue = desElevValue.Substring(0, desDotIndex); } else if (desElevValue.Substring(desDotIndex + 1).Length > precision && precision > 0) { //目标高程值的小数点位数大于精度 int desLen = desDotIndex + 1 + Convert.ToInt32(precision); desElevValue = desElevValue.Substring(0, desLen); } } //根据精度进行比较,在容许的范围内不相同不算错误 if (Convert.ToDouble(oriElevValue) != Convert.ToDouble(desElevValue)) { //说明点,或线与相应注记的高程值不一致。将错误结果显示出来 double pMapx = 0.0; double pMapy = 0.0; IPoint pPoint = new PointClass(); if (pOriFeaCls.ShapeType != esriGeometryType.esriGeometryPoint) { pPoint = TopologyCheckClass.GetPointofFeature(pOriFea); } else { //点要素类 pPoint = pOriFea.Shape as IPoint; } pMapx = pPoint.X; pMapy = pPoint.Y; List <object> ErrorLst = new List <object>(); ErrorLst.Add("要素属性检查"); //功能组名称 ErrorLst.Add("点线注记高程值一致性检查"); //功能名称 ErrorLst.Add(""); //数据文件名 ErrorLst.Add(0); //错误id; ErrorLst.Add("图层" + oriFeaClsName + "与图层" + desFeaClsName + "高程值不一致"); //错误描述 ErrorLst.Add(pMapx); //... ErrorLst.Add(pMapy); //... ErrorLst.Add(oriFeaClsName); ErrorLst.Add(pOriFea.OID); ErrorLst.Add(desFeaClsName); ErrorLst.Add(desFeature.OID); ErrorLst.Add(false); ErrorLst.Add(System.DateTime.Now.ToString()); //传递错误日志 IDataErrInfo dataErrInfo = new DataErrInfo(ErrorLst); DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo); DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent); } pOriFea = pCursor.NextFeature(); #endregion } //释放cursor System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor); } catch (Exception ex) { outError = ex; } }
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; //高程点图层,参数ID为19(还需要改进) string pointFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 19, out eError); if (eError != null) { eError = new Exception("读取数据减配置表失败。" + eError.Message); return; } //等高线图层,参数ID为20 string lineFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 20, out eError); if (eError != null) { eError = new Exception("读取数据减配置表失败。" + eError.Message); return; } //高程点高程字段名,参数ID为22 string pointFieldsname = TopologyCheckClass.GetParaValue(pSysTable, 22, out eError); if (eError != null) { eError = new Exception("读取数据减配置表失败。" + eError.Message); return; } //等高线高程字段名,参数ID为23 string lineFieldname = TopologyCheckClass.GetParaValue(pSysTable, 23, out eError); if (eError != null) { eError = new Exception("读取数据减配置表失败。" + eError.Message); return; } //等高线间距值,参数ID为21 string intervalValue = TopologyCheckClass.GetParaValue(pSysTable, 21, out eError); if (eError != null) { eError = new Exception("读取数据减配置表失败。" + eError.Message); return; } //高程点搜索半径,参数ID为38 string radiu = TopologyCheckClass.GetParaValue(pSysTable, 38, out eError); if (eError != null) { eError = new Exception("读取数据减配置表失败。" + eError.Message); return; } SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace); List <IDataset> LstFeaClass = sysGisDataSet.GetAllFeatureClass(); if (LstFeaClass.Count == 0) { return; } //执行等高线点线矛盾检查 PointLineElevCheck(Hook, LstFeaClass, lineFeaclsname, lineFieldname, pointFeaclsname, pointFieldsname, Convert.ToDouble(intervalValue), out eError); if (eError != null) { eError = new Exception("等高线点线矛盾检查失败!" + eError.Message); return; } #region ////获取所有数据集 //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为19(还需要改进) // string pointFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 19, out eError); // if (eError != null) // { // eError=new Exception("读取数据减配置表失败。" + eError.Message); // return; // } // //等高线图层,参数ID为20 // string lineFeaclsname = TopologyCheckClass.GetParaValue(pSysTable, 20, out eError); // if (eError != null) // { // eError = new Exception("读取数据减配置表失败。" + eError.Message); // return; // } // //高程点高程字段名,参数ID为22 // string pointFieldsname = TopologyCheckClass.GetParaValue(pSysTable, 22, out eError); // if (eError != null) // { // eError = new Exception("读取数据减配置表失败。" + eError.Message); // return; // } // //等高线高程字段名,参数ID为23 // string lineFieldname = TopologyCheckClass.GetParaValue(pSysTable, 23, out eError); // if (eError != null) // { // eError = new Exception("读取数据减配置表失败。" + eError.Message); // return; // } // //等高线间距值,参数ID为21 // string intervalValue = TopologyCheckClass.GetParaValue(pSysTable, 21, out eError); // if (eError != null) // { // eError = new Exception("读取数据减配置表失败。" + eError.Message); // return; // } // //高程点搜索半径,参数ID为38 // string radiu = TopologyCheckClass.GetParaValue(pSysTable, 38, out eError); // if (eError != null) // { // eError = new Exception("读取数据减配置表失败。" + eError.Message); // return; // } // //执行等高线点线矛盾检查 // PointLineElevCheck(Hook,featureDataset, lineFeaclsname, lineFieldname, pointFeaclsname, pointFieldsname, Convert.ToDouble(intervalValue), out eError); // if (eError != null) // { // eError = new Exception("等高线点线矛盾检查失败!" + eError.Message); // return; // } //} #endregion }
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 }
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; //获取所有数据集 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为17 DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 17, out eError); if (eError != null) { //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); return; } if (mTable.Rows.Count == 0) { continue; } LineCrossAreaCheck(Hook, featureDataset, mTable, out eError); if (eError != null) { eError = new Exception("线穿面检查失败!" + eError.Message); return; } } }
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; } }
/// <summary> /// 空值检查 /// </summary> /// <param name="hook"></param> /// <param name="pFeatureDataset"></param> /// <param name="FeaClsNameDic">图层名和属性非空的字段名对</param> /// <param name="outError"></param> public void IsNullableCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, Dictionary <string, List <string> > FeaClsNameDic, out Exception outError) { outError = null; try { //设置进度条 ProgressChangeEvent eInfo = new ProgressChangeEvent(); eInfo.Max = FeaClsNameDic.Count; int pValue = 0; foreach (KeyValuePair <string, List <string> > item in FeaClsNameDic) { IFeatureClass pFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(item.Key.Trim()); for (int i = 0; i < item.Value.Count; i++) { string fieldName = item.Value[i].Trim(); int index = pFeaCls.Fields.FindField(fieldName); if (index == -1) { outError = new Exception("找不到字段名为" + fieldName + "的字段"); return; } if (pFeaCls.Fields.get_Field(index).IsNullable == true) { //字段属性为空,与标准不一致,将结果保存起来 List <object> ErrorLst = new List <object>(); ErrorLst.Add("要素属性检查"); //功能组名称 ErrorLst.Add("空值检查"); //功能名称 ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名 ErrorLst.Add(enumErrorType.空值检查.GetHashCode()); //错误id; ErrorLst.Add("图层" + item.Key + "的字段" + fieldName + "属性值不允许为空"); //错误描述 ErrorLst.Add(0); //... ErrorLst.Add(0); //... ErrorLst.Add(item.Key); ErrorLst.Add(-1); ErrorLst.Add(""); ErrorLst.Add(-1); ErrorLst.Add(false); ErrorLst.Add(System.DateTime.Now.ToString()); //传递错误日志 IDataErrInfo dataErrInfo = new DataErrInfo(ErrorLst); DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo); DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent); } else { IFeatureCursor pFeaCusor = pFeaCls.Search(null, false); if (pFeaCusor == null) { return; } IFeature pFeature = pFeaCusor.NextFeature(); if (pFeature == null) { continue; } while (pFeature != null) { object fieldValue = pFeature.get_Value(index); if (fieldValue == null || fieldValue.ToString() == "") { //字段值不能为空,将检查结果保存起来 double pMapx = 0.0; double pMapy = 0.0; IPoint pPoint = new PointClass(); if (pFeaCls.ShapeType != esriGeometryType.esriGeometryPoint) { pPoint = TopologyCheckClass.GetPointofFeature(pFeature); } else { pPoint = pFeature.Shape as IPoint; } pMapx = pPoint.X; pMapy = pPoint.Y; List <object> ErrorLst = new List <object>(); ErrorLst.Add("要素属性检查"); //功能组名称 ErrorLst.Add("空值检查"); //功能名称 ErrorLst.Add((pFeatureDataset as IDataset).Workspace.PathName); //数据文件名 ErrorLst.Add(enumErrorType.空值检查.GetHashCode()); //错误id; ErrorLst.Add("图层" + item.Key + "的字段" + fieldName + "的值不能为空"); //错误描述 ErrorLst.Add(pMapx); //... ErrorLst.Add(pMapy); //... ErrorLst.Add(item.Key); ErrorLst.Add(pFeature.OID); ErrorLst.Add(""); ErrorLst.Add(-1); ErrorLst.Add(false); ErrorLst.Add(System.DateTime.Now.ToString()); //传递错误日志 IDataErrInfo dataErrInfo = new DataErrInfo(ErrorLst); DataErrTreatEvent dataErrTreatEvent = new DataErrTreatEvent(dataErrInfo); DataErrTreat(hook.DataCheckParaSet as object, dataErrTreatEvent); } pFeature = pFeaCusor.NextFeature(); } //释放cursor System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCusor); } } //进度条加1 pValue++; eInfo.Value = pValue; GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo); } } catch (Exception ex) { outError = ex; } }
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; } string path = dataCheckParaSet.Workspace.PathName; //实现代码 SysCommon.DataBase.SysTable pSysTable = new SysCommon.DataBase.SysTable(); pSysTable.DbConn = dataCheckParaSet.DbConnPara; pSysTable.DBConType = SysCommon.enumDBConType.OLEDB; pSysTable.DBType = SysCommon.enumDBType.ACCESS; DataTable mTable = TopologyCheckClass.GetParaValueTable(pSysTable, 2, out eError); if (eError != null) { //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); return; } if (mTable.Rows.Count == 0) { //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "未进行空值检查配置!"); return; } SysCommon.Gis.SysGisDataSet sysGisDataSet = new SysCommon.Gis.SysGisDataSet(dataCheckParaSet.Workspace); List <IDataset> LstFeaClass = sysGisDataSet.GetAllFeatureClass(); if (LstFeaClass.Count == 0) { return; } //执行空值检查 IsNullCheck(Hook, LstFeaClass, mTable, path, out eError); if (eError != null) { SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "空值检查失败。" + eError.Message); return; } #region ////获取所有数据集 //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为2 // DataTable mTable = TopologyCheckClass.GetParaValueTable(featureDataset, pSysTable, 2, out eError); // if (eError != null) // { // //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", eError.Message); // return; // } // if (mTable.Rows.Count == 0) // { // continue; // } // //执行空值检查 // IsNullCheck(Hook, featureDataset, mTable, out eError); // if (eError != null) // { // eError=new Exception("空值检查失败。" + eError.Message); // return; // } //} #endregion }