Esempio n. 1
0
 /// <summary>
 /// add the items of the source list to the end of this list.
 /// </summary>
 /// <param name="Source"></param>
 public void Append(ResponseItemList Source)
 {
     foreach (var item in Source)
     {
         this.Add(item);
     }
 }
Esempio n. 2
0
        /// <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));
        }