Esempio n. 1
0
        public PnrObject Format()
        {
            var lines    = getPnrLines();
            var analyzer = new NameAnalyzer();

            IAnalyzer[] analyzers = { new SkywayAnalyzer(),  new IDCardAnalyzer(), new TelAnalyzer(), new TicketNumAnalyzer(),
                                      new BigCodeAnalyzer(), new OfficeAnalyzer() };

            PnrObject obj = new PnrObject();

            obj.PnrType = lines.Item2;
            foreach (var pnrline in lines.Item1)
            {
                if (string.IsNullOrEmpty(obj.Pnr))
                {
                    analyzer.Analyze(obj, pnrline);
                    continue;
                }
                var oa = analyzers.Where(p => p.CanAnalyze(pnrline)).FirstOrDefault();
                if (oa != null)
                {
                    oa.Analyze(obj, pnrline);
                }
            }

            PatAnalyzer pat = new PatAnalyzer();

            pat.Analyzer(obj, pnrPat);


            return(obj);
        }
Esempio n. 2
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = skyWay.Match(pnrLine);

            if (mc.Success)
            {
                string Seat      = mc.Groups["set"].Value;
                string childSeat = string.Empty;
                string other     = mc.Groups["other"].Value;
                if (other.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries).Contains(Seat + "1"))
                {
                    childSeat = Seat + "1";
                }
                pnrObject.Skyways.Add(new PnrSkyway()
                {
                    FlightNo     = mc.Groups["fn"].Value,
                    FormCode     = mc.Groups["c"].Value.Substring(0, 3),
                    FormTerminal = Units.GetFTerminal(mc.Groups["tm"].Value),
                    Seat         = mc.Groups["set"].Value,
                    ToCode       = mc.Groups["c"].Value.Substring(3, 3),
                    ToTerminal   = Units.GetTTerminal(mc.Groups["tm"].Value),
                    FormTime     = Units.GetDateTime(mc.Groups["t"].Value, mc.Groups["ft"].Value),
                    ToTime       = Units.GetDateTime(mc.Groups["t"].Value, mc.Groups["et"].Value),
                    SkyState     = mc.Groups["state"].Value,
                    ChildSeat    = childSeat
                });
            }
        }
Esempio n. 3
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            Match mc;

            mc = nameAndPnrExp.Match(pnrLine);
            if (mc.Success)
            {
                pnrObject.Pnr = mc.Groups["pnr"].Value.Trim();
            }
            else
            {
                mc = nameExp.Match(pnrLine);
            }
            var passengerName = mc.Groups["name"].Value.Trim();
            var passenger     = new Passenger();

            passenger.Id            = mc.Groups["id"].Value;
            passenger.Name          = passengerName;
            passenger.PassengerType = EnumPassengerType.ADU;
            if (passengerName.EndsWith("CHD"))
            {
                passenger.Name          = passengerName.Substring(0, passengerName.Length - 3);
                passenger.PassengerType = EnumPassengerType.CHD;
            }

            pnrObject.Passengers.Add(passenger);
        }
Esempio n. 4
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = officeReg.Match(pnrLine);

            if (mc.Success)
            {
                pnrObject.Office = mc.Groups["of"].Value;
            }
        }
Esempio n. 5
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = bigCodeReg.Match(pnrLine);

            if (mc.Success)
            {
                pnrObject.BigPnr = mc.Groups["bc"].Value;
            }
        }
Esempio n. 6
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = tnReg.Match(pnrLine);

            if (mc.Success)
            {
                var i         = mc.Groups["in"].Value;
                var passenger = pnrObject.Passengers.FirstOrDefault(p => p.Id == i);
                if (passenger != null)
                {
                    passenger.TicketNum = mc.Groups["tn"].Value;
                }
            }
        }
Esempio n. 7
0
        public void Analyzer(PnrObject obj, string patContext)
        {
            var ms = patReg.Matches(patContext);

            foreach (Match m in ms)
            {
                obj.Pats.Add(new PatObject()
                {
                    FARE  = Units.GetPrice(m.Groups["fa"].Value),
                    TAX   = Units.GetPrice(m.Groups["t"].Value),
                    TOTAL = Units.GetPrice(m.Groups["to"].Value),
                    YQ    = Units.GetPrice(m.Groups["y"].Value)
                });
            }
        }
Esempio n. 8
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = babyReg.Match(pnrLine);

            if (mc.Success)
            {
                var i = mc.Groups["YinerName"].Value;
                pnrObject.Passengers.Add(new Passenger
                {
                    Name          = i,
                    Id            = string.Format("P{0}", mc.Groups["Num"].Value),
                    PassengerType = EnumPassengerType.BABY
                });
            }
        }
Esempio n. 9
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = bornReg.Match(pnrLine);

            if (mc.Success)
            {
                var i         = mc.Groups["in"].Value;
                var passenger = pnrObject.Passengers.FirstOrDefault(p => p.Id == i);
                if (passenger != null)
                {
                    passenger.BornDay       = mc.Groups["no"].Value;
                    passenger.PassengerType = EnumPassengerType.CHD;
                }
            }
        }
Esempio n. 10
0
        public void Analyze(PnrObject pnrObject, string pnrLine)
        {
            var mc = babyCarNoReg.Match(pnrLine);

            if (mc.Success)
            {
                var i         = string.Format("P{0}", mc.Groups["Num"].Value);
                var passenger = pnrObject.Passengers.FirstOrDefault(p => p.PassengerType == EnumPassengerType.BABY && p.Id == i && mc.Groups["YingerName"].Value.Replace("/", "").Equals(PinYingMange.GetSpellByChinese(p.Name)));
                if (passenger != null)
                {
                    passenger.BornDay = mc.Groups["YinerBirthday"].Value;
                }
                else
                {
                    pnrObject.Passengers.Add(new Passenger
                    {
                        Id            = i,
                        PassengerType = EnumPassengerType.BABY,
                        Name          = mc.Groups["YinerName"].Value.Trim(),
                        BornDay       = mc.Groups["YinerBirthday"].Value.Trim()
                    });
                }
            }
        }