共用方式為


如何撰寫交易整合器應用程式的程序代碼

部署交易整合器 (TI) 元件之後,您可以針對該元件撰寫程式代碼。 完成撰寫程式代碼之後,您可以測試程式代碼,並視需要修改 TI 元件的介面。

撰寫 TI 應用程式

  1. 建立 TI 對象的實例。

    TI 物件包含您將撰寫程式並與之互動的介面。 當您的應用程式在 TI 物件上呼叫介面時,TI 管理員會將資訊傳遞給遠端伺服器。

  2. 設定您的資料變數。

    與許多使用主機整合伺服器的應用程式一樣,請務必使用可成功轉譯至遠端伺服器的數據類型。 如需數據類型及其在系統之間對應方式的詳細資訊,請參閱數據類型和主機和自動化數據

  3. 對 TI 物件中的任何相關參數進行呼叫。

    執行應用程式所需的任何動作,這可能包括呼叫 TI 物件所描述的介面。 您可能也有應用程式所需的其他工作。 如需詳細資訊,請參閱 程序設計 Windows-Initiated 處理

  4. 撰寫應用程式時,請務必考慮環境的相關安全性詳細數據。

範例

下列範例剪自 SDK 範例目錄中歧視聯集教學課程的主要程式碼。 如需完整的程式代碼範例,請參閱 <安裝目錄>\Microsoft 主機整合伺服器\SDK\Samples\ApplicationIntegration\WindowsInitiated\DiscriminatedUnion。

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  
    }  
}  

選擇性批注。

另請參閱

如何建立新的主機整合伺服器設計工具專案