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); }
private static PandaPacket getVerifyLabelResponse(string clientID, PandaPacket request) { //Verify the requested carton PandaPacket response = null; try { //Find the carton string cartonID = request.MessageBody.Substring(0, PandaPacket.CartonIDLength).TrimEnd(); string verifyCode = request.MessageBody.Substring(PandaPacket.CartonIDLength, 1).TrimEnd(); string verifyFlag = CartonMgr.ProcessVerifyLabelRequest(cartonID, verifyCode); response = PandaPacket.Encode(clientID, RESPONSE_VERIFYLABEL, request, 0, 1, verifyFlag); } catch (Exception ex) { AppTrace.Instance().TheTrace.WriteLine(new TraceMessage("An error occurred while processing request to verify label." + ex.ToString(), AppLib.EVENTLOGNAME, LogLevel.Error, "PacketMgr")); response = PandaPacket.Encode(clientID, RESPONSE_VERIFYLABEL, request, 0, 1, "N"); } return(response); }