為 LU0 使用交易整合器傳送訊息

初始化並聯機到邏輯單元 (LU) 之後,您可以透過 LU0 連線傳送資訊。 會話整合器公開用來傳送 LU0 資訊的主要工具是 SessionLU0Data 物件和 SessionLU0.Send 方法。

除了傳送資訊之外,您可能也會想要接收資訊。

使用 TRANSACTION Integrator for LU0 傳送訊息

  1. 將資料收集成 LU 所使用的格式。

  2. 將資料放入 SessionLU0Data 物件中。

  3. 使用 SessionLU0.Send 傳送資料。

範例

下列程式碼範例示範如何使用會話整合器,透過 LU0 會話傳送資料。

private void InsertUserId_Click(object sender, EventArgs e)  
 {  
  try  
   {  
    // Disable every button and text box.  
     DisableEverything();  
     // Enter UserName (SNA200 is what is in the script).  
     // AID = 7D - Enter.  
     byte AID = 0x7D;  
     // Cursor address.  
     byte ca1 = 0x5B;  
     byte ca2 = 0x6B;  
     // SBA  
     byte SBA = 0x11;  
     byte fa1 = 0x5B;  
     byte fa2 = 0xE5;  
     byte[] sna200 = HostStringConverter.ConvertUnicodeToEbcdic("SNA200");  
     byte sixD = 0x6D;  
     byte [] message = new byte [8 + sna200.Length ];  
     message[0] = AID;  
     message[1] = ca1;  
     message[2] = ca2;  
     message[3] = SBA;  
     message[4] = fa1;  
     message[5] = fa2;  
     Array.Copy(sna200, 0, message, 6, sna200.Length);  
     message[6 + sna200.Length] = sixD;  
     message[7 + sna200.Length] = sixD;  
     // Send the data.  
     SessionLU0Data data = new SessionLU0Data();     data.Data = message;  
     // Trace out the data to send.  
     TraceData(true, message, 0);  
     _session.Send(data);  
     // Allow entering director.  
     EnableEnterDirector();  
     }  
    catch (Exception ex)  
    {  
     MessageBox.Show(ex.Message);  
    }  
   }  

此程式碼範例大部分是關於格式化資料,讓 LU 可以正確解譯資訊;的呼叫 SessionLU0.Send 相對簡單。 如需程式碼範例的詳細資訊,請參閱 LU0 程式碼範例的會話整合器

另請參閱

為 LU0 使用交易整合器接收訊息
LU0 的工作階段整合器
LU0 的工作階段整合器程式碼範例
IcomLU0 介面