COMConnector: SubscriptionManager
This code sample shows event subscription and unsubscribe:
Option Strict Off Option Explicit On <System.Runtime.InteropServices.ProgId("SubscriptionManager_NET. SubscriptionManager")> Public Class SubscriptionManager 'Private Const m_OneWorldEventCLSID = "{1E645180-6C93-4704-85C6- 57775E2ED2FC}" Private m_SubscribedEvents As Collection 'UPGRADE_NOTE: Class_Initialize was upgraded to Class_Initialize_ Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/ redirect.htm?keyword="vbup1061"' Private Sub Class_Initialize_Renamed() m_SubscribedEvents = New Collection comm_Initialize() End Sub Public Sub New() MyBase.New() Class_Initialize_Renamed() End Sub Public Sub GetEventList(ByRef eventList As String) getEventListFromOneWorld(eventList) End Sub Public Sub Logoff() SendLogoffToOneWorld() End Sub Public Sub CreateTransientSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) SubscribeToOneWorldEvent(eventName, oneworldevent, 0) End Sub Public Sub CreatePersistentSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) SubscribeToOneWorldEvent(eventName, oneworldevent, 1) End Sub Public Sub RemoveTransientSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) UnSubscribeToOneWorldEvent(eventName, oneworldevent, 0) End Sub Public Sub RemovePersistentSubscription(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent) UnSubscribeToOneWorldEvent(eventName, oneworldevent, 1) End Sub Public Sub GetEventTemplate(ByRef eventName As String, ByRef eventTemplate As String) getEventTemplateFromOneWorld(eventName, eventTemplate) End Sub Public Sub SubscribeToOneWorldEvent(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent, ByRef mode As Integer) 'Private Function SubscribeToOneWorldEvent(EventName As String) As Boolean ' we've already subscribed if the subscription is in our list Dim alreadySubscribed As Boolean 'UPGRADE_WARNING: Couldn't resolve default property of object CollectionContainsString(). Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' alreadySubscribed = (CollectionContainsString (m_SubscribedEvents, eventName) = True) ' now do the right thing... If (alreadySubscribed = False) Then ' this instance of the COMConnector has not seen this ' event before, so add it to our list... m_SubscribedEvents.Add((eventName)) ' ...and go ahead and subscribe to the event from JD Edwards EnterpriseOne SendSubscriptionToOneWorld(eventName, oneworldevent, mode) End If 'SubscribeToOneWorldEvent = alreadySubscribed End Sub 'UPGRADE_NOTE: str was upgraded to str_Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"' Private Function CollectionContainsString(ByRef col As Collection, ByRef str_Renamed As String) As Object Dim colItem As Object For Each colItem In col 'UPGRADE_WARNING: Couldn't resolve default property of object colItem. Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' If (colItem = str_Renamed) Then 'UPGRADE_WARNING: Couldn't resolve default property of object CollectionContainsString. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' CollectionContainsString = True Exit Function End If Next colItem 'UPGRADE_WARNING: Couldn't resolve default property of object CollectionContainsString. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' CollectionContainsString = False End Function Public Sub UnSubscribeToOneWorldEvent(ByRef eventName As String, ByRef oneworldevent As EventClass.IOWEvent, ByRef mode As Integer) Dim alreadySubscribed As Boolean 'alreadySubscribed = (CollectionContainsString (m_SubscribedEvents.Item, eventName)) ' now do the right thing... 'If (alreadySubscribed = True) Then ' this instance of the COMConnector has not seen this event before, so ' remove it from the list... alreadySubscribed = (RemoveFromCollection (m_SubscribedEvents, eventName)) If (alreadySubscribed = False) Then MsgBox("Event Not Subscribed") Else 'm_SubscribedEvents.Remove () ' ...and go ahead and subscribe to the event from JD Edwards EnterpriseOne SendUnSubscribeToOneWorld(eventName, oneworldevent, mode) End If ' End If End Sub 'UPGRADE_NOTE: str was upgraded to str_Renamed. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1061"' Private Function RemoveFromCollection(ByRef col As Collection, ByRef str_Renamed As String) As Object Dim colItem As Object Dim count As Short count = 0 For Each colItem In col count = count + 1 'UPGRADE_WARNING: Couldn't resolve default property of object colItem. Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' If (colItem = str_Renamed) Then col.Remove(count) 'UPGRADE_WARNING: Couldn't resolve default property of object RemoveFromCollection. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' RemoveFromCollection = True Exit Function End If Next colItem 'UPGRADE_WARNING: Couldn't resolve default property of object RemoveFromCollection. Click for more: 'ms-help: //MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"' RemoveFromCollection = False End Function End Class