Esempio n. 1
0
        public ExecuteResult <ReservedPnr> Rt(string pnrCode, string userName)
        {
            var veService = new veSWScnService();

            veService.Url = ReplaceUrl(veService.Url);
            var returnString = veService.RtPnr(pnrCode, userName, "");

            // 内容解析
            if (Domain.Utility.Parser.IsXmlFormat(returnString))
            {
                var xdoc        = XDocument.Parse(returnString, LoadOptions.None);
                var content     = xdoc.Element("P");
                var flag        = content.Element("R").Value == "1";
                var rawData     = content.Element("Q").Value;
                var reservedPnr = Domain.Utility.Parser.GetPnrContent(rawData);

                if (flag && reservedPnr != null)
                {
                    reservedPnr.PnrRawData = rawData;
                    return(new ExecuteResult <ReservedPnr>
                    {
                        Success = true,
                        Result = reservedPnr,
                        Message = reservedPnr.HasCanceled ? "编码已取消" : rawData
                    });
                }
            }

            return(new ExecuteResult <ReservedPnr>
            {
                Success = false,
                Message = ErrorMessageUtil.ReplaceErrorMessage(returnString)
            });
        }
Esempio n. 2
0
        /// <summary>
        /// 根据给出旅客订座记录编号和待取消航段的航段信息,取消相应的航段。
        /// </summary>
        /// <param name="pnrCode">旅客订座记录编号</param>
        /// <param name="cancelSegments">待取消航段的航段信息</param>
        /// <param name="userName">用户名</param>
        /// <returns>是否成功</returns>
        public bool Xe(string pnrCode, CancelSegmentInfo[] cancelSegments, string userName)
        {
            if (cancelSegments.Length == 0)
            {
                throw new ArgumentException("航段信息");
            }

            var veService = new veSWScnService();

            veService.Url = ReplaceUrl(veService.Url);

            var      returnString = veService.RtPnr(pnrCode, userName, "KMG215");
            var      xdoc         = XDocument.Parse(returnString, LoadOptions.None);
            XElement content      = xdoc.Element("P");
            var      hasSuccessed = content != null && content.Element("R").Value == "1";

            // 若提取编码失败,直接退出;
            if (!hasSuccessed)
            {
                return(false);
            }

            string rawData = content.Element("Q").Value;

            // 判断编码是否被取消,这种直接视为取消成功;
            if (Domain.Utility.Parser.IsCanceled(rawData))
            {
                return(true);
            }

            var segments = Domain.Utility.Parser.GetSegements(rawData);

            // 没有信息;
            if (segments.Count == 0)
            {
                return(false);
            }

            // 以下核对信息,主要是防止编码在线下被处理后,和平台的信息不符;
            // 找出待取消的编号列表;
            List <int> lineNumbers    = new List <int>();
            bool       hasRescheduled = false;

            foreach (var cs in cancelSegments)
            {
                foreach (var rs in segments)
                {
                    // 先匹配航班号
                    if (cs.FlightNumber.Equals(rs.FlightNumber))
                    {
                        // 若航班号和时间都能匹配,则说明没有改期;
                        if (cs.FlightDate.Date == rs.FlightDate.Date)
                        {
                            lineNumbers.Add(rs.LineNumber);
                        }
                        else
                        {
                            hasRescheduled = true;
                        }
                    }
                }
            }

            // 若有改期,则返回假,不做操作,由此,此结果将指向到平台,
            if (hasRescheduled)
            {
                return(false);
            }

            // 若行号中没有数据,则没有匹配到值,返回成功;
            if (lineNumbers.Count == 0)
            {
                return(true);
            }

            // 若待取消取消的数量和现有数量相等,即所有的都取消,此时取消编码;
            if (lineNumbers.Count() == segments.Count)
            {
                return(Xepnr(pnrCode, userName));
            }

            // 获取取消航段的指令;
            string cmd = CommandBuilderService.GetCancelSegmentInstruction(lineNumbers.ToArray());

            // 发送取消编码的指令;
            rawData = veService.EditPNR(pnrCode, cmd, "1", userName);
            rawData = Domain.Utility.Parser.RemoveLineBreakAndSpace(rawData);
            return(rawData == "1");
        }
Esempio n. 3
0
        /// <summary>
        /// 根据给出旅客订座记录编号和待取旅客的名称,取消相应的旅客。
        /// </summary>
        /// <param name="pnrCode">旅客订座记录编号</param>
        /// <param name="names">待取消旅客的姓名数组</param>
        /// <param name="userName">用户名</param>
        /// <returns>是否成功</returns>
        public bool Xe(string pnrCode, string[] names, string userName)
        {
            if (names.Length == 0)
            {
                throw new ArgumentException("旅客姓名");
            }

            var veService = new veSWScnService();

            veService.Url = ReplaceUrl(veService.Url);

            var      returnString = veService.RtPnr(pnrCode, userName, "KMG215");
            var      xdoc         = XDocument.Parse(returnString, LoadOptions.None);
            XElement content      = xdoc.Element("P");
            var      hasSuccessed = content != null && content.Element("R").Value == "1";

            // 若提取编码失败,直接退出;
            if (!hasSuccessed)
            {
                return(false);
            }

            string rawData = content.Element("Q").Value;

            // 判断编码是否被取消,这种直接视为取消成功;
            if (Domain.Utility.Parser.IsCanceled(rawData))
            {
                return(true);
            }

            // 获取姓名字串
            var nameAndOfficeStr = Domain.Utility.Parser.RemoveLineBreakAndSpace(Domain.Utility.Parser.GetNameAndOfficeNoString(rawData));
            // 获取名称项
            var passengers = Domain.Utility.Parser.GetPassengers(nameAndOfficeStr);

            // 没有信息;
            if (passengers.Count == 0)
            {
                return(false);
            }

            // 找出待取消的编号列表;
            var lineNumbers = (from n in names
                               join p in passengers on n equals p.Name
                               select p.LineNumber).ToList();

            if (lineNumbers.Count == 0)
            {
                return(true);
            }

            // 若待取消取消的数量和现有数量相等,即所有的都取消,此时取消编码;
            if (lineNumbers.Count == passengers.Count)
            {
                return(Xepnr(pnrCode, userName));
            }

            // 发送取消编码的指令;
            string cmd = CommandBuilderService.GetCancelPassengerInstruction(lineNumbers.ToArray());

            rawData = veService.EditPNR(pnrCode, cmd, "1", userName);
            rawData = Domain.Utility.Parser.RemoveLineBreakAndSpace(rawData);
            return(rawData == "1");
        }