本文整理汇总了C#中IWorkspace.get_DatasetNames方法的典型用法代码示例。如果您正苦于以下问题:C# IWorkspace.get_DatasetNames方法的具体用法?C# IWorkspace.get_DatasetNames怎么用?C# IWorkspace.get_DatasetNames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IWorkspace
的用法示例。
在下文中一共展示了IWorkspace.get_DatasetNames方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportToXml
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);
}
示例2: GetFeatureClassNames
internal static String[] GetFeatureClassNames(IWorkspace TheWrkspc)
{
String[] TheNames = new String[0];
IEnumDatasetName TheFCNames;
IDatasetName OneFCName;
// iterate through all the Feature Datasets...
IEnumDatasetName TheFDNames = TheWrkspc.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName OneFDName = TheFDNames.Next();
while (OneFDName != null)
{
// iterate through all the Feature Classes in the Dataset...
TheFCNames = OneFDName.SubsetNames;
OneFCName = TheFCNames.Next();
while (OneFCName != null)
{
if (OneFCName.Type == esriDatasetType.esriDTFeatureClass)
{
// add each Feature Class name to the listbox
System.Array.Resize<String>(ref TheNames, TheNames.Length + 1);
TheNames[TheNames.Length - 1] = OneFCName.Name;
}
// ...and continue iterating...
OneFCName = TheFCNames.Next();
}
// ...continue iterating through each feature dataset...
OneFDName = TheFDNames.Next();
}
// now iterate through all the non-dataset feature classes...
TheFCNames = TheWrkspc.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
OneFCName = TheFCNames.Next();
while (OneFCName != null)
{
// add each feature class name to the listbox
System.Array.Resize<String>(ref TheNames, TheNames.Length + 1);
TheNames[TheNames.Length - 1] = OneFCName.Name;
// ...and continue iterating...
OneFCName = TheFCNames.Next();
}
return TheNames;
}
示例3: Form2
public Form2(IWorkspace Wspace,Form1 F)
{
InitializeComponent();
f = F;
WS = Wspace;
IEnumDatasetName EDSN = Wspace.get_DatasetNames(esriDatasetType.esriDTFeatureClass);
IDatasetName DSN = EDSN.Next();
while (DSN != null)
{
string name = DSN.Name;
listBoxFeatureClass.Items.Add(name);
DSN = EDSN.Next();
}
}
示例4: GetDataSet
public static IDataset GetDataSet(IWorkspace inWorkspace, string objectname)
{
IEnumDatasetName enumDatasetName = inWorkspace.get_DatasetNames(esriDatasetType.esriDTAny);
IDatasetName datasetName = enumDatasetName.Next();
IDataset dataset = null;
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)inWorkspace;
while (datasetName != null)
{
if (datasetName.Name == objectname)
{
if (datasetName.Type == esriDatasetType.esriDTFeatureClass)
dataset = (IDataset)featureWorkspace.OpenFeatureClass(objectname);
else
dataset = (IDataset)featureWorkspace.OpenTable(objectname);
return dataset;
}
datasetName = enumDatasetName.Next();
}
return null;
}
示例5: TestConnectSDEData
private void TestConnectSDEData(string server, string instance,string database, string user, string password, string version)
{
try
{
m_pWorkspaceFactory = new SdeWorkspaceFactoryClass();
m_pPropSet = new PropertySetClass();
//���ãӣģ�����������Ϣ
m_pPropSet.SetProperty("SERVER", server);
m_pPropSet.SetProperty("INSTANCE", instance);
m_pPropSet.SetProperty("Database", database);
m_pPropSet.SetProperty("User", user);
m_pPropSet.SetProperty("password", password);
m_pPropSet.SetProperty("version", version);
m_pWorkspace = m_pWorkspaceFactory.Open(m_pPropSet, 0);
m_pFeatureWorkspace = m_pWorkspace as IFeatureWorkspace;
/////////////////////////////////////////////////////////
IEnumDatasetName pEnumDSName = m_pWorkspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName pSDEDsName = pEnumDSName.Next();
treeView1.Nodes.Clear();
TreeNode node1;
while (pSDEDsName != null)
{
node1=treeView1.Nodes.Add(pSDEDsName.Name);
LoadAllFeatClass(node1,pSDEDsName.Name );
pSDEDsName = pEnumDSName.Next();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例6: QueryFeatureClassName
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; }
}
示例7: GetFeatureDataSetNames
private static IEnumerable<string> GetFeatureDataSetNames(IWorkspace workspace)
{
IEnumDatasetName datasetNames = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName name = datasetNames.Next();
while (name != null)
{
yield return name.Name;
name = datasetNames.Next();
}
}
示例8: txtWorkspace_ButtonClick
private void txtWorkspace_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
m_Workspace = null;
switch (m_SelectedWorkspaceType)
{
case enumWorkspaceType.SDE:
FrmSDESetting frmSetting = new FrmSDESetting();
if (m_SDEPropertySet != null)
frmSetting.SDEPropertySet = m_SDEPropertySet;
if (frmSetting.ShowDialog(this) != DialogResult.OK)
return;
m_SDEPropertySet = frmSetting.SDEPropertySet;
txtWorkspace.Text = Utility.WorkspaceHelper.PropertySetToString(m_SDEPropertySet);
m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.SDE, m_SDEPropertySet);
break;
case enumWorkspaceType.FileGDB:
if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
return;
txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.FileGDB, folderBrowserWorkspace.SelectedPath);
break;
case enumWorkspaceType.PGDB:
dlgWorkspace.Filter = "PGDB |*.mdb";
if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
return;
txtWorkspace.Text = dlgWorkspace.FileName;
m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.PGDB, dlgWorkspace.FileName);
break;
case enumWorkspaceType.File:
if (this.m_PathType == enumPathType.Feature)
{
dlgWorkspace.Filter = "Shp |*.shp"; }
else
{
dlgWorkspace.Filter = "所有类型|*.jpg;*.bmp;*.tif;*.img;*.png;*.ovr;";
}
if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
return;
txtWorkspace.Text = dlgWorkspace.FileName;
m_Workspace = Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, System.IO.Path.GetDirectoryName(dlgWorkspace.FileName));
string strName=System.IO.Path.GetFileName(dlgWorkspace.FileName);
cmbClass.Properties.Items.Clear();
cmbClass.Properties.Items.Add(strName);
cmbClass.Text = strName;
// Shp / 文件栅格的话到此为止
return;
}
// 判断
if (m_Workspace == null)
{
XtraMessageBox.Show("非正确的数据库!");
return;
}
// 加载Dataset
cmbDataset.Properties.Items.Clear();
cmbDataset.Properties.Items.Add("");
esriDatasetType dsType = (this.m_PathType == enumPathType.Feature ? esriDatasetType.esriDTFeatureDataset : esriDatasetType.esriDTRasterCatalog);
IEnumDatasetName enDatasetName = m_Workspace.get_DatasetNames(dsType);
IDatasetName dsName = enDatasetName.Next();
while (dsName != null)
{
cmbDataset.Properties.Items.Add(dsName.Name);
dsName = enDatasetName.Next();
}
}
示例9: ResetLayerDatasource
/// <summary>
/// 重置图层数据源
/// </summary>
/// <param name="pLayer"></param>
/// <param name="pNewWksp"></param>
/// <returns></returns>
public static bool ResetLayerDatasource(IDataLayer2 pLayer, IWorkspace pNewWksp)
{
if (pLayer == null || pNewWksp == null) return false;
//// 2012-06-15 张航宇
//// 直接获取Layer的数据源名称,从新的Workspace打开FeatureClass进行替换
//IDatasetName fClassName = pLayer.DataSourceName as IDatasetName;
//if (fClassName != null)
//{
// string strClassName = fClassName.Name;
// try
// {
// IFeatureClass fClass = (pNewWksp as IFeatureWorkspace).OpenFeatureClass(strClassName);
// pLayer.DataSourceName = (fClass as IDataset).FullName;
// }
// catch
// {
// return false;
// }
//}
IEnumDatasetName pEnumDsName = pNewWksp.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName pFtDsName = pEnumDsName.Next();
try
{
if (!pLayer.InWorkspace(pNewWksp))
{
IFeatureClassName pOldName = pLayer.DataSourceName as IFeatureClassName;
// 2012-06-15 张航宇
// 修改对没有Dataset的Workspace,直接将Workspace重置
if (pOldName != null)
{
if (pOldName.FeatureDatasetName == null || pFtDsName == null)
{
(pOldName as IDatasetName).WorkspaceName = (pNewWksp as IDataset).FullName as IWorkspaceName;
}
else
{
pOldName.FeatureDatasetName = pFtDsName;
pOldName.FeatureDatasetName.WorkspaceName = ((IDataset)pNewWksp).FullName as IWorkspaceName;
}
}
pLayer.Connect(pOldName as IName);
}
}
catch (Exception exp)
{
Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString());
return false;
}
return true;
}
示例10: GetNetworkDSNames
/// <summary>
/// Gets the dataset name objects from the workspace.
/// </summary>
/// <param name="workspace">The workspace from which to get the dataset name objects.</param>
/// <param name="type">The type of datasets for which to get the name objects.</param>
/// <returns>Returns a dictionary of dataset names by qualified name.</returns>
public static IDictionary<string, IDatasetName> GetNetworkDSNames(IWorkspace workspace, string[] nwkDSNames, string fdsName, ref IDictionary<string, int> objClassIdByName)
{
IDictionary<string, IDatasetName> dnames = new Dictionary<string, IDatasetName>();
objClassIdByName = new Dictionary<string, int>();
try
{
if (workspace != null)
{
IEnumDatasetName names = workspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
names.Reset();
IDatasetName name = names.Next();
try
{
while (name != null)
{
string key = DisplayMap.GetQualifiedName(name, workspace);
if (string.Compare(key, fdsName, true) == 0)
{
GetDatasetNames(workspace, name, esriDatasetType.esriDTAny, nwkDSNames, ref dnames, ref objClassIdByName);
break;
}
name = names.Next();
}
}
catch (Exception e)
{
// _logger.LogAndDisplayException(e);
}
}
// else
// _logger.LogFormat("{0}: Null workspace parameter.", methodName, LogLevel.enumLogLevelWarn);
}
catch (Exception e)
{
// _logger.LogAndDisplayException(e);
}
return dnames;
}
示例11: ftrExists
/// <summary>
/// determins if a feature exists
/// wks = IWorkspace; ftr = ftrn name no extention
/// </summary>
/// <param name="wks">IWorkspace</param>
/// <param name="ftr">name of the feature not extension</param>
/// <returns>true if exist otherwise false</returns>
public bool ftrExists(IWorkspace wks, string ftr)
{
bool x = false;
try
{
if (wks != null)
{
//Console.WriteLine(wks.PathName);
//Console.WriteLine(ftr);
//Console.WriteLine(wks.WorkspaceFactory.WorkspaceType);
IEnumDatasetName dtsne = wks.get_DatasetNames(esriDatasetType.esriDTAny);
IDatasetName dtsn = dtsne.Next();
IEnumDatasetName subdtsne = null;
IDatasetName subdtsn = null;
while (dtsn != null)
{
//Console.WriteLine(dtsn.Name);
if (dtsn.Type == esriDatasetType.esriDTFeatureDataset)
{
subdtsne = dtsn.SubsetNames;
subdtsn = subdtsne.Next();
while (subdtsn != null)
{
if (subdtsn.Name.ToLower() == ftr.ToLower())
{
x = true;
break;
}
subdtsn = subdtsne.Next();
}
if (x == true) break;
}
else
{
if (dtsn.Name.ToLower() == ftr.ToLower())
{
x = true;
break;
}
}
dtsn = dtsne.Next();
}
}
}
catch (Exception e)
{
Console.WriteLine("Error: " + e.ToString());
}
return x;
}
开发者ID:GeospatialDaryl,项目名称:USFS_RMRS_FunctionalModeling_RasterModeling,代码行数:58,代码来源:geodatabaseutility.cs
示例12: txtWorkspace_ButtonClick
private void txtWorkspace_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
m_Workspace = null;
switch (m_SelectedWorkspaceType)
{
case enumWorkspaceType.SDE:
FrmSDESetting frmSetting = new FrmSDESetting();
if (m_SDEPropertySet != null)
frmSetting.SDEPropertySet = m_SDEPropertySet;
if (frmSetting.ShowDialog(this) != DialogResult.OK)
return;
m_SDEPropertySet = frmSetting.SDEPropertySet;
txtWorkspace.Text = Hy.Esri.Utility.WorkspaceHelper.PropertySetToString(m_SDEPropertySet);
m_Workspace = Hy.Esri.Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.SDE, m_SDEPropertySet);
break;
case enumWorkspaceType.FileGDB:
if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
return;
txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
m_Workspace = Hy.Esri.Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.FileGDB, folderBrowserWorkspace.SelectedPath);
break;
case enumWorkspaceType.PGDB:
dlgWorkspace.Filter = "PGDB |*.mdb";
if (dlgWorkspace.ShowDialog(this) != DialogResult.OK)
return;
txtWorkspace.Text = dlgWorkspace.FileName;
m_Workspace = Hy.Esri.Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.PGDB, dlgWorkspace.FileName);
break;
case enumWorkspaceType.File:
if (folderBrowserWorkspace.ShowDialog(this) != DialogResult.OK)
return;
txtWorkspace.Text = folderBrowserWorkspace.SelectedPath;
m_Workspace = Hy.Esri.Utility.WorkspaceHelper.OpenWorkspace(enumWorkspaceType.File, folderBrowserWorkspace.SelectedPath);
break;
}
// 判断
if (m_Workspace == null)
{
XtraMessageBox.Show("非正确的数据库!");
return;
}
// 加载Dataset
cmbDataset.Properties.Items.Clear();
cmbDataset.Properties.Items.Add("");
IEnumDatasetName enDatasetName = m_Workspace.get_DatasetNames(esriDatasetType.esriDTFeatureDataset);
IDatasetName dsName = enDatasetName.Next();
while (dsName != null)
{
cmbDataset.Properties.Items.Add(dsName.Name);
//System.Runtime.InteropServices.Marshal.FinalReleaseComObject(dsName);
dsName = enDatasetName.Next();
}
//System.Runtime.InteropServices.Marshal.FinalReleaseComObject(dsName);
//System.Runtime.InteropServices.Marshal.FinalReleaseComObject(enDatasetName);
}
示例13: BtConnectarClick
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;
}
}
示例14: GetRelationshipClass
public static IRelationshipClass GetRelationshipClass(IWorkspace inWorkspace, string objectname)
{
IEnumDatasetName enumDatasetName = inWorkspace.get_DatasetNames(esriDatasetType.esriDTAny);
IDatasetName datasetName = enumDatasetName.Next();
IDataset dataset = null;
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)inWorkspace;
while (datasetName != null)
{
if (datasetName.Name == objectname)
{
if (datasetName.Type == esriDatasetType.esriDTRelationshipClass)
{
dataset = (IDataset)featureWorkspace.OpenRelationshipClass(objectname);
return (IRelationshipClass)dataset;
}
}
datasetName = enumDatasetName.Next();
}
return null;
}