using System; using System.Collections.Generic; using Wayne.Lib; using Wayne.Lib.StateEngine; using Wayne.Lib.StateEngine.Generic; namespace SinochemInternetPlusApp.States.Shared { class NotifyPOS : TimeoutState { protected override void Enter(StateEntry stateEntry, ref Transition transition) { base.Enter(stateEntry, ref transition); Main.NotifyPosAync(); } protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition) { if (stateEngineEvent.Type is EventType) { switch ((EventType)stateEngineEvent.Type) { case EventType.PosNotifyOk: Main.CurrentEpsTrx.UpdateNotifyPosFlagToDb(NotifyPosFlag.NotifyOk); transition = new Transition(this, TransitionType.PosNotifyOk); stateEngineEvent.Handled = true; break; case EventType.PosNotifyFailed: transition = HandleFailedNotify(); stateEngineEvent.Handled = true; break; } } } private Transition HandleFailedNotify() { DebugLog(string.Format("Notify pos failed!!! jihao: {0}, fuelSeq: {1}", Main.CurrentEpsTrx.Model.jihao, Main.CurrentEpsTrx.Model.liushuino)); Main.CurrentEpsTrx.UpdateNotifyPosFlagToDb(NotifyPosFlag.NotifyFailed); Transition transition = new Transition(this, TransitionType.PosNotifyFailed); return transition; } protected override void Timeout(ref Transition transition) { transition = HandleFailedNotify(); } protected override int TimeoutInterval => TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Shared_NotifyPOS, 10); } }