'''
''' A helper object used to execute a specified class
''' from a specified DLL on the server.
'''
'''
'''
''' A worker object can be provided directly by the client
''' workstation. In that case, the worker object is passed
''' by value to the server where it is executed. The drawback
''' to such an approach is that the worker assembly must be
''' installed on both client and server.
'''
''' BatchJobRequest is a worker object that specifies the
''' type and assembly name of a class on the server. When
''' this job is run, it dynamically creates an instance of
''' the specified class and executes it on the server. This
''' means that the actual worker assembly needs to be installed
''' only on the server, not on the client.
'''
'''
_
Public Class BatchJobRequest
Implements IBatchEntry
Private mAssembly As String = ""
Private mType As String = ""
'''
''' Creates a new object, specifying the type and assembly
''' of the actual worker object.
'''
''' The class name of the actual worker object.
''' The name of the assembly containing the actual worker class.
Public Sub New(ByVal Type As String, ByVal [Assembly] As String)
mAssembly = [Assembly]
mType = Type
End Sub
'''
''' The class name of the worker object.
'''
Public Property Type() As String
Get
Return mType
End Get
Set(ByVal Value As String)
mType = Value
End Set
End Property
'''
''' The name of the assembly containing the actual worker class.
'''
Public Property [Assembly]() As String
Get
Return mAssembly
End Get
Set(ByVal Value As String)
mAssembly = Value
End Set
End Property
'''
''' Executes the batch job on the server.
'''
'''
''' This method runs on the server - it is called
''' by ,
''' which is called by
''' .
'''
'''
Public Sub Execute(ByVal State As Object) _
Implements IBatchEntry.Execute
' create an instance of the specified object
Dim job As IBatchEntry
job = CType(AppDomain.CurrentDomain.CreateInstanceAndUnwrap(mAssembly, mType), IBatchEntry)
' execute the job
job.Execute(State)
End Sub
#Region " System.Object overrides "
Public Overrides Function ToString() As String
Return "BatchJobRequest: " & mType & "," & mAssembly
End Function
#End Region
End Class