Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Dopo aver distribuito un componente Transaction Integrator (TI), è possibile scrivere codice su tale componente. Al termine della scrittura del codice, è possibile testare il codice e, se necessario, modificare l'interfaccia nel componente TI.
Per codificare un'applicazione TI
Creare un'istanza dell'oggetto TI.
L'oggetto TI contiene le interfacce in base alle quali si scriverà il codice. Quando l'applicazione chiama un'interfaccia nell'oggetto TI, TI Manager passerà le informazioni sul server remoto.
Configurare le variabili di dati.
Come per molte applicazioni che usano Host Integration Server, è importante usare un tipo di dati che può essere convertito correttamente da e verso il server remoto. Per altre informazioni sui tipi di dati e su come eseguono il mapping tra i sistemi, vedere Tipi di dati e Dati di automazione e host.
Effettuare chiamate a qualsiasi parametro pertinente nell'oggetto TI.
Eseguire tutte le azioni necessarie per l'applicazione, che probabilmente includerà la chiamata alle interfacce descritte dall'oggetto TI. È anche possibile che siano necessarie attività aggiuntive per l'applicazione. Per altre informazioni, vedere Programmazione Windows-Initiated Elaborazione.
Quando scrivi la tua applicazione, assicurati di considerare i dettagli di sicurezza pertinenti del tuo ambiente.
Esempio
L'esempio seguente viene estratto dal codice del programma principale del tutorial su Unione Discriminata nella directory dei campioni dell'SDK. Per l'esempio di codice completo, vedere <Directory> di installazione\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
}
}
Commenti facoltativi.
Vedere anche
Come creare un nuovo progetto di progettazione host integration server