當您連接到交易整合器的 LU2 工作階段時,必須執行的第一個動作是建立和初始化 Microsoft.HostIntegration.SNA.Session.SessionDisplay 物件。 顧名思義, Microsoft.HostIntegration.SNA.Session.SessionDisplay 代表應用程式的 3270 顯示,而且是您用來存取 SNA 網路的主要介面。
初始化連線之後,您就可以開始在 LU2 會話中傳送和接收資訊。
程序標題
如有必要,請使用
Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay建立新的會話連線。如果您有所有相關信息,您可以直接建立
Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay。 不過,您不需要執行此步驟。 更有可能的是,您只需要在步驟 2 中傳入 LU 連接字串。使用
Microsoft.HostIntegration.SNA.Session.SessionDisplay建立新的工作階段。將連線資訊傳遞至
Microsoft.HostIntegration.SNA.Session.SessionDisplay.Connect%2A。Microsoft.HostIntegration.SNA.Session.SessionDisplay.Connect%2A包含數個多載:您可以選擇使用已建立Microsoft.HostIntegration.SNA.Session.SessionDisplay的物件、Microsoft.HostIntegration.SNA.Session.SessionDisplay物件和其他初始化資訊,或使用連接字串和初始化資訊進行連線。如果您選擇使用連接字串呼叫
Microsoft.HostIntegration.SNA.Session.SessionDisplay.Connect%2A,交易整合器會為您建立新的Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay。 您可以透過Microsoft.HostIntegration.SNA.Session.SessionDisplay.Connection%2A直接存取Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay物件。如有必要,請確認您是使用
Microsoft.HostIntegration.SNA.Session.SessionDisplay.IsConnected%2A進行連接。
範例
下列程式代碼來自 SDK 範例目錄中的 COM3270 應用程式。
private void CreateSession_Click(object sender, EventArgs e)
{
try
{
LUName.Text = LUName.Text.Trim();
if (LUName.Text.Length == 0)
{
MessageBox.Show("You must fill out the LU or Pool Name");
return;
}
m_Handler = new SessionDisplay(); m_Handler.Connect("TRANSPORT=SNA;LOGICALUNITNAME=" + LUName.Text);
m_Handler.Connection.HostCodePage = 37;
FontFamily fontFamily = new FontFamily("Courier New");
m_FixedFont = new Font(fontFamily, 10, FontStyle.Regular, GraphicsUnit.Pixel);
ScreenText.Font = m_FixedFont;
TraceScreen();
// Disable every button and text box.
DisableEverything();
m_Handler.WaitForContent("TERM NAME", 20000);
TraceScreen();
// Enable Connect to CICS and Disconnect Session.
EnableCICSElements();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}