共用方式為


初始化 LU2 的工作階段整合器

當您連接到交易整合器的 LU2 工作階段時,必須執行的第一個動作是建立和初始化 Microsoft.HostIntegration.SNA.Session.SessionDisplay 物件。 顧名思義, Microsoft.HostIntegration.SNA.Session.SessionDisplay 代表應用程式的 3270 顯示,而且是您用來存取 SNA 網路的主要介面。

初始化連線之後,您就可以開始在 LU2 會話中傳送和接收資訊。

程序標題

  1. 如有必要,請使用 Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay建立新的會話連線。

    如果您有所有相關信息,您可以直接建立 Microsoft.HostIntegration.SNA.Session.SessionConnectionDisplay 。 不過,您不需要執行此步驟。 更有可能的是,您只需要在步驟 2 中傳入 LU 連接字串。

  2. 使用 Microsoft.HostIntegration.SNA.Session.SessionDisplay建立新的工作階段。

  3. 將連線資訊傳遞至 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 物件。

  4. 如有必要,請確認您是使用 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);  
            }  
        }  

另請參閱

LU2 程式碼的會話整合器範例
LU2 的會話整合器