SendQrCode.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. /// 云端油枪id
  16. /// </summary>
  17. public long CloundNozzleId { get; set; }
  18. /// <summary>
  19. /// 油枪号
  20. /// </summary>
  21. public int NozzleNum { get; set; }
  22. /// <summary>
  23. /// 小程序链接
  24. /// </summary>
  25. private string SmallProgram { get; set; }
  26. public SendQrCode(long cloundNozzleId,int nozzle,string samllProgram,byte frame)
  27. {
  28. this.Handle = (byte)Command.SEND_QR_CODE;
  29. this.NozzleNum = nozzle;
  30. this.CloundNozzleId = cloundNozzleId;
  31. this.SmallProgram = samllProgram;
  32. this.FrameNum = frame;
  33. }
  34. public override byte[] ToCommonByteArray()
  35. {
  36. List<Byte> list = new List<Byte>();
  37. byte[] commandAndNozzle = { this.Handle, (byte)this.NozzleNum };
  38. string qrCode = this.SmallProgram + "?id=" + this.CloundNozzleId;
  39. byte[] qrCodeBytes = Encoding.ASCII.GetBytes(qrCode);
  40. list.AddRange(commandAndNozzle);
  41. list.Add((byte)qrCodeBytes.Length);
  42. list.AddRange(qrCodeBytes);
  43. byte[] sendBytes = content2data(list.ToArray());
  44. return sendBytes;
  45. }
  46. public override CommonMessage ToObject(byte[] datas)
  47. {
  48. return this;
  49. }
  50. }
  51. }