IDataSource.Add()

Description:

The Add method adds an event (entry) to the event log database.

This method can be called both synchronously and asynchronously.

Syntax:

For synchronous calls:

result = so.IDataSource.Add(criteria);

For asynchronous calls:

result = so.IDataSource.Add(criteria, callback);

Arguments:

  • criteria:

    This is an object that specifies what type of device log entries are added to the event database and details about the entry. For more information about the object properties and how to define them, see section Criteria for adding a log entry.

  • callback:

    The callback argument is the name of the method that is executed when an asynchronous Add call has results or status information to return. You must define this method separately. Follow the instructions in section Defining the callback handler for an asynchronous method to define the callback method.

    This argument is used only with an asynchronous Add call.

Return value:

If synchronous, the Add method returns an object that contains a unique identifier for the log entry, an error code, and an error message.

Table: Return value properties for a synchronous Add

Property

Description

Value

result.ReturnValue

This is a text string that contains the unique identifier of the log entry that was added to the event log database.

 

result.ErrorCode

This is a number that specifies a predefined error code.

See Service API error codes .

result.ErrorMessage

This is a text string that describes the error.

See Logging Service API error messages.

If asynchronous, the Add method returns an object that contains the initial return value from the asynchronous call that it started (see the following table). The actual logging information is returned by the callback method in the ReturnValue property of its result object. The returned information is described in the preceding table.

Table: Return value properties for an asynchronous Add

Property

Description

Value

result.TransactionID

This is a number used as an identification to match transactions started with the asynchronous Add call to one or more calls it generates to callback.

This property is only valid for asynchronous calls.

 

result.ErrorCode

This is a number that specifies a predefined error code.

See Service API error codes.

result.ErrorMessage

This is a text string that describes the error.

See Logging Service API error messages.

Example code:

For the complete source of a sample widget that demonstrates how to use this Service API, see the full example.