Exemplo n.º 1
0
        //执行GP的数据修复功能
        //田晶添加20080916
        //修改,提高效率
        //靳军杰2011-11-30
        /// <summary>
        /// 修复面图层自相交错误
        /// </summary>
        /// <param name="sPath"></param>
        /// <returns></returns>
        public bool FeatureRepair(string sPath)
        {
            if (string.IsNullOrEmpty(sPath))
            {
                return(false);
            }

            IGeoProcessor pGP = new GeoProcessorClass();

            try
            {
                //GT_CARTO.XApplication.ProgressBar.ShowGifProgress(null);
                //GT_CARTO.XApplication.ProgressBar.ShowHint("正在预处理地类图斑数据...");
                //string sPath = pWks.PathName;
                pGP.OverwriteOutput = true;
                pGP.SetEnvironmentValue("workspace", (object)sPath);

                IGpEnumList pfds = pGP.ListFeatureClasses("", "Polygon", "Dataset");

                string sFeatClsName = pfds.Next();

                //IGeoProcessorResult pResult;

                while (!string.IsNullOrEmpty(sFeatClsName))
                {
                    if (!sFeatClsName.Contains("_Standard") &&
                        !sFeatClsName.Equals("TK", StringComparison.OrdinalIgnoreCase))
                    {
                        //要修复的FeatureClass路径
                        string        sInFeatureClassPath = string.Format("{0}\\dataset\\{1}", sPath, sFeatClsName);
                        IVariantArray pValues             = new VarArrayClass();
                        pValues.Add(sInFeatureClassPath);
                        pGP.Execute("RepairGeometry", pValues, null);
                        object obj = 2;
                        //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGP.GetMessages(ref obj));
                    }
                    sFeatClsName = pfds.Next();
                }
                return(true);
            }

            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                //GT_CARTO.XApplication.ProgressBar.Hide();
                return(false);
            }
            finally
            {
                //GT_CARTO.XApplication.ProgressBar.Hide();
                Marshal.ReleaseComObject(pGP);
            }
        }
Exemplo n.º 2
0
        //执行GP的数据修复功能
        //田晶添加20080916
        //修改,提高效率
        //靳军杰2011-11-30
        /// <summary>
        /// 修复面图层自相交错误
        /// </summary>
        /// <param name="sPath"></param>
        /// <returns></returns>
        public bool FeatureRepair(string sPath)
        {
            if (string.IsNullOrEmpty(sPath))
            {
                return false;
            }

            IGeoProcessor pGP = new GeoProcessorClass();
            try
            {
                //GT_CARTO.XApplication.ProgressBar.ShowGifProgress(null);
                //GT_CARTO.XApplication.ProgressBar.ShowHint("正在预处理地类图斑数据...");
                //string sPath = pWks.PathName;
                pGP.OverwriteOutput = true;
                pGP.SetEnvironmentValue("workspace", (object)sPath);

                IGpEnumList pfds = pGP.ListFeatureClasses("", "Polygon", "Dataset");

                string sFeatClsName = pfds.Next();

                //IGeoProcessorResult pResult;

                while (!string.IsNullOrEmpty(sFeatClsName))
                {
                    if (!sFeatClsName.Contains("_Standard") &&
                        !sFeatClsName.Equals("TK", StringComparison.OrdinalIgnoreCase))
                    {
                        //要修复的FeatureClass路径
                        string sInFeatureClassPath = string.Format("{0}\\dataset\\{1}", sPath, sFeatClsName);
                        IVariantArray pValues = new VarArrayClass();
                        pValues.Add(sInFeatureClassPath);
                        pGP.Execute("RepairGeometry", pValues, null);
                        object obj = 2;
                        //GT_CONST.LogAPI.CheckLog.AppendErrLogs(pGP.GetMessages(ref obj));
                    }
                    sFeatClsName = pfds.Next();
                }
                return true;
            }

            catch (Exception exp)
            {
                Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());

                //GT_CARTO.XApplication.ProgressBar.Hide();
                return false;
            }
            finally
            {
                //GT_CARTO.XApplication.ProgressBar.Hide();
                Marshal.ReleaseComObject(pGP);
            }
        }