Schedule Instance

This section looks at the interface exposed by the schedule instance object. You get a reference to this object either through the collection, exposed by the group manager, or through the corresponding moniker.

In Visual Basic, the type library for this object is in SkedCore.dll, the same as that for the group manager above.

The following code fragments show how to get a reference to a schedule instance. This is the idiomatic use of the default property, Item, of the group manager. The collection of instances exposed by the group manager is being indexed by the name of the instance, which is the GUID assigned to it by the XLANG Scheduler Engine:

Dim oInst As COMRUNTIME.IWFWorkflowInstance 
Set oInst = oGrp("{7DFE4B47-19EB-45a1-AE35-492886B4FF74}")

The following fragment iterates through all running schedule instances in the group manager. This is the idiomatic enumeration of a collection in Visual Basic:

For Each oInst in oGrp 
    ' your code goes here...
Next

The following code fragment gets a reference to a running instance by asking COM to bind the moniker to the referenced object. In the example, the group manager name is missing and defaults to the default host, XLANG Scheduler:

Set oInst = GetObject("sked:///{7DFE4B47-19EB-45a1-AE35-492886B4FF74}") 

The properties and methods of a schedule instance are described in this section. Table 11.5 summarizes the properties, and Table 11.6 summarizes the methods of schedule instance.

Table 11.5. Properties of a Schedule Instance
PropertyDescription
CompletionStatusCompletion return code from the schedule instance
FullPortNameA fully qualified name of the port based on the implementation
FullyQualifiedNameA moniker for the schedule instance
InstanceIdGUID identity of the schedule instance
IsCompletedTrue, if the schedule finished execution
ModuleIdGUID identity of the schedule itself
ModuleNameName of the schedule
ParentInstanceIdGUID identity of the parent instance
PortThe IUnknown interface to the port COM proxy

Table 11.6. Methods of a Schedule Instance
MethodDescription
WaitForCompletionCall blocks until schedule completes

Each property and method is described in the order listed in Tables 11.5 and 11.6. The property or method is identified with a bolded label; this is followed by a signature and a description.

Property CompletionStatus

Property CompletionStatus As Long 

The property CompletionStatus indicates whether the schedule instance was completely processed by the engine. The return code of '0' (zero) indicates successful completion. This code, however, does not indicate the success or failure of the embodied business process.

This is a read-only property.

Property FullPortName

Property FullPortName(varParam As String) As String 

The property FullPortName returns a String that is a fully qualified name of the specified port. A port in a schedule can be bound to a component or to a messaging system. The name returned reflects the technology used in the binding. Thus, the name can be used to acquire a reference to the object from appropriate APIs of the system. For example, if the port is bound to MSMQ queue, then the name can be used to locate and use the queue using MSMQ APIs.

This is a read-only property.

Property FullyQualifiedName

Property FullyQualifiedName As String 

The FullyQualifiedName property returns the moniker for the schedule instance. All optional fields of the moniker syntax are fully filled in in the returned string; hence, the returned string can be parsed to extract the system name, the group manager name, and instance GUID. As with any moniker, this string can be passed to another process or an application, which can then attempt to acquire a reference to this schedule instance.

This is a read-only property.

Property InstanceId

Property InstanceId As String 

The InstanceId property returns a String containing the GUID identifier assigned to the running schedule instance by the engine.

This is a read-only property.

Property IsCompleted

Property IsCompleted As Boolean 

The property IsCompleted returns True if the schedule instance has finished executing; False otherwise.

This is a read-only property.

See also the CompletionStatus property and the WaitForCompletion method of this object.

Property ModuleId

Property ModuleId As String 

The property ModuleId returns a String containing the GUID of the XLANG schedule (that is, the .skx file created after compilation, also called the module), which is used to create this instance. This GUID is the same as the one you would see as a property of the Begin shape in your schedule drawing.

Note that this GUID keeps changing every time you make changes to your drawing. Hence, this is a way of determining which schedule is running in the instance under consideration. You can see this GUID as a property of the Begin shape in the schedule drawing. This property is also visible in the XLANG Event Monitor described later in the chapter. Two running schedules can have the same module name but different module Ids.

This is a read-only property.

Property ModuleName

Property ModuleName As String 

The property ModuleName returns a string containing the name of the schedule the instance is derived from. The module name is based on the name of the compiled schedule's filename, the one with the .skx extension.

This is a read-only file.

Property ParentInstanceID

Property ParentInstanceID As String 

The ParentInstanceID property returns the GUID instance ID of the parent XLANG schedule.

This is a read-only property. It returns NULL if the current schedule has no parent.

Property Port

Property Port(varParam As String) As Unknown 

The Port property returns an interface to a COM proxy for the named port. You must specify a port name that exists in the schedule; otherwise, an error is generated. The returned interface is an IUnknown interface, hence you must QI (query interface) for the correct interface. In Visual Basic, you do this by declaring a variable of the correct type or by using a Variant data type to hold the returned interface. The following code shows this. Variable oInst is a running instance with a port named Port_1.

Dim oComp As MyProgID.MyClass 
Set oComp = oInst.Port("Port_1")
oComp.MyMethod

This is a read-only property.

Method WaitForCompletion

Sub WaitForCompletion() 

The method WaitForCompletion does not return until the current XLANG schedule instance completes executing.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset