Beispiel #1
0
        // 航假/小三通班次時刻表
        public static List <TrafficTimeTableModel> GetApkgTimeTable(BookingModel booking, List <TrafficSectorCostModel> sectors)
        {
            List <TrafficTimeTableModel> time_table = new List <TrafficTimeTableModel>();

            try
            {
                DateTime s_date = booking.S_DATE;
                foreach (var sec_item in sectors)
                {
                    //成本與搭乘限制
                    DataSet dtl_ds = LimitDAL.GetTrafficCostDtl(sec_item.TRAFFIC_COST_PRICE_XID, sec_item.TRAFFIC_XID, sec_item.TRAFFIC_COST_XID, s_date.ToString("yyyyMMdd"));

                    //所有交通班次
                    DataSet time_ds = TrainDAL.GetTimeTable(booking.Product.PROD_NO, s_date.ToString("yyyyMMdd"), sec_item.FORWARD_FLAG, sec_item.DEP_FROM, sec_item.ARR_TO);
                    foreach (DataRow dr in time_ds.Tables[0].Rows)
                    {
                        bool chk = false;

                        //過濾交通限制
                        if (dtl_ds.Tables[0].Rows.Count != 0)
                        {
                            chk = FilterTraffic(s_date, dr.ToStringEx("S_TIME"), dr.ToStringEx("FLY_NO"), sec_item, dtl_ds.Tables[0]);
                        }
                        else
                        {
                            chk = true;
                        }                                            //沒有限制

                        //通過過濾規則放入時刻表
                        if (chk)
                        {
                            time_table.Add(new TrafficTimeTableModel()
                            {
                                S_DATE       = s_date.AddDays(sec_item.ADD_DAY),
                                FLY_NO       = dr.ToStringEx("FLY_NO"),
                                FORWARD_FLAG = sec_item.FORWARD_FLAG,
                                SECTOR       = sec_item.SECTOR,

                                DEP_FROM      = dr.ToStringEx("DEP_FROM"),
                                DEP_FROM_NAME = dr.ToStringEx("DEP_FROM_NAME"),
                                ARR_TO        = dr.ToStringEx("ARR_TO"),
                                ARR_TO_NAME   = dr.ToStringEx("ARR_TO_NAME"),

                                DEP_FROM_TIME = dr.ToStringEx("S_TIME").Insert(2, ":"),
                                ARR_TO_TIME   = dr.ToStringEx("E_TIME").Insert(2, ":"),

                                SEAT_COUNT = dr.ToStringEx("QTY_KK")
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Website.Instance.logger.FatalFormat("{0},{1}", ex.Message, ex.StackTrace);
            }

            return(time_table);
        }
Beispiel #2
0
        // 查詢系統已設置航班時刻
        public static List <TrafficTimeTableModel> QueryTimeTable(string prod_no, DateTime s_date, DateTime?e_date, List <TrafficSectorCostModel> sectors)
        {
            List <TrafficTimeTableModel> time_tables = new List <TrafficTimeTableModel>();

            try
            {
                if (sectors.Count() < 1)
                {
                    return(time_tables);
                }

                foreach (var sec_item in sectors)
                {
                    //成本與搭乘限制
                    DataSet dtl_ds = LimitDAL.GetTrafficCostDtl(sec_item.TRAFFIC_COST_PRICE_XID, sec_item.TRAFFIC_XID, sec_item.TRAFFIC_COST_XID, s_date.ToString("yyyyMMdd"));

                    // 確認最後使用出發日
                    DateTime dept_date = s_date.AddDays(sec_item.ACCUM_ADD_DAY);

                    //所有航段班次
                    DataSet time_ds = (sec_item.TRAFFIC_TYPE == "0002") ?                      // 除高鐵外, 其它依系統指定
                                      ThsrDAL.GetTimeTable(prod_no,
                                                           dept_date.ToString("yyyyMMdd"),
                                                           sec_item.FORWARD_FLAG,
                                                           sec_item.DEP_FROM,
                                                           sec_item.ARR_TO) :
                                      TrainDAL.GetTimeTable(prod_no,                                           // 除航假只給 s_date 外, 其它一律會帶 s_date 與 e_date
                                                            (sec_item.FORWARD_FLAG == "1" ? dept_date : (e_date.HasValue ? e_date.Value.AddDays(sec_item.ACCUM_ADD_DAY) : s_date)).ToString("yyyyMMdd"),
                                                            sec_item.FORWARD_FLAG,
                                                            sec_item.DEP_FROM,
                                                            sec_item.ARR_TO);

                    foreach (DataRow dr in time_ds.Tables[0].Rows)
                    {
                        bool chk = false;

                        //過濾交通限制
                        if (dtl_ds.Tables[0].Rows.Count != 0)
                        {
                            chk = (sec_item.TRAFFIC_TYPE == "0002") ?
                                  FilterTraffic(s_date, dr.ToStringEx("DEP_TIME"), dr.ToStringEx("TRAIN"), sec_item, dtl_ds.Tables[0]) :
                                  FilterTraffic(s_date, dr.ToStringEx("S_TIME"), dr.ToStringEx("FLY_NO"), sec_item, dtl_ds.Tables[0]);
                        }
                        else
                        {
                            chk = true;
                        }                                            //沒有限制

                        //通過過濾規則放入時刻表
                        if (chk)
                        {
                            DateTime work_date = sec_item.FORWARD_FLAG.Equals("1") ? s_date : ((e_date.HasValue) ? e_date.Value : s_date);

                            if (sec_item.TRAFFIC_TYPE == "0002")
                            {
                                time_tables.Add(new TrafficTimeTableModel()
                                {
                                    S_DATE       = s_date.AddDays(sec_item.ADD_DAY),
                                    FLY_NO       = dr.ToStringEx("TRAIN"),
                                    FORWARD_FLAG = sec_item.FORWARD_FLAG,
                                    SECTOR       = sec_item.SECTOR,

                                    DEP_FROM      = dr.ToStringEx("DEP_STATION_NO"),
                                    DEP_FROM_NAME = dr.ToStringEx("DEP_STATION_NAME"),
                                    ARR_TO        = dr.ToStringEx("ARR_STATION_NO"),
                                    ARR_TO_NAME   = dr.ToStringEx("ARR_STATION_NAME"),

                                    DEP_FROM_TIME = dr.ToStringEx("DEP_TIME").Insert(2, ":"),
                                    ARR_TO_TIME   = dr.ToStringEx("ARR_TIME").Insert(2, ":"),

                                    SEAT_COUNT = dr.ToStringEx("QTY_KK"),
                                    CAN_HL     = sec_item.FLY_HL_FLAG.Equals("1") ? true : false,

                                    CARRIER_CODE = sec_item.CARRIER_CODE,
                                    CARRIER_NAME = sec_item.CARRIER_CODE_NAME,

                                    TOKEN_DATA = string.Format("{0:yyyyMMdd},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", work_date.AddDays(sec_item.ACCUM_ADD_DAY),
                                                               sec_item.FORWARD_FLAG, sec_item.TRAFFIC_XID, sec_item.TRAFFIC_COST_XID, sec_item.DEP_FROM,
                                                               sec_item.ARR_TO, dr.ToStringEx("TRAIN"), dr.ToStringEx("DEP_TIME").Insert(2, ":"), dr.ToStringEx("ARR_TIME").Insert(2, ":"),
                                                               dr.ToStringEx("QTY_KK"), "", "")
                                });
                            }
                            else
                            {
                                time_tables.Add(new TrafficTimeTableModel()
                                {
                                    S_DATE       = s_date.AddDays(sec_item.ADD_DAY),
                                    FLY_NO       = dr.ToStringEx("FLY_NO"),
                                    FORWARD_FLAG = sec_item.FORWARD_FLAG,
                                    SECTOR       = sec_item.SECTOR,

                                    DEP_FROM      = dr.ToStringEx("DEP_FROM"),
                                    DEP_FROM_NAME = dr.ToStringEx("DEP_FROM_NAME"),
                                    ARR_TO        = dr.ToStringEx("ARR_TO"),
                                    ARR_TO_NAME   = dr.ToStringEx("ARR_TO_NAME"),

                                    DEP_FROM_TIME = dr.ToStringEx("S_TIME").Insert(2, ":"),
                                    ARR_TO_TIME   = dr.ToStringEx("E_TIME").Insert(2, ":"),

                                    SEAT_COUNT = dr.ToStringEx("QTY_KK"),
                                    CAN_HL     = sec_item.FLY_HL_FLAG.Equals("1") ? true : false,

                                    CARRIER_CODE = sec_item.CARRIER_CODE,
                                    CARRIER_NAME = (sec_item.TRAFFIC_TYPE == "0003") ? sec_item.CARRIER_NAME : string.Format("{0},{1},{2}艙", sec_item.CARRIER_CODE, sec_item.CARRIER_NAME, sec_item.BOOKING_CLASS),

                                    TOKEN_DATA = string.Format("{0:yyyyMMdd},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}", work_date.AddDays(sec_item.ACCUM_ADD_DAY),
                                                               sec_item.FORWARD_FLAG, sec_item.TRAFFIC_XID, sec_item.TRAFFIC_COST_XID, sec_item.DEP_FROM,
                                                               sec_item.ARR_TO, dr.ToStringEx("FLY_NO"), dr.ToStringEx("S_TIME").Insert(2, ":"), dr.ToStringEx("E_TIME").Insert(2, ":"),
                                                               dr.ToStringEx("QTY_KK"), "", "")
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(time_tables);
        }
Beispiel #3
0
        ///////////////////////

        #region 班次時刻表

        // 取得航班時刻表
        //public static List<TrafficTimeTableModel> GetApkgTimeTable(string prod_no, DateTime s_date, string carrier_code, int total_psg)//, bool IsAEOneWayForce = false)
        //{
        //	List<TrafficTimeTableModel> time_tables = new List<TrafficTimeTableModel>();

        //	try
        //	{
        //		// 列出有關航假航段內容
        //		var apkg_sectors = sectors.Where(s => s.TRAFFIC_TYPE == "0001" && GetQtyTypeRule(s.CARRIER_CODE) == "CRS").ToList();
        //		time_tables.AddRange(QueryCrsTimeTable(carrier_code, s_date, apkg_sectors, total_psg));

        //		// 非航假航段內容
        //		var other_sectors = sectors.Where(s => !apkg_sectors.Contains(s)).ToList();
        //		time_tables.AddRange(QueryTimeTable(prod_no, s_date, null, other_sectors));
        //	}
        //	catch (Exception ex)
        //	{
        //		Website.Instance.logger.FatalFormat("{0},{1}", ex.Message, ex.StackTrace);
        //	}

        //	return time_tables;
        //}

        // 查詢 DPKG CRS, 取得航班時刻
        protected static List <TrafficTimeTableModel> QueryCrsTimeTable(DateTime s_date, DateTime e_date, TrafficSectorModel sector, int total_psg)       //(string carrier_code, DateTime S_DATE, string cityfrom, string cityto, int total_psg)
        {
            List <TrafficTimeTableModel> time_tables = new List <TrafficTimeTableModel>();

            try
            {
                var soapClients = Website.Instance.Configuration.GetSection("SoapClient");
                var binding     = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
                {
                    MaxReceivedMessageSize = Int32.MaxValue
                };
                var ep = new EndpointAddress(soapClients["WS_DPKG_CRS"]);
                WS_DPKG_CRS.CrsServiceSoapClient crs_service = new WS_DPKG_CRS.CrsServiceSoapClient(binding, ep);

                Request_GetAv reqGetAv = new Request_GetAv();
                reqGetAv.CrsSystem = sector.CARRIER_CODE.Equals("B7") ? CrsSystemOption.B7 : sector.CARRIER_CODE.Equals("AE") ? CrsSystemOption.AE : CrsSystemOption.GE;
                if (sector.CARRIER_CODE == "AE")
                {
                    reqGetAv.Rule_Type = sector.RULE_TYPE;
                }

                List <Segment> dep_seg = new List <Segment>();


                dep_seg.Add(new Segment()
                {
                    Airline  = sector.CARRIER_CODE,
                    TripFlag = sector.FORWARD_FLAG,

                    DepartureDate    = e_date.ToString("yyyyMMdd"),
                    DepartureTime    = "0000",
                    DepartureAirport = sector.DEP_FROM,

                    ArrivalDate      = s_date.ToString("yyyyMMdd"),
                    ArrivalTime      = "2359",
                    ArrivalAirport   = sector.ARR_TO,
                    BookingSeatCount = total_psg
                });



                List <Itinerary> _Itinerary = new List <Itinerary>();
                _Itinerary.Add(new Itinerary()
                {
                    Segment = dep_seg.ToArray()
                });

                reqGetAv.Itinerary = _Itinerary.ToArray();

                // 詢問CRSGW有效位控
                string xmlResp = GetAvTask(crs_service, XMLTool.XMLSerialize(reqGetAv)).Result;


                Response_GetAv respGetAv = new Response_GetAv();
                respGetAv = (Response_GetAv)XMLTool.XMLDeSerialize(xmlResp, respGetAv.GetType().ToString());

                var sel_segs = respGetAv.AvItinerary.Where(s => s.Segments != null && s.Segments.Count() > 0).SelectMany(s => s.Segments);

                // 產出 Time Table
                foreach (var seg in sel_segs)
                {
                    foreach (var item in seg.Segment)
                    {
                        var      sec       = sector.Where(s => s.DEP_FROM.Equals(item.DepartureAirport) && s.ARR_TO.Equals(item.ArrivalAirport)).FirstOrDefault();
                        DateTime dept_date = DateTime.ParseExact(item.DepartureDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                        //DateTime arrv_date = DateTime.ParseExact(item.ArrivalDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);

                        //成本與搭乘限制
                        DataSet dtl_ds = LimitDAL.GetTrafficCostDtl(sector.TRAFFIC_COST_PRICE_XID, sector.TRAFFIC_XID, sector.TRAFFIC_COST_XID, S_DATE.ToString("yyyyMMdd"));

                        int nInvalidRules = 0;                         //未符合規則計數, 0: 通過

                        //過濾交通限制
                        if (dtl_ds.Tables[0].Rows.Count != 0)
                        {
                            // 檢查是否指定使用 FAIR_BASIS
                            var sel_fair_basis = dtl_ds.Tables[0].AsEnumerable().Where(r => !string.IsNullOrEmpty(r.Field <string>("FAIR_BASIS"))).Select(b => b.Field <string>("FAIR_BASIS")).Distinct().ToList();
                            if (sel_fair_basis.Count() > 0)
                            {
                                // 比對 FAIR_BASIS
                                if (sel_fair_basis.Where(f => f.Equals(item.FareBasis, StringComparison.InvariantCultureIgnoreCase)).Count() < 1)
                                {
                                    nInvalidRules++;                                     // 累計未符合規則
                                }
                            }

                            // 過濾無效航班規則
                            bool IsValidFlight = FilterTraffic(dr.ToDateTime("S_DATE"), item.DepartureTime.Replace(":", ""), item.FlightNumber, sector, dtl_ds.Tables[0]);
                            if (!IsValidFlight)
                            {
                                nInvalidRules++;                                             // 累計未符合規則
                            }
                        }

                        if (nInvalidRules == 0)
                        {
                            //var HL_FLAG = sector.FLY_HL_FLAG.Equals("0") ? false : true;
                            var HL_FLAG = sector.FLY_HL_FLAG;

                            // 通過過濾規則放入時刻表
                            time_tables.Add(new TrafficTimeTableModel()
                            {
                                S_DATE        = dept_date.ToString(),
                                FORWARD_FLAG  = item.TripFlag,
                                DEP_FROM_NAME = sector.DEP_FROM_NAME,
                                DEP_FROM      = item.DepartureAirport,
                                ARR_TO_NAME   = sector.ARR_TO_NAME,
                                ARR_TO        = item.ArrivalAirport,
                                FLY_NO        = item.FlightNumber,
                                DEP_FROM_TIME = item.DepartureTime,
                                ARR_TO_TIME   = item.ArrivalTime,
                                BOOKING_CLASS = item.BookingClass,
                                SEAT_COUNT    = item.BookingSeatCount.Value,
                                FARE_BASIS    = item.FareBasis,
                                CAN_HL        = HL_FLAG
                            });
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(time_tables);
        }