12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using Wayne.Lib;
- using Wayne.Lib.StateEngine;
- using Wayne.Lib.StateEngine.Generic;
- namespace SinochemInternetPlusApp.States.Shared
- {
- class WaitForPayableTrx : TimeoutState<FuelingPoint>
- {
- protected override void Enter(StateEntry stateEntry, ref Transition transition)
- {
- base.Enter(stateEntry, ref transition);
- }
- protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
- {
- if (stateEngineEvent.Type is EventType)
- {
- switch ((EventType)stateEngineEvent.Type)
- {
- case EventType.FuelingDone:
- var genericEvent = stateEngineEvent as GenericEvent<FuelingDoneEventArgs>;
- if (genericEvent != null && genericEvent.EventArgs != null &&
- IsFdEventForCurrentFueling(genericEvent.EventArgs)) // check if it is for the current fueling
- {
- var liushuino = genericEvent.EventArgs.FuelingSqNo;
- var amount = genericEvent.EventArgs.Amount;
- var quantity = genericEvent.EventArgs.Quantity;
- if (Main.CurrentTrxMode == TransactionMode.CarPlateMode || Main.CurrentTrxMode == TransactionMode.ICCardMode)
- {
- Main.CurrentEpsTrx.Model.liushuino = Convert.ToString(liushuino);
- Main.CurrentEpsTrx.Model.amount = Convert.ToDouble(amount);
- Main.CurrentEpsTrx.Model.qty = Convert.ToDouble(quantity);
- Main.CurrentEpsTrx.Model.trx_status = EpsTrxStatus.FuelingDone;
- Main.CurrentEpsTrx.SaveToDb();
- }
- else if (Main.CurrentTrxMode == TransactionMode.BasicMode)
- {
- MultiFusionsSupport.CopyXiaofei2ToTargetFusion(Main.CurrentNozzleId, Convert.ToString(liushuino), Main.DebugLogger);
- }
- transition = new Transition(this, TransitionType.FuelingDone);
- stateEngineEvent.Handled = true;
- }
- else
- {
- DebugLog("Not matached AuthorizationId in FuelingDone event!!! Just ignore it and keep waiting.");
- }
- break;
- }
- }
- }
- private bool IsFdEventForCurrentFueling(FuelingDoneEventArgs fdEventArgs)
- {
- return fdEventArgs.AuthId == Main.AuthorizationId;
- }
- protected override void Timeout(ref Transition transition)
- {
- // two situations here:
- // 1) no fueling occured -- Zero filling
- // 2) fueling has occured, but eps did not receive the FuelingDone event from fcc in a given period
- if (Main.CurrentTrxMode == TransactionMode.CarPlateMode || Main.CurrentTrxMode == TransactionMode.ICCardMode)
- {
- Main.CurrentEpsTrx.Model.trx_status = EpsTrxStatus.PaymentFailed;
- Main.CurrentEpsTrx.Model.amount = 0.00;
- Main.CurrentEpsTrx.Model.qty = 0.00;
- Main.CurrentEpsTrx.Model.real_pay_amount = 0.00;
- Main.CurrentEpsTrx.SaveToDb();
- }
- transition = new Transition(this, TransitionType.Timeout);
- }
- protected override int TimeoutInterval =>
- TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Shared_WaitForPayableTrx, 5);
- }
- }
|