using log4net; using Repository.Station; using Service.Execute.Enum; namespace Service.Execute.Step; public class CancelState : IState { private SwapOrderRepository SwapOrderRepository { get; set; } private SwapAmtOrderRepository SwapAmtOrderRepository { get; set; } private static readonly ILog _log = LogManager.GetLogger(typeof(CancelState)); public StateResult Handle(SwappingStateMachine machine) { _log.Info($"'goto cancel"); SwappingStateMachine.CancelFlag = false; if (machine.SwapOrderBatteryInfo.swapAmtOrder != null) { machine.SwapOrderBatteryInfo.swapAmtOrder.Status = (byte)InfoEnum.AmtOrderStatus.SwapFail; SwapAmtOrderRepository.Update(machine.SwapOrderBatteryInfo.swapAmtOrder); } if (machine.SwapOrder != null) { machine.SwapOrder.SwapResult = (byte)InfoEnum.SwapOrderResult.Fail; SwapOrderRepository.Update(machine.SwapOrder); } machine.Reset(); return new StateResult() { SwappingState = SwappingState.StationReady }; } }