/// <summary> /// 删除名称包含指定关键字的要素类 /// </summary> /// <param name="workspace">工作空间</param> /// <param name="keyWord">关键字,不区分大小写</param> public static void DeleteFeatureClassesByKeyWord(this IWorkspace workspace, string keyWord) { if (!(workspace is IFeatureWorkspace featureWorkspace)) { throw new Exception("工作空间不是要素类工作空间!"); } keyWord = keyWord.ToLower(); IFeatureWorkspaceManage featureWorkspaceMange = (IFeatureWorkspaceManage)featureWorkspace; IEnumDatasetName enumDatasetName = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass]; IDatasetName datasetName; while ((datasetName = enumDatasetName.Next()) != null) { if (datasetName.Name.ToLower().Contains(keyWord)) { featureWorkspaceMange.DeleteByName(datasetName);//删除指定要素类 } } }
/// <summary> /// 获取当前任务子库中的图层集名 /// </summary> /// <param name="ipSonFWS"></param> /// <returns></returns> public static IFeatureDataset GetCurrentSonDataSet(IFeatureWorkspace ipSonFWS) { try { IWorkspace ipWks = (IWorkspace)ipSonFWS; IEnumDatasetName ipDatasetNames = ipWks.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); IDatasetName ipDatasetName = ipDatasetNames.Next(); IFeatureDataset ipDataset = null; if (ipDatasetName != null) { ipDataset = ipSonFWS.OpenFeatureDataset(ipDatasetName.Name); } return(ipDataset); } catch (Exception ex) { //GT_CONST.LogAPI.CheckLog.AppendErrLogs(ex.ToString()); return(null); } }
/// <summary> /// Finds the first table matching a specified name in a workspace, returning the /// fully qualified name for that table /// </summary> /// <param name="unqualifiedName">Unqualified name of the table</param> /// <param name="workspace">The workspace in which the table is located</param> /// <returns> /// The fully-qualified name of the first matching table found; null if /// none was found /// </returns> public static string GetQualifiedTableName(string unqualifiedName, IWorkspace workspace) { string tableNameStr = null; IEnumDatasetName allTables = workspace.get_DatasetNames(esriDatasetType.esriDTTable); // Get the name of the correct table from the workspace so // that the table doesn't have to be owned by the connecting user. IDatasetName tableName = null; while ((tableName = allTables.Next()) != null) { if (tableName.Name.EndsWith(unqualifiedName, StringComparison.CurrentCultureIgnoreCase)) { tableNameStr = tableName.Name; break; } } return(tableNameStr); }
/// <summary> /// 删除一个或多个要素类 /// </summary> /// <param name="workspace">工作空间</param> /// <param name="featueClassNames">要删除的要素类的名称,名称不区分大小写</param> public static void DeleteFeatureClasses(this IWorkspace workspace, params string[] featueClassNames) { if (!(workspace is IFeatureWorkspace featureWorkspace)) { throw new Exception("工作空间不是要素类工作空间!"); } featueClassNames = featueClassNames.Select(v => v.ToLower()).ToArray(); IFeatureWorkspaceManage featureWorkspaceMange = (IFeatureWorkspaceManage)featureWorkspace; IEnumDatasetName enumDatasetName = workspace.DatasetNames[esriDatasetType.esriDTFeatureClass]; IDatasetName datasetName; while ((datasetName = enumDatasetName.Next()) != null) { if (featueClassNames.Contains(datasetName.Name.ToLower())) { featureWorkspaceMange.DeleteByName(datasetName);//删除指定要素类 } } }
private static IDatasetName GetDatasetNameInWorkspaceSearchContainers(IWorkspace workspace, string dataname, esriDatasetType type) { //look for data in all FeatureDatasets IEnumDatasetName containers = workspace.DatasetNames[esriDatasetType.esriDTFeatureDataset]; IDatasetName name1 = containers.Next(); while (name1 != null) { IEnumDatasetName names = name1.SubsetNames; IDatasetName name2 = names.Next(); while (name2 != null) { if (name2.Name.ToLower() == dataname.ToLower()) { return(name2); } name2 = names.Next(); } name1 = containers.Next(); } //look for data in all containers (feature datasets are not containers, why I don't know) //containers are rasters (contain bands), coverage feature classes (contain arc, lines, ...), etc. containers = workspace.DatasetNames[esriDatasetType.esriDTContainer]; name1 = containers.Next(); while (name1 != null) { IEnumDatasetName names = name1.SubsetNames; IDatasetName name2 = names.Next(); while (name2 != null) { if (name2.Name.ToLower() == dataname.ToLower()) { return(name2); } name2 = names.Next(); } name1 = names.Next(); } return(null); }
/// <summary> /// 获取打开的工作空间的相关信息 /// </summary> private void refCoordinateArea() { ISpatialReference pSr; IFields pFields; double minX, minY, maxX, maxY, dScale = 0, dFalseX = 0, dFalseY = 0; if (File.Exists(mdbName)) { this.fcUpdate = GetUpdateRegionFC(); IEnumDatasetName enumDatasetName = (pCurWorkspace as IWorkspace).get_DatasetNames(esriDatasetType.esriDTFeatureClass); IDatasetName datasetName = enumDatasetName.Next(); if (datasetName != null) { string shapeField = this.fcUpdate.ShapeFieldName; pFields = this.fcUpdate.Fields; pSr = pFields.get_Field(pFields.FindField(shapeField)).GeometryDef.SpatialReference; pSr.GetDomain(out minX, out maxX, out minY, out maxY); pSr.GetFalseOriginAndUnits(out dFalseX, out dFalseY, out dScale); } } }
public static IEnumerable <IDatasetName> EnumerateDatasetNames(IEnumDatasetName enumDatasetNames, bool recursive) { if (enumDatasetNames != null) { enumDatasetNames.Reset(); IDatasetName datasetName = enumDatasetNames.Next(); while (datasetName != null) { yield return(datasetName); if (recursive && (datasetName.Type == esriDatasetType.esriDTFeatureDataset)) { foreach (var subDatasetName in EnumerateDatasetNames(datasetName.SubsetNames, recursive)) { yield return(subDatasetName); } } datasetName = enumDatasetNames.Next(); } } }
/// <summary> /// 删除特定数据集下的表 /// </summary> /// <param name="gdbPath">gdb路径</param> /// <param name="tableName">表名称</param> public static void DeleteFeatureClass(string gdbPath, string tableName) { IWorkspaceFactory worFact = new FileGDBWorkspaceFactory(); IWorkspace workspace = worFact.OpenFromFile(gdbPath, 0); IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace; IFeatureWorkspaceManage featureWorkspaceMange = (IFeatureWorkspaceManage)featureWorkspace; //得到的数据集是FeatureClass //IEnumDatasetName enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass); IEnumDatasetName enumDatasetName = workspace.get_DatasetNames(esriDatasetType.esriDTTable); IDatasetName datasetName = null; while ((datasetName = enumDatasetName.Next()) != null) { if (datasetName.Name.Equals(tableName)) { //删除指定要素类(表) featureWorkspaceMange.DeleteByName(datasetName); break; } } }
public IDataset GetUNDataset2(IServerObject serverObject, string versionName = null) { IDataset unDataset = null; IMapServer mapService = (MapServer)serverObject; IMapServerDataAccess mapServerDataAccess = (IMapServerDataAccess)serverObject; // Get feature class from any layer IFeatureClass fc = (IFeatureClass)mapServerDataAccess.GetDataSource(mapService.DefaultMapName, 0); // Get the container feature dataset IFeatureDataset fd = fc.FeatureDataset; // Open feature dataset in specified version if (!String.IsNullOrEmpty(versionName)) { IWorkspace workspace = fd.Workspace; IVersionedWorkspace4 versionedWorkspace = (IVersionedWorkspace4)workspace; IVersion4 childVersion = (IVersion4)versionedWorkspace.FindVersion(versionName); IFeatureWorkspace childFWS = (IFeatureWorkspace)childVersion; fd = childFWS.OpenFeatureDataset(fd.Name); } // Get extension container IFeatureDatasetExtensionContainer fdce = (IFeatureDatasetExtensionContainer)fd; // Find UN dataset by type IFeatureDatasetExtension unFDSExt = fdce.FindExtension(esriDatasetType.esriDTUtilityNetwork); IDatasetContainer2 unDSContainer = (IDatasetContainer2)unFDSExt; IEnumDatasetName dsNames = unDSContainer.DatasetNames[esriDatasetType.esriDTUtilityNetwork]; IDatasetName dsName = dsNames.Next(); if (dsName != null) { unDataset = unDSContainer.DatasetByName[esriDatasetType.esriDTUtilityNetwork, dsName.Name]; } return(unDataset); }
private void cmbDataset_SelectedIndexChanged(object sender, EventArgs e) { string strSetName = cmbDataset.Text; if (this.m_PathType == enumPathType.Feature) { if (string.IsNullOrWhiteSpace(strSetName)) { IEnumDatasetName enDsName = m_Workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass); IDatasetName dsName = enDsName.Next(); while (dsName != null) { if (dsName.Type == esriDatasetType.esriDTFeatureClass) { cmbClass.Properties.Items.Add(dsName.Name); } dsName = enDsName.Next(); } } else { IFeatureDataset fDs = this.FeatureDataset; IEnumDataset enDataset = fDs.Subsets; IDataset ds = enDataset.Next(); while (ds != null) { if (ds.Type == esriDatasetType.esriDTFeatureClass) { cmbClass.Properties.Items.Add(ds.Name); } ds = enDataset.Next(); } } } else { } }
public static string Check(IEnumDatasetName edn, string feat_Name, string index) { edn.Reset(); IDatasetName dsName = edn.Next(); while (dsName != null) { if (dsName.Name.ToLower().Equals((feat_Name + index).ToLower())) { if (index == string.Empty) { return(Check(edn, feat_Name, "1")); } else { return(Check(edn, feat_Name, (int.Parse(index) + 1).ToString())); } } dsName = edn.Next(); } return(feat_Name + index.ToString()); }
/// <summary> /// Determines if a table exists within the specified workspace. <para/><b>Note</b> you should use <see cref="IWorkspace2.NameExists">IWorkspace2.NameExists</see> /// when working with workspaces other than a ShapefileWorkspace as it does not implement <see cref="IWorkspace2">IWorkspace2</see>. /// </summary> /// <param name="workspace">The workspace.</param> /// <param name="tableName">Name of the table.</param> /// <returns></returns> public static bool TableExists(IWorkspace workspace, string tableName) { // Loop over all table dataset names in workspace IEnumDatasetName datasetNames = workspace.get_DatasetNames(esriDatasetType.esriDTTable); if (datasetNames == null) { return(false); } datasetNames.Reset(); IDatasetName datasetName = datasetNames.Next(); while (datasetName != null) { if (datasetName.Name.ToLower().Equals(tableName.ToLower())) { return(true); } datasetName = datasetNames.Next(); } return(false); }
private void method_0(IWorkspace iworkspace_1) { try { IEnumDatasetName name = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTAny); name.Reset(); IDatasetName name2 = name.Next(); IGxObject obj2 = null; while (name2 != null) { obj2 = null; if ((name2.Type == esriDatasetType.esriDTRasterDataset) || (name2.Type == esriDatasetType.esriDTRasterCatalog)) { obj2 = new GxRasterDataset(); } else if ((name2.Type == esriDatasetType.esriDTFeatureClass) || (name2.Type == esriDatasetType.esriDTTable)) { obj2 = new GxDataset(); } else { obj2 = new GxDataset(); } if (obj2 != null) { (obj2 as IGxDataset).DatasetName = name2; obj2.Attach(this, this.igxCatalog_0); } name2 = name.Next(); } } catch (Exception exception) { Logger.Current.Error("", exception, ""); } }
private void RepresentationPropertyPage_Load(object sender, EventArgs e) { IRepresentationWorkspaceExtension repWSExtFromFClass = this.GetRepWSExtFromFClass(this.ifeatureClass_0); if (repWSExtFromFClass.get_FeatureClassHasRepresentations(this.ifeatureClass_0)) { IEnumDatasetName name = repWSExtFromFClass.get_FeatureClassRepresentationNames(this.ifeatureClass_0); IDatasetName name2 = name.Next(); string[] items = new string[3]; while (name2 != null) { items[0] = name2.Name; items[1] = (name2 as IRepresentationClassName).RuleIDFieldName; items[2] = (name2 as IRepresentationClassName).OverrideFieldName; ListViewItem item = new ListViewItem(items) { Tag = name2 }; this.listView1.Items.Add(item); name2 = name.Next(); } } }
public List <string> GetTableNames(IWorkspace aWorkspace, string IncludeWildcard, string ExcludeWildcard, bool IncludeFullName = false) { // Define the wildcards as case insensitive Wildcard theInclude = new Wildcard(IncludeWildcard, RegexOptions.IgnoreCase); Wildcard theExclude = new Wildcard(ExcludeWildcard, RegexOptions.IgnoreCase); List <string> theStringList = new List <string>(); IEnumDatasetName enumDatasetName = aWorkspace.get_DatasetNames(esriDatasetType.esriDTAny); IDatasetName datasetName = enumDatasetName.Next(); while (datasetName != null) { string strName = datasetName.Name; // Does the name conform to the IncludeWildcard? if (theInclude.IsMatch(strName)) { if (!theExclude.IsMatch(strName)) { if (IncludeFullName) { theStringList.Add(strName); } else { strName = strName.Split('.')[2]; theStringList.Add(strName); } } } datasetName = enumDatasetName.Next(); } // Tidy up. enumDatasetName = null; datasetName = null; return(theStringList); }
private bool CheckIfDatasetOrFeatureClass(string checkedName, esriDatasetType datasetType) { bool checkedYes = false; IWorkspace workspace = featureWorkspace as IWorkspace; IEnumDatasetName datasetNames = workspace.get_DatasetNames(datasetType); if (datasetNames == null) { return(false); } datasetNames.Reset(); IDatasetName datasetName = datasetNames.Next(); while (datasetName != null) { if (checkedName == datasetName.Name) { checkedYes = true; break; } datasetName = datasetNames.Next(); } return(checkedYes); }
private void method_1() { try { IEnumDatasetName featureClassNames = (this.idatasetName_0 as IFeatureDatasetName2).FeatureClassNames; featureClassNames.Reset(); IDatasetName name2 = featureClassNames.Next(); IGxObject obj2 = null; while (name2 != null) { obj2 = new GxCoverageDataset(); if (obj2 != null) { (obj2 as IGxDataset).DatasetName = name2; obj2.Attach(this, this.igxCatalog_0); } name2 = featureClassNames.Next(); } } catch (Exception exception) { MessageBox.Show(exception.Message, "错误"); } }
public IRepresentationClass GetRepresentationClassForFeatureClass(IFeatureClass featureClass) { if (RepresentationWorkspaceExtension == null) { return(null); } IRepresentationClass repClass = null; IEnumDatasetName datasetNames = RepresentationWorkspaceExtension.get_FeatureClassRepresentationNames(featureClass); datasetNames.Reset(); IDatasetName dsName; while ((dsName = datasetNames.Next()) != null) { string repName = dsName.Name; repClass = RepresentationWorkspaceExtension.OpenRepresentationClass(repName); // TODO: only gets first Rep Class set / assumes only one name/set break; } return(repClass); }
private void buttonX2_Click(object sender, EventArgs e) { if (txtPC.Text == "" || txtSDESrvs.Text == "" || txtDB.Text == "" || txtUr.Text == "" || txtPswd.Text == "" || txtVersion.Text == "") { lblSDETest.Text = "请填写完整连接参数!"; return; } pSDEWs = SetWorkspace(txtPC.Text, txtSDESrvs.Text, txtDB.Text, txtUr.Text, txtPswd.Text, txtVersion.Text); if (pSDEWs == null) { lblSDETest.Text = "连接失败!请检查连接参数。"; this.Cursor = Cursors.Default; return; } if (rdoSdeBak.Checked) { this.Cursor = Cursors.WaitCursor; lstLyrFile.Items.Clear(); IEnumDatasetName pEDN = pSDEWs.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); IDatasetName pDN = pEDN.Next(); while (pDN != null) { lstLyrFile.Items.Add(pDN.Name); pDN = pEDN.Next(); } lstLyrFile.Refresh(); this.Cursor = Cursors.Default; gPSDEds.BringToFront(); } else { gPSdeRc.BringToFront(); } }
private void getPath(bool isRaster) { string outPath = null; string outName = ""; ESRI.ArcGIS.CatalogUI.IGxDialog gxDialog = new ESRI.ArcGIS.CatalogUI.GxDialogClass(); gxDialog.AllowMultiSelect = false; ESRI.ArcGIS.Catalog.IGxObjectFilter flt = null; if (isRaster) { flt = new ESRI.ArcGIS.Catalog.GxFilterDatasetsClass(); } else { flt = new ESRI.ArcGIS.Catalog.GxFilterFileGeodatabasesClass(); } gxDialog.ObjectFilter = flt; gxDialog.Title = "Select a Feature"; ESRI.ArcGIS.Catalog.IEnumGxObject eGxObj; if (gxDialog.DoModalOpen(0, out eGxObj)) { ESRI.ArcGIS.Catalog.IGxObject gxObj = eGxObj.Next(); outPath = gxObj.FullName; outName = gxObj.BaseName; if (isRaster) { string wksPath = geoUtil.getDatabasePath(outPath); IWorkspace wks = geoUtil.OpenWorkSpace(wksPath); IEnumDatasetName rsDsetName = wks.get_DatasetNames(esriDatasetType.esriDTRasterDataset); bool rsCheck = false; IDatasetName dsName = rsDsetName.Next(); while (dsName != null) { if (outName.ToLower() == dsName.Name.ToLower()) { rsCheck = true; break; } System.Runtime.InteropServices.Marshal.ReleaseComObject(dsName); dsName = rsDsetName.Next(); } System.Runtime.InteropServices.Marshal.ReleaseComObject(rsDsetName); if (rsCheck) { if (!rstDic.ContainsKey(outName)) { rstDic.Add(outName, rsUtil.createIdentityRaster(outPath)); cmbRst.Items.Add(outName); } else { rstDic[outName] = rsUtil.createIdentityRaster(outPath); } } else { ftrDic[outName] = geoUtil.getFeatureClass(outPath); } cmbRst.Text = outName; } else { txtOutWorkspace.Text = outPath; } } return; }
private void BtConnectarClick(object sender, EventArgs e) { Ws = null; _pPropSet = new PropertySetClass(); _pSdeFact = new SdeWorkspaceFactory(); _pPropSet.SetProperty("SERVER", txtBoxServer.Text); _pPropSet.SetProperty("INSTANCE", txtBoxInstancia.Text); _pPropSet.SetProperty("DATABASE", txtBoxDB.Text); _pPropSet.SetProperty("USER", txtBoxUsuario.Text); _pPropSet.SetProperty("PASSWORD", txtBoxPassword.Text); _pPropSet.SetProperty("VERSION", txtBoxVersao.Text); try { System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; Ws = _pSdeFact.Open(_pPropSet, 0); treeViewDatasets.Nodes.Clear(); treeViewTables.Nodes.Clear(); if (chkBoxFeatueClass.Checked) _enumDsFeatureClasses = Ws.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); if (chkBoxTables.Checked) _enumDsTables = Ws.get_DatasetNames(esriDatasetType.esriDTTable); if (_enumDsFeatureClasses != null) { IDatasetName dsName = _enumDsFeatureClasses.Next(); while (dsName != null) { treeViewDatasets.Nodes.Add(dsName.Name); dsName = _enumDsFeatureClasses.Next(); } } if (_enumDsTables != null) { IDatasetName dsName = _enumDsTables.Next(); while (dsName != null) { treeViewTables.Nodes.Add(dsName.Name); dsName = _enumDsTables.Next(); } } btGerar.Enabled = true; } catch (Exception ex) { MessageBox.Show("Impossible to Connect" + "\n\n" + ex.Message); } finally { System.Windows.Forms.Cursor.Current = Cursors.Default; } }
public static List <string> QueryFeatureClassName(IWorkspace pWorkspace, bool pUpperCase, bool pEscapeMetaTable) { IDatasetName i; string upper; string classShortName; List <string> strs; try { string str = ""; if (pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) { str = pWorkspace.ConnectionProperties.GetProperty("user").ToString(); str = str.ToUpper(); } List <string> strs1 = new List <string>(); IEnumDatasetName datasetNames = pWorkspace.DatasetNames[esriDatasetType.esriDTFeatureDataset]; for (i = datasetNames.Next(); i != null; i = datasetNames.Next()) { upper = i.Name.ToUpper(); if (str.Equals(LayerHelper.GetClassOwnerName(upper))) { IEnumDatasetName subsetNames = i.SubsetNames; for (i = subsetNames.Next(); i != null; i = subsetNames.Next()) { upper = i.Name.ToUpper(); if (!(i is ITopologyName)) { classShortName = LayerHelper.GetClassShortName(upper); if (pUpperCase) { classShortName = classShortName.ToUpper(); } if (!pEscapeMetaTable) { strs1.Add(classShortName); } } } } } datasetNames = pWorkspace.DatasetNames[esriDatasetType.esriDTFeatureClass]; for (i = datasetNames.Next(); i != null; i = datasetNames.Next()) { upper = i.Name.ToUpper(); if (str.Equals(LayerHelper.GetClassOwnerName(upper))) { classShortName = LayerHelper.GetClassShortName(upper); if (pUpperCase) { classShortName = classShortName.ToUpper(); } if (!pEscapeMetaTable) { strs1.Add(classShortName); } } } strs = strs1; } catch (Exception exception) { strs = null; } return(strs); }
// // PRIVATE METHODS // private void CreateReport() { // Exit if Workspace is NULL if (this.m_workspaceName == null) { return; } // DiagrammerEnvironment diagrammerEnvironment = DiagrammerEnvironment.Default; diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs("Creating Report")); // Get IWorkspace IName name = (IName)this.m_workspaceName; IWorkspace workspace = (IWorkspace)name.Open(); // Get Temporary File string filename = System.IO.Path.Combine(System.IO.Path.GetTempPath(), Guid.NewGuid().ToString("N").ToUpper() + ".xml"); // Specific XML Settings XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = Encoding.UTF8; // Encoding.Default; settings.Indent = false; settings.NewLineHandling = NewLineHandling.Entitize; settings.OmitXmlDeclaration = true; settings.NewLineOnAttributes = false; // Create the XmlWriter object and write some content. XmlWriter writer = XmlWriter.Create(filename, settings); // <DataReport> writer.WriteStartElement("DataReport"); // IEnumDatasetName enumDatasetName1 = workspace.get_DatasetNames(esriDatasetType.esriDTAny); IDatasetName datasetName1 = enumDatasetName1.Next(); while (datasetName1 != null) { switch (datasetName1.Type) { case esriDatasetType.esriDTFeatureDataset: // <DataReport><FeatureDataset> writer.WriteStartElement("FeatureDataset"); // <DataReport><FeatureDataset><Name> writer.WriteStartElement("Name"); writer.WriteValue(datasetName1.Name); writer.WriteEndElement(); IEnumDatasetName enumDatasetName2 = datasetName1.SubsetNames; IDatasetName datasetName2 = enumDatasetName2.Next(); while (datasetName2 != null) { switch (datasetName2.Type) { case esriDatasetType.esriDTFeatureClass: // Display Message string message = string.Format("Adding <{0}>", datasetName2.Name); diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(message)); // Add Dataset this.AddDataset(writer, datasetName2); break; default: break; } datasetName2 = enumDatasetName2.Next(); } // <DataReport></FeatureDataset> writer.WriteEndElement(); break; case esriDatasetType.esriDTFeatureClass: case esriDatasetType.esriDTTable: // Display Message string message2 = string.Format("Adding <{0}>", datasetName1.Name); diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(message2)); // Add Dataset this.AddDataset(writer, datasetName1); break; default: break; } datasetName1 = enumDatasetName1.Next(); } // </DataReport> writer.WriteEndElement(); // Close Writer writer.Close(); // Set Source XML this.Xml = filename; // Fire Invalidate Event so that the Report Tabbed Document can Reload this.OnInvalidated(new EventArgs()); // Clear Messages diagrammerEnvironment.OnProgressChanged(new ProgressEventArgs(string.Empty)); }
private void method_0(IWorkspace iworkspace_1) { try { IEnumDatasetName name = iworkspace_1.get_DatasetNames(esriDatasetType.esriDTAny); name.Reset(); IDatasetName name2 = name.Next(); IGxObject obj2 = null; while (name2 != null) { obj2 = null; if (this.IsEnterpriseGeodatabase) { if ((name2.Type == esriDatasetType.esriDTRasterDataset) || (name2.Type == esriDatasetType.esriDTRasterCatalog)) { obj2 = new GxRasterDataset(); } else if ((name2.Type == esriDatasetType.esriDTFeatureClass) || (name2.Type == esriDatasetType.esriDTTable)) { if (AppConfigInfo.UserID.Length > 0) { if (AppConfigInfo.UserID.ToLower() == "admin") { obj2 = new GxDataset(); } else if (this.sysGrants_0 != null) { if (this.sysGrants_0.GetStaffAndRolesLayerPri(AppConfigInfo.UserID, 1, name2.Name)) { obj2 = new GxDataset(); } } else { obj2 = new GxDataset(); } } else { obj2 = new GxDataset(); } } else { obj2 = new GxDataset(); } if (obj2 != null) { (obj2 as IGxDataset).DatasetName = name2; obj2.Attach(this, this.igxCatalog_0); } } else { if ((name2.Type == esriDatasetType.esriDTRasterDataset) || (name2.Type == esriDatasetType.esriDTRasterCatalog)) { obj2 = new GxRasterDataset(); } else if ((name2.Type == esriDatasetType.esriDTFeatureClass) || (name2.Type == esriDatasetType.esriDTTable)) { obj2 = new GxDataset(); } else { obj2 = new GxDataset(); } if (obj2 != null) { (obj2 as IGxDataset).DatasetName = name2; obj2.Attach(this, this.igxCatalog_0); } } name2 = name.Next(); } } catch (Exception exception) { Logger.Current.Error("", exception, ""); } }
// // 将vListView中数据集显示在vListView public static void ListDatasetLayer(ListView vListView) { if (vListView.SelectedItems[0] == null) { return; } ListViewItem vListItem = default(ListViewItem); vListItem = vListView.SelectedItems[0]; IDatasetName pDSN = default(IDatasetName); pDSN = (IDatasetName)vListItem.Tag; if (pDSN.Type != esriDatasetType.esriDTFeatureDataset) { return; } IEnumDatasetName pEnumFeatureDSN = default(IEnumDatasetName); //要素层名 IDatasetName pSubDSN = default(IDatasetName); IFeatureClassName pFtClsName = default(IFeatureClassName); int shpType = 0; //显示数据集中的要素层 pEnumFeatureDSN = pDSN.SubsetNames; vListView.Items.Clear(); pSubDSN = pEnumFeatureDSN.Next(); while ((pSubDSN != null)) { if (pSubDSN.Type == esriDatasetType.esriDTFeatureClass) { pFtClsName = (IFeatureClassName)pSubDSN; //显示点线面要素层 if (pFtClsName.FeatureType == esriFeatureType.esriFTSimple) { shpType = (int)pFtClsName.ShapeType; if (shpType == (int)esriGeometryType.esriGeometryPoint | shpType == (int)esriGeometryType.esriGeometryMultipoint) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDEPointLyr"); vListItem.Tag = pFtClsName; } else if (shpType == (int)esriGeometryType.esriGeometryRing | shpType == (int)esriGeometryType.esriGeometryPolyline | shpType == (int)esriGeometryType.esriGeometryCircularArc | shpType == (int)esriGeometryType.esriGeometryEllipticArc) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDELineLyr"); vListItem.Tag = pFtClsName; } else if (shpType == (int)esriGeometryType.esriGeometryPolygon | shpType == (int)esriGeometryType.esriGeometryEnvelope) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDEPolyLyr"); vListItem.Tag = pFtClsName; } //显示注记层 } else if (pFtClsName.FeatureType == esriFeatureType.esriFTAnnotation) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDEAnnoLyr"); vListItem.Tag = pFtClsName; //显示尺寸注记图层 } else if (pFtClsName.FeatureType == esriFeatureType.esriFTDimension) { vListItem = vListView.Items.Add(pDSN.Name, "SDEDimensionLyr"); vListItem.Tag = pFtClsName; //显示经过network处理的图层 } else if (pFtClsName.FeatureType == esriFeatureType.esriFTSimpleJunction | pFtClsName.FeatureType == esriFeatureType.esriFTSimpleEdge | pFtClsName.FeatureType == esriFeatureType.esriFTComplexEdge | pFtClsName.FeatureType == esriFeatureType.esriFTComplexJunction) { shpType = (int)pFtClsName.ShapeType; if (shpType == (int)esriGeometryType.esriGeometryPoint | shpType == (int)esriGeometryType.esriGeometryMultipoint) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDEPointLyr"); vListItem.Tag = pFtClsName; } else if (shpType == (int)esriGeometryType.esriGeometryRing | shpType == (int)esriGeometryType.esriGeometryPolyline | shpType == (int)esriGeometryType.esriGeometryCircularArc | shpType == (int)esriGeometryType.esriGeometryEllipticArc) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDELineLyr"); vListItem.Tag = pFtClsName; } else if (shpType == (int)esriGeometryType.esriGeometryPolygon | shpType == (int)esriGeometryType.esriGeometryEnvelope) { vListItem = vListView.Items.Add(pSubDSN.Name, "SDEPolyLyr"); vListItem.Tag = pFtClsName; } } } else if (pSubDSN.Type == esriDatasetType.esriDTGeometricNetwork) { vListItem = vListView.Items.Add(pSubDSN.Name, "NET"); vListItem.Tag = pSubDSN; // pFtClsName } pSubDSN = pEnumFeatureDSN.Next(); } }
// ' //添加Coverage图层 // Public Function ADDCoverageLayer(ByVal pBasicMap As IBasicMap, ByVal vPath As String, ByVal vFile As String, _ // ByVal pSelectedCln As Collection, ByVal blnAddData As Boolean) As Boolean // '<EhHeader> // On Error GoTo ErrorHandler // '</EhHeader> // Dim pFact As IWorkspaceFactory // Dim pWorkSpace As IWorkspace // Dim pFeatureWorkspace As IFeatureWorkspace // Dim pFtLyr As IFeatureLayer // Dim pFeatCls As IFeatureClass // pFact = New ArcInfoWorkspaceFactory // pWorkSpace = pFact.OpenFromFile(vPath, 0) // pFeatureWorkspace = pWorkSpace // '//添加Coverage个点线面要素层 // On Error Resume Next // pFeatCls = Nothing // pFeatCls = pFeatureWorkspace.OpenFeatureClass(vFile & ":polygon") // If Not pFeatCls Is Nothing Then // pFtLyr = New FeatureLayer // pFtLyr.FeatureClass = pFeatCls // pFtLyr.Name = vFile & ":polygon" // If blnAddData = True Then // 'pBasicMap.AddLayer pFtLyr // AddLyrToBasicMap(pBasicMap, pFtLyr) // SortLayer(pBasicMap, pFtLyr) // End If // pSelectedCln.Add(pFtLyr) // ADDCoverageLayer = True // End If // pFeatCls = Nothing // pFeatCls = pFeatureWorkspace.OpenFeatureClass(vFile & ":arc") // If Not pFeatCls Is Nothing Then // pFtLyr = New FeatureLayer // pFtLyr.FeatureClass = pFeatCls // pFtLyr.Name = vFile & ":arc" // If blnAddData = True Then // 'pBasicMap.AddLayer pFtLyr // AddLyrToBasicMap(pBasicMap, pFtLyr) // SortLayer(pBasicMap, pFtLyr) // End If // pSelectedCln.Add(pFtLyr) // ADDCoverageLayer = True // End If // pFeatCls = Nothing // pFeatCls = pFeatureWorkspace.OpenFeatureClass(vFile & ":point") // If Not pFeatCls Is Nothing Then // pFtLyr = New FeatureLayer // pFtLyr.FeatureClass = pFeatCls // pFtLyr.Name = vFile & ":point" // If blnAddData = True Then // 'pBasicMap.AddLayer pFtLyr // AddLyrToBasicMap(pBasicMap, pFtLyr) // SortLayer(pBasicMap, pFtLyr) // End If // pSelectedCln.Add(pFtLyr) // ADDCoverageLayer = True // End If // '待修改,添加Coverage注记层 // ' Set pFeatCls = Nothing // ' Set pFeatCls = pFeatureWorkspace.OpenFeatureClass(vFile & ":annotation") // ' If Not pFeatCls Is Nothing Then // ' Dim pCovAnnoLyr As ICoverageAnnotationLayer // ' Set pCovAnnoLyr = New CoverageAnnotationLayer // ' Set pCovAnnoLyr.FeatureClass = pFeatCls // ' pCovAnnoLyr.GenerateGraphics // ' pFtLyr.Name = vFile & ":annotation" // ' pBasicMap.AddLayer pFtLyr // ' ADDCoverageLayer = True // ' End If // '<EhFooter> // Exit Function //ErrorHandler: // HandleError(True, "错误文件名:" & c_sModuleFileName & ";错误过程名:ADDCoverageLayer" & ";错误行数: " & GetErrorLineNumberString(Erl), Err.Number, Err.Source, Err.Description, g_Sys) // '</EhFooter> // End Function ////显示SDE或mdb图层列表,可以显示在树列表TreeView也可以显示在ListView中 public static void AddDatasetToListView(IWorkspace pWorkSpace, ref ListView vListView) { if ((vListView != null)) { vListView.Items.Clear(); } IEnumDatasetName pEnumFeatureDSN = default(IEnumDatasetName); //要素层名 IEnumDatasetName pEnumDSN = default(IEnumDatasetName); //要素集名 IEnumDatasetName pEnumRasterDSN = default(IEnumDatasetName); //栅格数据集名 IDatasetName pDSN = default(IDatasetName); IFeatureClassName pFtClsName = default(IFeatureClassName); ListViewItem vListItem = default(ListViewItem); int shpType = 0; //添加SDE数据集 pEnumDSN = pWorkSpace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); pDSN = pEnumDSN.Next(); while ((pDSN != null)) { vListItem = vListView.Items.Add(pDSN.Name, "SDEDataset"); vListItem.Tag = pDSN; pDSN = pEnumDSN.Next(); } //添加SDE独立要素层 pEnumFeatureDSN = pWorkSpace.get_DatasetNames(esriDatasetType.esriDTFeatureClass); pDSN = null; pDSN = pEnumFeatureDSN.Next(); while ((pDSN != null)) { if (pDSN.Type == esriDatasetType.esriDTFeatureClass) { pFtClsName = (IFeatureClassName)pDSN; //显示点线面要素层 if (pFtClsName.FeatureType == esriFeatureType.esriFTSimple | pFtClsName.FeatureType == esriFeatureType.esriFTSimpleJunction | pFtClsName.FeatureType == esriFeatureType.esriFTSimpleEdge | pFtClsName.FeatureType == esriFeatureType.esriFTComplexEdge | pFtClsName.FeatureType == esriFeatureType.esriFTComplexJunction) { shpType = (int)pFtClsName.ShapeType; if (shpType == (int)esriGeometryType.esriGeometryPoint | shpType == (int)esriGeometryType.esriGeometryMultipoint) { vListItem = vListView.Items.Add(pDSN.Name, "SDEPointLyr"); vListItem.Tag = pFtClsName; } else if (shpType == (int)esriGeometryType.esriGeometryRing | shpType == (int)esriGeometryType.esriGeometryPolyline | shpType == (int)esriGeometryType.esriGeometryCircularArc | shpType == (int)esriGeometryType.esriGeometryEllipticArc) { vListItem = vListView.Items.Add(pDSN.Name, "SDELineLyr"); vListItem.Tag = pFtClsName; } else if (shpType == (int)esriGeometryType.esriGeometryPolygon | shpType == (int)esriGeometryType.esriGeometryEnvelope) { vListItem = vListView.Items.Add(pDSN.Name, "SDEPolyLyr"); vListItem.Tag = pFtClsName; } //显示注记层 } else if (pFtClsName.FeatureType == esriFeatureType.esriFTAnnotation) { vListItem = vListView.Items.Add(pDSN.Name, "SDEAnnoLyr"); vListItem.Tag = pFtClsName; //添加尺寸图层 } else if (pFtClsName.FeatureType == esriFeatureType.esriFTDimension) { vListItem = vListView.Items.Add(pDSN.Name, "SDEDimensionLyr"); vListItem.Tag = pFtClsName; } } pDSN = pEnumFeatureDSN.Next(); } //添加SDE栅格RasterDataset图层 pEnumRasterDSN = pWorkSpace.get_DatasetNames(esriDatasetType.esriDTRasterDataset); pDSN = null; pDSN = pEnumRasterDSN.Next(); while ((pDSN != null)) { vListItem = vListView.Items.Add(pDSN.Name, "SDERasterLyr"); vListItem.Tag = pDSN; pDSN = pEnumRasterDSN.Next(); // 陈昉 2009-3-22 修改 修改原因 原先代码有误('pDSN = pEnumFeatureDSN.Next ) } //添加SDE栅格RasterCatalog图层 pEnumRasterDSN = pWorkSpace.get_DatasetNames(esriDatasetType.esriDTRasterCatalog); pDSN = null; pDSN = pEnumRasterDSN.Next(); while ((pDSN != null)) { //添加到listView vListItem = vListView.Items.Add(pDSN.Name, "SDERasterBand"); vListItem.Tag = pDSN; pDSN = pEnumRasterDSN.Next(); } }
public static List <String> QueryFeatureClassName(IWorkspace pWorkspace, bool pUpperCase, bool pEscapeMetaTable) { try { String ownerName = ""; if (pWorkspace.Type == esriWorkspaceType.esriRemoteDatabaseWorkspace) { ownerName = pWorkspace.ConnectionProperties.GetProperty("user").ToString(); ownerName = ownerName.ToUpper(); } List <String> sc = new List <String>(); IEnumDatasetName edn = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset); IDatasetName dn = edn.Next(); while (dn != null) { string dsName = dn.Name.ToUpper(); if (ownerName.Equals(LayerHelper.GetClassOwnerName(dsName))) { #region 添加数据集下面的FeatureClass IEnumDatasetName fdn = dn.SubsetNames; dn = fdn.Next(); while (dn != null) { dsName = dn.Name.ToUpper(); bool isTopology = dn is ITopologyName; if (!isTopology) { string shortName = LayerHelper.GetClassShortName(dsName); if (pUpperCase) { shortName = shortName.ToUpper(); } if (pEscapeMetaTable) { } else { sc.Add(shortName); } } dn = fdn.Next(); } #endregion } dn = edn.Next(); } #region 获取直接的FeatureClass edn = pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass); dn = edn.Next(); while (dn != null) { string dsName = dn.Name.ToUpper(); if (ownerName.Equals(LayerHelper.GetClassOwnerName(dsName))) { string shortName = LayerHelper.GetClassShortName(dsName); if (pUpperCase) { shortName = shortName.ToUpper(); } if (pEscapeMetaTable) { } else { sc.Add(shortName); } } dn = edn.Next(); } #endregion return(sc); } catch (Exception ex) { return(null); } }
/// <summary> /// Occurs when this command is clicked /// </summary> public override void OnClick() { try { IMongoDbDialogVM dbDialog = UIUtils.GetDialogVM(); ButtonInfo okBtn; okBtn.OnClick = (() => { string connString = dbDialog.File; if (String.IsNullOrEmpty(connString)) { return; } string selectedFC = dbDialog.GetSelectedFCName(); if (String.IsNullOrEmpty(selectedFC)) { return; } //get the type using the ProgID Type t = Type.GetTypeFromProgID("esriGeoDatabase.MongoDBPluginWorkspaceFactory"); //Use activator in order to create an instance of the workspace factory IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(t); IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(connString, 0); //get a featureclass from the workspace IFeatureClass featureClass = featureWorkspace.OpenFeatureClass(selectedFC); //create a new feature layer and add it to the map IFeatureLayer featureLayer = new FeatureLayerClass(); featureLayer.Name = featureClass.AliasName; featureLayer.FeatureClass = featureClass; m_hookHelper.FocusMap.AddLayer((ILayer)featureLayer); dbDialog.Close(); }); okBtn.IsEnabled = null; dbDialog.SetOk(okBtn); ButtonInfo cancelBtn; cancelBtn.OnClick = () => { dbDialog.Close(); }; cancelBtn.IsEnabled = null; dbDialog.SetCancel(cancelBtn); ButtonInfo browseBtn; browseBtn.OnClick = () => { string result = UIUtils.BrowseToFile(null, "Connection File to MongoDB (.mongoconn)|*.mongoconn", false); if (String.IsNullOrEmpty(result)) { return; } string connInfoStr = ConnectionUtilities.DecodeConnFile(result); MongoDBConnInfo connInfo = ConnectionUtilities.ParseConnectionString(connInfoStr); dbDialog.DatabaseText = connInfo.DBName; dbDialog.ServerText = connInfo.Connection.ToString(); dbDialog.File = result; //get the type using the ProgID Type t = Type.GetTypeFromProgID("esriGeoDatabase.MongoDBPluginWorkspaceFactory"); //Use activator in order to create an instance of the workspace factory IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(t); IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(result, 0); IEnumDatasetName ipNames = ((IWorkspace)featureWorkspace).get_DatasetNames(esriDatasetType.esriDTFeatureClass); List <string> dsNames = new List <string>(); IDatasetName ipCurr = ipNames.Next(); while (ipCurr != null) { dsNames.Add(ipCurr.Name); ipCurr = null; ipCurr = ipNames.Next(); } dbDialog.ClearFCList(); if (dsNames.Count > 0) { dbDialog.SetFCNames(dsNames); } }; browseBtn.IsEnabled = null; dbDialog.SetBrowse(browseBtn); UIUtils.DisplayMongoBrowseDialog(dbDialog); } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } }
/// <summary> /// 获取workspace中的所有FeatureClass名称 /// </summary> /// <returns></returns> public static List <string> GetAllFeatureClassName(this IWorkspace workspace) { IEnumDatasetName datasetNameEnum = workspace.DatasetNames[esriDatasetType.esriDTAny]; return(GetAllFeatureClassName(datasetNameEnum)); }
internal IFeatureClass CreateShapefile(string path, string name, esriGeometryType geometryType, ISpatialReference spatialRef, string idFieldName) { const string SHAPE_FIELD = "Shape"; IFeatureClass shapeFile = null; IWorkspace workspace = null; try { workspace = OpenShapeFileWorkspace(path); IFeatureWorkspace featureWorkspace = workspace as IFeatureWorkspace; //Delete any existing IEnumDatasetName datasets = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass); datasets.Reset(); IDataset existing = null; IDatasetName datasetName = datasets.Next(); while (datasetName != null) { if (string.Compare(name, datasetName.Name, true) == 0) { existing = (IDataset)((IName)datasetName).Open(); break; } datasetName = datasets.Next(); } if (existing != null) { try { existing.Delete(); } finally { UrbanDelineationExtension.ReleaseComObject(existing); } } //Get elements to create a new table/feature class IFieldsEdit fields = new FieldsClass(); IGeometryDefEdit geometryDef = new GeometryDefClass(); geometryDef.GeometryType_2 = geometryType; geometryDef.SpatialReference_2 = spatialRef; IFieldEdit shapeField = new FieldClass(); shapeField.Name_2 = SHAPE_FIELD; shapeField.Type_2 = esriFieldType.esriFieldTypeGeometry; shapeField.GeometryDef_2 = geometryDef; fields.AddField(shapeField); IFieldEdit eidField = new FieldClass(); eidField.Name_2 = idFieldName; eidField.Type_2 = esriFieldType.esriFieldTypeInteger; eidField.Length_2 = 16; fields.AddField(eidField as IField); //Create feature class shapeFile = featureWorkspace.CreateFeatureClass(name, fields, null, null, esriFeatureType.esriFTSimple, SHAPE_FIELD, null); } finally { UrbanDelineationExtension.ReleaseComObject(workspace); } return(shapeFile); }
//利用quickexport进行数据转换 dwg-->mdb private void QuickImportTopdb(string strSrcDwg, string strdesPdb) { ITrackCancel pTrackCancel = null; //找到tool ESRI.ArcGIS.Geoprocessor.Geoprocessor _geoPro = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); //ESRI.ArcGIS.Geoprocessing.IGeoProcessor _geoPro = new ESRI.ArcGIS.Geoprocessing.GeoProcessorClass(); pTrackCancel = new TrackCancelClass(); IVariantArray pVArray = new VarArrayClass(); IVariantArray parameters = new VarArrayClass(); parameters.Add("ACAD," + strSrcDwg); string strtoolName = ""; //parameters.Add("RUNTIME_MACROS,"); //parameters.Add("METAFILE,acad,_EXPAND_BLOCKS,yes,ACAD_IN_USE_BLOCK_HEADER_LAYER,yes," //+ "ACAD_IN_RESOLVE_ENTITY_COLOR,yes,_EXPAND_VISIBLE,yes,_READ_AS_2_5D,no," //+ "_BULGES_AS_ARCS,no,_STORE_BULGE_INFO,no,_READ_PAPER_SPACE,no," //+ "ACAD_IN_READ_GROUPS,no,_IGNORE_UCS,no,_ACADPreserveComplexHatches,no," //+ "_MERGE_SCHEMAS,YES,"); //parameters.Add("META_MACROS,"); //parameters.Add("Source_EXPAND_BLOCKS,yes," //+ "SourceACAD_IN_USE_BLOCK_HEADER_LAYER,yes,SourceACAD_IN_RESOLVE_ENTITY_COLOR,yes" //+ ",Source_EXPAND_VISIBLE,yes,Source_READ_AS_2_5D,no,Source_BULGES_AS_ARCS,no," //+ "Source_STORE_BULGE_INFO,no,Source_READ_PAPER_SPACE,no,SourceACAD_IN_READ_GROUPS,no" //+ ",Source_IGNORE_UCS,no,Source_ACADPreserveComplexHatches,no,METAFILE,acad,COORDSYS,,IDLIST,,"); //parameters.Add("__FME_DATASET_IS_SOURCE__,true"); //string param = "__FME_DATASET_IS_SOURCE__,true"; //parameters.Add(param); parameters.Add(strdesPdb + "\\..\\tmp.mdb"); strtoolName = "QuickImport_interop"; IGPEnvironmentManager pgpEnv = new GPEnvironmentManager(); IGPMessages pGpMessages; //= _geoPro.Validate(parameters, false, pgpEnv); IGPComHelper pGPCOMHelper = new GpDispatch(); //这里是关键,如果不赋值的话,那么就会报错 IGPEnvironmentManager pEnvMgr = pGPCOMHelper.EnvironmentManager; pgpEnv.PersistAll = true; pGpMessages = new GPMessagesClass(); _geoPro.OverwriteOutput = true; //Execute the model tool by name. _geoPro.Execute(strtoolName, parameters, pTrackCancel); //QuickImport qi = new QuickImport(); //qi.Input = txtSource.Text; //qi.Output = txtTarget.Text; //_geoPro.Execute(qi, pTrackCancel); ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile FCTS = new ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile(); FCTS.Output_Folder = strdesPdb; IWorkspaceFactory pWF = new AccessWorkspaceFactoryClass(); IWorkspace pWorkSpace = pWF.OpenFromFile(strdesPdb + "\\..\\tmp.mdb", 0); IEnumDatasetName pED = pWorkSpace.get_DatasetNames(esriDatasetType.esriDTFeatureClass); IDatasetName pDataSet = pED.Next(); while (pDataSet != null) { if ((pWorkSpace as IFeatureWorkspace).OpenFeatureClass(pDataSet.Name).FeatureType != esriFeatureType.esriFTSimple)//排除注记等 { pDataSet = pED.Next(); continue; } //_geoPro = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); //_geoPro.OverwriteOutput = true; FCTS.Input_Features = pWorkSpace.PathName + "\\" + pDataSet.Name; _geoPro.Execute(FCTS, pTrackCancel); pDataSet = pED.Next(); } Stream s = new System.IO.FileStream("d:\\qimport.txt", FileMode.Create); StreamWriter sw = new StreamWriter(s); for (int i = 0; i < _geoPro.MessageCount; i++) { sw.WriteLine(_geoPro.GetMessage(i)); } sw.Close(); s.Close(); }