123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878 |
- using Edge.Core.Processor;using Edge.Core.IndustryStandardInterface.Pump;
- using NozzleLockConfiguration;
- using SinochemCarplateService.Models;
- using SinochemCloudClient.Models;
- using SinoChemFC2PosProxy;
- using SinochemInternetPlusApp.EpsTrxCleanup;
- using SinochemPosClient.Models;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml.Serialization;
- using Wayne.FDCPOSLibrary;
- using Wayne.Lib;
- using Wayne.Lib.Log;
- using WayneChina_IcCardReader_SinoChem.MessageEntity;
- using WayneChina_IcCardReader_SinoChem.MessageEntity.Incoming;
- namespace SinochemInternetPlusApp
- {
- public class Eps : IDisposable
- {
- static NLog.Logger logger = NLog.LogManager.LoadConfiguration("nlog.config").GetLogger("Application");
- private IEnumerable<GenericDeviceProcessor<System.String, Edge.Core.Parser.HttpMessageParser.BaseHttpMessage<System.String>>> carPlateProcessors;
- private IEnumerable<GenericDeviceProcessor<System.Byte[], WayneChina_IcCardReader_SinoChem.MessageEntity.IcCardReaderMessageBase>> icCardReaderProcessors;
- private List<FuelingPoint> fuelingPoints;
- private EpsTrxCleanupManager epsTrxCleanupManager;
- //protected DebugLogger debugLogger;
- private int requestId;
- private object requestSyncObj = new object();
- #region devices and services
- private IEnumerable<IFdcPumpController> pumpControllers;
- private Sinochem_CarPlateRecognizeCamera_HuLianWangJia.Handler carPlateServer;
- private IEnumerable<WayneChina_IcCardReader_SinoChem.Handler> cardReaderHandlers;
- //private FdcCommunicator fccClient;
- private CloudManager cloudManager;
- private PosManager posManger;
- #endregion
- #region constants
- public int InvalidNozzleId { get { return 9999; } }
- #endregion
- #region Constructor
- public Eps(IEnumerable<int> fpIds, Dictionary<int, IEnumerable<int>> fpNozzlesDict,
- IEnumerable<IFdcPumpController> pumpControllers,
- IEnumerable<GenericDeviceProcessor<System.String, Edge.Core.Parser.HttpMessageParser.BaseHttpMessage<System.String>>> carPlateProcessors,
- IEnumerable<GenericDeviceProcessor<System.Byte[], WayneChina_IcCardReader_SinoChem.MessageEntity.IcCardReaderMessageBase>> icCardReaderProcessors)
- {
- var identifiableEntity = new IdentifiableEntity(0, "EpsMain", "", null);
- fuelingPoints = new List<FuelingPoint>(fpIds.Count());
- foreach (int nozzleId in fpIds)
- {
- fuelingPoints.Add(new FuelingPoint(nozzleId, fpNozzlesDict[nozzleId], this));
- }
- epsTrxCleanupManager = new EpsTrxCleanupManager(this);
- cloudManager = new CloudManager();
- posManger = new PosManager();
- NozzleLockAccessor.FillinNozzles(fpNozzlesDict);
- this.pumpControllers = pumpControllers;
- this.carPlateProcessors = carPlateProcessors;
- this.icCardReaderProcessors = icCardReaderProcessors;
- logger.Info("eps has been constructed");
- logger.Info(string.Format($"{this.pumpControllers.Count()} processors were loaded."));
- foreach (var proc in this.pumpControllers)
- {
- logger.Debug(proc.GetType().ToString());
- }
- }
- internal TrxNotificationResponse NotifySuccessfulTrxToPos(EpsTransactionModel model, DebugLogger debugLogger)
- {
- return posManger.NotifyPosSuccessfulTrx(model, debugLogger);
- }
- internal PaymentResponse SendPaymentToCloud(EpsTransactionModel currentEpsTrxModel, DebugLogger debugLogger)
- {
- return cloudManager.Payment(currentEpsTrxModel, debugLogger);
- }
- internal BalanceInquiryResponse SendBalanceInquiryToCloud(string cardNo, string encryptedPin, string tid, int nozzleId, DebugLogger debugLogger)
- {
- return cloudManager.BalanceInquiry(cardNo, encryptedPin, tid, nozzleId, debugLogger);
- }
- #endregion
- public void Run()
- {
- SetupICCardReaderHandler();
- if (fuelingPoints != null)
- {
- foreach (var fp in fuelingPoints)
- {
- fp.Start();
- }
- }
- epsTrxCleanupManager.Start();
- SetupFccClient();
- SetupCarplateServer();
- }
- private void SetupFccClient()
- {
- //SinoChemFC2PosProxy.EntryPoint.Main(null);
- //fccClient = SinoChemFC2PosProxy.EntryPoint.FdcComm;
- foreach (var pumpController in this.pumpControllers)
- {
- pumpController.OnStateChange += (s, a) =>
- {
- var pump = s as IFdcPumpController;
- if (a.NewPumpState == LogicalDeviceState.FDC_CALLING)
- {
- int sitewiseNozzleId =
- SiteConfigUtility.Default.GetSiteLevelNozzleIdByLogicalNozzleId(pump.PumpId, a.StateChangedNozzles.FirstOrDefault()?.LogicalId ?? 0);
- this.FccClient_NozzleLifted(sitewiseNozzleId, pump);
- }
- else if (a.NewPumpState == LogicalDeviceState.FDC_READY)
- {
- int sitewiseNozzleId =
- SiteConfigUtility.Default.GetSiteLevelNozzleIdByLogicalNozzleId(pump.PumpId, a.StateChangedNozzles.FirstOrDefault()?.LogicalId ?? 0);
- this.FccClient_NozzleReplaced(sitewiseNozzleId);
- }
- else if (a.NewPumpState == LogicalDeviceState.FDC_AUTHORISED)
- {
- int sitewiseNozzleId =
- SiteConfigUtility.Default.GetSiteLevelNozzleIdByLogicalNozzleId(pump.PumpId, a.StateChangedNozzles.FirstOrDefault()?.LogicalId ?? 0);
- this.FccClient_AuthOk(sitewiseNozzleId, 1999);
- }
- };
- }
- foreach (var pumpController in this.pumpControllers)
- {
- pumpController.OnCurrentFuellingStatusChange += (s, a) =>
- {
- var pump = s as IFdcPumpController;
- if (a.Transaction.Finished)
- {
- int sitewiseNozzleId =
- SiteConfigUtility.Default.GetSiteLevelNozzleIdByLogicalNozzleId(pump.PumpId, a.Transaction.Nozzle.LogicalId);
- this.FccClient_FuelingDone(sitewiseNozzleId, a.Transaction.SequenceNumberGeneratedOnPhysicalPump, a.Transaction.Amount, a.Transaction.Volumn, 1999);
- }
- };
- }
- //if (fccClient != null)
- //{
- // //fccClient.NozzleLifted += FccClient_NozzleLifted;
- // //fccClient.NozzleReplaced += FccClient_NozzleReplaced;
- // fccClient.AuthOk += FccClient_AuthOk;
- // fccClient.AuthFailed += FccClient_AuthFailed;
- // fccClient.FuelingDone += FccClient_FuelingDone;
- //}
- //else
- //{
- // Console.WriteLine("FdcClient not available!!");
- //}
- }
- // find car plate handler and listen to the new car plate event
- private void SetupCarplateServer()
- {
- carPlateServer = carPlateProcessors.Select(proc => (Sinochem_CarPlateRecognizeCamera_HuLianWangJia.Handler)proc.Context.Handler)
- .FirstOrDefault();
- if (carPlateServer != null)
- {
- carPlateServer.NewCarPlateScanned += CarPlateServer_NewCarPlateScanned;
- carPlateServer.OnMessageReceivedViaFdc += (msg) =>
- {
- logger.Debug($"fdc message:\n {msg}");
- if (msg.Length > 10 && msg.StartsWith("<Tran"))
- {
- var serializer = new XmlSerializer(typeof(TransactionOperation));
- using (var reader = new StringReader(msg))
- {
- var trxOpRequest = (TransactionOperation)serializer.Deserialize(reader);
- if (trxOpRequest != null)
- {
- foreach (var fp in fuelingPoints)
- {
- fp.SignalTrxOpRequest(trxOpRequest);
- }
- }
- }
- }
- else
- {
- var serializer = new XmlSerializer(typeof(DisplayResponse));
- using (var reader = new StringReader(msg))
- {
- var displayResp = (DisplayResponse)serializer.Deserialize(reader);
- logger.Debug($"Display Response, id = {displayResp.RequestId}");
- if (displayResp != null && displayResp.OverallResult == ResultType.Success)
- {
- foreach (var fp in fuelingPoints)
- {
- if (fp.ContainsRequestId(displayResp.RequestId))
- fp.SignalDisplayResponseReceived(displayResp);
- }
- }
- }
- }
- return new Tuple<string, OverallResult>("DisplayResponse ACK", OverallResult.Success);
- };
- }
- else
- {
- Console.WriteLine("carPlateServer not found!!!");
- logger.Info("carPlateServer not found!!!");
- }
- }
- private void CarPlateServer_NewCarPlateScanned(CarPlateTrxRequest request)
- {
- int sitewiseNozzleId = InvalidNozzleId;
- try
- {
- sitewiseNozzleId = int.Parse(request.gun);
- }
- catch (Exception ex)
- { }
- if (IsNozzleConfiguredOpen(sitewiseNozzleId))
- {
- var fp = GetFp(sitewiseNozzleId);
- fp?.SignalNewCarplate(request);
- }
- else
- {
- logger.Info
- (string.Format($"Physical nozzle# {sitewiseNozzleId} is closed, so we ignore the car plate event!!!"));
- }
- }
- private void SetupICCardReaderHandler()
- {
- cardReaderHandlers = icCardReaderProcessors.Select(proc => (WayneChina_IcCardReader_SinoChem.Handler)proc.Context.Handler);
- if (cardReaderHandlers != null && cardReaderHandlers.Count() > 0)
- {
- foreach (var handler in cardReaderHandlers)
- {
- handler.OnCardReaderMessageReceived += Handler_OnCardReaderMessageReceived;
- }
- }
- else
- {
- Console.WriteLine("card reader handlers not found!!");
- logger.Info("card reader handlers not found!!");
- }
- }
- private void Handler_OnCardReaderMessageReceived(object sender, WayneChina_IcCardReader_SinoChem.CardReaderMessageEventArgs e)
- {
- logger.Info($"Receiving Card Reader message {e.CardReaderMessage.GetType().ToString()} for FP id = {e.FuelingPointId}");
- var targetFP = fuelingPoints.First(_ => _.FuelingPointId == e.FuelingPointId);//GetFp(e.NozzleId);
- if (e.CardReaderMessage is ACK)
- {
- targetFP?.SingalAckReceived((ACK)e.CardReaderMessage);
- }
- else if (e.CardReaderMessage is SignDataResponse)
- {
- targetFP?.SignalSignedDataArrived((SignDataResponse)e.CardReaderMessage);
- }
- else if (e.CardReaderMessage is CardReaderStateEvent)
- {
- targetFP?.SingalCardReaderStateEvent((CardReaderStateEvent)e.CardReaderMessage);
- }
- else if (e.CardReaderMessage is CardExternalCheckErrorRequest)
- {
- targetFP?.SignalCardExternalCheckFailure((CardExternalCheckErrorRequest)e.CardReaderMessage);
- }
- else if (e.CardReaderMessage is CardOnlineVerificationRequest)
- {
- targetFP?.SignalCardOnlineVerification((CardOnlineVerificationRequest)e.CardReaderMessage);
- }
- else if (e.CardReaderMessage is HeartBeat)
- {
- targetFP?.SignalCardReaderHeartbeat((HeartBeat)e.CardReaderMessage);
- }
- }
- #region Cloud interactions
- internal RefundResponse SendRefundToCloud(EpsTransactionModel trxModel, DebugLogger debugLogger)
- {
- return cloudManager.Refund(trxModel, debugLogger);
- }
- internal TrxStatusInquiryResponse SendTrxQueryToCloud(EpsTransactionModel trxModel, DebugLogger debugLogger)
- {
- return cloudManager.TrxStatusInquiry(trxModel, debugLogger);
- }
- #endregion
- #region FDC client interactions
- private void FccClient_NozzleReplaced(int sitewiseNozzleId)
- {
- var fp = GetFp(sitewiseNozzleId);
- fp?.SignalNozzleReplaced(sitewiseNozzleId);
- }
- private void FccClient_AuthFailed(int sitewiseNozzleId)
- {
- var fp = GetFp(sitewiseNozzleId);
- fp?.SignalAuthFailed();
- }
- private void FccClient_AuthOk(int sitewiseNozzleId, long? authId)
- {
- var fp = GetFp(sitewiseNozzleId);
- fp?.SignalAuthOk(authId);
- }
- private void FccClient_NozzleLifted(int sitewiseNozzleId, IFdcPumpController callingPump)
- {
- if (IsNozzleConfiguredOpen(sitewiseNozzleId))
- {
- var fp = GetFp(sitewiseNozzleId);
- fp?.SignalNozzleLifted(callingPump, sitewiseNozzleId);
- }
- else
- {
- logger.Info(string.Format($"Physical nozzle# {sitewiseNozzleId} is closed, so we ignore the nozzle lift event!!!"));
- }
- }
- private bool IsNozzleConfiguredOpen(int sitewiseNozzleId)
- {
- return !NozzleLockAccessor.IsNozzleClosedInTermsOfSale(sitewiseNozzleId);
- }
- private void FccClient_FuelingDone(int sitewiseNozzleId, int seqNum, decimal fuelAmount, decimal fuelingQty, long authId)
- {
- var fp = GetFp(sitewiseNozzleId);
- fp?.SignalFuelingDone(sitewiseNozzleId, seqNum, fuelAmount, fuelingQty, authId);
- }
- public void AuthorizePumpAsync(IFdcPumpController callingPump, int sitewiseNozzleId, decimal authAmount)
- {
- callingPump.AuthorizeWithAmountAsync((int)((double)authAmount * Math.Pow(10, callingPump.AmountDecimalDigits)), 1);
- }
- #endregion
- private void TeardownFccClient()
- {
- //if (fccClient != null)
- //{
- // fccClient.NozzleLifted -= FccClient_NozzleLifted;
- // fccClient.NozzleReplaced -= FccClient_NozzleReplaced;
- // fccClient.AuthOk -= FccClient_AuthOk;
- // fccClient.AuthFailed -= FccClient_AuthFailed;
- // fccClient.FuelingDone -= FccClient_FuelingDone;
- //}
- }
- public void Shutdown()
- {
- TeardownCarplateServer();
- TeardownCardReaderHandler();
- if (fuelingPoints != null)
- {
- foreach (var fp in fuelingPoints)
- {
- fp.SignalShutdown();
- }
- }
- }
- public WayneChina_IcCardReader_SinoChem.Handler GetHandler(int nozzleId)
- {
- logger.Info($"Trying to get card reader handler for fueling point: {nozzleId}");
- foreach (var handler in cardReaderHandlers)
- {
- if (handler.SupportedNozzles.Contains(nozzleId))
- return handler;
- }
- return null;
- }
- private void TeardownCarplateServer()
- {
- if (carPlateServer != null)
- {
- carPlateServer.NewCarPlateScanned -= CarPlateServer_NewCarPlateScanned;
- }
- }
- private void TeardownCardReaderHandler()
- {
- if (cardReaderHandlers != null)
- {
- foreach (var handler in cardReaderHandlers)
- {
- handler.OnCardReaderMessageReceived -= Handler_OnCardReaderMessageReceived;
- }
- }
- }
- public Sinochem_CarPlateRecognizeCamera_HuLianWangJia.Handler CarPlateHandler => carPlateServer;
- public WayneChina_IcCardReader_SinoChem.Handler GetCardReader(int nozzleId)
- {
- return cardReaderHandlers.FirstOrDefault(h => h.SupportedNozzles.Contains(nozzleId));
- }
- public FuelingPoint GetFp(int nozzleId)
- {
- foreach (var fp in fuelingPoints)
- {
- if (fp.AssociatedNozzles != null && fp.AssociatedNozzles.Contains(nozzleId))
- return fp;
- }
- return null;
- }
- public FuelingPoint GetFuelingPoint(int fpId)
- {
- return fuelingPoints?.FirstOrDefault(_ => fpId == _.FuelingPointId);
- }
- public int GetNextRequestId()
- {
- lock (requestSyncObj)
- {
- if (requestId == int.MaxValue)
- {
- requestId = 0;
- }
- return requestId++;
- }
- }
- public string CreateDisplayTrxCommand(IEnumerable<EpsTransactionModel> epsTrxList, out int requestId, int i)
- {
- Display display;
- string cmdText = "";
- XmlSerializer serializer = new XmlSerializer(typeof(Display));
- MemoryStream ms;
- StreamReader sr;
- display = new Display();
- display.ScreenType = ScreenType.ShowTrxList;
- display.RequestId = GetNextRequestId();
- display.TimeoutSpecified = true;
- display.Timeout = 300;
- requestId = display.RequestId;
- display.PumpInfo = new DisplayPumpInfo
- {
- Id = 1,
- NozzleId = 1
- };
- int count = epsTrxList.Count();
- display.TrxList = new DisplayTrx[epsTrxList.Count()];
- for (int index = 0; index < count; index++)
- {
- display.TrxList[index] = ConvertEpsTrxModelToDisplayTrx(epsTrxList.ToArray()[index]);
- }
- ms = new MemoryStream();
- serializer.Serialize(ms, display);
- ms.Position = 0;
- sr = new StreamReader(ms, true);
- cmdText = sr.ReadToEnd();
- ms.Close();
- sr.Close();
- return cmdText;
- }
- public DisplayTrx ConvertEpsTrxModelToDisplayTrx(EpsTransactionModel epsTrxModel)
- {
- TrxStatus state = TrxStatus.ReadyForFillingStart;
- if (epsTrxModel.trx_status == EpsTrxStatus.BeforeFueling)
- state = TrxStatus.ReadyForFillingStart;
- else if (epsTrxModel.trx_status == EpsTrxStatus.BeforePayment)
- state = TrxStatus.PendingForPayment;
- else if (epsTrxModel.trx_status == EpsTrxStatus.Fueling)
- state = TrxStatus.FillingOngoing;
- else if (epsTrxModel.trx_status == EpsTrxStatus.FuelingDone)
- state = TrxStatus.PendingForPayment;
- else if (epsTrxModel.trx_status == EpsTrxStatus.PaymentOk)
- state = TrxStatus.Success;
- else if (epsTrxModel.trx_status == EpsTrxStatus.PaymentFailed)
- state = TrxStatus.Failed;
- else if (epsTrxModel.trx_status == EpsTrxStatus.PaymentNeedConfirm)
- state = TrxStatus.Failed;
- else if (epsTrxModel.trx_status == EpsTrxStatus.PaymentOkButNeedRefund)
- state = TrxStatus.Failed;
- else if (epsTrxModel.trx_status == EpsTrxStatus.PaymentRefunded)
- state = TrxStatus.Failed;
- var displayTrx = new DisplayTrx
- {
- Id = epsTrxModel.id.ToString(),
- State = state,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = epsTrxModel.created_time,
- FinishTime = string.IsNullOrEmpty(epsTrxModel.xf_time) ?
- epsTrxModel.created_time :
- Utilities.CombineDateAndTime(epsTrxModel.xf_date, epsTrxModel.xf_time)
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- Id = epsTrxModel.cardNo_masked,
- LicensePlateNo = epsTrxModel.car_number
- },
- FillingInfo = new DisplayTrxFillingInfo
- {
- PumpId = 1,
- NozzleId = epsTrxModel.jihao,
- ProductNo = 1,
- UnitPrice = (decimal)epsTrxModel.danjia,
- ProductType = epsTrxModel.youpin,
- ProductDiscription = "汽油",
- Amount = (decimal)epsTrxModel.real_pay_amount,
- Volume = (decimal)epsTrxModel.qty,
- }
- };
- return displayTrx;
- }
- public string CreateDisplayCommand(ScreenType screenType)
- {
- Display display;
- string cmdText = "";
- XmlSerializer serializer = new XmlSerializer(typeof(Display));
- MemoryStream ms;
- StreamReader sr;
- switch (screenType)
- {
- case ScreenType.Idle:
- display = new Display();
- display.ScreenType = screenType;
- display.CompanyContactInfo = new DisplayCompanyContactInfo
- {
- Tel = "010-59569575",
- Address = "世界500强企业\n中国第四大国家石油公司"
- };
- display.StationInfo = new DisplayStationInfo
- {
- StationNo = "000001",
- StationName = "沈阳望花中街加油加气站"
- };
- display.PumpInfo = new DisplayPumpInfo
- {
- Id = 1,
- NozzleId = 1
- };
- ms = new MemoryStream();
- serializer.Serialize(ms, display);
- ms.Position = 0;
- sr = new StreamReader(ms, true);
- cmdText = sr.ReadToEnd();
- break;
- case ScreenType.Welcome:
- display = new Display();
- display.ScreenType = screenType;
- display.CompanyContactInfo = new DisplayCompanyContactInfo
- {
- Tel = "010-59569575",
- Address = "世界500强企业\n中国第四大国家石油公司"
- };
- display.MemberInfo = new DisplayMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- };
- display.PumpInfo = new DisplayPumpInfo
- {
- Id = 1,
- NozzleId = 1
- };
- ms = new MemoryStream();
- serializer.Serialize(ms, display);
- ms.Position = 0;
- sr = new StreamReader(ms, true);
- cmdText = sr.ReadToEnd();
- break;
- case ScreenType.ShowTrxList:
- display = new Display();
- display.ScreenType = screenType;
- display.PumpInfo = new DisplayPumpInfo
- {
- Id = 1,
- NozzleId = 1
- };
- display.TrxList = new DisplayTrx[]
- {
- new DisplayTrx
- {
- Id = "100",
- FillingInfo = new DisplayTrxFillingInfo
- {
- Amount = 200,
- NozzleId = 1,
- ProductType = "95#",
- UnitPrice = 6.78m,
- Volume = 35,
- ProductDiscription = "汽油"
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- },
- State = TrxStatus.Success,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = DateTime.Now,
- FinishTime =DateTime.Now
- }
- },
- new DisplayTrx
- {
- Id = "101",
- FillingInfo = new DisplayTrxFillingInfo
- {
- Amount = 211,
- NozzleId = 1,
- ProductType = "95#",
- UnitPrice = 6.78m,
- Volume = 35,
- ProductDiscription = "汽油"
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- },
- State = TrxStatus.Success,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = DateTime.Now,
- FinishTime =DateTime.Now
- }
- },
- new DisplayTrx
- {
- Id = "102",
- FillingInfo = new DisplayTrxFillingInfo
- {
- Amount = 222,
- NozzleId = 1,
- ProductType = "95#",
- UnitPrice = 6.78m,
- Volume = 35,
- ProductDiscription = "汽油"
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- },
- State = TrxStatus.Success,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = DateTime.Now,
- FinishTime =DateTime.Now
- }
- },
- new DisplayTrx
- {
- Id = "103",
- FillingInfo = new DisplayTrxFillingInfo
- {
- Amount = 233,
- NozzleId = 1,
- ProductType = "95#",
- UnitPrice = 6.78m,
- Volume = 35,
- ProductDiscription = "汽油"
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- },
- State = TrxStatus.Success,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = DateTime.Now,
- FinishTime =DateTime.Now
- }
- },
- new DisplayTrx
- {
- Id = "104",
- FillingInfo = new DisplayTrxFillingInfo
- {
- Amount = 244,
- NozzleId = 1,
- ProductType = "95#",
- UnitPrice = 6.78m,
- Volume = 35,
- ProductDiscription = "汽油"
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- },
- State = TrxStatus.Success,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = DateTime.Now,
- FinishTime =DateTime.Now
- }
- }
- };
- ms = new MemoryStream();
- serializer.Serialize(ms, display);
- ms.Position = 0;
- sr = new StreamReader(ms, true);
- cmdText = sr.ReadToEnd();
- break;
- case ScreenType.TrxResult:
- display = new Display();
- display.ScreenType = screenType;
- display.PumpInfo = new DisplayPumpInfo
- {
- Id = 1,
- NozzleId = 1
- };
- display.TrxList = new DisplayTrx[]
- {
- new DisplayTrx
- {
- Id = "100",
- FillingInfo = new DisplayTrxFillingInfo
- {
- Amount = 200,
- NozzleId = 1,
- ProductType = "95#",
- UnitPrice = 6.78m,
- Volume = 35,
- ProductDiscription = "汽油"
- },
- MemberInfo = new DisplayTrxMemberInfo
- {
- LicensePlateNo = "京A88888",
- Id = "1234567"
- },
- State = TrxStatus.Success,
- TimeStamp = new DisplayTrxTimeStamp
- {
- StartTime = DateTime.Now,
- FinishTime =DateTime.Now
- }
- }
- };
- ms = new MemoryStream();
- serializer.Serialize(ms, display);
- ms.Position = 0;
- sr = new StreamReader(ms, true);
- cmdText = sr.ReadToEnd();
- break;
- default:
- throw new Exception("Unsupported screen type");
- }
- return cmdText;
- }
- #region IDisposable Support
- private bool disposedValue = false; // To detect redundant calls
- protected virtual void Dispose(bool disposing)
- {
- if (!disposedValue)
- {
- if (disposing)
- {
- // TODO: dispose managed state (managed objects).
- if (fuelingPoints != null)
- {
- foreach (var fp in fuelingPoints)
- {
- fp.Dispose();
- }
- }
- if (epsTrxCleanupManager != null)
- {
- epsTrxCleanupManager.Dispose();
- }
- }
- // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
- // TODO: set large fields to null.
- disposedValue = true;
- }
- }
- // TODO: override a finalizer only if Dispose(bool disposing) above has code to free unmanaged resources.
- // ~Eps() {
- // // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
- // Dispose(false);
- // }
- // This code added to correctly implement the disposable pattern.
- public void Dispose()
- {
- // Do not change this code. Put cleanup code in Dispose(bool disposing) above.
- Dispose(true);
- // TODO: uncomment the following line if the finalizer is overridden above.
- // GC.SuppressFinalize(this);
- }
- #endregion
- }
- }
|