/// <summary> /// 解析工具中的ParseCmd方法使用Demo /// </summary> /// <remarks> /// 返回结果:RT JQF0B7 /// </remarks> public static void ParserDemo_ParseCmd_SeekPNR() { JetermEntity.Request.SeekPNR request = new JetermEntity.Request.SeekPNR(); request.Pnr = "JQF0B7"; request.PassengerType = EtermCommand.PassengerType.Adult; request.GetPrice = true; JetermEntity.Parser.SeekPNR seekPNRParser = new JetermEntity.Parser.SeekPNR(); string cmd = seekPNRParser.ParseCmd(request); Console.WriteLine("获得的RT指令为:" + Environment.NewLine + cmd); Console.ReadLine(); }
private void GetPriceCmd(JetermEntity.Request.SeekPNR request) { priceCmd = string.Empty; if (request.GetPrice) { switch (request.PassengerType) { case EtermCommand.PassengerType.Adult: priceCmd = "PAT:A"; break; case EtermCommand.PassengerType.Children: priceCmd = "PAT:A*CH"; break; case EtermCommand.PassengerType.Baby: priceCmd = "PAT:A*IN"; break; } } }
/// <summary> /// 主方法:【提取编码RT】指令返回结果解析 /// </summary> /// <param name="request">请求对象</param> /// <returns>返回结果</returns> public override CommandResult <JetermEntity.Response.SeekPNR> BusinessDispose(JetermEntity.Request.SeekPNR request) { JetermEntity.Parser.SeekPNR seekPNR = new JetermEntity.Parser.SeekPNR(this.config, this.OfficeNo); this.Cmd = seekPNR.ParseCmd(request); if (string.IsNullOrEmpty(this.Cmd)) { return(seekPNR.Response); } GetPriceCmd(request); ExcuteCmd(); seekPNR.Response.error = ParserHelper.ValidRTResult(this.CmdResult, request.Pnr, request.PassengerType); if (seekPNR.Response.error != null) { seekPNR.Response.error.CmdResultBag = this.CmdResult; return(seekPNR.Response); } try { seekPNR.Response = seekPNR.ParseCmdResult(this.CmdResult); } catch { seekPNR.Response.error = new Error(EtermCommand.ERROR.PARSE_FAIL); seekPNR.Response.error.CmdResultBag = this.CmdResult; return(seekPNR.Response); } return(seekPNR.Response); }