Invoking a Method of a COM-Visible Object from an SCC Schedule
- Last UpdatedMar 19, 2016
- 3 minute read
Triggering an import schedule with the Import Data Type Import from COM object or an export schedule with the Transport Type Call COM object causes MES Service (or MES Supervisor, in the case when the Test button is clicked on the Summary tab) to:
-
Create an instance of the object specified in the COM Object field using late binding.
-
Call the method specified in the Method to Call on COM Object field.
The contents of the COM Object field must be a fully qualified name with the format Namespace.Class.Version.
For an import, the method needs to conform to the following signature:
-
For Visual Basic: Public Method xxxxxx (ByVal session_id as long, ByVal sched_id as string, Optional ByVal context as string) as long
-
For C#: public long xxxxxx (long session_id, string sched_id, string context)
For an export, the method needs to conform to the following signature:
-
For Visual Basic: Public Method xxxxxx (ByVal session_id as long, ByVal sched_id as string, ByVal rs as ADODB.recordset, Optional ByVal context as string) as long
-
For C#: public long xxxxxx (long session_id, string sched_id, ADODB.Recordset rs, string context)
The method utilizes the parameters passed to it to know what it is to do in each particular case:
-
The session_id parameter is the session ID of the MES Service (or MES Supervisor) that triggered the import, and is used as a parameter in most stateless API methods.
-
The sched_id parameter identifies the SCC schedule that triggered the import, and allows the COM object to extract additional configuration information from the dx_sched table (and other) if required, or to use the sched_id if creating additional entries in the SCC log table (dx_log), where it is a required field.
-
In the case of a method called from an export schedule, the rs parameter is the recordset returned by the query associated with the export schedule.
-
The optional context parameter allows passing of context information to the COM object. For example, context information can be passed to allow multiple schedules to call the same COM object yet have it respond differently by passing different context values it can use to conditionalize different behaviors. It is always a string even though it is passed as a variant in Visual Basic. It is only included in the method call if it is not null and not an empty string.
The method should return a (long) 0 if the import was handled successfully or a (long) -1 if an error occurred. While SCC will create entries in its log if it is unable to invoke the method or the method caused an unhandled exception, it otherwise does not know if the intended processing succeeded. Therefore, it is up to the method to make entries in the log (the dx_log table) if its internal processing was not successful, to provide users a record of what failed and, to the extent possible, why. Note that there are currently no stateless API methods to access the dx_* tables, so this must be done via a direct connection to the MES middleware.
It is up to the method called by an input schedule to actually insert records into the MES database, preferably by using the stateless API. A method called by an export schedule can either use the ADODB recordset passed to it, or it could do its own query. However, if all the required information to be exported is in the recordset, a separate query is not required.