using System; using System.Collections.Generic; using Wayne.Lib; using Wayne.Lib.StateEngine; using Wayne.Lib.StateEngine.Generic; namespace SinochemInternetPlusApp.States.Shared { class AuthorizePump : TimeoutState { protected override void Enter(StateEntry stateEntry, ref Transition transition) { base.Enter(stateEntry, ref transition); Main.AuthorizePumpAsync(0); // auth unlimited amount } protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition) { if (stateEngineEvent.Type is EventType) { switch ((EventType)stateEngineEvent.Type) { case EventType.PumpAuthOk: if (Main.CurrentTrxMode == TransactionMode.CarPlateMode || Main.CurrentTrxMode == TransactionMode.ICCardMode) { var genericEvent = stateEngineEvent as GenericEvent>; if (genericEvent != null && Main.CurrentEpsTrx != null) { Main.CurrentEpsTrx.Model.auth_time = genericEvent.EventArgs.Arg; Main.CurrentEpsTrx.Model.trx_status = EpsTrxStatus.Fueling; Main.CurrentEpsTrx.SaveToDb(); } } transition = new Transition(this, TransitionType.PumpAuthOk); stateEngineEvent.Handled = true; break; case EventType.PumpAuthFailed: transition = new Transition(this, TransitionType.PumpAuthFailed); stateEngineEvent.Handled = true; break; } } } protected override void Timeout(ref Transition transition) { transition = new Transition(this, TransitionType.Timeout); } protected override int TimeoutInterval => TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Shared_AuthorizePump, 10); } }