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 :
- Fetch the data from RETAILSUSPENDEDTRANSACTIONS Table. The TRANSDATA field is the field which contains the binary data.
- Use the below code to deserialize the data from binary format to object.
Int32 bufferSize = 0;
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);
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.