Exemple #1
0
        public static string ConvertPagesToFeatureClass(string filepath, string layerName, string prefix = "GBDX")
        {
            try
            {
                var json = MergeJsonStrings(filepath);

                json = MergeProperties(json);

                var jsonOutput = json.ToString(Formatting.None);

                var workspace = Jarvis.OpenWorkspace(Settings.Default.geoDatabase);

                IFieldChecker fieldChecker = new FieldCheckerClass();
                fieldChecker.ValidateWorkspace = workspace;

                var    proposedTableName = string.Format("{0}{1}", prefix, Guid.NewGuid());
                string tableName;

                fieldChecker.ValidateTableName(proposedTableName, out tableName);

                WriteToTable(workspace, jsonOutput, tableName);

                return(tableName);
            }
            catch (Exception error)
            {
                Jarvis.Logger.Error(error);
            }
            return(string.Empty);
        }
        //
        // PUBLIC METHODS
        //
        /// <summary>
        /// Validates a table name
        /// </summary>
        /// <param name="name">The table name to validate</param>
        /// <param name="message">If table name fails then this variable will contain a description</param>
        /// <returns>True if passed. False if failed.</returns>
        public bool ValidateTableName(string name, out string message)
        {
            // Check Arguments
            if (string.IsNullOrEmpty(name))
            {
                throw new NullReferenceException("<name> argument cannot be null");
            }

            // Get Table Name
            string tableName = GeodatabaseUtility.GetTableName(name);

            // Validate Table Name
            IFieldChecker fieldChecker = new FieldCheckerClass();

            fieldChecker.ValidateWorkspace = this._workspace;
            string newName = null;
            int    error   = fieldChecker.ValidateTableName(tableName, out newName);

            // Create Message
            switch (error)
            {
            case 0:
                message = null;
                break;

            case 1:
                message = string.Format("Table name [{0}] contains a reserved word.", name);
                break;

            case 2:
                message = string.Format("Table name [{0}] contains an invalid character.", name);
                break;

            case 4:
                message = string.Format("Table name [{0}] has invalid starting character.", name);
                break;

            default:
                message = string.Format("Table name [{0}] is invalid.", name);
                break;
            }

            // Append Recommended Name
            switch (error)
            {
            case 0:
                return(true);

            default:
                if (!(string.IsNullOrEmpty(newName)))
                {
                    if (newName != name)
                    {
                        message += string.Format(" Try [{0}].", newName);
                    }
                }
                return(false);
            }
        }
Exemple #3
0
        private void btnSelectIn_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile
            {
                AllowMultiSelect = false,
                Text             = "选择要素"
            };

            file.RemoveAllFilters();
            file.AddFilter(new MyGxFilterDatasets(), true);
            if (file.DoModalOpen() == DialogResult.OK)
            {
                IArray items = file.Items;
                if (items.Count != 0)
                {
                    this.igxDataset_0      = items.get_Element(0) as IGxDataset;
                    this.idataset_0        = this.igxDataset_0.Dataset;
                    this.txtInputFeat.Text = (this.igxDataset_0 as IGxObject).FullName;
                    this.iworkspace_0      = this.idataset_0.Workspace;
                    string        tableName = this.idataset_0.Name + "_Project1";
                    IFieldChecker checker   = new FieldCheckerClass
                    {
                        InputWorkspace = this.iworkspace_0
                    };
                    checker.ValidateTableName(tableName, out this.string_0);
                    this.txtOutFeat.Text = this.iworkspace_0.PathName + @"\" + this.string_0;
                    if ((this.iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) ||
                        (this.iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace))
                    {
                        if (((IWorkspace2)this.iworkspace_0).get_NameExists(esriDatasetType.esriDTFeatureClass,
                                                                            this.string_0))
                        {
                            this.bool_0 = true;
                        }
                        else
                        {
                            this.bool_0 = false;
                        }
                    }
                    else if (this.iworkspace_0.Type == esriWorkspaceType.esriFileSystemWorkspace)
                    {
                        if (File.Exists(this.txtOutFeat.Text + ".shp"))
                        {
                            this.bool_0 = true;
                        }
                        else
                        {
                            this.bool_0 = false;
                        }
                    }
                }
            }
        }
Exemple #4
0
        private IFeatureClass method_2(IFeatureWorkspace ifeatureWorkspace_0, string string_4,
                                       esriFeatureType esriFeatureType_0, esriGeometryType esriGeometryType_0, IFields ifields_0)
        {
            IFeatureClass class2 = null;
            string        str;
            IFieldChecker checker = new FieldCheckerClass
            {
                ValidateWorkspace = ifeatureWorkspace_0 as IWorkspace
            };

            checker.ValidateTableName(string_4, out str);
            IObjectClassDescription description = null;

            if (esriFeatureType_0 == esriFeatureType.esriFTAnnotation)
            {
                return(this.method_1(ifeatureWorkspace_0, string_4, 1000.0, new TextSymbolClass(), ifields_0));
            }
            description = new FeatureClassDescriptionClass();
            IFieldsEdit requiredFields = description.RequiredFields as IFieldsEdit;
            IFieldEdit  edit2          = null;
            int         index          = requiredFields.FindField((description as IFeatureClassDescription).ShapeFieldName);

            edit2 = requiredFields.get_Field(index) as IFieldEdit;
            IGeometryDefEdit geometryDef  = edit2.GeometryDef as IGeometryDefEdit;
            esriFeatureType  esriFTSimple = esriFeatureType.esriFTSimple;

            edit2.GeometryDef_2 = geometryDef;
            for (int i = 0; i < ifields_0.FieldCount; i++)
            {
                requiredFields.AddField(ifields_0.get_Field(i));
            }
            try
            {
                class2 = ifeatureWorkspace_0.CreateFeatureClass(string_4, requiredFields, null, null, esriFTSimple,
                                                                (description as IFeatureClassDescription).ShapeFieldName, "");
            }
            catch (Exception exception)
            {
                Logger.Current.Error("", exception, "");
            }
            return(class2);
        }
Exemple #5
0
        private void ConvertPagesToFeatureClass(string filepath, string layerName)
        {
            try
            {
                var json = MergeJsonStrings(filepath);

                json = MergeProperties(json);

                var jsonOutput = json.ToString(Formatting.None);

                var workspace = Jarvis.OpenWorkspace(Settings.Default.geoDatabase);

                IFieldChecker fieldChecker = new FieldCheckerClass();
                fieldChecker.ValidateWorkspace = workspace;

                var    proposedTableName = string.Format("AnswerFactory{0}", Guid.NewGuid());
                string tableName;

                fieldChecker.ValidateTableName(proposedTableName, out tableName);

                WriteToTable(workspace, jsonOutput, tableName);

                this.Invoke((MethodInvoker)(() =>
                {
                    this.loadingCircle.Active = false;
                    this.loadingCircle.Visible = false;
                    AddLayerToMap(tableName, layerName);
                }));

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
            }
            catch (Exception error)
            {
                Jarvis.Logger.Error(error);
            }
        }
Exemple #6
0
        public static void Project(IFeatureClass ifeatureClass_0, ISpatialReference ispatialReference_0,
                                   IWorkspace iworkspace_0, string string_0, double double_0)
        {
            string                str2;
            double                num3;
            double                num4;
            double                num5;
            double                num6;
            IEnumFieldError       error;
            IFields               fields2;
            IWorkspace            workspace = ((IDataset)ifeatureClass_0).Workspace;
            IFeatureDataConverter converter = new FeatureDataConverterClass();
            IWorkspaceName        name      = new WorkspaceNameClass
            {
                ConnectionProperties   = workspace.ConnectionProperties,
                WorkspaceFactoryProgID = workspace.WorkspaceFactory.GetClassID().Value.ToString()
            };
            IWorkspaceName name2 = new WorkspaceNameClass();

            new PropertySetClass();
            name2.ConnectionProperties   = iworkspace_0.ConnectionProperties;
            name2.WorkspaceFactoryProgID = iworkspace_0.WorkspaceFactory.GetClassID().Value.ToString();
            IDatasetName name3     = new FeatureClassNameClass();
            string       aliasName = ifeatureClass_0.AliasName;
            int          index     = aliasName.LastIndexOf(".");

            if (index != -1)
            {
                aliasName = aliasName.Substring(index + 1);
            }
            name3.Name          = aliasName;
            name3.WorkspaceName = name;
            IDatasetName name4 = new FeatureClassNameClass
            {
                WorkspaceName = name2
            };
            IFieldChecker checker = new FieldCheckerClass
            {
                ValidateWorkspace = iworkspace_0
            };

            string[] strArray = string_0.Split(new char[] { '.' });
            string_0 = strArray[strArray.Length - 1] + "_Project";
            checker.ValidateTableName(string_0, out str2);
            string str3 = str2;
            int    num2 = 1;

            if ((iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) ||
                (iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace))
            {
                while (((IWorkspace2)iworkspace_0).get_NameExists(esriDatasetType.esriDTFeatureClass, str3))
                {
                    str3 = str2 + "_" + num2.ToString();
                    num2++;
                }
            }
            else if (iworkspace_0.Type == esriWorkspaceType.esriFileSystemWorkspace)
            {
                while (File.Exists(str3 + ".shp"))
                {
                    str3 = str2 + "_" + num2.ToString();
                    num2++;
                }
            }
            name4.Name = str3;
            IFields inputField = new FieldsClass();

            index = ifeatureClass_0.Fields.FindField(ifeatureClass_0.ShapeFieldName);
            IField            field            = ifeatureClass_0.Fields.get_Field(index);
            IGeometryDef      geometryDef      = field.GeometryDef;
            ISpatialReference spatialReference = geometryDef.SpatialReference;

            ispatialReference_0.GetDomain(out num3, out num4, out num5, out num6);
            ((IGeometryDefEdit)geometryDef).GridCount_2 = 1;
            ((IGeometryDefEdit)geometryDef).set_GridSize(0, double_0);
            ((IGeometryDefEdit)geometryDef).SpatialReference_2 = ispatialReference_0;
            ((IFieldEdit)field).GeometryDef_2 = geometryDef;
            for (int i = 0; i < ifeatureClass_0.Fields.FieldCount; i++)
            {
                if (i == index)
                {
                    ((IFieldsEdit)inputField).AddField(field);
                }
                else
                {
                    IField field2 = ifeatureClass_0.Fields.get_Field(i);
                    ((IFieldsEdit)inputField).AddField(field2);
                }
            }
            checker.Validate(inputField, out error, out fields2);
            if (m_pfrm != null)
            {
                m_pfrm.FeatureProgress = converter;
            }
            try
            {
                converter.ConvertFeatureClass((IFeatureClassName)name3, null, null, (IFeatureClassName)name4,
                                              geometryDef, fields2, "", 1000, 0);
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
 /// <summary>returns a validated table name</summary>
 /// <param name="workspace">the input workspace of the tablenaam</param>
 /// <param name="tableName">the input tablename</param>
 /// <returns>the output laundered tablenaam</returns>
 public static String ValidateTableName(IWorkspace workspace, String tableName)
 {
     // Create a field checker to validate the table name.
     IFieldChecker fieldChecker = new FieldCheckerClass();
     String validatedName = null;
     fieldChecker.ValidateWorkspace = workspace;
     fieldChecker.ValidateTableName(tableName, out validatedName);
     validatedName = validatedName.Replace("\"", "_").Replace("\'", "_");
     return validatedName;
 }
        private void AggregationResponse(IRestResponse<MotherOfGodAggregations> response, int attempts = 0)
        {
            Jarvis.Logger.Info(response.ResponseUri.ToString());

            // If we are getting timeouts retry up to MAX ATTEMPTS and log that a timeout occurred attempting the following URL
            if (response.StatusCode == HttpStatusCode.GatewayTimeout && attempts <= MaxAttempts)
            {
                IRestClient restClient = new RestClient(Settings.Default.AuthBase);
                restClient.ExecuteAsync<MotherOfGodAggregations>(
                    response.Request,
                    resp => this.AggregationResponse(response, attempts + 1));

                Jarvis.Logger.Warning(string.Format("{0} :: {1}", response.StatusCode, response.ResponseUri));
                return;
            }

            if (response.Data != null && response.StatusCode == HttpStatusCode.OK)
            {
                var workspace = Jarvis.OpenWorkspace(Settings.Default.geoDatabase);
                var resultDictionary = new Dictionary<string, Dictionary<string, double>>();
                var uniqueFieldNames = new Dictionary<string, string>();

                AggregationHelper.ProcessAggregations(
                    response.Data.aggregations,
                    0,
                    ref resultDictionary,
                    string.Empty,
                    false,
                    ref uniqueFieldNames);

                if (resultDictionary.Count == 0 && uniqueFieldNames.Count == 0)
                {
                    MessageBox.Show(GbdxResources.NoDataFound);
                    this.Invoke((MethodInvoker)delegate { this.goButton.Enabled = true; });

                    return;
                }

                FieldChecker checker = new FieldCheckerClass();

                // Create a unique name for the feature class based on name.
                var featureClassName = "Agg_" + Guid.NewGuid();

                checker.ValidateTableName(featureClassName, out featureClassName);

                // Function being called really says it all but ... lets CREATE A FEATURE CLASS
                var featureClass = Jarvis.CreateStandaloneFeatureClass(
                    workspace,
                    featureClassName,
                    uniqueFieldNames,
                    false,
                    0);

                this.WriteToFeatureClass(featureClass, resultDictionary, uniqueFieldNames, workspace);

                // Use the dispatcher to make sure the following calls occur on the MAIN thread.
                this.Invoke(
                    (MethodInvoker)delegate
                        {
                            this.AddLayerToArcMap(featureClassName);
                            this.goButton.Enabled = true;
                        });
            }
            else
            {
                var error = string.Format(
                    "STATUS: {0}\n{1}\n\n{2}",
                    response.StatusCode,
                    response.ResponseUri.AbsoluteUri,
                    response.Content);
                Jarvis.Logger.Error(error);

                this.Invoke((MethodInvoker)delegate { this.goButton.Enabled = true; });

                MessageBox.Show(GbdxResources.Source_ErrorMessage);
            }
        }
Exemple #9
0
        private void btnSelectOut_Click(object sender, EventArgs e)
        {
            frmOpenFile file = new frmOpenFile
            {
                Text = "保存位置"
            };

            file.RemoveAllFilters();
            file.AddFilter(new MyGxFilterFeatureClasses(), true);
            if (file.DoModalSave() == DialogResult.OK)
            {
                IArray items = file.Items;
                if (items.Count != 0)
                {
                    IGxObject obj2 = items.get_Element(0) as IGxObject;
                    if (obj2 is IGxDatabase)
                    {
                        this.iname_0 = obj2.InternalObjectName;
                    }
                    else if (obj2 is IGxFolder)
                    {
                        IWorkspaceName name = new WorkspaceNameClass
                        {
                            WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory",
                            PathName = (obj2.InternalObjectName as IFileName).Path
                        };
                        this.iname_0 = name as IName;
                    }
                    else if (obj2 is IGxDataset)
                    {
                        return;
                    }
                    this.iworkspace_0 = this.iname_0.Open() as IWorkspace;
                    string        saveName = file.SaveName;
                    IFieldChecker checker  = new FieldCheckerClass
                    {
                        InputWorkspace = this.iworkspace_0
                    };
                    checker.ValidateTableName(saveName, out this.string_0);
                    this.txtOutFeat.Text = this.iworkspace_0.PathName + @"\" + this.string_0;
                    if ((this.iworkspace_0.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) ||
                        (this.iworkspace_0.Type == esriWorkspaceType.esriLocalDatabaseWorkspace))
                    {
                        if (((IWorkspace2)this.iworkspace_0).get_NameExists(esriDatasetType.esriDTFeatureClass,
                                                                            this.string_0))
                        {
                            this.bool_0 = true;
                        }
                        else
                        {
                            this.bool_0 = false;
                        }
                    }
                    else if (this.iworkspace_0.Type == esriWorkspaceType.esriFileSystemWorkspace)
                    {
                        if (File.Exists(this.txtOutFeat.Text + ".shp"))
                        {
                            this.bool_0 = true;
                        }
                        else
                        {
                            this.bool_0 = false;
                        }
                    }
                }
            }
        }
Exemple #10
0
        public static IFeatureClass CreateStandaloneFeatureClass(
            IWorkspace workspace,
            string featureClassName,
            Dictionary <string, string> uniqueNames,
            bool allowNull,
            double defaultValue)
        {
            var featureWorkspace            = (IFeatureWorkspace)workspace;
            IFeatureClassDescription fcDesc = new FeatureClassDescriptionClass();
            var ocDesc = (IObjectClassDescription)fcDesc;

            // Use IFieldChecker to create a validated fields collection.
            IFieldChecker   fieldChecker    = new FieldCheckerClass();
            IEnumFieldError enumFieldError  = null;
            IFields         validatedFields = null;

            fieldChecker.ValidateWorkspace = workspace;

            IFields fields = new FieldsClass();

            // if a fields collection is not passed in then supply our own
            var fieldsEdit = (IFieldsEdit)fields; // Explicit Cast

            var        tmpField     = new FieldClass();
            IFieldEdit tmpFieldEdit = tmpField;

            tmpFieldEdit.Name_2   = "GeoHash";
            tmpFieldEdit.Type_2   = esriFieldType.esriFieldTypeString;
            tmpFieldEdit.Length_2 = 20;
            fieldsEdit.AddField(tmpField);

            foreach (var name in uniqueNames.Keys)
            {
                var        tempField     = new FieldClass();
                IFieldEdit tempFieldEdit = tempField;
                tempFieldEdit.Name_2 = "DG_" + uniqueNames[name];
                if (name.EndsWith("_str"))
                {
                    tempFieldEdit.Type_2         = esriFieldType.esriFieldTypeString;
                    tempFieldEdit.Length_2       = 250;
                    tempFieldEdit.AliasName_2    = name;
                    tempFieldEdit.IsNullable_2   = allowNull;
                    tempFieldEdit.DefaultValue_2 = "";
                }
                else
                {
                    tempFieldEdit.Name_2         = "DG_" + uniqueNames[name];
                    tempFieldEdit.Type_2         = esriFieldType.esriFieldTypeDouble;
                    tempFieldEdit.Length_2       = 20;
                    tempFieldEdit.AliasName_2    = name;
                    tempFieldEdit.IsNullable_2   = allowNull;
                    tempFieldEdit.DefaultValue_2 = defaultValue;
                }

                fieldsEdit.AddField(tempField);
            }

            ISpatialReferenceFactory spatialReferenceFactory = new SpatialReferenceEnvironment();
            var geographicCoordinateSystem =
                spatialReferenceFactory.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

            IGeometryDef geometryDef     = new GeometryDefClass();
            var          geometryDefEdit = (IGeometryDefEdit)geometryDef;

            geometryDefEdit.GeometryType_2     = esriGeometryType.esriGeometryPolygon;
            geometryDefEdit.SpatialReference_2 = geographicCoordinateSystem;
            var        shapeField     = new FieldClass();
            IFieldEdit shapeFieldEdit = shapeField;

            shapeFieldEdit.Name_2        = "SHAPE";
            shapeFieldEdit.Type_2        = esriFieldType.esriFieldTypeGeometry;
            shapeFieldEdit.GeometryDef_2 = geometryDef;
            shapeFieldEdit.IsNullable_2  = true;
            shapeFieldEdit.Required_2    = true;
            fieldsEdit.AddField(shapeField);
            fields = fieldsEdit;

            fieldChecker.Validate(fields, out enumFieldError, out validatedFields);
            fieldChecker.ValidateTableName(featureClassName, out featureClassName);
            // The enumFieldError enumerator can be inspected at this point to determine
            // which fields were modified during validation.
            try
            {
                var featureClass = featureWorkspace.CreateFeatureClass(
                    featureClassName,
                    validatedFields,
                    ocDesc.InstanceCLSID,
                    ocDesc.ClassExtensionCLSID,
                    esriFeatureType.esriFTSimple,
                    "SHAPE",
                    string.Empty);
                return(featureClass);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new Exception("Issue with creating feature class");
            }
        }
        //
        // PUBLIC METHODS 
        //
        /// <summary>
        /// Validates a table name
        /// </summary>
        /// <param name="name">The table name to validate</param>
        /// <param name="message">If table name fails then this variable will contain a description</param>
        /// <returns>True if passed. False if failed.</returns>
        public bool ValidateTableName(string name, out string message) {
            // Check Arguments
            if (string.IsNullOrEmpty(name)) {
                throw new NullReferenceException("<name> argument cannot be null");
            }

            // Get Table Name
            string tableName = GeodatabaseUtility.GetTableName(name);

            // Validate Table Name
            IFieldChecker fieldChecker = new FieldCheckerClass();
            fieldChecker.ValidateWorkspace = this._workspace;
            string newName = null;
            int error = fieldChecker.ValidateTableName(tableName, out newName);

            // Create Message
            switch (error) {
                case 0:
                    message = null;
                    break;
                case 1:
                    message = string.Format("Table name [{0}] contains a reserved word.", name);
                    break;
                case 2:
                    message = string.Format("Table name [{0}] contains an invalid character.", name);
                    break;
                case 4:
                    message = string.Format("Table name [{0}] has invalid starting character.", name);
                    break;
                default:
                    message = string.Format("Table name [{0}] is invalid.", name);
                    break;
            }

            // Append Recommended Name
            switch (error) {
                case 0:
                    return true;
                default:
                    if (!(string.IsNullOrEmpty(newName))) {
                        if (newName != name) {
                            message += string.Format(" Try [{0}].", newName);
                        }
                    }
                    return false;
            }
        }
        private void ConvertPagesToFeatureClass(string filepath, string layerName)
        {
            try
            {
                var json = MergeJsonStrings(filepath);

                json = MergeProperties(json);

                var jsonOutput = json.ToString(Formatting.None);

                var workspace = Jarvis.OpenWorkspace(Settings.Default.geoDatabase);

                IFieldChecker fieldChecker = new FieldCheckerClass();
                fieldChecker.ValidateWorkspace = workspace;

                var proposedTableName = string.Format("AnswerFactory{0}", Guid.NewGuid());
                string tableName;

                fieldChecker.ValidateTableName(proposedTableName, out tableName);

                WriteToTable(workspace, jsonOutput, tableName);

                this.Invoke((MethodInvoker)(() =>
                {
                    this.loadingCircle.Active = false;
                    this.loadingCircle.Visible = false;
                    AddLayerToMap(tableName, layerName);
                }));

                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
            }
            catch (Exception error)
            {
                Jarvis.Logger.Error(error);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pSourceFeatureClass"></param>
        /// <param name="_pTWorkspaceFactory"></param>
        /// <param name="_pTWs"></param>
        /// <param name="_pTName"></param>
        public void ConvertQuery2FeatureClass( IFeatureClass pSourceFeatureClass , IWorkspaceFactory _pTWorkspaceFactory, String _pTWs, string _pTName)
        {
            IWorkspace pTWorkspace = _pTWorkspaceFactory.OpenFromFile(_pTWs, 0);

            IDataset pSDataset = pSourceFeatureClass as IDataset;

            IFeatureClassName pSourceFeatureClassName = pSDataset.FullName as IFeatureClassName;

            IDataset pTDataset = (IDataset)pTWorkspace;

            IName pTDatasetName = pTDataset.FullName;

            IWorkspaceName pTargetWorkspaceName = (IWorkspaceName)pTDatasetName;

            IFeatureClassName pTargetFeatureClassName = new FeatureClassNameClass();

            IDatasetName pTargetDatasetName = (IDatasetName)pTargetFeatureClassName;

            // 验证要素类的名称是否合法,但是并没有对这个名称是否存在做检查
            string pTableName = null;

            IFieldChecker pNameChecker = new FieldCheckerClass();

            pNameChecker.ValidateWorkspace = pTWorkspace;

            int pFlag = pNameChecker.ValidateTableName(_pTName, out pTableName);

            pTargetDatasetName.Name = pTableName;

            pTargetDatasetName.WorkspaceName = pTargetWorkspaceName;

            // 创建字段检查对象
            IFieldChecker pFieldChecker = new FieldCheckerClass();

            IFields sourceFields = pSourceFeatureClass.Fields;
            IFields pTargetFields = null;

            IEnumFieldError pEnumFieldError = null;

            pFieldChecker.InputWorkspace = ((IDataset)pSourceFeatureClass).Workspace;

            pFieldChecker.ValidateWorkspace = pTWorkspace;

            // 验证字段
            pFieldChecker.Validate(sourceFields, out pEnumFieldError, out pTargetFields);
            if (pEnumFieldError != null)
            {
                // 报错提示
                Console.WriteLine("Errors were encountered during field validation.");
            }

            String pShapeFieldName = pSourceFeatureClass.ShapeFieldName;

            int pFieldIndex = pSourceFeatureClass.FindField(pShapeFieldName);

            IField pShapeField = sourceFields.get_Field(pFieldIndex);

            IGeometryDef pTargetGeometryDef = pShapeField.GeometryDef;

            // 创建要素转换对象
            IFeatureDataConverter pFDConverter = new FeatureDataConverterClass();

            IEnumInvalidObject pEnumInvalidObject = pFDConverter.ConvertFeatureClass(pSourceFeatureClassName, null, null, pTargetFeatureClassName,
                pTargetGeometryDef, pTargetFields, "", 1000, 0);

            // 检查是否有错误
            IInvalidObjectInfo pInvalidInfo = null;

            pEnumInvalidObject.Reset();

            while ((pInvalidInfo = pEnumInvalidObject.Next()) != null)
            {
                // 报错提示.
                Console.WriteLine("Errors occurred for the following feature: {0}",
                    pInvalidInfo.InvalidObjectID);
            }
        }