LU2 セッションを作成した後、3270 コンソールから Microsoft.HostIntegration.SNA.Session.ScreenData
および Microsoft.HostIntegration.SNA.Session.SessionDisplay
オブジェクトを介して情報とメッセージを取得できます。
LU2 接続経由で情報を受信する
必要に応じて、
Microsoft.HostIntegration.SNA.Session.ScreenData
を使用して画面全体を画面ダンプとして取得します。ほとんどの場合、画面上のすべての情報を取得する必要はありません。 代わりに、ほとんどのアプリケーションで
Microsoft.HostIntegration.SNA.Session.SessionDisplay
オブジェクトを使用できます。Microsoft.HostIntegration.SNA.Session.ScreenCursor
の呼び出しでカーソルの位置を取得します。必要に応じて、
Microsoft.HostIntegration.SNA.Session.SessionDisplay.GetField%2A
メソッドまたはMicrosoft.HostIntegration.SNA.Session.SessionDisplay.GetFields%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);
}
}