Пример #1
0
        /// <summary>
        ///     Creates an <see cref="IEnumerable{T}" /> from an <see cref="IEnumDomain" />
        /// </summary>
        /// <param name="source">An <see cref="IEnumInvalidObject" /> to create an <see cref="IEnumerable{T}" /> from.</param>
        /// <returns>An <see cref="IEnumerable{T}" /> that contains the fields from the input source.</returns>
        public static IEnumerable <IInvalidObjectInfo> AsEnumerable(this IEnumInvalidObject source)
        {
            if (source != null)
            {
                source.Reset();
                var value = source.Next();
                while (value != null)
                {
                    yield return(value);

                    value = source.Next();
                }
            }
        }
Пример #2
0
        /// <summary>
        /// convert featureclass in shapefile
        /// </summary>
        /// <param name="sourceWorkspace">oggetto workspace</param>
        /// <param name="outputName">nome feature class e nome shapefile</param>
        /// <param name="targetWorkspacePath">cartella shapefile</param>
        /// <param name="errorField">lista degli eventuali errori nella creazione dei campi</param>
        /// <param name="invalidObject">lista degli eventuale errori di creazione record</param>
        private void ConvertFeatureClassToShapefile(IWorkspace sourceWorkspace, string outputName, string targetWorkspacePath, ref List <string> errorField, ref List <string> invalidObject)
        {
            IWorkspace targetWorkspace = null;

            try
            {
                Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory");
                IWorkspaceFactory targetWorkspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
                targetWorkspace = targetWorkspaceFactory.OpenFromFile(targetWorkspacePath, 0);

                // Cast the workspaces to the IDataset interface and get name objects.
                IDataset       sourceWorkspaceDataset     = (IDataset)sourceWorkspace;
                IDataset       targetWorkspaceDataset     = (IDataset)targetWorkspace;
                IName          sourceWorkspaceDatasetName = sourceWorkspaceDataset.FullName;
                IName          targetWorkspaceDatasetName = targetWorkspaceDataset.FullName;
                IWorkspaceName sourceWorkspaceName        = (IWorkspaceName)sourceWorkspaceDatasetName;
                IWorkspaceName targetWorkspaceName        = (IWorkspaceName)targetWorkspaceDatasetName;

                // Create a name object for the shapefile and cast it to the IDatasetName interface.
                IFeatureClassName sourceFeatureClassName = new FeatureClassNameClass();
                IDatasetName      sourceDatasetName      = (IDatasetName)sourceFeatureClassName;
                sourceDatasetName.Name          = outputName;
                sourceDatasetName.WorkspaceName = sourceWorkspaceName;

                // Create a name object for the FGDB feature class and cast it to the IDatasetName interface.
                IFeatureClassName targetFeatureClassName = new FeatureClassNameClass();
                IDatasetName      targetDatasetName      = (IDatasetName)targetFeatureClassName;
                targetDatasetName.Name          = outputName;
                targetDatasetName.WorkspaceName = targetWorkspaceName;

                // Open source feature class to get field definitions.
                IName         sourceName         = (IName)sourceFeatureClassName;
                IFeatureClass sourceFeatureClass = (IFeatureClass)sourceName.Open();

                // Create the objects and references necessary for field validation.
                IFieldChecker   fieldChecker   = new FieldCheckerClass();
                IFields         sourceFields   = sourceFeatureClass.Fields;
                IFields         targetFields   = null;
                IEnumFieldError enumFieldError = null;

                // Set the required properties for the IFieldChecker interface.
                fieldChecker.InputWorkspace    = sourceWorkspace;
                fieldChecker.ValidateWorkspace = targetWorkspace;

                // Validate the fields and check for errors.
                fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields);
                if (enumFieldError != null)
                {
                    IFieldError fieldError = null;
                    enumFieldError.Reset();
                    while ((fieldError = enumFieldError.Next()) != null)
                    {
                        errorField.Add($"Errore: {Enum.GetName(typeof(esriFieldNameErrorType), fieldError.FieldError)} - Campo: {targetFields.get_Field(fieldError.FieldIndex).Name}");
                    }
                }

                // Find the shape field.
                string shapeFieldName  = sourceFeatureClass.ShapeFieldName;
                int    shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName);
                IField shapeField      = sourceFields.get_Field(shapeFieldIndex);

                // Get the geometry definition from the shape field and clone it.
                IGeometryDef geometryDef            = shapeField.GeometryDef;
                IClone       geometryDefClone       = (IClone)geometryDef;
                IClone       targetGeometryDefClone = geometryDefClone.Clone();
                IGeometryDef targetGeometryDef      = (IGeometryDef)targetGeometryDefClone;

                // Create the converter and run the conversion.
                IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();
                IEnumInvalidObject    enumInvalidObject    =
                    featureDataConverter.ConvertFeatureClass(sourceFeatureClassName,
                                                             null, null, targetFeatureClassName, targetGeometryDef, targetFields,
                                                             string.Empty, 1000, 0);

                // Check for errors.
                IInvalidObjectInfo invalidObjectInfo = null;
                enumInvalidObject.Reset();
                while ((invalidObjectInfo = enumInvalidObject.Next()) != null)
                {
                    invalidObject.Add($"{invalidObjectInfo.InvalidObjectID}");
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                if (targetWorkspace != null)
                {
                    Marshal.FinalReleaseComObject(targetWorkspace);
                }
            }
        }
Пример #3
0
        public void ConvertFileGDBToSDE(string fileGDBPath, string sourceFCName, string targetFCName)
        {
            // Create a name object for the source (fileGDB) workspace and open it.
            IWorkspaceName sourceWorkspaceName = getWorkspaceName("esriDataSourcesGDB.FileGDBWorkspaceFactory", fileGDBPath);

            IName      sourceWorkspaceIName = (IName)sourceWorkspaceName;
            IWorkspace sourceWorkspace      = (IWorkspace)sourceWorkspaceIName.Open();

            // Create a name object for the target (SDE) workspace and open it.
            IWorkspaceName targetWorkspaceName  = getWorkspaceName("esriDataSourcesGDB.SdeWorkspaceFactory", sdePath);
            IName          targetWorkspaceIName = (IName)targetWorkspaceName;
            IWorkspace     targetWorkspace      = (IWorkspace)targetWorkspaceIName.Open();

            // Create a name object for the source dataset.
            IFeatureClassName sourceFeatureClassName = getFeatureClassName(sourceWorkspaceName, sourceFCName);

            // Create a name object for the target dataset.
            IFeatureClassName targetFeatureClassName = getFeatureClassName(targetWorkspaceName, targetFCName);

            // Open source feature class to get field definitions.
            IName         sourceName         = (IName)sourceFeatureClassName;
            IFeatureClass sourceFeatureClass = (IFeatureClass)sourceName.Open();

            // Create the objects and references necessary for field validation.
            IFieldChecker   fieldChecker   = new FieldCheckerClass();
            IFields         sourceFields   = sourceFeatureClass.Fields;
            IFields         targetFields   = null;
            IEnumFieldError enumFieldError = null;

            // Set the required properties for the IFieldChecker interface.
            fieldChecker.InputWorkspace    = sourceWorkspace;
            fieldChecker.ValidateWorkspace = targetWorkspace;

            // Validate the fields and check for errors.
            fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields);
            if (enumFieldError != null)
            {
                // Handle the errors in a way appropriate to your application.
                Console.WriteLine("Errors were encountered during field validation.");
            }

            // Find the shape field.
            String shapeFieldName  = sourceFeatureClass.ShapeFieldName;
            int    shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName);
            IField shapeField      = sourceFields.get_Field(shapeFieldIndex);

            // Get the geometry definition from the shape field and clone it.
            IGeometryDef geometryDef            = shapeField.GeometryDef;
            IClone       geometryDefClone       = (IClone)geometryDef;
            IClone       targetGeometryDefClone = geometryDefClone.Clone();
            IGeometryDef targetGeometryDef      = (IGeometryDef)targetGeometryDefClone;

            // Cast the IGeometryDef to the IGeometryDefEdit interface.
            IGeometryDefEdit targetGeometryDefEdit = (IGeometryDefEdit)targetGeometryDef;

            // Set the IGeometryDefEdit properties.
            //targetGeometryDefEdit.GridCount_2 = 1;
            //targetGeometryDefEdit.set_GridSize(0, 0.75);

            // Create a query filter to only select features you want to convert
            IQueryFilter queryFilter = new QueryFilterClass();

            // Create the converter and run the conversion.
            IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();
            IEnumInvalidObject    enumInvalidObject    = featureDataConverter.ConvertFeatureClass
                                                             (sourceFeatureClassName, queryFilter, null, targetFeatureClassName,
                                                             targetGeometryDef, targetFields, "", 1000, 0);

            // Check for errors.
            IInvalidObjectInfo invalidObjectInfo = null;

            enumInvalidObject.Reset();
            while ((invalidObjectInfo = enumInvalidObject.Next()) != null)
            {
                // Handle the errors in a way appropriate to the application.
                Console.WriteLine("Errors occurred for the following feature: {0}",
                                  invalidObjectInfo.InvalidObjectID);
            }
        }
Пример #4
0
        /// <summary>
        /// 将指定要素类复制到目标数据库中(在目标数据库中创建要素类)
        /// </summary>
        /// <param name="pSrcFC">源要素类</param>
        /// <param name="pQueryFilter">查询条件</param>
        /// <param name="pTargetWks">目标数据库</param>
        /// <param name="sMessage">转换消息</param>
        /// <param name="sTargetName">目标要素类名</param>
        /// <param name="sAlias">目标要素类别名</param>
        /// <param name="sFDatasetName">目标要素数据集</param>
        /// <returns></returns>
        public bool TranslateFeatureClass(IFeatureClass pSrcFC, IQueryFilter pQueryFilter, IWorkspace pTargetWks, string sTargetName = null, string sAlias = null, string sFDatasetName = null)
        {
            GeoDataUtils geoDataUtils = new GeoDataUtils();

            IDataset            pSrcDataset         = pSrcFC as IDataset;
            IFeatureClassName   pSrcName            = pSrcDataset.FullName as IFeatureClassName;
            IFeatureDatasetName pFeatureDatasetName = null;

            if (pTargetWks.Type != esriWorkspaceType.esriFileSystemWorkspace)
            {
                string sFeatureDatasetName = sFDatasetName;
                if (string.IsNullOrEmpty(sFeatureDatasetName) && pSrcFC.FeatureDataset != null)
                {
                    sFeatureDatasetName = geoDataUtils.ExtractDatasetName(pSrcFC.FeatureDataset.Name);
                }
                if (!string.IsNullOrEmpty(sFeatureDatasetName))
                {
                    if (geoDataUtils.IsNameExist(pTargetWks, sFeatureDatasetName, esriDatasetType.esriDTFeatureDataset))
                    {
                        IFeatureDataset pTargetFeatureDataset = (pTargetWks as IFeatureWorkspace).OpenFeatureDataset(sFeatureDatasetName);
                        pFeatureDatasetName = pTargetFeatureDataset.FullName as IFeatureDatasetName;
                        Marshal.ReleaseComObject(pTargetFeatureDataset);
                    }
                    else
                    {
                        pFeatureDatasetName = new FeatureDatasetName() as IFeatureDatasetName;
                        IDatasetName pDatasetName = pFeatureDatasetName as IDatasetName;
                        pDatasetName.Name          = sFeatureDatasetName;
                        pDatasetName.WorkspaceName = (pTargetWks as IDataset).FullName as IWorkspaceName;
                    }
                }
            }

            //目标要素类名
            FeatureClassName pTargetName        = new FeatureClassName();
            IDatasetName     pTargetDatasetName = pTargetName as IDatasetName;

            if (string.IsNullOrEmpty(sTargetName))
            {
                sTargetName = geoDataUtils.ExtractDatasetName(pSrcDataset.Name);
            }
            pTargetDatasetName.Name          = sTargetName;
            pTargetDatasetName.WorkspaceName = (pTargetWks as IDataset).FullName as IWorkspaceName;
            geoDataUtils.DeleteDataset(pTargetWks, pTargetDatasetName);

            // 验证字段
            IFields pTargetFields;
            string  sShapeFieldName;

            geoDataUtils.CheckFields(pSrcFC, pTargetWks, out pTargetFields, out sShapeFieldName);
            IEnumInvalidObject    pEnumInvalidObject = null;
            IFeatureDataConverter pConverter         = null;

            try
            {
                int          iIndex             = pTargetFields.FindField(sShapeFieldName);
                IGeometryDef pTargetGeometryDef = pTargetFields.get_Field(iIndex).GeometryDef;

                // 执行批量转换
                pConverter         = new FeatureDataConverter();
                pEnumInvalidObject = pConverter.ConvertFeatureClass(pSrcName, pQueryFilter, pFeatureDatasetName as IFeatureDatasetName,
                                                                    pTargetName as IFeatureClassName, pTargetGeometryDef, pTargetFields, "", 1000, 0);

                // 检查转换过程中是否产生错误
                if (pEnumInvalidObject != null)
                {
                    IInvalidObjectInfo pInvalidInfo = null;
                    pEnumInvalidObject.Reset();
                    while ((pInvalidInfo = pEnumInvalidObject.Next()) != null)
                    {
                        ErrorMessage += pSrcFC.AliasName + "图层要素:" + pInvalidInfo.InvalidObjectID + "执行失败!";
                    }
                }
            }
            finally //释放资源
            {
                if (pEnumInvalidObject != null)
                {
                    Marshal.ReleaseComObject(pEnumInvalidObject);
                }
                if (pConverter != null)
                {
                    Marshal.ReleaseComObject(pConverter);
                }
            }
            //修改要素类别名
            if (string.IsNullOrEmpty(sAlias))
            {
                sAlias = pSrcFC.AliasName;
            }
            IFeatureClass pTargetFC = (pTargetWks as IFeatureWorkspace).OpenFeatureClass(sTargetName);

            geoDataUtils.AlterDatasetAlias(pTargetFC, sAlias);
            Marshal.ReleaseComObject(pTargetFC);
            return(true);
        }
        public void DataImport(IWorkspace sourceWorkspace, IWorkspace targetWorkspace, IFeatureClass sourceFeatureClass, IDataset targetFeatureDataset, string storeName)
        {
            int errorRowCount = 0;
            int totalRowCount = 0;
            Dictionary <int, string> dicError         = new Dictionary <int, string>();
            IDataset       sourceWorkspaceDataset     = (IDataset)sourceWorkspace;
            IDataset       targetWorkspaceDataset     = (IDataset)targetWorkspace;
            string         sourceLayerName            = ((IDataset)sourceFeatureClass).Name;
            IName          sourceWorkspaceDatasetName = sourceWorkspaceDataset.FullName;
            IName          targetWorkspaceDatasetName = targetWorkspaceDataset.FullName;
            IWorkspaceName sourceWorkspaceName        = (IWorkspaceName)sourceWorkspaceDatasetName;
            IWorkspaceName targetWorkspaceName        = (IWorkspaceName)targetWorkspaceDatasetName;

            // Create a name object for the shapefile and cast it to the IDatasetName interface.
            IFeatureClassName sourceFeatureClassName = new FeatureClassNameClass();
            IDatasetName      sourceDatasetName      = (IDatasetName)sourceFeatureClassName;

            sourceDatasetName.Name          = sourceLayerName;
            sourceDatasetName.WorkspaceName = sourceWorkspaceName;

            // Create a name object for the FGDB feature class and cast it to the IDatasetName interface.
            IFeatureClassName targetFeatureClassName = new FeatureClassNameClass();
            IDatasetName      targetDatasetName      = (IDatasetName)targetFeatureClassName;

            targetDatasetName.Name          = storeName;// importMappingScheme.StoreDatasetName;"GEODATA.DLTB7"
            targetDatasetName.WorkspaceName = targetWorkspaceName;

            // Create the objects and references necessary for field validation.
            IFieldChecker   fieldChecker   = new FieldCheckerClass();
            IFields         sourceFields   = sourceFeatureClass.Fields;
            IFields         targetFields   = null;
            IEnumFieldError enumFieldError = null;

            // Set the required properties for the IFieldChecker interface.
            fieldChecker.InputWorkspace    = sourceWorkspace;
            fieldChecker.ValidateWorkspace = targetWorkspace;

            // Validate the fields and check for errors.
            fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields);

            // Find the shape field.
            String shapeFieldName  = sourceFeatureClass.ShapeFieldName;
            int    shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName);
            IField shapeField      = sourceFields.get_Field(shapeFieldIndex);

            // Get the geometry definition from the shape field and clone it.
            IGeometryDef geometryDef            = shapeField.GeometryDef;
            IClone       geometryDefClone       = (IClone)geometryDef;
            IClone       targetGeometryDefClone = geometryDefClone.Clone();
            IGeometryDef targetGeometryDef      = (IGeometryDef)targetGeometryDefClone;

            // Cast the IGeometryDef to the IGeometryDefEdit interface.
            IGeometryDefEdit targetGeometryDefEdit = (IGeometryDefEdit)targetGeometryDef;

            // Set the IGeometryDefEdit properties.
            targetGeometryDefEdit.GridCount_2 = 1;
            targetGeometryDefEdit.set_GridSize(0, 0.75);

            //修改目标字段
            string fieldNameString = ChangeTargetFields(targetFields);

            if (fieldNameString != string.Empty)
            {
                fieldNameString += string.Format(",{0}", shapeFieldName);
            }
            else
            {
                fieldNameString = shapeFieldName;
            }
            IQueryFilter queryFilter = new QueryFilterClass();

            queryFilter.SubFields = fieldNameString;

            //设置导出的要素集
            IFeatureDatasetName featureDatasetName = null;

            if (targetFeatureDataset != null)
            {
                featureDatasetName = (IFeatureDatasetName)targetFeatureDataset.FullName;
            }

            // Create the converter and run the conversion.
            IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();
            IEnumInvalidObject    enumInvalidObject    = featureDataConverter.ConvertFeatureClass
                                                             (sourceFeatureClassName, queryFilter, featureDatasetName, targetFeatureClassName,
                                                             targetGeometryDef, targetFields, "", 1000, 0);

            // Check for errors.
            IInvalidObjectInfo invalidObjectInfo = null;

            enumInvalidObject.Reset();
            while ((invalidObjectInfo = enumInvalidObject.Next()) != null)
            {
                if (dicError.ContainsKey(invalidObjectInfo.InvalidObjectID) == false)
                {
                    // Handle the errors in a way appropriate to the application.
                    dicError.Add(invalidObjectInfo.InvalidObjectID, invalidObjectInfo.ErrorDescription);
                    errorRowCount++;
                }
                Console.WriteLine(invalidObjectInfo.InvalidObjectID + "" + invalidObjectInfo.ErrorDescription);
            }
        }
Пример #6
0
        public static void ConvertFeatureClassToShapefile(string sourceWorkspacePath, string targetWorkspacePath, string sourceDataName, string targetDataName)
        {
            // Open the source and target workspaces.
            //String sourceWorkspacePath = @"C:\arcgis\DeveloperKit\SamplesNET\data\Atlanta.gdb";
            //String targetWorkspacePath = @"C:\Temp";
            IWorkspaceFactory sourceWorkspaceFactory = new FileGDBWorkspaceFactoryClass();
            IWorkspaceFactory targetWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
            IWorkspace        sourceWorkspace        = sourceWorkspaceFactory.OpenFromFile
                                                           (sourceWorkspacePath, 0);
            IWorkspace targetWorkspace = targetWorkspaceFactory.OpenFromFile
                                             (targetWorkspacePath, 0);

            // Cast the workspaces to the IDataset interface and get name objects.
            IDataset       sourceWorkspaceDataset     = (IDataset)sourceWorkspace;
            IDataset       targetWorkspaceDataset     = (IDataset)targetWorkspace;
            IName          sourceWorkspaceDatasetName = sourceWorkspaceDataset.FullName;
            IName          targetWorkspaceDatasetName = targetWorkspaceDataset.FullName;
            IWorkspaceName sourceWorkspaceName        = (IWorkspaceName)
                                                        sourceWorkspaceDatasetName;
            IWorkspaceName targetWorkspaceName = (IWorkspaceName)
                                                 targetWorkspaceDatasetName;

            // Create a name object for the shapefile and cast it to the IDatasetName interface.
            IFeatureClassName sourceFeatureClassName = new FeatureClassNameClass();
            IDatasetName      sourceDatasetName      = (IDatasetName)sourceFeatureClassName;

            sourceDatasetName.Name          = sourceDataName;//"streets";
            sourceDatasetName.WorkspaceName = sourceWorkspaceName;

            // Create a name object for the FGDB feature class and cast it to the IDatasetName interface.
            IFeatureClassName targetFeatureClassName = new FeatureClassNameClass();
            IDatasetName      targetDatasetName      = (IDatasetName)targetFeatureClassName;

            targetDatasetName.Name          = targetDataName;// "AtlantaStreets";
            targetDatasetName.WorkspaceName = targetWorkspaceName;

            // Open source feature class to get field definitions.
            IName         sourceName         = (IName)sourceFeatureClassName;
            IFeatureClass sourceFeatureClass = (IFeatureClass)sourceName.Open();

            // Create the objects and references necessary for field validation.
            IFieldChecker   fieldChecker   = new FieldCheckerClass();
            IFields         sourceFields   = sourceFeatureClass.Fields;
            IFields         targetFields   = null;
            IEnumFieldError enumFieldError = null;

            // Set the required properties for the IFieldChecker interface.
            fieldChecker.InputWorkspace    = sourceWorkspace;
            fieldChecker.ValidateWorkspace = targetWorkspace;

            // Validate the fields and check for errors.
            fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields);
            if (enumFieldError != null)
            {
                // Handle the errors in a way appropriate to your application.
                Console.WriteLine("Errors were encountered during field validation.");
            }

            // Find the shape field.
            String shapeFieldName  = sourceFeatureClass.ShapeFieldName;
            int    shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName);
            IField shapeField      = sourceFields.get_Field(shapeFieldIndex);

            // Get the geometry definition from the shape field and clone it.
            IGeometryDef geometryDef            = shapeField.GeometryDef;
            IClone       geometryDefClone       = (IClone)geometryDef;
            IClone       targetGeometryDefClone = geometryDefClone.Clone();
            IGeometryDef targetGeometryDef      = (IGeometryDef)targetGeometryDefClone;

            // Create a query filter to remove ramps, interstates and highways.
            IQueryFilter queryFilter = new QueryFilterClass();

            //queryFilter.WhereClause = "NAME <> 'Ramp' AND PRE_TYPE NOT IN ('I', 'Hwy')";
            queryFilter.WhereClause = "1=1";
            // Create the converter and run the conversion.
            IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();
            IEnumInvalidObject    enumInvalidObject    =
                featureDataConverter.ConvertFeatureClass(sourceFeatureClassName,
                                                         queryFilter, null, targetFeatureClassName, targetGeometryDef, targetFields,
                                                         "", 1000, 0);

            // Check for errors.
            IInvalidObjectInfo invalidObjectInfo = null;

            enumInvalidObject.Reset();
            while ((invalidObjectInfo = enumInvalidObject.Next()) != null)
            {
                // Handle the errors in a way appropriate to the application.
                Console.WriteLine("Errors occurred for the following feature: {0}",
                                  invalidObjectInfo.InvalidObjectID);
            }
        }
Пример #7
0
        //public static ICursor UncheckGridCode(ITable pTable,string pVersionName)
        //{
        //    //根据表格数据获取grid code:
        //    IQueryFilter filter = new QueryFilterClass();
        //    filter.WhereClause = "TaskName = '" + pVersionName + "'";
        //    ICursor cursor = pTable.Search(filter, true);
        //    return cursor;
        //}

        //public static void Check(IFeature pFeature, IWorkspace pWorkspace,string pVersionName)
        //{
        //    //更新检查状态:
        //    int ii = 1;
        //    int fieldindex = pFeature.Fields.FindField("passed");
        //    if (pFeature.get_Value(pFeature.Fields.FindField("VersionName")).ToString() == pVersionName)
        //    {
        //        pFeature.set_Value(fieldindex, ii);
        //        pFeature.Store();
        //    }

        //}

        //public static void Check(IFeature pFeature, IWorkspace pWorkspace)
        //{
        //    //更新检查状态:
        //    int ii = 1;
        //    int fieldindex = pFeature.Fields.FindFieldByAliasName("Pass");

        //        pFeature.set_Value(fieldindex, ii);
        //        pFeature.Store();

        //}

        public static bool ExportSHP(string pDestPath, IWorkspace pWorkspace)
        {
            IWorkspace    sourceWorkspace    = pWorkspace;
            IFeatureClass sourceFeatureClass = DBOperator.getFeatureClass(pWorkspace, "CheckArea");
            string        shpFolderPath      = pDestPath.Substring(0, pDestPath.LastIndexOf("\\"));
            string        shpFileName        = pDestPath.Substring(pDestPath.LastIndexOf("\\") + 1);

            shpFileName = shpFileName.Substring(0, shpFileName.Length - 4);

            IWorkspace targetWorkspace = DBOperator.openShapeFileWorkspace(shpFolderPath);

            if (File.Exists(pDestPath) == true)
            {
                DBOperator.DeleteFeatureClass(targetWorkspace, shpFileName);
            }

            IDataset       sourcedataset       = sourceWorkspace as IDataset;
            IWorkspaceName sourceWorkspaceName = sourcedataset.FullName as IWorkspaceName;
            IDataset       targetdataset       = targetWorkspace as IDataset;
            IWorkspaceName targetWorkspaceName = targetdataset.FullName as IWorkspaceName;

            sourcedataset = sourceFeatureClass as IDataset;
            IFeatureClassName sourceFeatureClassName = sourcedataset.FullName as IFeatureClassName;

            // Create a name object for the target dataset.
            IFeatureClassName targetFeatureClassName = new FeatureClassNameClass();
            IDatasetName      targetDatasetName      = (IDatasetName)targetFeatureClassName;

            targetDatasetName.Name          = shpFileName;
            targetDatasetName.WorkspaceName = targetWorkspaceName;

            // Create the objects and references necessary for field validation.
            IFieldChecker   fieldChecker   = new FieldCheckerClass();
            IFields         sourceFields   = sourceFeatureClass.Fields;
            IFields         targetFields   = null;
            IEnumFieldError enumFieldError = null;

            // Validate the fields and check for errors.
            fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields);
            if (enumFieldError != null)
            {
                IFieldError error = enumFieldError.Next();
                while (error != null)
                {
                    // Handle the errors in a way appropriate to your application.
                    Console.WriteLine("Errors were encountered during field validation.");
                    error = enumFieldError.Next();
                }
            }

            // Find the shape field.
            String shapeFieldName  = sourceFeatureClass.ShapeFieldName;
            int    shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName);
            IField shapeField      = sourceFields.get_Field(shapeFieldIndex);

            // Get the geometry definition from the shape field and clone it.
            IGeometryDef geometryDef            = shapeField.GeometryDef;
            IClone       geometryDefClone       = (IClone)geometryDef;
            IClone       targetGeometryDefClone = geometryDefClone.Clone();
            IGeometryDef targetGeometryDef      = (IGeometryDef)targetGeometryDefClone;

            // Cast the IGeometryDef to the IGeometryDefEdit interface.
            IGeometryDefEdit targetGeometryDefEdit = (IGeometryDefEdit)targetGeometryDef;

            // Set the IGeometryDefEdit properties.
            targetGeometryDefEdit.GridCount_2 = 1;
            targetGeometryDefEdit.set_GridSize(0, 0.75);

            // Set the required properties for the IFieldChecker interface.
            fieldChecker.InputWorkspace    = sourceWorkspace;
            fieldChecker.ValidateWorkspace = targetWorkspace;

            // Create the converter and run the conversion.
            IFeatureDataConverter2 featureDataConverter = new FeatureDataConverterClass();

            IDatasetName       sourceFClassName  = sourceFeatureClassName as IDatasetName;
            IEnumInvalidObject enumInvalidObject = featureDataConverter.ConvertFeatureClass
                                                       (sourceFClassName, null, null, null, targetFeatureClassName,
                                                       targetGeometryDef, targetFields, "", 1000, 0);
            // Check for errors.
            IInvalidObjectInfo invalidObjectInfo = null;

            enumInvalidObject.Reset();
            while ((invalidObjectInfo = enumInvalidObject.Next()) != null)
            {
                // Handle the errors in a way appropriate to the application.
                Console.WriteLine("Errors occurred for the following feature: {0}",
                                  invalidObjectInfo.InvalidObjectID);
                return(false);
            }
            return(true);
        }