adTempus API
PreviousUpNext
Logging a Message to the Job Log

This example demonstrates how to use the Server API to log a message to the job log for an executing job.

Description

Programs and scripts run by adTempus can use the ArcanaDevelopment.adTempus.Server component to communicate with the adTempus service. The ApplicationIntegration interface can be used by your application to log a message in the job log for the currently-executing instance of the job. 

Note that this code can only be used by a program or script that is being run as part of an adTempus job. 

 

    'This function logs the message to the job log.
    'The program loads an ActiveX object exposed by the adTempus service
    '(the Engine). It then requests an ApplicationIntegration interface
    'that exposes the LogMessage method.
    'When adTempus runs a job, it stores a session token in an environment variable named "ADTSessionToken".
    'The program must use that token when requesting the ApplicationIntegration
    'interface, so that the service can associate the interface with the correct job.
    public Sub LogMessage(ByVal message As String, ByVal severity As ArcanaDevelopment.adTempus.Server.ADErrorSeverity, ByVal messageCode As Int32)
        Dim engine As ArcanaDevelopment.adTempus.Server.Engine
        Dim session As ArcanaDevelopment.adTempus.Server.ApplicationIntegration

        Try
            'Load the adTempus service object.
            engine = New ArcanaDevelopment.adTempus.Server.Engine
        Catch ex As Exception
            Throw New Exception("Failed to connect to adTempus service: " & ex.Message)
        End Try

        Try
            'Request the ApplicationIntegration interface for the job in which
            'this program is running. We get the session token (set by adTempus) from the environment
            'and pass it back to adTempus to get the right interface.
            'If the environment variable isn't set, that means that the program was
            'not started by adTempus, so we can't log messages.
            session = engine.GetIntegrationInterface(Environment.GetEnvironmentVariable("ADTSessionToken"))
        Catch ex As Exception
            Throw New Exception("Could not obtain a session with the adTempus service: " & ex.Message)
        End Try

        Try
            session.LogMessage(severity, messageCode, message)

        Catch ex As Exception
            Throw New Exception("Failed to log message: " & ex.Message)
        End Try

    End Sub
adTempus API Reference version 3.0.0.0, revised 10/30/2008