LU2 のセッション インテグレーターを使用してメッセージを受信する
LU2 セッションを作成した後、3270 コンソールから および オブジェクトを介して情報とMicrosoft.HostIntegration.SNA.Session.SessionDisplay
メッセージをMicrosoft.HostIntegration.SNA.Session.ScreenData
取得できます。
LU2 接続経由で情報を受信する
必要に応じて、 を使用して
Microsoft.HostIntegration.SNA.Session.ScreenData
画面全体を画面ダンプとして取得します。ほとんどの状況では、画面上のすべての情報を取得する必要はありません。 代わりに、ほとんどのアプリケーションで オブジェクトを
Microsoft.HostIntegration.SNA.Session.SessionDisplay
使用できます。への呼び出しでカーソルの位置を取得します
Microsoft.HostIntegration.SNA.Session.ScreenCursor
。必要に応じて、 メソッドまたは
Microsoft.HostIntegration.SNA.Session.SessionDisplay.GetFields%2A
メソッドの 1 つ、または プロパティを呼び出して、画面上のMicrosoft.HostIntegration.SNA.Session.SessionDisplay.GetField%2A
異なるフィールドに含まれる場所と情報をMicrosoft.HostIntegration.SNA.Session.SessionDisplay.CurrentField%2A
取得できます。Microsoft.HostIntegration.SNA.Session.SessionDisplay.GetField%2A
とMicrosoft.HostIntegration.SNA.Session.SessionDisplay.GetFields%2A
の両方に複数のオーバーロードが含まれており、指定した情報に応じて画面からフィールド情報を取得できます。 これに対し、Microsoft.HostIntegration.SNA.Session.SessionDisplay.CurrentField%2A
は、カーソルが現在存在するフィールドのみを表します。最後に、さまざまな
SessionDisplay.Wait
メソッドの呼び出しでフィールド更新情報を受け取ることができます。
例
次のコードは、Host Integration Server SDK の 3270 アプリケーションからのコードです。 このサンプルでは、 を使用 SessionDisplay.CurrentField.Data
して画面データにアクセスします。
private void PerformTX_Click(object sender, EventArgs e)
{
try
{
// Disable every button and text box.
DisableEverything();
m_Handler.SendKey("@E");
TraceScreen();
// Wait for screen to calm down.
m_Handler.WaitForSession(SessionDisplayWaitType.NotBusy, 5000);
TraceScreen();
// See if the Balance Field is filled out.
m_Handler.Cursor.Row = m_row;
m_Handler.Cursor.Column = m_column;
TraceScreen();
// Tab to the Account Number field.
m_Handler.SendKey("@T");
TraceScreen();
// Move to the Next Field (Empty Stuff after 123456).
m_Handler.MoveNextField();
TraceScreen();
// Move to the Next Field (Title, Account Balance).
m_Handler.MoveNextField();
TraceScreen();
// Move to the Next Field (Account Balance).
m_Handler.MoveNextField();
TraceScreen();
// Extract Data from this field.
string accountBalance = m_Handler.CurrentField.Data;
// Trim the string.
accountBalance = accountBalance.Trim();
// Only things to do now are clear screen or disconnect.
EnableClearScreen();
// If we failed (not Abended) then this field will be blank.
if (accountBalance.Length == 0)
throw new Exception("Failed to get Account Balance");
else
MessageBox.Show(accountBalance, "Account Balance");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}