Contents Index end_download_rows table event end_synchronization connection event

MobiLink Synchronization Reference
  Synchronization Events

end_publication connection event


Function 

Provides useful information about the publication(s) being synchronized.

Parameters 

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, you should use the appropriate corresponding data type. See SQL-Java data types and SQL-.NET data types.

Item Parameter Description
1 generation_number INTEGER. If your deployment does not use file-based downloads, this parameter can be ignored. The default is 1.
2 ml_username VARCHAR(128). If an UltraLite remote is synchronizing with UL_SYNC_ALL, this event is invoked once with the name 'unknown'.
3 publication_name VARCHAR(128)
4 last_upload TIMESTAMP. Last successful upload.
5 last_download TIMESTAMP. Last successful download.
Default action 

None.

Description 

This event lets you design synchronization logic based on the publications currently being synchronized. This event is invoked in the same transaction as the end_synchronization event, and is invoked before the end_synchronization event. It is invoked once per publication being synchronized.

If the current synchronization successfully applied an upload, the last_upload parameter will contain the time this latest upload was applied. If the current synchronization has a successful download acknowledgement, the last_download time will contain the time this latest download was generated. This is the same value that was passed to the download scripts as the last download timestamp.

Generation number 

The generation_number parameter is specifically for file-based downloads.

The output value of the generation number is passed from the begin_publication script to the end_publication script. The meaning of the generation_number depends on whether the current synchronization is being used to create a download file, or whether the current synchronization has an upload.

In file-based downloads, generation numbers are used to force an upload before the download. The number is stored in the download file.

See also 

begin_publication connection event

File-Based Downloads

SQL example 

You may want to record the information for each publication being synchronized:

call ml_add_connection_script(
   'version1',
   'end_publication',
   '{call RecordPubEndSync( ?, ?, ?, ?, ? )}' );
Java example 

The following stored procedure call registers a Java method called endPublication as the script for the begin_publication connection event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_java_connection_script(
   'ver1',
   'end_publication',
   'ExamplePackage.ExampleClass.endPublication' )

Following is the sample Java method endPublication. It outputs a message to the MobiLink log.

public String endPublication(
    ianywhere.ml.script.InOutInteger generation_number,
    String user,
    String pub_name,
    Timestamp last_upload,
    Timestamp last_download )
{  System.out.println(
     "Finished synchronizing publication " + pub_name );
   return( null ); }
.NET example 

The following stored procedure call registers a .NET method called EndPub as the script for the end_publication connection event when synchronizing the script version ver1. This syntax is for Adaptive Server Anywhere consolidated databases.

call ml_add_dnet_connection_script( 'ver1',
  'end_publication',
  'TestScripts.Test.EndPub'
)

Following is the C# signature for EndPub.

public void EndPub(
    ref int generation_number,
    string user,
    string pub_name,
    DateTime last_upload,
    DateTime last_download )
{
    Console.Write(
      "Finished synchronizing publication " + pub_name );
}

Contents Index end_download_rows table event end_synchronization connection event