SendQrCode.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using Edge.Core.Parser.BinaryParser.MessageEntity;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace HengshanPaymentTerminal.MessageEntity.Outgoing
  8. {
  9. /// <summary>
  10. /// 发送二维码至油机数据对象
  11. /// </summary>
  12. public class SendQrCode : CommonMessage
  13. {
  14. /// <summary>
  15. /// 油枪号
  16. /// </summary>
  17. public int NozzleNum { get; set; }
  18. /// <summary>
  19. /// 小程序链接
  20. /// </summary>
  21. private string SmallProgram { get; set; }
  22. public SendQrCode(int nozzle,string samllProgram,byte frame)
  23. {
  24. this.Handle = (byte)Command.SEND_QR_CODE;
  25. this.NozzleNum = nozzle;
  26. this.SmallProgram = samllProgram;
  27. this.FrameNum = frame;
  28. }
  29. public override byte[] ToCommonByteArray()
  30. {
  31. List<Byte> list = new List<Byte>();
  32. byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum };
  33. string qrCode = this.SmallProgram + "/" + this.NozzleNum;
  34. byte[] qrCodeBytes = Encoding.ASCII.GetBytes(qrCode);
  35. list.AddRange(commandAndNozzle);
  36. list.Add((byte)qrCodeBytes.Length);
  37. list.AddRange(qrCodeBytes);
  38. byte[] sendBytes = content2data(list.ToArray());
  39. return sendBytes;
  40. }
  41. public override CommonMessage ToObject(byte[] datas)
  42. {
  43. return this;
  44. }
  45. }
  46. }