Exemple #1
0
 public AVHCommand(AirportPair airportPair, DateTime date, Time time)
 {
     this.airportPair = airportPair;
     this.date        = date;
     this.time        = time;
     Initialize();
 }
Exemple #2
0
        /// <summary>
        /// 根据给出的起飞机场、中转机场、到达机场、排除航线字串,以及此字串的分隔符,
        /// 判断对于此政策是否保留。
        /// </summary>
        /// <param name="departure">出发机场</param>
        /// <param name="transit">中转机场</param>
        /// <param name="arrival">到达机场</param>
        /// <param name="filter">以分隔符分隔的多条排除航线</param>
        /// <param name="separator">排除航线分隔符</param>
        /// <returns>是否保留</returns>
        private static bool MatchAirway(string departure, string transit, string arrival, string filter, string separator)
        {
            if (string.IsNullOrWhiteSpace(departure))
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(transit))
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(arrival))
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(filter))
            {
                return(true);
            }

            var first  = new AirportPair(departure, transit);
            var second = new AirportPair(transit, arrival);
            var list   = new List <AirportPair> {
                first, second
            };

            return(MatchAirway(list, filter, separator));
        }
Exemple #3
0
 /// <summary>
 /// 提取座位可用情况的航信指令
 /// </summary>
 /// <param name="airportPair">航程</param>
 /// <param name="date">日期</param>
 /// <param name="transactionId">事务编号</param>
 public AVHCommand(AirportPair airportPair, DateTime date, string transactionId)
 {
     this.airportPair   = airportPair;
     this.date          = date;
     this.transactionId = transactionId;
     Initialize();
 }
Exemple #4
0
 /// <summary>
 /// 执行查询运价的指令
 /// </summary>
 /// <param name="airportPair">城市对</param>
 /// <param name="date">日期</param>
 /// <param name="carrier">承运人</param>
 public FdCommand(AirportPair airportPair, DateTime date, string carrier)
 {
     _airportPair = airportPair;
     _date        = date;
     _carrier     = carrier;
     Initialize();
 }
Exemple #5
0
        private IEnumerable <RefundFeeView> CollectFeeInfo()
        {
            var result = new List <RefundFeeView>();

            foreach (RepeaterItem item in RefundInfos.Items)
            {
                var Passengers = item.FindControl("Passengers") as Repeater;
                if (Passengers != null)
                {
                    foreach (RepeaterItem repeaterItem in Passengers.Items)
                    {
                        var txtReate = repeaterItem.FindControl("Reate") as TextBox;
                        var txtFee   = repeaterItem.FindControl("Fee") as TextBox;
                        var voyage   = repeaterItem.FindControl("Voyage") as HiddenField;
                        if (Validates(txtReate.Text.Trim()) && Validates(txtFee.Text.Trim()))
                        {
                            string[] voyageItems  = voyage.Value.Split('-');
                            var      flightVoyage = new AirportPair(voyageItems[0], voyageItems[1]);
                            result.Add(new RefundFeeView(flightVoyage, decimal.Parse(txtReate.Text.Trim()) / 100,
                                                         decimal.Parse(txtFee.Text.Trim())));
                        }
                    }
                }
            }
            return(result);
        }
Exemple #6
0
 internal bool IsSameVoyage(AirportPair airportPair)
 {
     if (airportPair == null)
     {
         return(false);
     }
     return(this.Departure.Code == airportPair.Departure && this.Arrival.Code == airportPair.Arrival);
 }
Exemple #7
0
 public Segment(string airlineCode, string internalNo, string cabinSeat, DateTime flightDate, AirportPair airportPair, int seatCount)
 {
     AirlineCode = airlineCode;
     InternalNo  = internalNo;
     CabinSeat   = cabinSeat;
     Date        = flightDate;
     AirportPair = airportPair;
     SeatCount   = seatCount;
 }
Exemple #8
0
 /// <summary>
 /// 建立航段组的航信指令
 /// </summary>
 /// <param name="flightNo">航班号</param>
 /// <param name="cabinSeat">舱位</param>
 /// <param name="flightDate">飞行日期</param>
 /// <param name="airport">机场对</param>
 /// <param name="seatCount">座位数</param>
 public SsCommand(string flightNo, string cabinSeat, DateTime flightDate, AirportPair airport, int seatCount)
 {
     _flightNo   = flightNo;
     _cabinSeat  = cabinSeat;
     _flightDate = flightDate;
     _airport    = airport;
     _seatCount  = seatCount;
     Initialize();
 }
Exemple #9
0
 /// <summary>
 /// 建立航段组的航信指令
 /// </summary>
 /// <param name="flightNo">航班号</param>
 /// <param name="cabinSeat">舱位</param>
 /// <param name="flightDate">飞行日期</param>
 /// <param name="airportPair">航程</param>
 /// <param name="seatCount">座位数</param>
 public SSCommand(string flightNo, string cabinSeat, DateTime flightDate, AirportPair airportPair, int seatCount)
 {
     this.flightNo    = flightNo;
     this.cabinSeat   = cabinSeat;
     this.flightDate  = flightDate;
     this.airportPair = airportPair;
     this.seatCount   = seatCount;
     Initialize();
 }
Exemple #10
0
        /// <summary>
        /// 获取指定航空公司下的某城市对的运价信息。
        /// </summary>
        /// <param name="airportPair">机场对</param>
        /// <param name="flightDate">航班时间</param>
        /// <param name="carrier">承运人</param>
        /// <param name="oemId">OEM编号</param>
        /// <returns>运价</returns>
        public static ExecuteResult <AirportPairFares> GetFare(AirportPair airportPair, DateTime flightDate, string carrier, Guid oemId)
        {
            const ConfigUseType type = ConfigUseType.Reserve;
            var userName             = GetUserName(oemId, type);

            var repository = Factory.CreateCommandRepository();

            return(repository.Fd(airportPair, flightDate, carrier, userName));
        }
Exemple #11
0
        public ExecuteResult <AirportPairFares> Fd(AirportPair airportPair, DateTime date, string carrier, string userName)
        {
            var veService = new veSWScnService();

            veService.Url = ReplaceUrl(veService.Url);
            var returnString = veService.FD(airportPair.ToString(), date.ToString("ddMMMyy", CultureInfo.CreateSpecificCulture("en-US")), carrier, "0", userName);
            var rawData      = returnString;

            // 解析命令执行后的结果字串;
            var result = Domain.Utility.Parser.GetFare(rawData);

            // 根据解析结果返回
            return(new ExecuteResult <AirportPairFares>
            {
                Result = result,
                Success = result != null,
                Message = rawData
            });
        }
Exemple #12
0
        public ExecuteResult <AirportPairFares> Fd(AirportPair airportPair, DateTime date, string carrier,
                                                   string userName)
        {
            // 构建命令并执行;
            var fdCommand    = new FdCommand(airportPair, date, carrier);
            var user         = new User("8000", "123");
            var returnString = CommandExecutorService.Execute(fdCommand, user);
            var xdoc         = XDocument.Parse(returnString, LoadOptions.None);
            var rawData      = GetRawDate(xdoc, "FD");

            // 解析命令执行后的结果字串;
            var result = Domain.Utility.Parser.GetFare(rawData);

            // 根据解析结果返回
            return(new ExecuteResult <AirportPairFares>
            {
                Result = result,
                Success = result != null,
                Message = rawData
            });
        }
Exemple #13
0
 internal bool ContainsFlight(AirportPair airportPair)
 {
     return(GetFlight(airportPair) != null);
 }
Exemple #14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="pnrContent"></param>
        /// <returns></returns>
        public static IssuedPNR GetPNRDetail(string pnrContent)
        {
            IssuedPNR issuedPNR = null;
            string    tempStr   = null;

            //将已经出过票的信息出票信息替换掉;
            pnrContent = pnrContent.Replace("  **ELECTRONIC TICKET PNR** ;", "");

            // 取得第一行;
            Regex pattern = new Regex(RegexUtil.CodeLineRegex);
            Match match   = pattern.Match(pnrContent);

            if (!match.Success)
            {
                if (IsCanceledPNR(pnrContent))
                {
                    issuedPNR            = new IssuedPNR();
                    issuedPNR.IsCanceled = true;
                }
                return(issuedPNR);
            }
            else
            {
                issuedPNR            = new IssuedPNR();
                issuedPNR.IsCanceled = false;
                tempStr = match.Captures[0].Value;
            }

            issuedPNR.IsTeam = GetPassengerConsistsType(pnrContent) == PassengerConsistsType.Group;
            if (issuedPNR.IsTeam)
            {
                pattern = new Regex(RegexUtil.TeamRegex);
                match   = pattern.Match(pnrContent);
                issuedPNR.NumberOfTerm = int.Parse(match.Groups["ActualNumber"].Value);
            }
            else
            {
                // 如果是非团队,去空格后去掉最后的编码部分;
                tempStr = tempStr.Trim();
                tempStr = Regex.Replace(tempStr, RegexUtil.PNRCodeRegex + @"$", "");
            }

            issuedPNR.Code = GetPnrPair(pnrContent);

            #region  称组
            pattern = new Regex(RegexUtil.NMCmdRegex);
            tempStr = Regex.Replace(tempStr, @"(\s{1,})?;", "");
            MatchCollection matchCollection = pattern.Matches(tempStr);
            if (matchCollection.Count > 0)
            {
                issuedPNR.Passenges = new Dictionary <int, Passenger>();
                foreach (Match item in matchCollection)
                {
                    Passenger passenger  = new Passenger();
                    int       lineNumber = int.Parse(item.Groups["LineNumber"].Value);
                    passenger.Name = item.Groups["Name"].Value;
                    passenger.Type = (item.Groups["PassengerType"].Value == "CHD") ? PassengerType.Child : PassengerType.Adult;
                    issuedPNR.Passenges.Add(lineNumber, passenger);
                }
            }
            else
            {
                throw new CustomException("编码内容错误,姓名项不存在!");
            }
            #endregion

            #region 航段
            pattern         = new Regex(RegexUtil.SSCmdRegex);
            matchCollection = pattern.Matches(pnrContent);
            if (matchCollection.Count > 0)
            {
                issuedPNR.Segments = new Dictionary <int, Segment>();

                foreach (Match item in matchCollection)
                {
                    int     id      = int.Parse(item.Groups["LineNumber"].Value);
                    Segment segment = new Segment();
                    segment.AirlineCode         = item.Groups["AirlineCode"].Value;
                    segment.InternalNo          = item.Groups["FlightNo"].Value;
                    segment.CabinSeat           = item.Groups["CabinSeat"].Value;
                    segment.AirportPair         = new AirportPair(item.Groups["Departure"].Value, item.Groups["Arrival"].Value);
                    segment.Date                = DateTime.Parse(item.Groups["Day"].Value + item.Groups["Month"].Value, new CultureInfo("en-US"));
                    segment.Status              = item.Groups["SeatStatus"].Value;
                    segment.SeatCount           = int.Parse(item.Groups["SeatCount"].Value);
                    segment.IsETicket           = (item.Groups["ETicketFlag"].Value == "E");
                    segment.AircraftType        = item.Groups["AircraftType"].Value;
                    segment.IsShared            = (item.Groups["IsShared"].Value == "*");
                    segment.TerminalOfArrival   = item.Groups["TerminalOfArrival"].Value;
                    segment.TerminalOfDeparture = item.Groups["TerminalOfDeparture"].Value;

                    string extendedInfo = item.Groups["ExtendedInformation"].Value;

                    //转出来的日期,默认是当年的,如果跨年,则加一;
                    if (segment.Date < DateTime.Today)
                    {
                        segment.Date = segment.Date.AddYears(1);
                    }

                    //出发时间有可能为OPEN,此时时间不赋值;
                    string departureTime = item.Groups["DepartureTime"].Value;
                    if (departureTime != "OPEN")
                    {
                        int hour   = int.Parse(departureTime.Substring(0, 2));
                        int minute = int.Parse(departureTime.Substring(2, 2));
                        segment.DepartureTime = new Time(hour, minute);
                    }
                    // 到达时间有可能为OPEN,此时时间不赋值,同时注意,到达时间有可能跨天;
                    string ArrivalTime = item.Groups["ArrivalTime"].Value;
                    //先取下是否跨天;
                    string days = item.Groups["AddDays"].Value;
                    segment.AddDays = string.IsNullOrWhiteSpace(days) ? 0 : int.Parse(days);
                    if (departureTime != "OPEN")
                    {
                        int hour   = int.Parse(ArrivalTime.Substring(0, 2));
                        int minite = int.Parse(ArrivalTime.Substring(2, 2));
                        segment.ArrivalTime = new Time(hour, minite);
                    }

                    // 对扩展信息的处理,没有用正则;
                    // 2.  8L9933 M   WE14NOV  KMGLUM HK1   1310 1405      E      M1
                    // 6. *MU9287 V   TH22NOV  TSNKMG RR5   1710 2030      E      OP-FM9287
                    Match extendedMatch;
                    if (!string.IsNullOrEmpty(extendedInfo.Trim()) && (extendedMatch = Regex.Match(extendedInfo.Trim(), @"^(?<CabinSeat>[A-Z]\d)$")).Success)
                    {
                        segment.CabinSeat = extendedMatch.Groups["CabinSeat"].Value;
                    }

                    issuedPNR.Segments.Add(id, segment);
                }
            }
            #endregion

            #region 行程类型
            // 获取一个按照飞行时间排序的列表
            var voyages = issuedPNR.Segments.OrderBy(s => s.Value.Date).Select(s => s.Value.AirportPair).ToList();

            issuedPNR.ItineraryType = GetItineraryType(voyages);
            #endregion

            #region 缺口程搭桥信息处理
            if (issuedPNR.ItineraryType == ItineraryType.Notch)
            {
                // 生成一个包含搭桥信息的键值列表;
                Dictionary <int, AirportPair> temp = issuedPNR.Segments.OrderBy(s => s.Value.Date).Select(s => s).ToDictionary(s => s.Key, s => s.Value.AirportPair);
                pattern         = new Regex(RegexUtil.SARegex);
                matchCollection = pattern.Matches(pnrContent);
                foreach (Match item in matchCollection)
                {
                    int         key         = int.Parse(item.Groups["LineNumber"].Value);
                    AirportPair airportPair = new AirportPair(item.Groups["Departure"].Value, item.Groups["Arrival"].Value);
                    temp.Add(key, airportPair);
                }
                voyages = temp.OrderBy(s => s.Key).Select(s => s.Value).ToList();

                // 判断搭桥后的行程是否连续;
                issuedPNR.IsFilled = IsContinuousVoyages(voyages);
            }
            else
            {
                issuedPNR.IsFilled = false;
            }
            #endregion

            #region 票号
            pattern         = new Regex(RegexUtil.PNRTicketsRegex);
            matchCollection = pattern.Matches(pnrContent);
            if (matchCollection.Count > 0)
            {
                issuedPNR.TicketNumbers = new Dictionary <int, string>();

                foreach (Match item in matchCollection)
                {
                    int    lineNumber   = int.Parse(item.Groups["LineNumber"].Value);
                    int    key          = int.Parse(item.Groups["PassengerId"].Value);
                    string ticketNumber = item.Groups["TicketNumber"].Value;
                    if (issuedPNR.Passenges[key].TicketNumbers == null)
                    {
                        issuedPNR.Passenges[key].TicketNumbers = new List <string>();
                    }
                    issuedPNR.Passenges[key].TicketNumbers.Add(ticketNumber);
                    issuedPNR.TicketNumbers.Add(lineNumber, ticketNumber);
                }
            }
            #endregion

            #region 特殊信息
            pattern         = new Regex(RegexUtil.SSRCmdRegex);
            matchCollection = pattern.Matches(pnrContent);
            if (matchCollection.Count > 0)
            {
                issuedPNR.CertificateNumbers = new Dictionary <int, string>();
                foreach (Match item in matchCollection)
                {
                    int    lineNumber        = int.Parse(item.Groups["LineNumber"].Value);
                    int    key               = int.Parse(item.Groups["PassengerId"].Value);
                    string certificateNumber = item.Groups["CertificateNumber"].Value;
                    issuedPNR.Passenges[key].CertificateNumber = certificateNumber;
                    issuedPNR.CertificateNumbers.Add(lineNumber, certificateNumber);
                }
            }

            // 南航儿童票处理
            pattern         = new Regex(RegexUtil.CZChildSSRRegex);
            matchCollection = pattern.Matches(pnrContent);
            if (issuedPNR.Segments.First().Value.AirlineCode == "CZ" && matchCollection.Count > 0)
            {
                foreach (Match item in matchCollection)
                {
                    int key = int.Parse(item.Groups["PassengerId"].Value);
                    issuedPNR.Passenges[key].Type = PassengerType.Child;
                }
            }


            #endregion

            #region 票价组
            pattern = new Regex(RegexUtil.PriceRegExp);
            match   = pattern.Match(pnrContent);
            if (match.Success)
            {
                issuedPNR.Price      = new PriceView();
                issuedPNR.Price.Fare = decimal.Parse(match.Groups["Fare"].Value);
                if (!string.IsNullOrEmpty(match.Groups["AirportTax"].Value))
                {
                    issuedPNR.Price.AirportTax = decimal.Parse(match.Groups["AirportTax"].Value);
                }
                else
                {
                    issuedPNR.Price.AirportTax = 0;
                }

                issuedPNR.Price.BunkerAdjustmentFactor = decimal.Parse(match.Groups["BunkerAdjustmentFactor"].Value);
                issuedPNR.Price.Total = decimal.Parse(match.Groups["Total"].Value);
            }
            #endregion

            #region 联系组
            pattern         = new Regex(RegexUtil.CTCmdRegex);
            matchCollection = pattern.Matches(pnrContent);
            if (matchCollection.Count > 0)
            {
                issuedPNR.ContractInformations = new Dictionary <int, string>();
                foreach (Match item in matchCollection)
                {
                    int    lineNumber  = int.Parse(item.Groups["LineNumber"].Value);
                    string phoneNumber = item.Groups["PhoneNumber"].Value;
                    issuedPNR.ContractInformations.Add(lineNumber, phoneNumber);
                }
            }
            #endregion

            #region 特殊服务组
            pattern         = new Regex(RegexUtil.OSICmdRegex);
            matchCollection = pattern.Matches(pnrContent);
            if (matchCollection.Count > 0)
            {
                int ctctCount = 0;
                foreach (Match item in matchCollection)
                {
                    if (item.Groups["OSIType"].Value == "CTCT")
                    {
                        ctctCount++;
                        // 这个是防止用户多输内容
                        if (ctctCount > issuedPNR.Passenges.Count)
                        {
                            break;
                        }
                        int    lineNumber  = int.Parse(item.Groups["LineNumber"].Value);
                        string mobilephone = item.Groups["PassengerInformation"].Value;
                        //有可能操作时不书写用户对应编号,即如下格式:
                        //7.OSI MU CTCT 13529033863,而非7.OSI MU CTCT 13529033863/P1
                        if (!string.IsNullOrEmpty(item.Groups["PassengerId"].Value))
                        {
                            int key = int.Parse(item.Groups["PassengerId"].Value);
                            issuedPNR.Passenges[key].Mobilephone = mobilephone;
                        }
                        else
                        {
                            //给默认值,以循环计数器为默认值,即依次赋值;
                            issuedPNR.Passenges[ctctCount].Mobilephone = mobilephone;
                        }
                    }
                    else if (item.Groups["OSIType"].Value == "CTC")
                    {
                        int    lineNumber  = int.Parse(item.Groups["LineNumber"].Value);
                        string phoneNumber = item.Groups["PassengerInformation"].Value;

                        if (issuedPNR.ContractInformations == null)
                        {
                            issuedPNR.ContractInformations = new Dictionary <int, string>();
                        }

                        issuedPNR.ContractInformations.Add(lineNumber, phoneNumber);
                    }
                    else
                    {
                    }
                }
            }
            #endregion

            return(issuedPNR);
        }
Exemple #15
0
 internal Flight GetFlight(AirportPair airportPair)
 {
     return(_flights.FirstOrDefault(item => item.IsSameVoyage(airportPair)));
 }
Exemple #16
0
 public bool IsSameRoute(AirportPair pair)
 {
     return((First.City == pair.First.City && Second.City == pair.Second.City) || (First.City == pair.Second.City && Second.City == pair.First.City));
 }
Exemple #17
0
 public RefundFeeView(AirportPair airportPair, decimal rate, decimal fee)
 {
     this.AirportPair = airportPair;
     this.Rate        = rate;
     this.Fee         = fee;
 }