-
-
-
- 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)
- {
-
- 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();
- }
-
- IFeatureClassContainer topFcList = top as IFeatureClassContainer;
- for (int d = topFcList.ClassCount - 1; d >= 0; d--)
- {
- top.RemoveClass(topFcList.get_Class(d) as IClass);
- }
-
- (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);
- }
- }
- }
- catch (Exception ee)
- {
- rbc = false;
- AppLogErrWrite.WriteErrLog(ee.ToString());
- }
- return rbc;
- }
转载于:https://www.cnblogs.com/sqlite3/archive/2008/09/17/2566996.html