ArcFM Solution Developer Guide
Execute Method (IMMAbandonAUStrategy)


Passes in an IObject

Passes in a second IObject

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.
Syntax
'Declaration
 
Sub Execute( _
   ByVal pObj As ESRI.ArcGIS.Geodatabase.IObject, _
   ByVal pNewObj As ESRI.ArcGIS.Geodatabase.IObject _
) 
'Usage
 
Dim instance As IMMAbandonAUStrategy
Dim pObj As ESRI.ArcGIS.Geodatabase.IObject
Dim pNewObj As ESRI.ArcGIS.Geodatabase.IObject
 
instance.Execute(pObj, pNewObj)
void Execute( 
   ESRI.ArcGIS.Geodatabase.IObject pObj,
   ESRI.ArcGIS.Geodatabase.IObject pNewObj
)

Parameters

pObj

Passes in an IObject

pNewObj

Passes in a second IObject

Example
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)
'Unrelate the related objects from the original object and re-relate
'them to the new object class.
'All this code is within an operation.

  If pObj Is Nothing Or pNewObj Is Nothing Then Exit Sub
  If pObj.OID = pNewObj.OID Then Exit Sub 'same objects no need to do the following

  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
    'Get related classes. Forward direction only.
    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

    'Iterate the relationship classes
    Dim pRelClass As IRelationshipClass
    Dim pDestClass As IObjectClass

    pEnumRelClass.Reset
    Do
      Set pRelClass = pEnumRelClass.Next
      If pRelClass Is Nothing Then Exit Do

      'Get all the objects from the destination class related to pObj
      'Unrelate and re-relate
      Dim pRelObjSet As ISet
      Set pRelObjSet = pRelClass.GetObjectsRelatedToObject(pObj)
      Set pDestClass = pRelClass.DestinationClass

      'Iterate all the relationship classes in the new object
      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 'unrelate
        Set pRelationship = pNewRelClass.CreateRelationship(pNewObj, pRelObj) 'relate
      Loop
      End If
    Loop
    End If
  'Delete the original object after it has been abandoned.
  pObj.Delete

End Sub
Requirements

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.

See Also

Reference

IMMAbandonAUStrategy Interface
IMMAbandonAUStrategy Members

 

 


Send Comment