从空间数据库中删除所有拓扑对象
2008-09-17 20:03
295 查看
/// <summary>
/// //从空间数据库中删除所有拓扑对象
/// </summary>
/// <returns></returns>
public bool DeleteALLTopolgyFromGISDB()
{
bool rbc = true;
try
{
IWorkspace ws = this.DefaultWorkSpace;
if (ws != null)
{
//读取所有拓扑
IEnumDataset topEnumDataset = this.getEnumDataset(ws);
if (topEnumDataset != null)
{
topEnumDataset.Reset();
IDataset ds = topEnumDataset.Next();
while (ds != null)
{
switch (ds.Type)
{
case esriDatasetType.esriDTFeatureDataset:
if (ds is ITopologyContainer)
{
ITopologyContainer topContainer = ds as ITopologyContainer;
ISchemaLock schemaLock = (ISchemaLock)ds;
try
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
int tc = topContainer.TopologyCount;
for (int i = tc - 1; i >= 0; i--)
{
ITopology top = topContainer.get_Topology(i);
if (top != null && top is IDataset)
{
//delete top's ITopologyRuleContainer
ITopologyRuleContainer topruleList = top as ITopologyRuleContainer;
IEnumRule ER = topruleList.Rules;
ER.Reset();
IRule r = ER.Next();
while (r != null && r is ITopologyRule)
{
topruleList.DeleteRule(r as ITopologyRule);
r = ER.Next();
}
//delete top's featureclass
IFeatureClassContainer topFcList = top as IFeatureClassContainer;
for (int d = topFcList.ClassCount - 1; d >= 0; d--)
{
top.RemoveClass(topFcList.get_Class(d) as IClass);
}
//delete top object
(top as IDataset).Delete();
rbc = true;
}
}
}
catch (Exception ex)
{
AppLogErrWrite.WriteErrLog(ex.ToString());
}
finally
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
}
break;
case esriDatasetType.esriDTFeatureClass:
break;
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(ds);
ds = topEnumDataset.Next();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(topEnumDataset);
}//
} //end ws!=null
}
catch (Exception ee)
{
rbc = false;
AppLogErrWrite.WriteErrLog(ee.ToString());
}
return rbc;
}
/// //从空间数据库中删除所有拓扑对象
/// </summary>
/// <returns></returns>
public bool DeleteALLTopolgyFromGISDB()
{
bool rbc = true;
try
{
IWorkspace ws = this.DefaultWorkSpace;
if (ws != null)
{
//读取所有拓扑
IEnumDataset topEnumDataset = this.getEnumDataset(ws);
if (topEnumDataset != null)
{
topEnumDataset.Reset();
IDataset ds = topEnumDataset.Next();
while (ds != null)
{
switch (ds.Type)
{
case esriDatasetType.esriDTFeatureDataset:
if (ds is ITopologyContainer)
{
ITopologyContainer topContainer = ds as ITopologyContainer;
ISchemaLock schemaLock = (ISchemaLock)ds;
try
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
int tc = topContainer.TopologyCount;
for (int i = tc - 1; i >= 0; i--)
{
ITopology top = topContainer.get_Topology(i);
if (top != null && top is IDataset)
{
//delete top's ITopologyRuleContainer
ITopologyRuleContainer topruleList = top as ITopologyRuleContainer;
IEnumRule ER = topruleList.Rules;
ER.Reset();
IRule r = ER.Next();
while (r != null && r is ITopologyRule)
{
topruleList.DeleteRule(r as ITopologyRule);
r = ER.Next();
}
//delete top's featureclass
IFeatureClassContainer topFcList = top as IFeatureClassContainer;
for (int d = topFcList.ClassCount - 1; d >= 0; d--)
{
top.RemoveClass(topFcList.get_Class(d) as IClass);
}
//delete top object
(top as IDataset).Delete();
rbc = true;
}
}
}
catch (Exception ex)
{
AppLogErrWrite.WriteErrLog(ex.ToString());
}
finally
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
}
break;
case esriDatasetType.esriDTFeatureClass:
break;
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(ds);
ds = topEnumDataset.Next();
}
System.Runtime.InteropServices.Marshal.ReleaseComObject(topEnumDataset);
}//
} //end ws!=null
}
catch (Exception ee)
{
rbc = false;
AppLogErrWrite.WriteErrLog(ee.ToString());
}
return rbc;
}
相关文章推荐
- 从空间数据库中删除所有拓扑对象
- 表空间删除不了 提示 ora01561 无法删除指定表空间中的所有对象
- 保存数据库中其他对象不变,删除数据库中所有数据的实现方法
- oracle 强制删除指定schema及相关的所有数据库的对象
- Oracle 导入数据库 删除用户、删除表空间、删除表空间下所有表,查看当前表空间
- 由于文件组 'PRIMARY 中的磁盘空间不足,无法为数据库 'newnet' 分配新页。请删除文件组中的对象、将其他文件添加到文件组或者为文件组中的现有文件启用自动增长,以便增加必要的空间。
- 删除表空间 提示ORA-01561: 无法删除指定表空间中的所有对象
- 还原Wss3.0内容数据库时遇到:"ComputerName\Microsoft##SSEE 上的 WSS_Content 包含用户定义的架构。数据库在能够使用之前必须为空。请删除所有表、存储过程以及其他对象,或使用其他数据库。 " 的提示,无法加载内容数据库
- Oracle 基础 导入数据库 删除用户、删除表空间、删除表空间下所有表
- 保存中其他对象不变,删除数据库中所有数据的实现方法
- 保存数据库中其他对象不变,删除数据库中所有数据的实现方法
- sql2008出现问题“因为无法为数据库 'MRsys' 中的对象 'dbo.T_USER_1311_DATA' 分配空间, 'PRIMARY' 文件组已满。请删除不需要的文件..."问题,解决了
- 503错误、磁盘已满、无法为数据库 'VR' 中的对象 'dbo.TNew'.'PK_TNew' 分配空间,因为 'PRIMARY' 文件组已满。请删除不需要的
- oracle 导入导出数据库、删除用户以及该用户所有的对象
- oracle 导入导出数据库、删除用户以及该用户所有的对象
- 一段删除某个数据库下所有数据的好脚本
- 查询数据库中所有表占用空间的语句
- oracle中的数据库、用户、方案、表空间、表对象之间的关系
- mysql delete删除记录数据库空间不减少问题解决方法(优化表)
- 关于C#数据库删除数据时提示未将对象引用设置到对象的实例