连接到事务集成器的 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);
}
}