Exemple #1
0
        private RequestResult <TicketInfo> parseTicketInfo(string ticketResponse)
        {
            var result = new RequestResult <TicketInfo>();
            var doc    = new XmlDocument();

            doc.LoadXml(ticketResponse);
            string errMessage;

            if (ResponseSuccess(doc, out errMessage))
            {
                var ticketNoText = doc.SelectSingleNode("/result/airId").InnerText;
                if (string.IsNullOrWhiteSpace(ticketNoText) || ticketNoText.ToLower().Contains("null"))
                {
                    result.Success    = false;
                    result.ErrMessage = "无票号信息";
                }
                else
                {
                    var passengers = doc.SelectSingleNode("/result/passengerName").InnerText.Split('^');
                    var ticketNos  = ticketNoText.Split('^');
                    result.Success = true;
                    result.Result  = new TicketInfo();
                    var newPNRCode = doc.SelectSingleNode("/result/newPnr").InnerText;
                    var settleCode = string.Empty;
                    if (!string.IsNullOrWhiteSpace(newPNRCode))
                    {
                        result.Result.NewPNR = new PNRPair(newPNRCode, string.Empty);
                    }
                    var ticketNoViews = new List <DataTransferObject.Order.TicketNoView.Item>();
                    var index         = 0;
                    foreach (var passenger in passengers)
                    {
                        var ticketNoForPassenger = new DataTransferObject.Order.TicketNoView.Item {
                            Name = passenger
                        };
                        if (ticketNos.Length > index)
                        {
                            var ticketFullNo = ticketNos[index];
                            if (settleCode.Length == 0)
                            {
                                settleCode = ticketFullNo.Substring(0, 3);
                            }
                            ticketNoForPassenger.TicketNos = new[] { ticketFullNo.Substring(3, ticketFullNo.Length - 3) };
                        }
                        ticketNoViews.Add(ticketNoForPassenger);
                        index++;
                    }
                    result.Result.SettleCode = settleCode;
                    result.Result.TicketNos  = ticketNoViews;
                }
            }
            else
            {
                result.Success    = false;
                result.ErrMessage = errMessage;
            }
            return(result);
        }
Exemple #2
0
        protected override ExternalPlatformNotifyView ExecuteCore()
        {
            var result = new ETDZSuccessNotifyView()
            {
                Valid  = true,
                Ticket = new TicketInfo()
            };
            var newPNRCode = GetParameter("newPnr");
            var settleCode = string.Empty;

            if (!string.IsNullOrWhiteSpace(newPNRCode))
            {
                result.Ticket.NewPNR = new PNRPair(newPNRCode, string.Empty);
            }
            var passengers    = GetParameter("passengerName").Split('^');
            var ticketNos     = GetParameter("airId").Split('^');
            var ticketNoViews = new List <DataTransferObject.Order.TicketNoView.Item>();
            var index         = 0;

            foreach (var passenger in passengers)
            {
                var ticketNoForPassenger = new DataTransferObject.Order.TicketNoView.Item {
                    Name = passenger
                };
                if (ticketNos.Length > index)
                {
                    var ticketFullNo = ticketNos[index];
                    if (settleCode.Length == 0)
                    {
                        settleCode = ticketFullNo.Substring(0, 3);
                    }
                    var ticketNo = ticketFullNo.Substring(3, ticketFullNo.Length - 3);
                    ticketNoForPassenger.TicketNos = new[] { ticketNo.TrimStart('-') };
                }
                ticketNoViews.Add(ticketNoForPassenger);
                index++;
            }
            result.Ticket.SettleCode = settleCode;
            result.Ticket.TicketNos  = ticketNoViews;
            return(result);
        }