private static NetworkMessage ParseMessage(Iso8583Bitmap bitmap, MessageReader mr, Iso8583MessageType messageType) { NetworkMessage message = new NetworkMessage(messageType); message.Bitmap = bitmap; // initialize the factory message.Factory = Iso8583ElementFactory.GetConfiguredFactory(mr, messageType); // read the primary bitmap DataElementId currentElement = bitmap.GetNextDataElement(); do { message.elements[currentElement] = message.Factory.CreateElement(currentElement); currentElement = bitmap.GetNextDataElement(); }while (currentElement != 0); // check for secondary bitmap if (message.Has(DataElementId.DE_001)) { byte[] secondaryBuffer = message.GetByteArray(DataElementId.DE_001); Iso8583Bitmap secondaryMap = new Iso8583Bitmap(secondaryBuffer, 64); currentElement = secondaryMap.GetNextDataElement(); while (currentElement != 0) { message.elements[currentElement] = message.Factory.CreateElement(currentElement); currentElement = secondaryMap.GetNextDataElement(); } } // return the document return(message); }
public static NetworkMessage Parse(string input, Iso8583MessageType messageType) { MessageReader mr = new MessageReader(Encoding.UTF8.GetBytes(input)); Iso8583Bitmap bitmap = new Iso8583Bitmap(StringUtils.BytesFromHex(mr.ReadString(16))); return(ParseMessage(bitmap, mr, messageType)); }
public static NetworkMessage Parse(byte[] input, Iso8583MessageType messageType) { MessageReader mr = new MessageReader(input); Iso8583Bitmap bitmap = new Iso8583Bitmap(mr.ReadBytes(8)); return(ParseMessage(bitmap, mr, messageType)); }
private void GenerateBitmaps() { Bitmap = new Iso8583Bitmap(new byte[8]); // check if we need a secondary bitmap if (messageType.Equals(Iso8583MessageType.CompleteMessage)) { secondaryBitmap = new Iso8583Bitmap(new byte[8], 64); Bitmap.SetDataElement(DataElementId.DE_001); } foreach (DataElementId elementType in elements.Keys) { if (secondaryBitmap != null && elementType.GetHashCode() > 64) { secondaryBitmap.SetDataElement(elementType); } else { Bitmap.SetDataElement(elementType); } } // put the finished secondary bitmap to the elements if (messageType.Equals(Iso8583MessageType.CompleteMessage)) { Set(DataElementId.DE_001, secondaryBitmap.ToByteArray()); } }