/// <summary> /// parse the 5250 data stream that is sent from the client to the server. /// </summary> /// <param name="LogFile"></param> /// <param name="ToServerStream"></param> /// <returns></returns> public static Tuple <object[], string> ParseResponseStream( TelnetLogList LogList, byte[] ResponseStream) { List <object> listItems = new List <object>(); string errmsg = null; var inputArray = new NetworkStreamBackedInputByteArray(ResponseStream, ResponseStream.Length); var writeStream = new ByteArrayBuilder(); DataStreamHeader dsHeader = null; ResponseHeader responseHeader = null; // stream starts with data stream header. dsHeader = new DataStreamHeader(inputArray); listItems.Add(dsHeader); errmsg = dsHeader.Errmsg; LogList.AddItems(Direction.Write, dsHeader.ToReportLines(), true); // next is the response header. if (errmsg == null) { responseHeader = new ResponseHeader(inputArray); listItems.Add(responseHeader); errmsg = responseHeader.Errmsg; LogList.AddItems(Direction.Write, responseHeader.ToReportLines(), true); } // repeating instances of sbaOrder, textDataOrder pairs. while (true) { // check that an SBA order is starting. Leave loop when it is not. if (SetBufferAddressOrder.CheckOrder(inputArray) != null) { break; } var orderPair = new LocatedTextDataOrderPair(inputArray); if (orderPair.Errmsg != null) { break; } listItems.Add(orderPair); LogList.AddItems(Direction.Write, orderPair.ToReportLines(), true); } return(new Tuple <object[], string>(listItems.ToArray(), errmsg)); }
public IEnumerable <string> ReportResponseItems() { bool gotDataOrder = false; var lines = new List <string>(); { var titleText = "5250 Response Data Stream."; lines.Add(titleText.PadCenter(80)); } foreach (var responseItem in this) { if (responseItem is IDataStreamReport) { var report = responseItem as IDataStreamReport; lines.AddRange(report.ToColumnReport(report.ReportTitle)); } else if (responseItem is LocatedTextDataOrderPair) { if (gotDataOrder == false) { var s1 = LocatedTextDataOrderPair.ToColumnReportHeaderLine(); lines.Add(s1); gotDataOrder = true; } { var item = responseItem as LocatedTextDataOrderPair; var s1 = item.ToColumnReportLine(); lines.Add(s1); } } } return(lines); }
/// <summary> /// parse the 5250 data stream that is sent from the client to the server. /// </summary> /// <param name="LogFile"></param> /// <param name="ToServerStream"></param> /// <returns></returns> public static Tuple <ResponseItemList, string> ParseResponseStream( InputByteArray InputArray, ResponseHeader ResponseHeader = null) { var responseItemList = new ResponseItemList(); string errmsg = null; var writeStream = new ByteArrayBuilder(); DataStreamHeader dsHeader = null; ResponseHeader responseHeader = ResponseHeader; // stream starts with data stream header. if (responseHeader == null) { var rv = DataStreamHeader.Factory(InputArray); dsHeader = rv.Item1; responseItemList.Add(dsHeader); errmsg = dsHeader.Errmsg; // next is the response header. if (errmsg == null) { responseHeader = new ResponseHeader(InputArray); responseItemList.Add(responseHeader); errmsg = responseHeader.Errmsg; } } // look for 5250 query reply. if ((errmsg == null) && (responseHeader.AidKey != null) && (responseHeader.AidKey.Value == AidKey.Query5250Reply)) { var queryResp = new Query5250Response(InputArray); if (queryResp.Errmsg == null) { responseItemList.Add(queryResp); } } // repeating instances of sbaOrder, textDataOrder pairs. while (true) { var telCmd = TelnetCommand.Factory(InputArray); if (telCmd != null) { continue; } // check that an SBA order is starting. Leave loop when it is not. if (SetBufferAddressOrder.CheckOrder(InputArray) != null) { break; } var orderPair = new LocatedTextDataOrderPair(InputArray); if (orderPair.Errmsg != null) { break; } responseItemList.Add(orderPair); } return(new Tuple <ResponseItemList, string>(responseItemList, errmsg)); }