Tuesday 13 August 2013

DESERIALIZING THE POS TRANSACTION BINARY DATA




Deserializing the Binary Data into PosTransaction



I have came across people who have to make the use of the suspended transactions. So, here I am writing about the deserializing the suspended transactions.

There are certain steps which needs to be followed :


  1. Fetch the data from RETAILSUSPENDEDTRANSACTIONS Table. The TRANSDATA field is the field which contains the binary data.
  2. Use the below code to deserialize the data from binary format to object.
                 MemoryStream memStream;

                 BinaryWriter binaryWriter;
                 BinaryFormatter binaryFormatter;
                 Int32 bufferSize = 0;
                 byte[] outbyte;
                 long retVal;
                 long startIndex = 0;
                 PosTransaction transaction = null;

                bufferSize = Convert.ToInt32(reader.GetValue(0));
                outbyte = new byte[bufferSize];
                memStream = new MemoryStream();
                binaryWriter = new BinaryWriter(memStream);
                binaryFormatter = new BinaryFormatter();

                retVal = reader.GetBytes(1, startIndex, outbyte, 0, bufferSize);

                binaryWriter.Write(outbyte);

                memStream.Position = 0;
                transaction = (PosTransaction)binaryFormatter.Deserialize(memStream);

This will fetch the data in the "transaction" object and then you can make the use of this object to show the data in your customized form.

For sale line items use can use "((RetailTransaction)transaction).SaleItems"

Similarly, there are lines for Tenders, Discounts etc. in transaction object. 

1 comment:

Unknown said...

i want to inquire about Microsoft Dynamics AX Training can you please guide me.

Wikipedia

Search results

Contact Form

Name

Email *

Message *