Collection Contents 上一页 下一页 PDF

MobiLink 教程

教程:Adaptive Server Anywhere 的 .NET 同步逻辑

第 2 课:为事件指定类方法


有关 CustDB 示例数据库和使用备用 RDBMS 服务器的详细信息,请参见建立 CustDB 统一数据库

上一课中创建的 CustdbScripts.dll 封装 UploadInsert() 和 DownloadCursor() 方法。这些方法分别包含 ULCustomer upload_insert 和 upload_update 事件的实现。

在本节中,可以用两种方法为表级别事件指定类方法:

  1. 使用 MobiLink 同步插件。

    使用 Sybase Central 连接到 CustDB 数据库,将 upload_insert 脚本的语言更改为 .NET,然后指定 MLExample.CustdbScripts.UploadInsert 来处理事件。

  2. 使用 ml_add_dnet_table_script 存储过程。

    您将用 Interactive SQL 连接到 CustDB 数据库并执行 ml_add_dnet_table_script,从而为 download_cursor 事件指定 MLExample.CustdbScripts.DownloadCursor。

将 CustdbScripts.uploadInsert() 预订到 ULCustomer 表的 upload_insert 事件

  1. 使用 MobiLink 同步插件连接到示例数据库:

  2. 将 ULCustomer 表的 upload_insert 事件的语言更改为 .NET:

  3. 输入完全限定的 .NET 方法名作为 upload_insert 脚本。

  4. 退出 Sybase Central。

此步骤使用 Sybase Central 将 .NET 方法指定为 ULCustomer upload_insert 事件的脚本。

或者,您也可以使用 ml_add_dnet_connection_script 和 ml_add_dnet_table_script 存储过程。使用这些存储过程效率更高,特别是在使用大量 .NET 方法处理同步事件时。

有关详细信息,请参见 ml_add_dnet_connection_scriptml_add_dnet_table_script

下一节将使用 Interactive SQL 连接到 CustDB 数据库并执行 ml_add_dnet_table_script,从而将 MLExample.CustdbScripts.DownloadCursor 指派给 download_cursor 事件。

为 ULCustomer download_cursor 事件指定 MLExample.CustdbScripts.DownloadCursor

  1. 使用 Interactive SQL 连接到示例数据库。

  2. 在 Interactive SQL 中执行以下命令:

    call ml_add_dnet_table_script(
    'custdb 9.0',
    'ULCustomer',
    'download_cursor',
    'MLExample.CustdbScripts.DownloadCursor');
    commit;

    以下是对各个参数的说明:

    参数 说明
    custdb 9.0 脚本版本。
    ULCustomer 同步表。
    download_cursor 事件名称。
    MLExample,CustdbScripts.DownloadCursor 完全限定的 .NET 方法。
  3. 退出 Interactive SQL。

在这一课,您为处理 ULCustomer 表级别事件指定了 .NET 方法。下一课将确保 MobiLink 服务器装载适当的类文件和 MobiLink API。

进一步阅读 

有关添加和删除同步脚本的详细信息,请参见在统一数据库中添加和删除脚本

有关本课使用的脚本的详细信息,请参见 ml_add_dnet_connection_scriptml_add_dnet_table_script


Collection Contents 上一页 下一页 PDF