Compartir a través de


Cómo codificar una aplicación integradora de transacciones

Una vez que haya implementado un componente integrador de transacciones (TI), puede escribir código en ese componente. Una vez que haya terminado de escribir el código, puede probar el código y, si es necesario, modificar la interfaz al componente de TI.

Para codificar una aplicación de TI

  1. Cree una instancia del objeto TI.

    El objeto TI contiene las interfaces en las que escribirá código. Cuando la aplicación llama a una interfaz en el objeto TI, el Administrador de TI pasará la información al servidor remoto.

  2. Configure las variables de datos.

    Al igual que con muchas aplicaciones que usan Host Integration Server, es importante usar un tipo de datos que pueda traducirse correctamente a y desde el servidor remoto. Para obtener más información sobre los tipos de datos y cómo se asignan entre sistemas, consulte Tipos de datos y Host y Datos de Automatización.

  3. Realice llamadas sobre cualquier parámetro relevante del objeto TI.

    Realice cualquier acción necesaria para tu aplicación, lo que probablemente incluirá llamar a las interfaces descritas por el objeto TI. También puede tener tareas adicionales necesarias para su aplicación. Para obtener más información, consulte Programación de Procesamiento Windows-Initiated.

  4. Al escribir la aplicación, asegúrese de tener en cuenta los detalles de seguridad pertinentes de su entorno.

Ejemplo

En el siguiente ejemplo se extrae del código fuente principal del tutorial de Unión Discriminada en el directorio de muestras del SDK. Para obtener el ejemplo de código completo, vea <Directorio de instalación>\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  
    }  
}  

Comentarios opcionales.

Véase también

Cómo crear un nuevo proyecto de Host Integration Server Designer