ShowTrxListReadyForPay.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.CarPlateMode
  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. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  17. Main.GetAllNozzlesOnThisSide(),
  18. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  19. Main.DebugLogger);
  20. DebugLog("validTrx: " + validTrx.Count());
  21. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out requestId, 0);
  22. if (Main.Eps.CarPlateHandler != null)
  23. {
  24. DebugLog(text);
  25. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  26. if (!Main.ContainsRequestId(requestId))
  27. Main.AddRequestId(requestId);
  28. }
  29. }
  30. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  31. {
  32. if (stateEngineEvent.Type.Equals(EventType.DisplayResponseReceived))
  33. {
  34. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  35. if (e != null && e.EventArgs != null)
  36. {
  37. if (requestId == e.EventArgs.DispResponse.RequestId)
  38. {
  39. e.Handled = true;
  40. if (Main.ContainsRequestId(requestId))
  41. Main.RemoveRequestId(requestId);
  42. transition = new Transition(this, TransitionType.Done);
  43. }
  44. }
  45. }
  46. }
  47. protected override void Timeout(ref Transition transition)
  48. {
  49. transition = new Transition(this, TransitionType.Timeout);
  50. }
  51. protected override int TimeoutInterval =>
  52. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.CarPlateMode_ShowTrxListReadyForPay, 10);
  53. }
  54. }