Share via


MSFT_Computer.InsertEventsIntoWorkflow Method

Inserts one or more events into the workflow on the server running MOM.

 uint32 MSFT_Computer.InsertEventsIntoWorkflow(Events, Index)

Parameters

  • Events
    An array of MSFT_ParameterEvent objects to submit.

  • Index
    If all of the objects in the array are added successfully, the value is null. If an error occurs, this value is set to an unsigned 32-bit integer with the zero-based array index of the last event object successfully added to the workflow.

Return Value

This method returns an unsigned 32-bit integer. If all objects in the array are added successfully, the method returns 0. If errors occurred, a nonzero value is returned and you should check the value of the Index parameter. If this method is called on a computer with a Type property that is not equal to 8192 (non-Windows), both the method return value and the value of the Index parameter are null.

Remarks

The InsertEventsIntoWorkflow method requires that events are submitted as MSFT_ParameterEvent objects.

This method works only for computers that have been created and added through MOM APIs.

When creating event rules to monitor data created by the InsertEventsIntoWorkflow method, your rule must use the Script-Generated Data provider.

Examples

The following example shows the use of the InsertEventsIntoWorkflow method.

'*********************************************************************
' Routine: Function SendEventForNonWindowsComputer
' Purpose: Generates an event for a non-Windows computer.
' Arguments: The server running MOM, computer GUID, event source, event ID,
'            event message text.
' Returns: The result from calling InsertEventsIntoWorkflow.
'
'**********************************************************************
Const TYPE_NONWINDOWS = 8192

Function SendEventForNonWindowsComputer(strMOMServer, strComputerGUID, strSource, lngEventID, strMessage)
    Dim objComputer, objEventClass, objGeneratedEvent
    Dim arrEvents(0)
    Dim lngResult, lngLastEventAdded

    lngResult = -1
    lngLastEventAdded = -1

    Set objComputer = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_Computer='" & strComputerGUID & "'")

   If Not(objComputer Is Nothing) Then
        If (objComputer.Type = TYPE_NONWINDOWS) Then

            ' create a new event and set its property values
            Set objEventClass = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_ParameterEvent")

            Set objGeneratedEvent = objEventClass.SpawnInstance_()

            objGeneratedEvent.EventSource = strSource
            objGeneratedEvent.EventNumber = lngEventID
            objGeneratedEvent.Message = strMessage

            ' add the event to an array
            Set arrEvents(0) = objGeneratedEvent

            ' submit the event array for the non-Windows computer
            lngResult = objComputer.InsertEventsIntoWorkflow(arrEvents, lngLastEventAdded)

        End If
    End If

    Set objComputer = Nothing
    Set objEventClass = Nothing
    Set objGeneratedEvent = Nothing

    SendEventForNonWindowsComputer = lngResult
End Function
  

Requirements

Platforms: Requires Windows 2000 Server or later

Version: Requires MOM 2000 SP1 or later

See Also

MSFT_Computer Class | MSFT_Computer.Type Property | MSFT_ParameterEvent Class