SendUnAuthorization.cs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using Org.BouncyCastle.Asn1.Ocsp;
  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 SendUnAuthorization:CommonMessage
  13. {
  14. /// <summary>
  15. /// 请求授权的枪号
  16. /// </summary>
  17. public int NozzleNum { get; set; }
  18. /// <summary>
  19. /// 请求授权时间
  20. /// </summary>
  21. private DateTime AuthorizationTime { get; set; }
  22. /// <summary>
  23. /// 授权后分配的流水号
  24. /// </summary>
  25. private int TTC { get; set; }
  26. public SendUnAuthorization(int nozzleNum, DateTime authorizationTime, int tTC,byte frame)
  27. {
  28. this.Handle = (byte)Command.CANCEL_ACCREDIT;
  29. NozzleNum = nozzleNum;
  30. AuthorizationTime = authorizationTime;
  31. TTC = tTC;
  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. byte[] authorizationTimeBytes = ConvertDateTimeToByteArray(this.AuthorizationTime);
  39. byte[] ttcBytes = NumberToByteArrayWithPadding(this.TTC, 4);
  40. list.AddRange(commandAndNozzle);
  41. list.AddRange(authorizationTimeBytes);
  42. list.AddRange(ttcBytes);
  43. byte[] sendBytes = content2data(list.ToArray());
  44. return sendBytes;
  45. }
  46. public override CommonMessage ToObject(byte[] datas)
  47. {
  48. return this;
  49. }
  50. }
  51. }