Exemplo n.º 1
0
        private static PandaPacket getLabelDataResponse(string clientID, PandaPacket request)
        {
            //
            PandaPacket response = null;
            DataSet     ds       = null;

            try {
                //Extract message body
                string barcode1 = request.MessageBody.Substring(0, 32).TrimEnd();
                string barcode2 = request.MessageBody.Substring(32, 32).TrimEnd();
                string barcode3 = request.MessageBody.Substring(64, 32).TrimEnd();
                string barcode4 = request.MessageBody.Substring(96, 32).TrimEnd();
                string barcode5 = request.MessageBody.Substring(128, 32).TrimEnd();
                string barcode6 = request.MessageBody.Substring(160, 32).TrimEnd();
                float  weight   = Convert.ToInt32(request.MessageBody.Substring(192, 5)) / 100;

                //Process the label data request
                ds = CartonMgr.ProcessLabelDataRequest(barcode1, barcode2, barcode3, barcode4, barcode5, barcode6, weight);
                if (ds != null)
                {
                    //New carton
                    response = PandaPacket.Encode(clientID, RESPONSE_LABELDATA, request, 0, 1, PandaPacket.FormatLabelDataMessageBody(ds.Tables["PandATable"].Rows[0]["CartonID"].ToString(), int.Parse(ds.Tables["PandATable"].Rows[0]["StatusCode"].ToString()), ds.Tables["PandATable"].Rows[0]["LabelData"].ToString()));
                }
            }
            catch (Exception ex) {
                AppTrace.Instance().TheTrace.WriteLine(new TraceMessage("Error occurred while processing request for label data- " + ex.ToString(), AppLib.EVENTLOGNAME, LogLevel.Error, "PacketMgr"));
                if (ds != null)
                {
                    response = PandaPacket.Encode(clientID, RESPONSE_LABELDATA, request, 0, 1, PandaPacket.FormatLabelDataMessageBody(ds.Tables["PandATable"].Rows[0]["CartonID"].ToString(), int.Parse(ds.Tables["PandATable"].Rows[0]["StatusCode"].ToString()), ds.Tables["PandATable"].Rows[0]["LabelData"].ToString()));
                }
            }
            return(response);
        }