コード例 #1
0
        private void ExportDatasetToXML(string fileGdbPath, string sourceFCName, string outputXmlFile)
        {
            // Open the source geodatabase and create a name object for it.
            IWorkspaceName sourceWorkspaceName = getWorkspaceName("esriDataSourcesGDB.FileGDBWorkspaceFactory", fileGdbPath);

            IFeatureClassName sourceFeatureClassName = getFeatureClassName(sourceWorkspaceName, sourceFCName);
            IName             sourceName             = (IName)sourceFeatureClassName;

            // Create a new names enumerator and add the feature dataset name.
            IEnumNameEdit enumNameEdit = new NamesEnumeratorClass();

            enumNameEdit.Add(sourceName);
            IEnumName enumName = (IEnumName)enumNameEdit;

            // Create a GeoDBDataTransfer object and create a name mapping.
            IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
            IEnumNameMapping   enumNameMapping   = null;

            geoDBDataTransfer.GenerateNameMapping(enumName, sourceWorkspaceName as IName, out enumNameMapping);

            // Create an exporter and export the dataset with binary geometry, not compressed,
            // and including metadata.
            IGdbXmlExport gdbXmlExport = new GdbExporterClass();

            gdbXmlExport.ExportDatasets(enumNameMapping, outputXmlFile, true, false, true);
        }
コード例 #2
0
ファイル: TranferDatabase.cs プロジェクト: truonghinh/TnX
        public static void ExportToXml(IWorkspace sourceWorkspace, string targetPath,bool binaryGeometry,bool compressed,bool retriveMetadata)
        {
            // Open the source geodatabase and create a name object for it.
            IWorkspaceFactory workspaceFactory = new AccessWorkspaceFactoryClass();
            //IWorkspace workspace = workspaceFactory.OpenFromFile(databaseName, 0);
            IDataset workspaceDataset = (IDataset)sourceWorkspace;
            IName workspaceName = workspaceDataset.FullName;

            // Retrieve the first feature dataset from the workspace.
            IEnumDatasetName enumDatasetName = sourceWorkspace.get_DatasetNames
              (esriDatasetType.esriDTFeatureDataset);
            enumDatasetName.Reset();
            IName featureDatasetName = (IName)enumDatasetName.Next();
            if (featureDatasetName == null)
            {
                throw new Exception(
                  "No feature datasets exist in the specified geodatabase.");
            }

            // Create a new names enumerator and add the feature dataset name.
            IEnumNameEdit enumNameEdit = new NamesEnumeratorClass();
            enumNameEdit.Add(featureDatasetName);
            IEnumName enumName = (IEnumName)enumNameEdit;

            // Create a GeoDBDataTransfer object and create a name mapping.
            IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
            IEnumNameMapping enumNameMapping = null;
            geoDBDataTransfer.GenerateNameMapping(enumName, workspaceName, out enumNameMapping);

            // Create an exporter and export the dataset with binary geometry, not compressed,
            // and including metadata.
            IGdbXmlExport gdbXmlExport = new GdbExporterClass();
            gdbXmlExport.ExportDatasets(enumNameMapping, targetPath, binaryGeometry, compressed, retriveMetadata);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: vasnake/gdbexport2xml
        } // getFCNames

        public void doWork()
        {
            Log.p("doWork started...");
            String sdeconnfname = mSdeConnFileName; // "c:\\t\\test.sde";
            String tabnames     = mTabName;         // "T.TAB1,T.TAB2";

            Log.p("Open the source gdb");
            IWorkspaceFactory wspFact = new SdeWorkspaceFactoryClass();
            IWorkspace        wsp     = wspFact.OpenFromFile(sdeconnfname, 0);

            Log.p("Get FC names");
            IEnumNameEdit edtNames = getFCNames(wsp, tabnames);
            IEnumName     names    = (IEnumName)edtNames;

            Log.p("Create a scratch workspace factory");
            IScratchWorkspaceFactory scrWspFact = new ScratchWorkspaceFactoryClass();
            IWorkspace scrWsp     = scrWspFact.CreateNewScratchWorkspace();
            IDataset   dset       = (IDataset)scrWsp;
            IName      scrWspName = dset.FullName;

            Log.p("Create a Transfer object and a name mapping");
            IGeoDBDataTransfer trans        = new GeoDBDataTransferClass();
            IEnumNameMapping   nameMaps     = null;
            Boolean            hasConflicts = trans.GenerateNameMapping(
                names, scrWspName, out nameMaps);

            if (hasConflicts)
            {
                throw new ArgumentException("Name mapping has conflicts.");
            }

            bool          expData    = mNeedData;
            string        fname      = mExpFileName;
            bool          getMeta    = mNeedMeta;
            bool          compressed = false;
            bool          binaryGeom = true;
            IGdbXmlExport exp        = new GdbExporterClass();

            if (expData == false)
            {
                Log.p(String.Format("Export schema (u need sdeexport for data); file [{0}], metadata [{1}]",
                                    fname, getMeta));
                exp.ExportDatasetsSchema(nameMaps, fname, compressed, getMeta);
            }
            else
            {
                Log.p(String.Format("Export schema&data; file [{0}], metadata [{1}]",
                                    fname, getMeta));
                exp.ExportDatasets(nameMaps, fname, binaryGeom, compressed, getMeta);
            }

            Log.p("OK, xml writed.", "both");
        } // method doWork
コード例 #4
0
ファイル: CopyPasteGDBData.cs プロジェクト: radtek/geosufan
        public static void CopyPasteGeodatabaseData(IWorkspace sourceWorkspace, IWorkspace targetWorkspace, string objectName, esriDatasetType esriDataType)
        {
            // Validate input

            if ((sourceWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace) || (targetWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace))
            {
                return; // Should be a throw
            }
            //create source workspace name

            IDataset sourceWorkspaceDataset = (IDataset)sourceWorkspace;

            IWorkspaceName sourceWorkspaceName = (IWorkspaceName)sourceWorkspaceDataset.FullName;

            //create target workspace name

            IDataset targetWorkspaceDataset = (IDataset)targetWorkspace;

            IWorkspaceName targetWorkspaceName = (IWorkspaceName)targetWorkspaceDataset.FullName;

            //Create Name Object Based on data type

            IDatasetName datasetName;

            switch (esriDataType)
            {
            case esriDatasetType.esriDTFeatureDataset:

                IFeatureDatasetName inFeatureDatasetName = new FeatureDatasetNameClass();

                datasetName          = (IDatasetName)inFeatureDatasetName;
                inFeatureDatasetName = null;
                break;

            case esriDatasetType.esriDTFeatureClass:

                IFeatureClassName inFeatureClassName = new FeatureClassNameClass();

                datasetName        = (IDatasetName)inFeatureClassName;
                inFeatureClassName = null;

                break;

            case esriDatasetType.esriDTTable:

                ITableName inTableName = new TableNameClass();

                datasetName = (IDatasetName)inTableName;
                inTableName = null;

                break;

            case esriDatasetType.esriDTGeometricNetwork:

                IGeometricNetworkName inGeometricNetworkName = new GeometricNetworkNameClass();

                datasetName            = (IDatasetName)inGeometricNetworkName;
                inGeometricNetworkName = null;

                break;

            case esriDatasetType.esriDTRelationshipClass:

                IRelationshipClassName inRelationshipClassName = new RelationshipClassNameClass();

                datasetName             = (IDatasetName)inRelationshipClassName;
                inRelationshipClassName = null;
                break;

            case esriDatasetType.esriDTNetworkDataset:

                INetworkDatasetName inNetworkDatasetName = new NetworkDatasetNameClass();

                datasetName          = (IDatasetName)inNetworkDatasetName;
                inNetworkDatasetName = null;

                break;

            case esriDatasetType.esriDTTopology:

                ITopologyName inTopologyName = new TopologyNameClass();

                datasetName    = (IDatasetName)inTopologyName;
                inTopologyName = null;

                break;

            default:

                return;     // Should be a throw
            }

            // Set the name of the object to be copied

            datasetName.WorkspaceName = (IWorkspaceName)sourceWorkspaceName;

            datasetName.Name = objectName;

            //Setup mapping for copy/paste

            IEnumNameMapping fromNameMapping;

            ESRI.ArcGIS.esriSystem.IEnumNameEdit editFromName;

            ESRI.ArcGIS.esriSystem.IEnumName fromName = new NamesEnumerator();

            editFromName = (ESRI.ArcGIS.esriSystem.IEnumNameEdit)fromName;

            editFromName.Add((ESRI.ArcGIS.esriSystem.IName)datasetName);

            ESRI.ArcGIS.esriSystem.IName toName = (ESRI.ArcGIS.esriSystem.IName)targetWorkspaceName;

            // Generate name mapping


            ESRI.ArcGIS.Geodatabase.IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();

            bool targetWorkspaceExists;

            targetWorkspaceExists = geoDBDataTransfer.GenerateNameMapping(fromName, toName, out fromNameMapping);

            // Copy/Pate the data

            geoDBDataTransfer.Transfer(fromNameMapping, toName);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(geoDBDataTransfer);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(datasetName);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(fromName);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(editFromName);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(fromNameMapping);
            geoDBDataTransfer = null;
            datasetName       = null;
            editFromName      = null;
            fromName          = null;

            sourceWorkspaceDataset = null;
            sourceWorkspaceName    = null;
            targetWorkspaceDataset = null;
            targetWorkspaceName    = null;
            toName          = null;
            fromNameMapping = null;
        }
コード例 #5
0
        public void TansferFileGDBToSDE(string fileGDBPath, string sourceFCName)
        {
            // Create workspace name objects.
            IWorkspaceName sourceWorkspaceName = getWorkspaceName("esriDataSourcesGDB.FileGDBWorkspaceFactory", fileGDBPath);

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

            IName targetName = (IName)targetWorkspaceName;

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

            // Create an enumerator for source datasets.
            IEnumName     sourceEnumName     = new NamesEnumeratorClass();
            IEnumNameEdit sourceEnumNameEdit = (IEnumNameEdit)sourceEnumName;

            // Add the name object for the source class to the enumerator.
            sourceEnumNameEdit.Add(sourceName);

            // Create a GeoDBDataTransfer object and a null name mapping enumerator.
            IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
            IEnumNameMapping   enumNameMapping   = null;

            // Use the data transfer object to create a name mapping enumerator.
            Boolean conflictsFound = geoDBDataTransfer.GenerateNameMapping(sourceEnumName,
                                                                           targetName, out enumNameMapping);

            enumNameMapping.Reset();

            // Check for conflicts.
            if (conflictsFound)
            {
                // Iterate through each name mapping.
                INameMapping nameMapping = null;
                while ((nameMapping = enumNameMapping.Next()) != null)
                {
                    // Resolve the mapping's conflict (if there is one).
                    if (nameMapping.NameConflicts)
                    {
                        nameMapping.TargetName = nameMapping.GetSuggestedName(targetName);
                    }

                    // See if the mapping's children have conflicts.
                    IEnumNameMapping childEnumNameMapping = nameMapping.Children;
                    if (childEnumNameMapping != null)
                    {
                        childEnumNameMapping.Reset();

                        // Iterate through each child mapping.
                        INameMapping childNameMapping = null;
                        while ((childNameMapping = childEnumNameMapping.Next()) != null)
                        {
                            if (childNameMapping.NameConflicts)
                            {
                                childNameMapping.TargetName = childNameMapping.GetSuggestedName(targetName);
                            }
                        }
                    }
                }
            }

            // Start the transfer.
            geoDBDataTransfer.Transfer(enumNameMapping, targetName);
        }
 /// <summary>
 /// copies the feature Class table from one database to another
 /// </summary>
 /// <param name="inWks">inWorkspace</param>
 /// <param name="inObjName">object name</param>
 /// <param name="outWks">out workspace</param>
 /// <param name="dType">data type</param>
 /// <returns>messages</returns>
 public string copyFeatureClassTable(IWorkspace inWks, string inObjName, IWorkspace outWks, esriDatasetType dType)
 {
     if (!(dType == esriDatasetType.esriDTFeatureClass || dType == esriDatasetType.esriDTTable))
     {
         return "Error: must specify a FeatureClass or Table";
     }
     if (!((IWorkspace2)inWks).get_NameExists(dType, inObjName))
     {
         return "Error: Parent object does not exist!";
     }
     Console.WriteLine(inObjName);
     string x = "successfully copied " + inObjName;
     try
     {
         IDataset outWksDset = (IDataset)outWks;
         IName targetWks = outWksDset.FullName;
         IEnumName eName = new NamesEnumeratorClass();
         IEnumNameEdit eNameEdit = (IEnumNameEdit)eName;
         //need to get name of table
         IFeatureWorkspace ftrWks = (IFeatureWorkspace)inWks;
         IObjectClass objCls;
         if (dType == esriDatasetType.esriDTTable)
         {
             ITable inTbl = ftrWks.OpenTable(inObjName);
             objCls = (IObjectClass)inTbl;
         }
         else
         {
             IFeatureClass inFtr = ftrWks.OpenFeatureClass(inObjName);
             objCls = (IObjectClass)inFtr;
         }
         IDataset tblDset = (IDataset)objCls;
         eNameEdit.Add(tblDset.FullName);
         IGeoDBDataTransfer geoTrans = new GeoDBDataTransferClass();
         IEnumNameMapping enumNameMapping = null;
         Boolean conflictsFound = geoTrans.GenerateNameMapping(eName, targetWks, out enumNameMapping);
         enumNameMapping.Reset();
         try
         {
             if (conflictsFound)
             {
                 Console.WriteLine("Conflicts found can't transfer");
             }
             else
             {
                 geoTrans.Transfer(enumNameMapping, targetWks);
             }
         }
         catch (Exception e)
         {
             x = "Error in trasfering data: " + e.ToString();
             MessageBox.Show(x);
         }
     }
     catch (Exception e)
     {
         x = "Error: " + e.ToString();
         Console.WriteLine(x);
     }
     return x;
 }
コード例 #7
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            //首先进行坐标系x,y变换
            //string fileExpTran;//进行x,y做表转换后输出的tiff文件存储路径,用这一文件在进行后期的Z转换
            //fileExpTran = System.IO.Path.GetDirectoryName(LayerExpName) +"\\"+ System.IO.Path.GetFileNameWithoutExtension(LayerExpName)+"XY.tif";
            //try
            //{
            //    if (NorthEastToEastNorth(pRasterLayer, LayerExpName))
            //    {
            //        RasterLayerClass rasterlayer = new RasterLayerClass();
            //        rasterlayer.CreateFromFilePath(LayerExpName);
            //        IRaster2 pRaster2 = rasterlayer.Raster as IRaster2;
            //        IRasterDataset2 pRasterDataset = pRaster2.RasterDataset as IRasterDataset2;
            //        ChangeRasterValue(pRasterDataset, -1, 0);
            //        pMapControl.AddLayer(rasterlayer as ILayer);
            //        this.Close();
            //    }
            //}
            //catch (System.Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}

            try
            {
                IFeatureClass    pFC        = pFeatureLayer.FeatureClass;
                IDataset         pDS        = pFC as IDataset;
                IWorkspace       pWS        = pDS.Workspace;
                string           filedir    = pWS.PathName;
                string           fdestname  = System.IO.Path.GetFileNameWithoutExtension(txtFeatureName.Text);
                ClsGDBDataCommon CGD        = new ClsGDBDataCommon();
                IWorkspace       pTargetWS  = CGD.OpenFromShapefile(txtLayerExp.Text);
                IWorkspace2      workspace2 = pTargetWS as IWorkspace2;

                if (workspace2.get_NameExists(ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass, fdestname))
                {
                    MessageBox.Show("目标文件已存在!");
                    return;
                }
                //shape文件直接拷贝后再修改
                if (pDS.CanCopy() == true)
                {
                    pDS.Copy(txtFeatureName.Text, pTargetWS);
                    IFeatureWorkspace pFW = pTargetWS as IFeatureWorkspace;
                    pTargetFeatureClass = pFW.OpenFeatureClass(txtFeatureName.Text);
                    TransCoordiante(pFW as IWorkspace, pTargetFeatureClass);
                }
                //表示为gdb的feature,只能往gdb拷贝
                else
                {
                    // Create workspace name objects.
                    IWorkspaceName sourceWorkspaceName = new WorkspaceNameClass();
                    IWorkspaceName targetWorkspaceName = new WorkspaceNameClass();
                    IName          targetName          = (IName)targetWorkspaceName;

                    // Set the workspace name properties.
                    sourceWorkspaceName.PathName = pWS.PathName;
                    sourceWorkspaceName.WorkspaceFactoryProgID =
                        "esriDataSourcesGDB.FileGDBWorkspaceFactory";
                    // targetWorkspaceName.PathName = @"PartialMontgomery.gdb";
                    targetWorkspaceName.PathName = txtLayerExp.Text;
                    targetWorkspaceName.WorkspaceFactoryProgID =
                        "esriDataSourcesGDB.FileGDBWorkspaceFactory";

                    //if (txtLayerExp.Text.Length>4 && txtLayerExp.Text.Substring(txtLayerExp.Text.Length-4,4) == ".gdb")
                    //{
                    //    targetWorkspaceName.WorkspaceFactoryProgID =
                    //      "esriDataSourcesGDB.FileGDBWorkspaceFactory";
                    //}
                    //else
                    //{
                    //    targetWorkspaceName.WorkspaceFactoryProgID =
                    //     "esriDataSourcesFile.ShapefileWorkspaceFactory";
                    //}

                    // Create a name object for the source feature class.
                    IFeatureClassName featureClassName = new FeatureClassNameClass();

                    // Set the featureClassName properties.
                    IDatasetName sourceDatasetName = (IDatasetName)featureClassName;
                    sourceDatasetName.WorkspaceName = sourceWorkspaceName;
                    sourceDatasetName.Name          = pDS.BrowseName;
                    IName sourceName = (IName)sourceDatasetName;


                    // Create an enumerator for source datasets.
                    IEnumName     sourceEnumName     = new NamesEnumeratorClass();
                    IEnumNameEdit sourceEnumNameEdit = (IEnumNameEdit)sourceEnumName;

                    // Add the name object for the source class to the enumerator.
                    sourceEnumNameEdit.Add(sourceName);

                    // Create a GeoDBDataTransfer object and a null name mapping enumerator.
                    IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
                    IEnumNameMapping   enumNameMapping   = null;

                    // Use the data transfer object to create a name mapping enumerator.
                    Boolean conflictsFound = geoDBDataTransfer.GenerateNameMapping(sourceEnumName,
                                                                                   targetName, out enumNameMapping);
                    enumNameMapping.Reset();
                    //修改拷贝的文件名
                    INameMapping nameMapping = enumNameMapping.Next();
                    if ((nameMapping != null))
                    {
                        nameMapping.TargetName = txtFeatureName.Text;
                    }

                    // Check for conflicts.
                    //if (conflictsFound)
                    //{
                    //    // Iterate through each name mapping.
                    //    INameMapping nameMapping = null;
                    //    while ((nameMapping = enumNameMapping.Next()) != null)
                    //    {
                    //        // Resolve the mapping's conflict (if there is one).
                    //        if (nameMapping.NameConflicts)
                    //        {
                    //            nameMapping.TargetName = nameMapping.GetSuggestedName(targetName);
                    //        }

                    //        // See if the mapping's children have conflicts.
                    //        IEnumNameMapping childEnumNameMapping = nameMapping.Children;
                    //        if (childEnumNameMapping != null)
                    //        {
                    //            childEnumNameMapping.Reset();

                    //            // Iterate through each child mapping.
                    //            INameMapping childNameMapping = null;
                    //            while ((childNameMapping = childEnumNameMapping.Next()) != null)
                    //            {
                    //                if (childNameMapping.NameConflicts)
                    //                {
                    //                    childNameMapping.TargetName = childNameMapping.GetSuggestedName
                    //                        (targetName);
                    //                }
                    //            }
                    //        }
                    //    }
                    //}

                    // Start the transfer.
                    geoDBDataTransfer.Transfer(enumNameMapping, targetName);
                    IFeatureWorkspace pFW = CGD.OpenFromFileGDB(txtLayerExp.Text) as IFeatureWorkspace;
                    pTargetFeatureClass = pFW.OpenFeatureClass(txtFeatureName.Text);
                    TransCoordiante(pFW as IWorkspace, pTargetFeatureClass);
                }

                if (pTargetFeatureClass != null)
                {
                    //添加到图层中
                    IFeatureLayer featureLayer = new FeatureLayerClass();
                    featureLayer.FeatureClass = pTargetFeatureClass;
                    featureLayer.Name         = fdestname;
                    pMapControl.AddLayer(featureLayer as ILayer);
                    pMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);
                }

                this.DialogResult = DialogResult.OK;
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
0
ファイル: TranferDatabase.cs プロジェクト: truonghinh/TnX
        public static void TranferBetweenGeodatabase(string featureClass, string targetPath, string sourcePath)
        {
            // Create new workspace name objects.
            IWorkspaceName sourceWorkspaceName = new WorkspaceNameClass();
            IWorkspaceName targetWorkspaceName = new WorkspaceNameClass();
            IName targetName = (IName)targetWorkspaceName;

            // Set the workspace name properties.
            sourceWorkspaceName.PathName = @sourcePath;//"C:\arcgis\ArcTutor\BuildingaGeodatabase\Montgomery.gdb";
            sourceWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";
            targetWorkspaceName.PathName = @targetPath;//"PartialMontgomery.gdb";
            targetWorkspaceName.WorkspaceFactoryProgID = "esriDataSourcesGDB.FileGDBWorkspaceFactory";

            // Create a name object for the source feature class.
            IFeatureClassName featureClassName = new FeatureClassNameClass();

            // Set the featureClassName properties.
            IDatasetName sourceDatasetName = (IDatasetName)featureClassName;
            sourceDatasetName.WorkspaceName = sourceWorkspaceName;
            sourceDatasetName.Name = featureClass;//"Blocks";
            IName sourceName = (IName)sourceDatasetName;

            // Create an enumerator for source datasets.
            IEnumName sourceEnumName = new NamesEnumeratorClass();
            IEnumNameEdit sourceEnumNameEdit = (IEnumNameEdit)sourceEnumName;

            // Add the name object for the source class to the enumerator.
            sourceEnumNameEdit.Add(sourceName);

            // Create a GeoDBDataTransfer object and a null name mapping enumerator.
            IGeoDBDataTransfer geoDBDataTransfer = new GeoDBDataTransferClass();
            IEnumNameMapping enumNameMapping = null;

            // Use the data transfer object to create a name mapping enumerator.
            Boolean conflictsFound = geoDBDataTransfer.GenerateNameMapping(sourceEnumName,
              targetName, out enumNameMapping);
            enumNameMapping.Reset();

            // Check for conflicts.
            if (conflictsFound)
            {
                // Iterate through each name mapping.
                INameMapping nameMapping = null;
                while ((nameMapping = enumNameMapping.Next()) != null)
                {
                    // Resolve the mapping's conflict (if there is one).
                    if (nameMapping.NameConflicts)
                    {
                        nameMapping.TargetName = nameMapping.GetSuggestedName(targetName);
                    }

                    // See if the mapping's children have conflicts.
                    IEnumNameMapping childEnumNameMapping = nameMapping.Children;
                    if (childEnumNameMapping != null)
                    {
                        childEnumNameMapping.Reset();

                        // Iterate through each child mapping.
                        INameMapping childNameMapping = null;
                        while ((childNameMapping = childEnumNameMapping.Next()) != null)
                        {
                            if (childNameMapping.NameConflicts)
                            {
                                childNameMapping.TargetName = childNameMapping.GetSuggestedName
                                  (targetName);
                            }
                        }
                    }
                }
            }

            // Start the transfer.
            geoDBDataTransfer.Transfer(enumNameMapping, targetName);
        }
コード例 #9
0
ファイル: GxDataset.cs プロジェクト: secondii/Yutai
 public bool Paste(IEnumName ienumName_0, ref bool bool_2)
 {
     try
     {
         if (bool_2)
         {
             ienumName_0.Reset();
             IName name = ienumName_0.Next();
             if (((name as IDatasetName).WorkspaceName.Type != esriWorkspaceType.esriFileSystemWorkspace) &&
                 ((name as IDatasetName).WorkspaceName.PathName == this.idatasetName_0.WorkspaceName.PathName))
             {
                 IDatasetContainer container = (this.idatasetName_0 as IName).Open() as IDatasetContainer;
                 if (container != null)
                 {
                     while (name != null)
                     {
                         IGxObject obj2;
                         if (name is IFeatureDatasetName)
                         {
                             IEnumDatasetName subsetNames = (name as IDatasetName).SubsetNames;
                             subsetNames.Reset();
                             for (IDatasetName name3 = subsetNames.Next();
                                  name3 != null;
                                  name3 = subsetNames.Next())
                             {
                                 container.AddDataset((name3 as IName).Open() as IDataset);
                                 obj2 = new GxDataset();
                                 if (name3 is IFeatureClassName)
                                 {
                                     (name3 as IFeatureClassName).FeatureDatasetName = this.idatasetName_0;
                                 }
                                 else if (name3 is IRelationshipClassName)
                                 {
                                     (name3 as IRelationshipClassName).FeatureDatasetName = this.idatasetName_0;
                                 }
                                 else if (name3 is IGeometricNetworkName)
                                 {
                                     (name3 as IGeometricNetworkName).FeatureDatasetName = this.idatasetName_0;
                                 }
                                 (obj2 as IGxDataset).DatasetName = name3;
                                 obj2.Attach(this, this.igxCatalog_0);
                                 this.igxCatalog_0.ObjectAdded(obj2);
                             }
                         }
                         else
                         {
                             container.AddDataset(name.Open() as IDataset);
                             obj2 = new GxDataset();
                             if (name is IFeatureClassName)
                             {
                                 (name as IFeatureClassName).FeatureDatasetName = this.idatasetName_0;
                             }
                             else if (name is IRelationshipClassName)
                             {
                                 (name as IRelationshipClassName).FeatureDatasetName = this.idatasetName_0;
                             }
                             else if (name is IGeometricNetworkName)
                             {
                                 (name as IGeometricNetworkName).FeatureDatasetName = this.idatasetName_0;
                             }
                             (obj2 as IGxDataset).DatasetName = name as IDatasetName;
                             obj2.Attach(this, this.igxCatalog_0);
                             this.igxCatalog_0.ObjectAdded(obj2);
                         }
                         name = ienumName_0.Next();
                     }
                     return(true);
                 }
             }
         }
         else
         {
             IEnumNameMapping mapping;
             ienumName_0.Reset();
             IGeoDBDataTransfer transfer = new GeoDBDataTransferClass();
             transfer.GenerateNameMapping(ienumName_0, this.idatasetName_0.WorkspaceName as IName, out mapping);
             frmGeoDBDataTransfer transfer2 = new frmGeoDBDataTransfer
             {
                 EnumNameMapping = mapping,
                 ToName          = this.idatasetName_0 as IName,
                 GeoDBTransfer   = transfer
             };
             if (transfer2.ShowDialog() == DialogResult.OK)
             {
                 this.Refresh();
                 return(true);
             }
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message);
         return(false);
     }
     return(false);
 }