ShowTrxListReadyForPay - Copy.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Wayne.Lib.StateEngine;
  7. using Wayne.Lib.StateEngine.Generic;
  8. namespace SinochemInternetPlusApp.States.CarPlateManualMode
  9. {
  10. public class ShowTrxListReadyForPay : TimeoutState<FuelingPoint>
  11. {
  12. private int requestId;
  13. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  14. {
  15. base.Enter(stateEntry, ref transition);
  16. if (Main.CurrentEpsTrx != null)
  17. {
  18. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  19. Main.GetAllNozzlesOnThisSide(),
  20. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  21. Main.DebugLogger);
  22. DebugLog("validTrx: " + validTrx.Count());
  23. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 0);
  24. if (Main.Eps.CarPlateHandler != null)
  25. {
  26. DebugLog(text);
  27. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  28. if (!Main.ContainsRequestId(requestId))
  29. Main.AddRequestId(requestId);
  30. }
  31. }
  32. else
  33. {
  34. transition = new Transition(this, TransitionType.Done);
  35. }
  36. }
  37. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  38. {
  39. if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
  40. {
  41. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  42. if (e != null && e.EventArgs != null)
  43. {
  44. if (requestId == e.EventArgs.DispResponse.RequestId)
  45. {
  46. e.Handled = true;
  47. if (Main.ContainsRequestId(requestId))
  48. Main.RemoveRequestId(requestId);
  49. transition = new Transition(this, TransitionType.Done);
  50. }
  51. }
  52. }
  53. }
  54. protected override void Timeout(ref Transition transition)
  55. {
  56. transition = new Transition(this, TransitionType.Timeout);
  57. }
  58. protected override int TimeoutInterval =>
  59. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_ShowTrxListReadyForPay, 10);
  60. }
  61. }