SendQrCode.cs 1.8 KB

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