Idle.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. using SinochemCarplateService.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Xml.Serialization;
  7. using Wayne.Lib;
  8. using Wayne.Lib.StateEngine;
  9. using Wayne.Lib.StateEngine.Generic;
  10. using WayneChina_IcCardReader_SinoChem.MessageEntity.Incoming;
  11. namespace SinochemInternetPlusApp.States
  12. {
  13. class Idle : TimeoutState<FuelingPoint>
  14. {
  15. int screen = 0;
  16. private int idleRequestId;
  17. private int trxOpRequestId;
  18. private List<EpsTransactionModel> trxList;
  19. private byte? sqNo = null;
  20. public Idle()
  21. {
  22. #region testing code
  23. /*
  24. trxList = new List<EpsTransactionModel>();
  25. trxList.Clear();
  26. trxList.Add(new EpsTransactionModel
  27. {
  28. id = 120,
  29. jihao = 1,
  30. youpin = "92#",
  31. qty = 10,
  32. danjia = 6.78,
  33. amount = 67.8,
  34. xf_date = DateTime.Now.Date,
  35. xf_time = DateTime.Now.TimeOfDay.ToString(),
  36. liushuino = "12345",
  37. fzqty = "",
  38. fzamount = 0,
  39. trx_status = EpsTrxStatus.BeforeFueling,
  40. mop = 1,
  41. car_number = "京NS1695",
  42. card_no = "1234567",
  43. ttc = "IOT1234567890",
  44. token = "TestToken",
  45. tid = "1",
  46. mac = "",
  47. balance_before_trx = 250,
  48. real_pay_amount = 67.8,
  49. auth_time = DateTime.Now.ToString("yyMMdd HHmmSS"),
  50. bill_id = "1",
  51. created_time = DateTime.Now,
  52. shift_id = "1",
  53. business_date = DateTime.Now.ToString("yyMMddHHmmSS")
  54. });
  55. trxList.Add(new EpsTransactionModel
  56. {
  57. id = 121,
  58. jihao = 1,
  59. youpin = "92#",
  60. qty = 10,
  61. danjia = 6.78,
  62. amount = 167.8,
  63. xf_date = DateTime.Now.Date,
  64. xf_time = DateTime.Now.TimeOfDay.ToString(),
  65. liushuino = "12345",
  66. fzqty = "",
  67. fzamount = 0,
  68. trx_status = EpsTrxStatus.PaymentOk,
  69. mop = 1,
  70. car_number = "京A88888",
  71. card_no = "1234567",
  72. ttc = "IOT1234567890",
  73. token = "TestToken",
  74. tid = "1",
  75. mac = "",
  76. balance_before_trx = 250,
  77. real_pay_amount = 67.8,
  78. auth_time = DateTime.Now.ToString("yyMMdd HHmmSS"),
  79. bill_id = "1",
  80. created_time = DateTime.Now,
  81. shift_id = "1",
  82. business_date = DateTime.Now.ToString("yyMMddHHmmSS")
  83. });
  84. trxList.Add(new EpsTransactionModel
  85. {
  86. id = 122,
  87. jihao = 1,
  88. youpin = "92#",
  89. qty = 10,
  90. danjia = 6.78,
  91. amount = 200,
  92. xf_date = DateTime.Now.Date,
  93. xf_time = DateTime.Now.TimeOfDay.ToString(),
  94. liushuino = "12345",
  95. fzqty = "",
  96. fzamount = 0,
  97. trx_status = EpsTrxStatus.PaymentOk,
  98. mop = 1,
  99. car_number = "冀J25089",
  100. card_no = "1234567",
  101. ttc = "IOT1234567890",
  102. token = "TestToken",
  103. tid = "1",
  104. mac = "",
  105. balance_before_trx = 250,
  106. real_pay_amount = 67.8,
  107. auth_time = DateTime.Now.ToString("yyMMdd HHmmSS"),
  108. bill_id = "1",
  109. created_time = DateTime.Now,
  110. shift_id = "1",
  111. business_date = DateTime.Now.ToString("yyMMddHHmmSS")
  112. });
  113. trxList.Add(new EpsTransactionModel
  114. {
  115. id = 123,
  116. jihao = 1,
  117. youpin = "92#",
  118. qty = 10,
  119. danjia = 6.78,
  120. amount = 366.5,
  121. xf_date = DateTime.Now.Date,
  122. xf_time = DateTime.Now.TimeOfDay.ToString(),
  123. liushuino = "12345",
  124. fzqty = "",
  125. fzamount = 0,
  126. trx_status = EpsTrxStatus.PaymentFailed,
  127. mop = 1,
  128. car_number = "沪B35L36",
  129. card_no = "1234567",
  130. ttc = "IOT1234567890",
  131. token = "TestToken",
  132. tid = "1",
  133. mac = "",
  134. balance_before_trx = 250,
  135. real_pay_amount = 67.8,
  136. auth_time = DateTime.Now.ToString("yyMMdd HHmmSS"),
  137. bill_id = "1",
  138. created_time = DateTime.Now,
  139. shift_id = "1",
  140. business_date = DateTime.Now.ToString("yyMMddHHmmSS")
  141. });
  142. trxList.Add(new EpsTransactionModel
  143. {
  144. id = 124,
  145. jihao = 1,
  146. youpin = "95#",
  147. qty = 10,
  148. danjia = 7.33,
  149. amount = 73.3,
  150. xf_date = DateTime.Now.Date,
  151. xf_time = DateTime.Now.TimeOfDay.ToString(),
  152. liushuino = "12345",
  153. fzqty = "",
  154. fzamount = 0,
  155. trx_status = EpsTrxStatus.PaymentOk,
  156. mop = 1,
  157. car_number = "京QD8R01",
  158. card_no = "1234567",
  159. ttc = "IOT1234567890",
  160. token = "TestToken",
  161. tid = "1",
  162. mac = "",
  163. balance_before_trx = 250,
  164. real_pay_amount = 67.8,
  165. auth_time = DateTime.Now.ToString("yyMMdd HHmmSS"),
  166. bill_id = "1",
  167. created_time = DateTime.Now,
  168. shift_id = "1",
  169. business_date = DateTime.Now.ToString("yyMMddHHmmSS")
  170. });
  171. */
  172. #endregion
  173. }
  174. protected override void Enter(StateEntry stateEntry, ref Transition transition)
  175. {
  176. base.Enter(stateEntry, ref transition);
  177. if (Main.CardReaderDisabled)
  178. {
  179. Main.OpenCardReader(out sqNo);
  180. if (sqNo.HasValue)
  181. Main.IdleStateCardReaderSqNo = sqNo.Value;
  182. }
  183. if (Main.Eps.CarPlateHandler != null)
  184. {
  185. int remainder = screen % 5;
  186. if (remainder == 0)
  187. {
  188. var text = CreateDisplayIdleCommand();
  189. DebugLog(text);
  190. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  191. if (!Main.ContainsRequestId(idleRequestId))
  192. {
  193. DebugLog($"Adding RequestId: {idleRequestId} to the list");
  194. Main.AddRequestId(idleRequestId);
  195. }
  196. }
  197. else if (remainder == 1)
  198. {
  199. var text = CreateDisplayWelcomeCommand();
  200. DebugLog(text);
  201. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  202. }
  203. else
  204. {
  205. var text = CreateDisplayTrxListCommand(remainder);
  206. DebugLog(text);
  207. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  208. if (remainder == 4)
  209. {
  210. var text1 = CreateDisplayTrxResultCommand(screen);
  211. DebugLog(text1);
  212. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text1);
  213. }
  214. }
  215. //used for 15" screen test
  216. //screen++;
  217. }
  218. }
  219. protected override void HandleNonTimeoutEvent(StateEngineEvent stateEngineEvent, ref Transition transition)
  220. {
  221. if (stateEngineEvent.Type is EventType)
  222. {
  223. switch ((EventType)stateEngineEvent.Type)
  224. {
  225. case EventType.NozzleLifted:
  226. var nlEvent = stateEngineEvent as GenericEvent<NozzleLiftedEventArgs>;
  227. Main.CurrentNozzleId = nlEvent.EventArgs.NozzleId;
  228. transition = new Transition(this, TransitionType.NozzleLifted);
  229. stateEngineEvent.Handled = true;
  230. break;
  231. case EventType.CarPlateScanned:
  232. var genericEvent = stateEngineEvent as GenericEvent<CarPlateTrxRequest>;
  233. //Current physical nozzle to be used
  234. Main.CurrentNozzleId = Convert.ToInt32(genericEvent.EventArgs.gun);
  235. Main.CreateEpsTransaction(TransactionMode.CarPlateMode);
  236. Main.CurrentEpsTrx.Model.car_number = genericEvent.EventArgs.car_Number;
  237. //Main.CurrentEpsTrx.Model.card_no = genericEvent.EventArgs.card_No; // will be set when payment ok
  238. Main.CurrentEpsTrx.Model.ttc = genericEvent.EventArgs.ttc;
  239. Main.CurrentEpsTrx.Model.balance_before_trx = genericEvent.EventArgs.amount;
  240. Main.CurrentEpsTrx.Model.token = genericEvent.EventArgs.token;
  241. Main.CurrentEpsTrx.Model.tid = genericEvent.EventArgs.tid;
  242. Main.CurrentEpsTrx.Model.youpin = genericEvent.EventArgs.oilName;
  243. Main.CurrentEpsTrx.Model.xf_date = DateTime.Parse(DateTime.Now.Date.ToString("yyyy-MM-dd"));
  244. Main.CurrentEpsTrx.SaveToDb();
  245. Main.ClearAllRequestIds();
  246. transition = new Transition(this, TransitionType.CarPlateScanned);
  247. stateEngineEvent.Handled = true;
  248. break;
  249. case EventType.ShutdownRequest:
  250. transition = new Transition(this, TransitionType.Shutdown);
  251. stateEngineEvent.Handled = true;
  252. break;
  253. case EventType.DisplayResponseReceived:
  254. {
  255. var e = stateEngineEvent as GenericEvent<DisplayResponseEventArgs>;
  256. if (e != null && e.EventArgs != null)
  257. {
  258. if (idleRequestId == e.EventArgs.DispResponse.RequestId ||
  259. trxOpRequestId == e.EventArgs.DispResponse.RequestId)
  260. {
  261. e.Handled = true;
  262. var reqId = e.EventArgs.DispResponse.RequestId;
  263. if (Main.ContainsRequestId(reqId))
  264. {
  265. Main.RemoveRequestId(reqId);
  266. DebugLog($"Removed RequestId : {reqId} from the list");
  267. }
  268. }
  269. }
  270. }
  271. break;
  272. //Delete pending fueling trx when 15" screen is in Idle
  273. case EventType.TrxOpRequest:
  274. {
  275. GenericEvent<TransactionOperationEventArgs> trxOpEvent = stateEngineEvent as GenericEvent<TransactionOperationEventArgs>;
  276. if (trxOpEvent != null && trxOpEvent.EventArgs != null)
  277. {
  278. trxOpEvent.Handled = true;
  279. if (trxOpEvent.EventArgs.TrxOp.OpType == OpType.Delete)
  280. {
  281. var allTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  282. Main.GetAllNozzlesOnThisSide(),
  283. -1, // force all trxes
  284. Main.DebugLogger);
  285. //Delete the matching trx
  286. int trxId = trxOpEvent.EventArgs.TrxOp.TrxId;
  287. bool hasTrxDeleted = false;
  288. foreach (var trx in allTrx)
  289. {
  290. if ((trx.id == trxId) && Main.GetAllNozzlesOnThisSide().Contains(trx.jihao) && (trx.trx_status == EpsTrxStatus.BeforeFueling))
  291. {
  292. hasTrxDeleted = true;
  293. DebugLog($"Deleting Trx, id = {trxId}");
  294. EpsTransaction.RestroeEpsTrxFrom(trx).UpdateTrxStatusToDb(EpsTrxStatus.Removed);
  295. }
  296. }
  297. if (hasTrxDeleted)
  298. {
  299. var validTrx = EpsTransactionQuery.GetValidCarPlateEpsTrxModels(
  300. Main.GetAllNozzlesOnThisSide(),
  301. ConfigurationValues.AlreadyDoneEpsTrxCountPerDisplay,
  302. Main.DebugLogger);
  303. //Refresh 15" screen
  304. var text = Main.Eps.CreateDisplayTrxCommand(validTrx, out trxOpRequestId, 0);
  305. if (Main.Eps.CarPlateHandler != null)
  306. {
  307. DebugLog(text);
  308. Main.Eps.CarPlateHandler.BroadcastMessageViaFdc(text);
  309. if (!Main.ContainsRequestId(trxOpRequestId))
  310. Main.AddRequestId(trxOpRequestId);
  311. }
  312. }
  313. }
  314. }
  315. }
  316. break;
  317. case EventType.ReaderStateChanged:
  318. {
  319. var e = stateEngineEvent as GenericEvent<CardReaderStateEventArgs>;
  320. if (e != null && e.EventArgs != null)
  321. {
  322. if (e.EventArgs.CardReaderState.State == CardReaderState.CardInserted)
  323. {
  324. e.Handled = true;
  325. transition = new Transition(this, TransitionType.CardInserted);
  326. }
  327. else if (e.EventArgs.CardReaderState.State == CardReaderState.Idle)
  328. {
  329. e.Handled = true;
  330. return;
  331. }
  332. }
  333. }
  334. break;
  335. case EventType.CardReaderAck:
  336. {
  337. if (sqNo.HasValue && sqNo.Value == sqNo.Value)
  338. {
  339. stateEngineEvent.Handled = true;
  340. sqNo = null;
  341. Main.CardReaderDisabled = false;
  342. }
  343. }
  344. break;
  345. case EventType.FuelingDone:
  346. var fdEvent = stateEngineEvent as GenericEvent<FuelingDoneEventArgs>;
  347. if (fdEvent != null && fdEvent.EventArgs != null)
  348. {
  349. var nozzleId = fdEvent.EventArgs.NozzleId;
  350. var liushuino = fdEvent.EventArgs.FuelingSqNo;
  351. var amount = fdEvent.EventArgs.Amount;
  352. var authId = fdEvent.EventArgs.AuthId;
  353. DebugLog(string.Format($"Floating fuel trx, liushuihao({liushuino}), amount({amount}), authId({authId})"));
  354. MultiFusionsSupport.CopyXiaofei2ToTargetFusion(nozzleId, Convert.ToString(liushuino), Main.DebugLogger);
  355. fdEvent.Handled = true;
  356. }
  357. break;
  358. default:
  359. DebugLog("ATTENTION unhandled event " + stateEngineEvent);
  360. stateEngineEvent.Handled = true;
  361. break;
  362. }
  363. }
  364. }
  365. protected override void Timeout(ref Transition transition)
  366. {
  367. transition = new Transition(this, TransitionType.Done);
  368. }
  369. protected override int TimeoutInterval =>
  370. TimeoutValues.GetValueInMilliSec(TimeoutValues.FuelingPoint.Idle, 15);
  371. private string CreateDisplayIdleCommand()
  372. {
  373. Display display;
  374. string cmdText = "";
  375. XmlSerializer serializer = new XmlSerializer(typeof(Display));
  376. MemoryStream ms;
  377. StreamReader sr;
  378. display = new Display
  379. {
  380. ScreenType = ScreenType.Idle,
  381. RequestId = Main.Eps.GetNextRequestId(),
  382. TimeoutSpecified = true,
  383. Timeout = TimeoutValues.GetValueInSec(TimeoutValues.Misc.BigScreenBackToIdle, 300)
  384. };
  385. idleRequestId = display.RequestId;
  386. display.CompanyContactInfo = new DisplayCompanyContactInfo
  387. {
  388. Tel = "010-59569575",
  389. Address = "世界500强企业\n中国第四大国家石油公司"
  390. };
  391. display.StationInfo = new DisplayStationInfo
  392. {
  393. StationNo = Main.StationNo,
  394. StationName = Main.StationName
  395. };
  396. display.PumpInfo = new DisplayPumpInfo
  397. {
  398. Id = 1,
  399. NozzleId = Main.AssociatedNozzles.First()
  400. };
  401. ms = new MemoryStream();
  402. serializer.Serialize(ms, display);
  403. ms.Position = 0;
  404. sr = new StreamReader(ms, true);
  405. cmdText = sr.ReadToEnd();
  406. return cmdText;
  407. }
  408. #region Used for 15" screen debug
  409. private string CreateDisplayWelcomeCommand()
  410. {
  411. Display display;
  412. string cmdText = "";
  413. XmlSerializer serializer = new XmlSerializer(typeof(Display));
  414. MemoryStream ms;
  415. StreamReader sr;
  416. display = new Display();
  417. display.ScreenType = ScreenType.Welcome;
  418. display.TimeoutSpecified = true;
  419. display.Timeout = 10;
  420. display.PumpInfo = new DisplayPumpInfo
  421. {
  422. Id = 1,
  423. NozzleId = 1
  424. };
  425. display.MemberInfo = new DisplayMemberInfo
  426. {
  427. LicensePlateNo = "京NS1695",//epsTrxModel.car_number,
  428. Id = "" //epsTrxModel.card_no
  429. };
  430. ms = new MemoryStream();
  431. serializer.Serialize(ms, display);
  432. ms.Position = 0;
  433. sr = new StreamReader(ms, true);
  434. cmdText = sr.ReadToEnd();
  435. return cmdText;
  436. }
  437. private string CreateDisplayTrxListCommand(int screen)
  438. {
  439. Display display;
  440. string cmdText = "";
  441. XmlSerializer serializer = new XmlSerializer(typeof(Display));
  442. MemoryStream ms;
  443. StreamReader sr;
  444. display = new Display();
  445. display.ScreenType = ScreenType.ShowTrxList;
  446. display.TimeoutSpecified = true;
  447. display.Timeout = 10;
  448. display.PumpInfo = new DisplayPumpInfo
  449. {
  450. Id = 1,
  451. NozzleId = 1
  452. };
  453. var state = TrxStatus.ReadyForFillingStart;
  454. if (screen == 2)
  455. {
  456. state = TrxStatus.ReadyForFillingStart;
  457. display.Timeout = 30;
  458. }
  459. else if (screen == 3)
  460. state = TrxStatus.PendingForPayment;
  461. else if (screen == 4)
  462. state = TrxStatus.Success;
  463. display.TrxList = new DisplayTrx[trxList.Count];
  464. for (int i = 0; i < trxList.Count; i++)
  465. {
  466. display.TrxList[i] = Main.Eps.ConvertEpsTrxModelToDisplayTrx(trxList[i]);
  467. }
  468. display.TrxList[0].State = state;
  469. //display.TrxList = new DisplayTrx[]
  470. //{
  471. // new DisplayTrx
  472. // {
  473. // Id = "200",
  474. // FillingInfo = new DisplayTrxFillingInfo
  475. // {
  476. // Amount = 200,
  477. // NozzleId = 1,
  478. // ProductType = "95#",
  479. // UnitPrice = 6.78m,
  480. // Volume = 35,
  481. // ProductDiscription = "汽油"
  482. // },
  483. // MemberInfo = new DisplayTrxMemberInfo
  484. // {
  485. // LicensePlateNo = "京NS1695",
  486. // Id = "1234567"
  487. // },
  488. // State = state,
  489. // TimeStamp = new DisplayTrxTimeStamp
  490. // {
  491. // StartTime = DateTime.Now,
  492. // FinishTime =DateTime.Now
  493. // }
  494. // },
  495. // new DisplayTrx
  496. // {
  497. // Id = "101",
  498. // FillingInfo = new DisplayTrxFillingInfo
  499. // {
  500. // Amount = 211,
  501. // NozzleId = 1,
  502. // ProductType = "95#",
  503. // UnitPrice = 6.78m,
  504. // Volume = 35,
  505. // ProductDiscription = "汽油"
  506. // },
  507. // MemberInfo = new DisplayTrxMemberInfo
  508. // {
  509. // LicensePlateNo = "京A22222",
  510. // Id = "1234567"
  511. // },
  512. // State = TrxStatus.Success,
  513. // TimeStamp = new DisplayTrxTimeStamp
  514. // {
  515. // StartTime = DateTime.Now,
  516. // FinishTime =DateTime.Now
  517. // }
  518. // },
  519. // new DisplayTrx
  520. // {
  521. // Id = "102",
  522. // FillingInfo = new DisplayTrxFillingInfo
  523. // {
  524. // Amount = 222,
  525. // NozzleId = 1,
  526. // ProductType = "95#",
  527. // UnitPrice = 6.78m,
  528. // Volume = 35,
  529. // ProductDiscription = "汽油"
  530. // },
  531. // MemberInfo = new DisplayTrxMemberInfo
  532. // {
  533. // LicensePlateNo = "京A33333",
  534. // Id = "1234567"
  535. // },
  536. // State = TrxStatus.Success,
  537. // TimeStamp = new DisplayTrxTimeStamp
  538. // {
  539. // StartTime = DateTime.Now,
  540. // FinishTime =DateTime.Now
  541. // }
  542. // },
  543. // new DisplayTrx
  544. // {
  545. // Id = "103",
  546. // FillingInfo = new DisplayTrxFillingInfo
  547. // {
  548. // Amount = 233,
  549. // NozzleId = 1,
  550. // ProductType = "95#",
  551. // UnitPrice = 6.78m,
  552. // Volume = 35,
  553. // ProductDiscription = "汽油"
  554. // },
  555. // MemberInfo = new DisplayTrxMemberInfo
  556. // {
  557. // LicensePlateNo = "京A44444",
  558. // Id = "1234567"
  559. // },
  560. // State = TrxStatus.Success,
  561. // TimeStamp = new DisplayTrxTimeStamp
  562. // {
  563. // StartTime = DateTime.Now,
  564. // FinishTime =DateTime.Now
  565. // }
  566. // },
  567. // new DisplayTrx
  568. // {
  569. // Id = "104",
  570. // FillingInfo = new DisplayTrxFillingInfo
  571. // {
  572. // Amount = 244,
  573. // NozzleId = 1,
  574. // ProductType = "95#",
  575. // UnitPrice = 6.78m,
  576. // Volume = 35,
  577. // ProductDiscription = "汽油"
  578. // },
  579. // MemberInfo = new DisplayTrxMemberInfo
  580. // {
  581. // LicensePlateNo = "京A55555",
  582. // Id = "1234567"
  583. // },
  584. // State = TrxStatus.Success,
  585. // TimeStamp = new DisplayTrxTimeStamp
  586. // {
  587. // StartTime = DateTime.Now,
  588. // FinishTime =DateTime.Now
  589. // }
  590. // }
  591. //};
  592. ms = new MemoryStream();
  593. serializer.Serialize(ms, display);
  594. ms.Position = 0;
  595. sr = new StreamReader(ms, true);
  596. cmdText = sr.ReadToEnd();
  597. return cmdText;
  598. }
  599. private string CreateDisplayTrxResultCommand(int i)
  600. {
  601. Display display;
  602. string cmdText = "";
  603. XmlSerializer serializer = new XmlSerializer(typeof(Display));
  604. MemoryStream ms;
  605. StreamReader sr;
  606. display = new Display();
  607. display.ScreenType = ScreenType.TrxResult;
  608. display.TimeoutSpecified = true;
  609. display.Timeout = 10;
  610. display.PumpInfo = new DisplayPumpInfo
  611. {
  612. Id = 1,
  613. NozzleId = 1
  614. };
  615. display.TrxList = new DisplayTrx[]
  616. {
  617. new DisplayTrx
  618. {
  619. Id = "200",
  620. State = TrxStatus.Success,
  621. MemberInfo = new DisplayTrxMemberInfo
  622. {
  623. LicensePlateNo = "京NS1695",//epsTrxModel.car_number,
  624. Id = "1234567"//epsTrxModel.card_no
  625. },
  626. FillingInfo = new DisplayTrxFillingInfo
  627. {
  628. PumpId = 1,
  629. NozzleId = 1,
  630. ProductNo = 1,
  631. ProductDiscription = "92#",
  632. Amount = 105,
  633. Volume = 18.90m
  634. }
  635. }
  636. };
  637. ms = new MemoryStream();
  638. serializer.Serialize(ms, display);
  639. ms.Position = 0;
  640. sr = new StreamReader(ms, true);
  641. cmdText = sr.ReadToEnd();
  642. ms.Close();
  643. sr.Close();
  644. return cmdText;
  645. }
  646. #endregion
  647. }
  648. }