Esempio n. 1
0
 public static void DoDispose()
 {
     if (instance != null)
     {
         instance = null;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 同层线重叠检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="pFeaDataset"></param>
        /// <param name="pTable"></param>
        /// <param name="eError"></param>
        public void SpecialFeaClsTopoCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeaDataset, DataTable pTable, esriTopologyRuleType pTopoRule, out Exception eError)
        {
            eError = null;

            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();

            eInfo.Max = pTable.Rows.Count;
            int pValue = 0;


            for (int i = 0; i < pTable.Rows.Count; i++)
            {
                string FeaClsName = pTable.Rows[i]["图层"].ToString().Trim();  //图层名
                if (FeaClsName == "")
                {
                    eError = new Exception("图层名为空!");
                    return;
                }
                CommonTopologyCheckClass commonTopologyCheckClass = new CommonTopologyCheckClass();
                commonTopologyCheckClass.DataErrTreat += new DataErrTreatHandle(DataCheckRealize_DataErrTreat);
                commonTopologyCheckClass.OrdinaryTopoCheck(hook, pFeaDataset, FeaClsName, pTopoRule, out eError);
                if (eError != null)
                {
                    return;
                }

                //进度条加1
                pValue++;
                eInfo.Value = pValue;
                GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
            }
        }
Esempio n. 3
0
        //处理检查结果
        public void GeoDataChecker_DataErrTreat(object sender, DataErrTreatEvent e)
        {
            //用户界面上表现出错误信息
            DevComponents.DotNetBar.Controls.DataGridViewX pDataGrid = sender as DevComponents.DotNetBar.Controls.DataGridViewX;
            if (_ResultTable == null)
            {
                return;
            }
            DataRow newRow = _ResultTable.NewRow();

            newRow["检查功能名"]  = e.ErrInfo.FunctionName;
            newRow["错误类型"]   = GeoDataChecker.GetErrorTypeString(Enum.Parse(typeof(enumErrorType), e.ErrInfo.ErrID.ToString()).ToString());
            newRow["错误描述"]   = e.ErrInfo.ErrDescription;
            newRow["数据图层1"]  = e.ErrInfo.OriginClassName;
            newRow["要素OID1"] = e.ErrInfo.OriginFeatOID;
            newRow["数据图层2"]  = e.ErrInfo.DestinationClassName;
            newRow["要素OID2"] = e.ErrInfo.DestinationFeatOID;
            newRow["检查时间"]   = e.ErrInfo.OperatorTime;
            newRow["定位点X"]   = e.ErrInfo.MapX;
            newRow["定位点Y"]   = e.ErrInfo.MapY;
            newRow["数据文件名"]  = e.ErrInfo.DataFileName;
            _ResultTable.Rows.Add(newRow);

            pDataGrid.Update();

            //将结果输出excle

            InsertRowToExcel(e);
        }
Esempio n. 4
0
        public static GeoDataChecker GetInstance()
        {
            if (instance == null)
            {
                instance = new GeoDataChecker();
            }

            return(instance);
        }
        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);
            }
        }
Esempio n. 6
0
        //将数据检查结果存入ACCESS中
        private static void InsertRowToAccess(DbConnection dbCon, string tableName, DataErrTreatEvent e)
        {
            SysCommon.DataBase.SysTable sysTable = new SysCommon.DataBase.SysTable();
            sysTable.DbConn    = dbCon;
            sysTable.DBConType = SysCommon.enumDBConType.OLEDB;
            sysTable.DBType    = SysCommon.enumDBType.ACCESS;
            string sql = "insert into " + tableName +
                         "(数据文件路径,检查功能名,错误类型,错误描述,数据图层1,数据OID1,数据图层2,数据OID2,定位点X,定位点Y,检查时间) values(" +
                         "'" + e.ErrInfo.DataFileName + "','" + e.ErrInfo.FunctionName + "','" + GeoDataChecker.GetErrorTypeString(Enum.Parse(typeof(enumErrorType), e.ErrInfo.ErrID.ToString()).ToString()) + "','" + e.ErrInfo.ErrDescription + "','" + e.ErrInfo.OriginClassName + "','" + e.ErrInfo.OriginFeatOID.ToString() + "','" +
                         e.ErrInfo.DestinationClassName + "','" + e.ErrInfo.DestinationFeatOID.ToString() + "'," + e.ErrInfo.MapX + "," + e.ErrInfo.MapY + ",'" + e.ErrInfo.OperatorTime + "')";

            Exception errEx = null;

            sysTable.UpdateTable(sql, out errEx);
        }
Esempio n. 7
0
 public void OnDataCheck()
 {
     GeoDataChecker.LoadDataCheckLogicFunction(Name, Hook, this);
 }
Esempio n. 8
0
        //将数据检查结果存入Excel中
        private void InsertRowToExcel(DataErrTreatEvent e)
        {
            if (_ErrDbCon != null && _ErrTableName != "")
            {
                SysCommon.DataBase.SysTable sysTable = new SysCommon.DataBase.SysTable();
                sysTable.DbConn    = _ErrDbCon;
                sysTable.DBConType = SysCommon.enumDBConType.OLEDB;
                sysTable.DBType    = SysCommon.enumDBType.ACCESS;
                string sql = "insert into " + _ErrTableName +
                             "(数据文件路径,检查功能名,错误类型,错误描述,数据图层1,数据OID1,数据图层2,数据OID2,定位点X,定位点Y,检查时间) values(" +
                             "'" + e.ErrInfo.DataFileName + "','" + e.ErrInfo.FunctionName + "','" + GeoDataChecker.GetErrorTypeString(Enum.Parse(typeof(enumErrorType), e.ErrInfo.ErrID.ToString()).ToString()) + "','" + e.ErrInfo.ErrDescription + "','" + e.ErrInfo.OriginClassName + "','" + e.ErrInfo.OriginFeatOID.ToString() + "','" +
                             e.ErrInfo.DestinationClassName + "','" + e.ErrInfo.DestinationFeatOID.ToString() + "'," + e.ErrInfo.MapX + "," + e.ErrInfo.MapY + ",'" + e.ErrInfo.OperatorTime + "')";

                Exception errEx = null;
                sysTable.UpdateTable(sql, out errEx);
                if (errEx != null)
                {
                    SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "写入Excel文件出错!");
                    return;
                }
            }
        }
        private void ExcuteCheck(List <IDataset> LstDataset, string path)
        {
            Exception eError = null;

            string pClassifyName = GetClassifyName1(out eError);

            if (eError != null || pClassifyName == "")
            {
                return;
            }

            //用来存储MapControl上的图层的分类代码的相关信息
            Dictionary <IFeatureClass, Dictionary <string, List <int> > > DicFea = new Dictionary <IFeatureClass, Dictionary <string, List <int> > >();

            foreach (IDataset pDT in LstDataset)
            {
                IFeatureClass pFeatureClass = pDT as IFeatureClass;
                if (pFeatureClass == null)
                {
                    return;
                }
                string pFeaClsName = pDT.Name.Trim();

                #region 首先检查Mapcontrol上的要素类是否具有分类代码这个字段
                int index = -1;   //分类代码索引
                index = pFeatureClass.Fields.FindField(pClassifyName);
                if (index == -1)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "不存在分类代码字段!");
                    //return;
                    continue;
                }
                #endregion

                #region 将MapControl上的图层相关信息用字典存储起来
                IFeatureCursor pFeaCursor = pFeatureClass.Search(null, false);
                if (pFeaCursor == null)
                {
                    return;
                }
                IFeature pFeature = pFeaCursor.NextFeature();
                if (pFeature == null)
                {
                    continue;
                }
                while (pFeature != null)
                {
                    string pGISID = pFeature.get_Value(index).ToString().Trim(); //分类代码
                    int    pOID   = pFeature.OID;                                //OID

                    if (!DicFea.ContainsKey(pFeatureClass))
                    {
                        //用来保存GISID和对应的OID
                        Dictionary <string, List <int> > DicCode = new Dictionary <string, List <int> >();
                        List <int> LstOID = new List <int>();
                        LstOID.Add(pOID);
                        DicCode.Add(pGISID, LstOID);
                        DicFea.Add(pFeatureClass, DicCode);
                    }
                    else
                    {
                        if (!DicFea[pFeatureClass].ContainsKey(pGISID))
                        {
                            List <int> LstOID = new List <int>();
                            LstOID.Add(pOID);
                            DicFea[pFeatureClass].Add(pGISID, LstOID);
                        }
                        else
                        {
                            DicFea[pFeatureClass][pGISID].Add(pOID);
                        }
                    }
                    pFeature = pFeaCursor.NextFeature();
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pFeaCursor);

                #endregion
            }
            //设置进度条
            ProgressChangeEvent eInfo = new ProgressChangeEvent();
            eInfo.Max = DicFea.Count;
            int pValue = 0;

            //int pMax =DicFea.Count;
            //int pValue = 0;
            //GeoDataChecker._CheckForm.Invoke(new GeoDataChecker.IntiProgressBar(GeoDataChecker.intiaProgress), new object[] { pMax });

            #region 进行分类代码检查
            //遍历要素类
            foreach (KeyValuePair <IFeatureClass, Dictionary <string, List <int> > > FeaCls in DicFea)
            {
                IFeatureClass pFeaCls  = FeaCls.Key;
                IDataset      pDataset = pFeaCls as IDataset;
                if (pDataset == null)
                {
                    return;
                }
                string pFeaClsNameStr = pDataset.Name;
                if (pFeaClsNameStr.Contains("."))
                {
                    pFeaClsNameStr = pFeaClsNameStr.Substring(pFeaClsNameStr.IndexOf('.') + 1);
                }


                //遍历分类代码值,进行检查
                foreach (KeyValuePair <string, List <int> > pGISIDItem in FeaCls.Value)
                {
                    //分类代码的值
                    string ppGISID = pGISIDItem.Key;
                    string sqlStr  = "select * from GeoCheckCode where 分类代码 ='" + ppGISID + "'";
                    //执行检查
                    int pResult = CodeStandardizeCheck(sqlStr);
                    #region 对检查结果进行判断
                    if (pResult == -1)
                    {
                        return;
                    }
                    if (pResult == 1)
                    {
                        continue;
                    }
                    if (pResult == 0)
                    {
                        //该分类代码不存在
                        #region 保存错误结果
                        //遍历该分类代码对应的要素OID集合
                        for (int m = 0; m < pGISIDItem.Value.Count; m++)
                        {
                            int pOID = pGISIDItem.Value[m];

                            IFeature pFeature = pFeaCls.GetFeature(pOID);
                            IPoint   pPoint   = ModCommonFunction.GetPntOfFeature(pFeature);

                            double pMapx = 0; // pPoint.X; ;
                            double pMapy = 0; // pPoint.Y;
                            if (pPoint != null)
                            {
                                pMapx = pPoint.X;
                                pMapy = pPoint.Y;
                            }

                            //用来保存错误结果
                            List <object> ErrorLst = new List <object>();
                            ErrorLst.Add("批量检查");
                            ErrorLst.Add("分类代码检查");
                            ErrorLst.Add(path);
                            ErrorLst.Add(enumErrorType.分类代码不存在.GetHashCode());
                            ErrorLst.Add("分类代码" + ppGISID + "不存在!");
                            ErrorLst.Add(pMapx);     //...
                            ErrorLst.Add(pMapy);     //...
                            ErrorLst.Add(pFeaClsNameStr);
                            ErrorLst.Add(pOID);
                            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);
                        }
                        #endregion
                    }
                    #endregion
                }

                //进度条加1
                //进度条加1
                pValue++;
                eInfo.Value = pValue;
                //GeoDataChecker._CheckForm.Invoke(new GeoDataChecker.GEODataCheckerProgressShow(GeoDataChecker.GeoDataChecker_ProgressShow), new object[] { (object)GeoDataChecker._ProgressBarInner, eInfo });
                GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);

                //pValue++;
                //GeoDataChecker._CheckForm.Invoke(new GeoDataChecker.ChangeProgressBar(GeoDataChecker.changeProgress), new object[] {pValue});
            }
            #endregion
        }
Esempio n. 10
0
        /// <summary>
        /// 等高线点线矛盾一致性检查
        /// </summary>
        /// <param name="pFeatureDataset"></param>
        /// <param name="lineFeaClsName">等高线要素类名称</param>
        /// <param name="lineFieldName">等高线高程字段名</param>
        /// <param name="pointFeaClsName">高程点要素类名称</param>
        /// <param name="pointFieldName">高程点字段名</param>
        /// <param name="radiu">高程点搜索半径</param>
        /// <param name="intervalValue">等高线间距值</param>
        /// <param name="eError"></param>
        private void PointLineElevCheck(IArcgisDataCheckHook hook, IFeatureDataset pFeatureDataset, string lineFeaClsName, string lineFieldName, string pointFeaClsName, string pointFieldName, double intervalValue, out Exception eError)
        {
            eError = null;
            try
            {
                //等高线要素类
                IFeatureClass lineFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(lineFeaClsName);
                //等高线高程字段索引值
                int lineIndex = lineFeaCls.Fields.FindField(lineFieldName);
                if (lineIndex == -1)
                {
                    eError = new Exception("等高线图层的高程字段不存在,字段名为:" + lineFieldName);
                    return;
                }
                //高程点要素类
                IFeatureClass pointFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(pointFeaClsName);
                int           pointIndex  = pointFeaCls.Fields.FindField(pointFieldName);
                if (lineIndex == -1)
                {
                    eError = new Exception("高程点图层的高程字段不存在,字段名为:" + pointFieldName);
                    return;
                }

                //遍历高程点要素
                IFeatureCursor pCusor = pointFeaCls.Search(null, false);
                if (pCusor == null)
                {
                    return;
                }
                IFeature pointFeature = pCusor.NextFeature();

                //设置进度条
                ProgressChangeEvent eInfo = new ProgressChangeEvent();
                eInfo.Max = pointFeaCls.FeatureCount(null);
                int pValue = 0;

                while (pointFeature != null)
                {
                    //高程点要素的高程值
                    double pointElevValue = Convert.ToDouble(pointFeature.get_Value(pointIndex).ToString());
                    //查找高程点相邻的两条高程线要素

                    //与高程点最近的等高线要素以及最短距离
                    Dictionary <double, IFeature> nearestFeaDic = GetShortestDis(lineFeaCls, pointFeature, out eError);
                    if (eError != null || nearestFeaDic == null)
                    {
                        eError = new Exception("在搜索范围内的未找到要素!");
                        return;
                    }
                    double   pShortestDis = -1;
                    IFeature nearestFea   = null;
                    foreach (KeyValuePair <double, IFeature> item in nearestFeaDic)
                    {
                        pShortestDis = item.Key;
                        nearestFea   = item.Value;
                        break;
                    }
                    if (eError != null || pShortestDis == -1)
                    {
                        return;
                    }
                    //获得等高线上离高程点最近的点
                    IPoint             nearestPoint = new PointClass();//等高线上的最近点
                    IProximityOperator mProxiOpe    = nearestFea.Shape as IProximityOperator;
                    if (mProxiOpe == null)
                    {
                        return;
                    }
                    nearestPoint = mProxiOpe.ReturnNearestPoint(pointFeature.Shape as IPoint, esriSegmentExtension.esriNoExtension);
                    //将高程点和等高线上的点连成线段并进行两端延长

                    PointLineAccordanceCheck2(hook, pFeatureDataset, lineFeaCls, pointFeaCls, pointFeature, lineFieldName, lineIndex, pointIndex, nearestFea, pShortestDis, intervalValue, out eError);
                    //PointLineAccordanceCheck(pFeatureDataset, lineFeaCls, pointFeaCls, pointFeature, lineIndex, pointIndex, pShortestDis, nearestFea, intervalValue, out eError);
                    if (eError != null)
                    {
                        return;
                    }
                    pointFeature = pCusor.NextFeature();

                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCusor);
            }
            catch (Exception ex)
            {
                eError = ex;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// 注记高程值一致性检查
        /// </summary>
        /// <param name="hook"></param>
        /// <param name="pFeatureDataset"></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, IFeatureDataset pFeatureDataset, 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 = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(oriFeaClsName);
                //源要素类高程字段索引值
                int oriEleIndex = pOriFeaCls.Fields.FindField(oriElevFieldName);
                if (oriEleIndex == -1)
                {
                    outError = new Exception("要素类" + oriFeaClsName + "字段" + oriElevFieldName + "不存在!");
                    return;
                }

                //目标要素类
                IFeatureClass pDesFeaCls = (pFeatureDataset.Workspace as IFeatureWorkspace).OpenFeatureClass(desFeaClsName);
                //目标要素类高程字段索引值
                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();

                //设置进度条
                ProgressChangeEvent eInfo = new ProgressChangeEvent();
                eInfo.Max = pOriFeaCls.FeatureCount(null);
                int pValue = 0;

                //遍历源要素,进行比较
                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();
                        //进度条加1
                        pValue++;
                        eInfo.Value = pValue;
                        GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);

                        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((pFeatureDataset as IDataset).Workspace.PathName);        //数据文件名
                        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

                    //进度条加1
                    pValue++;
                    eInfo.Value = pValue;
                    GeoDataChecker.GeoDataChecker_ProgressShow((object)GeoDataChecker._ProgressBarInner, eInfo);
                }

                //释放cursor
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pCursor);
            }
            catch (Exception ex)
            {
                outError = ex;
            }
        }
Esempio n. 12
0
        /// <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;
            }
        }
Esempio n. 13
0
        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)