Use this method to code your abandon autoupdater task. This can contain code to perform any task that you want to assign to an abandon event.
The following code sample uses the MMAbandonRelate model name to identify any object related to the object that is to be abandoned. These related objects are then related to the abandoned (destination) object. This ensures that no related objects are left orphaned when an object is abandoned.
The following code sample shows how IMMAbandonAUStrategy::Execute may be implemented.
Visual Basic |
Copy Code |
Private Sub IMMAbandonAUStrategy_Execute(ByVal pObj As IObject, ByVal pNewObj As IObject)
If pObj Is Nothing Or pNewObj Is Nothing Then Exit Sub
If pObj.OID = pNewObj.OID Then Exit Sub
Dim pOriginalOC As IObjectClass
Set pOriginalOC = pObj.Class
Dim pDestOC As IObjectClass
Set pDestOC = pNewObj.Class
Dim pOriginalDS As IDataset
Set pOriginalDS = pOriginalOC
Dim pDestDS As IDataset
Set pDestDS = pDestDS
If (pOriginalDS.Name = "PrimaryOH" And pDestDS.Name = "AbandonedElectricLineSegment") Then
Dim pEnumRelClass As IEnumRelationshipClass
Set pEnumRelClass = pOriginalOC.RelationshipClasses(esriRelRoleOrigin)
Dim pEnumNewRelClass As IEnumRelationshipClass
Set pEnumNewRelClass = pDestOC.RelationshipClasses(esriRelRoleOrigin)
If pEnumRelClass Is Nothing Or pEnumNewRelClass Is Nothing Then Exit Sub
Dim pRelClass As IRelationshipClass
Dim pDestClass As IObjectClass
pEnumRelClass.Reset
Do
Set pRelClass = pEnumRelClass.Next
If pRelClass Is Nothing Then Exit Do
Dim pRelObjSet As ISet
Set pRelObjSet = pRelClass.GetObjectsRelatedToObject(pObj)
Set pDestClass = pRelClass.DestinationClass
Dim pNewRelClass As IRelationshipClass
Dim pNewDestDS As IDataset
Dim pNewDestOC As IObjectClass
pEnumNewRelClass.Reset
Do
Set pNewRelClass = pEnumNewRelClass.Next
If pNewRelClass Is Nothing Then Exit Do
Set pNewDestOC = pNewRelClass .DestinationClass
Set pNewDestDS = pNewDestOC
If (pNewDestDS.Name = "ConductorInfo") Then
If pDestOC.ObjectClassID = pNewDestOC .ObjectClassID Then
Exit Do
End If
End If
Loop
If Not pNewRelClass Is Nothing Then
pRelObjSet.Reset
Dim pRelObj As IObject
Dim pRelationship As IRelationship
Do
Set pRelObj = pRelObjSet.Next
If pRelObj Is Nothing Then Exit Do
pRelClass.DeleteRelationship pObj, pRelObj
Set pRelationship = pNewRelClass.CreateRelationship(pNewObj, pRelObj)
Loop
End If
Loop
End If
pObj.Delete
End Sub |
|
Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)
Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.