如何编码事务集成器应用程序

(TI) 组件部署事务集成器后,可以针对该组件编写代码。 编写完代码后,可以测试代码,并在必要时修改 TI 组件的接口。

编写 TI 应用程序代码

  1. 创建 TI 对象的实例。

    TI 对象包含要对其编写代码的接口。 当应用程序调用 TI 对象上的接口时,TI 管理器会将信息传递到远程服务器。

  2. 设置数据变量。

    与使用 Host Integration Server 的许多应用程序一样,请务必使用能够成功转换到远程服务器或从远程服务器转换的数据类型。 有关数据类型及其如何在系统之间映射的详细信息,请参阅 数据类型主机和自动化数据

  3. 对 TI 对象中的任何相关参数进行调用。

    执行应用程序所需的任何操作,其中可能包括调用 TI 对象描述的接口。 应用程序可能还需要执行其他任务。 有关详细信息,请参阅 编程 Windows-Initiated 处理

  4. 编写应用程序时,请务必考虑环境的相关安全详细信息。

示例

以下示例是从 SDK 示例目录中的可区分联合教程main程序代码剪切的。 有关完整的代码示例,请参阅 <Installation Directory>\Microsoft Host Integration Server\SDK\Samples\ApplicationIntegration\WindowsInitiated\DiscrimiatedUnion。

using System;  
using System.Collections.Generic;  
using System.Text;  
using Banking;  
  
namespace DiscriminatedUnions  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Console.WriteLine("Processing Output only Account Information");  
            AccountInformationOutOnly();  
  
            Console.WriteLine("\n\nProcessing Input and Output Account Information");  
            AccountInformationInOut();  
  
            Console.WriteLine("\nPress any key to continue...");  
            Console.Read();  
  
        }  
  
        #region Output Only Discriminated Union Processing  
        static void AccountInformationOutOnly()  
        {  
            // Define an instance of the TI Banking object  
            Banking.Accounts MyBankObj = new Banking.Accounts();  
  
            // Call the Get Account Information method on the TI Object  
            // passing it the array that contains the checking and saving   
            // account information   
            string AccountNumber = "BNK4566112";  
            string AccountType = " ";  
            Object AcctInfoUnionObj = null;  
            string FillerNotUsedByThisSample = " ";  
  
            MyBankObj.GetAInfoOutOnly("111223333", AccountNumber, out AccountType, out AcctInfoUnionObj, out FillerNotUsedByThisSample);  
            switch (AcctInfoUnionObj.GetType().ToString())  
            {  
                // check the type of the union that was returned to determine   
                // whether the array element  
                // is a checking or saving account so that the correct  
                // structure of the union can be used  
                case "Banking.CHECKING":  
                        Banking.CHECKING ChkInfo = (Banking.CHECKING)AcctInfoUnionObj;  
  
                        Console.WriteLine("Checking account number: {0}", AccountNumber);  
                        Console.WriteLine("\tOverdraft charge:\t {0,10:C2}", ChkInfo.CHK_OD_CHG);  
                        Console.WriteLine("\tOverdraft limit:\t {0,10:C2}", ChkInfo.CHK_OD_LIMIT);  
                        Console.WriteLine("\tLinked account:\t {0,18}", ChkInfo.CHK_OD_LINK_ACCT);  
                        Console.WriteLine("\tLast Statement:\t {0,18}", ChkInfo.CHK_LAST_STMT);  
                        Console.WriteLine("\tDetail Items:\t {0,18:F0}", ChkInfo.CHK_DETAIL_ITEMS);  
                        Console.WriteLine("\tBalance:\t {0,18:C2}\n", ChkInfo.CHK_BAL);  
                    break;  
  
                case "Banking.SAVINGS":  
                        Banking.SAVINGS SavInfo = (Banking.SAVINGS)AcctInfoUnionObj;  
  
                        Console.WriteLine("Savings account number: {0}", AccountNumber);  
                        Console.WriteLine("\tInterest rate:\t {0,20:P}", SavInfo.SAV_INT_RATE / 100);  
                        Console.WriteLine("\tService charge:\t {0,18:C2}", SavInfo.SAV_SVC_CHRG);  
                        Console.WriteLine("\tLast Statement:\t {0,18}", SavInfo.SAV_LAST_STMT);  
                        Console.WriteLine("\tDetail Items:\t {0,18:F0}", SavInfo.SAV_DETAIL_ITEMS);  
                        Console.WriteLine("\tBalance:\t {0,18:C2}\n", SavInfo.SAV_BAL);  
                    break;  
  
                default:  
                    break;  
            }  
        }  
        #endregion Output Only Discriminated Union Processing  
    }  
}  

可选注释。

另请参阅

如何创建新的主机集成服务器Designer项目