示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        from    = Request.QueryString["from"];
        to      = Request.QueryString["to"];
        airline = Request.QueryString["airline"];

        AiFeiService  afs    = new AiFeiService();
        FeiYingFlight flight = afs.getFlightMsg2(from, to, airline, string.Empty);

        //没有数据
        if (flight == null)
        {
            Response.Write("false");
            Response.End();
            return;
        }

        Response.Write(flight.airplan);
        Response.End();
    }
    protected void GetAiFeiTickets()
    {
        //获得页面参数
        string dpt    = "";
        string arr    = "";
        string toTime = "";
        string reTime = "";
        string cate   = "";

        //出发城市
        if (fromCity.SelectedValue != "" && fromCity.SelectedValue != "0")
        {
            //获得出发城市三字码
            string  cityCodeSql = "select cityCode from FY_FromCity where fId='" + fromCity.SelectedValue + "'";
            DataSet dsCityCode  = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, cityCodeSql);
            if (dsCityCode != null)
            {
                dpt = dsCityCode.Tables[0].Rows[0]["cityCode"].ToString();
            }
        }
        else
        {
            return;
        }

        //目的城市
        if (txtSearch_tocity.Value.Trim() != "")
        {
            //获得目的城市三字码
            arr = txtSearch_tocity.Value.Trim().Substring(0, 3);
        }
        else
        {
            return;
        }

        //获得出发时间
        if (fromtripDate_more.Value.Trim() != "")
        {
            toTime = fromtripDate_more.Value.Trim().Replace("-", "");
        }
        else
        {
            return;
        }

        //获得到达时间
        if (totripDate_more.Value.Trim() != "")
        {
            reTime = totripDate_more.Value.Trim().Replace("-", "");
        }
        else
        {
            return;
        }

        //获得客票类型
        if (cateSelect.Value.Trim() != "")
        {
            cate = cateSelect.Value.Trim();
        }
        else
        {
            return;
        }



        //请求客票
        AiFeiService aifeiService = new AiFeiService();

        ArrayList data    = aifeiService.GlobalTicket(dpt, arr, toTime, reTime, cate);
        ArrayList tickets = new ArrayList();

        //排序爱飞机票
        foreach (AiFeiTicketEntity orderTicket in data)
        {
            //过滤日期
            DateTime dt = Convert.ToDateTime(orderTicket.totripDate.Substring(0, 4) + "-" + orderTicket.totripDate.Substring(4, 2) + "-" + orderTicket.totripDate.Substring(6, 2));
            if ((dt - DateTime.Now).Days < 0)
            {
                continue;
            }

            //获取中转
            FeiYingFlight toFlight = aifeiService.getFlightMsg2(orderTicket.fromCity, orderTicket.toCity, orderTicket.airlineCode, "");
            if (toFlight != null)
            {
                if (string.IsNullOrEmpty(toFlight.relayPort))
                {
                    orderTicket.relayPort = "直飞";
                }
                else
                {
                    orderTicket.relayPort = ReadXmlHelper.GetAirPortNameByCode(toFlight.relayPort);
                }
            }
            if (tickets.Count == 0)
            {
                tickets.Add(orderTicket);
            }
            else
            {
                for (int i = 0; i < tickets.Count; i++)
                {
                    AiFeiTicketEntity aft = (AiFeiTicketEntity)tickets[i];

                    if (tickets.Count <= i + 1)
                    {
                        tickets.Add(orderTicket);
                        break;
                    }
                    else
                    {
                        AiFeiTicketEntity next = (AiFeiTicketEntity)tickets[i + 1];
                        if (Convert.ToDecimal(orderTicket.ticketPrice) > Convert.ToDecimal(aft.ticketPrice) && Convert.ToDecimal(orderTicket.ticketPrice) <= Convert.ToDecimal(next.ticketPrice))
                        {
                            tickets.Insert(i + 1, orderTicket);
                            break;
                        }
                    }
                }
            }
        }

        this.GetData           = tickets;
        rptshopnews.DataSource = tickets;
        rptshopnews.DataBind();
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["tId"] != null)
        {
            string tId = Request.QueryString["tId"];

            if (tId.IndexOf("aifei") == -1)
            {
                id        = Convert.ToInt32(Request.QueryString["tId"].ToString());
                ticketOne = GetTicketDetail(id);
            }
            else
            {
                string ticketNum = tId.Replace("aifei", "");
                //去爱飞查询机票详细信息
                AiFeiService    afs  = new AiFeiService();
                AiFeiTicketInfo afti = afs.TicketInfo(ticketNum);
                afti.engerTicket = "电子客票";
                afti.score       = "100";
                afti.zongping    = "3";
                afti.xiai        = "2";
                afti.xiaofei     = "4";
                afti.manyi       = "4";
                afti.fuwu        = "4";



                //出发  到达  航司  查询转机信息


                DataTable dt = new DataTable();

                dt.Columns.Add("fromCity");
                dt.Columns.Add("toCity");
                dt.Columns.Add("fromCityname");
                dt.Columns.Add("fromCityCode");
                dt.Columns.Add("toCityname");
                dt.Columns.Add("toCityCode");
                dt.Columns.Add("addtime");
                dt.Columns.Add("untaxPrice");
                dt.Columns.Add("tripType");
                dt.Columns.Add("tId");
                dt.Columns.Add("fAirportCode");
                dt.Columns.Add("fromPort");
                dt.Columns.Add("tAirportName");
                dt.Columns.Add("logoPic");
                dt.Columns.Add("airname");
                dt.Columns.Add("planNum");
                dt.Columns.Add("age");
                dt.Columns.Add("smallPic");
                dt.Columns.Add("bagPrice");
                dt.Columns.Add("engerTicket");
                dt.Columns.Add("seatShip");
                dt.Columns.Add("shortstayDate");
                dt.Columns.Add("attPrice");
                dt.Columns.Add("longstayDate");
                dt.Columns.Add("childPrice");
                dt.Columns.Add("fromsaleDate");
                dt.Columns.Add("tosaleDate");
                dt.Columns.Add("fromtripDate");
                dt.Columns.Add("totripDate");
                dt.Columns.Add("returnMoney");
                dt.Columns.Add("updateProvision");
                dt.Columns.Add("limitProvision");
                dt.Columns.Add("fAirportName");
                dt.Columns.Add("tAirportCode");
                dt.Columns.Add("toPort");
                dt.Columns.Add("airId");
                dt.Columns.Add("score");
                dt.Columns.Add("zongping");
                dt.Columns.Add("xiai");
                dt.Columns.Add("xiaofei");
                dt.Columns.Add("manyi");
                dt.Columns.Add("fuwu");
                dt.Columns.Add("relayPort");
                dt.Columns.Add("returnTip");
                dt.Columns.Add("tairportdescription");

                dt.Columns.Add("startTime");
                dt.Columns.Add("arriveTime");
                this.pan_aifeitime.Visible = true;

                //查询机场信息
                string  airlineSql = "select chName,planNum,age,aid,airlineCode,description,smallPic,logoPic from FY_Airline where airlineCode='" + afti.airlineName + "'";
                DataSet airlineDS  = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, airlineSql);

                if (airlineDS != null && airlineDS.Tables.Count > 0 && airlineDS.Tables[0].Rows.Count > 0)
                {
                    afti.airchName           = airlineDS.Tables[0].Rows[0]["chName"].ToString();
                    afti.airId               = airlineDS.Tables[0].Rows[0]["aid"].ToString();
                    afti.smallPic            = airlineDS.Tables[0].Rows[0]["smallPic"].ToString();
                    afti.logoPic             = airlineDS.Tables[0].Rows[0]["logoPic"].ToString();
                    afti.tairportdescription = airlineDS.Tables[0].Rows[0]["description"].ToString();
                    afti.planNum             = airlineDS.Tables[0].Rows[0]["planNum"].ToString();
                    afti.age = airlineDS.Tables[0].Rows[0]["age"].ToString();
                }


                string starStr   = Request.QueryString["startTime"];
                string arriveStr = Request.QueryString["arriveTime"];

                if (starStr != null && !starStr.Equals(""))
                {
                    afti.startTime = convertDate2(starStr);
                }
                else
                {
                    afti.startTime = "待定";
                }

                if (arriveStr != null && !arriveStr.Equals(""))
                {
                    afti.arriveTime = convertDate2(arriveStr);
                }
                else
                {
                    afti.arriveTime = "待定";
                }

                afti.relayPort = getRelayPort(afti.fromCityCode, afti.toCityCode, afti.airlineName);

                dt.Rows.Add(getFromCityIdByName(afti.fromCityName), getToCityIdByName(afti.toCityName), afti.fromCityName, afti.fromCityCode, afti.toCityName, afti.toCityCode, "2013-06-08", afti.untaxprice, afti.tripType, "tId", afti.fromAirportCode, afti.fromAirportName, afti.toAirportName, afti.logoPic, afti.airchName, afti.planNum, afti.age, afti.smallPic, afti.bagPrice, afti.engerTicket, "经济舱", afti.shortstayDate, afti.attPrice, afti.longstayDate.Trim() == "-1" ? "0" : afti.longstayDate, afti.childPrice, convertDate(afti.fromsaleDate.Trim()), convertDate(afti.tosaleDate.Trim()), convertDate(afti.fromtripDate.Trim()), convertDate(afti.totripDate.Trim()), afti.returnMoney, afti.updateProvision, afti.limitProvision, afti.fromAirportName, afti.toAirportCode, "toPort", afti.airId, afti.score, afti.zongping, afti.xiai, afti.xiaofei, afti.manyi, afti.fuwu, afti.relayPort, "returnTip", afti.tairportdescription, afti.startTime, afti.arriveTime);


                //fromCityname,toCityname,toCityCode,toCityname,addtime,
                //untaxPrice,tripType,tId,fAirportCode,fromCityCode,fromPort,
                //tAirportName,logoPic,airname,planNum,age
                //smallPic,bagPrice,engerTicket,seatShip,shortstayDate,attPrice
                //longstayDate,childPrice,fromsaleDate,tosaleDate,
                //fromtripDate,totripDate,returnMoney,updateProvision



                ticketOne = dt.Rows[0];
            }

            int fCityId = Convert.ToInt32(ticketOne["fromCity"].ToString());
            int tCityId = Convert.ToInt32(ticketOne["toCity"].ToString());
            ticket_7  = GetTicketDetailBydelay(7, fCityId, tCityId, 6);
            ticket_14 = GetTicketDetailBydelay(14, fCityId, tCityId, 6);

            ticket_30  = GetTicketDetailBydelay(30, fCityId, tCityId, 6);
            ticket_60  = GetTicketDetailBydelay(60, fCityId, tCityId, 6);
            ticket_90  = GetTicketDetailBydelay(90, fCityId, tCityId, 6);
            ticket_120 = GetTicketDetailBydelay(120, fCityId, tCityId, 6);

            ticket_180 = GetTicketDetailBydelay(180, fCityId, tCityId, 6);
            ticket_365 = GetTicketDetailBydelay(365, fCityId, tCityId, 6);

            ticket_all = GetTicketDetailBydelay(0, fCityId, tCityId, 5);

            tmax = tmax > ticket_7.Count ? tmax : ticket_7.Count;
            tmax = tmax > ticket_14.Count ? tmax : ticket_14.Count;
            tmax = tmax > ticket_30.Count ? tmax : ticket_30.Count;
            tmax = tmax > ticket_60.Count ? tmax : ticket_60.Count;
            tmax = tmax > ticket_90.Count ? tmax : ticket_90.Count;
            tmax = tmax > ticket_120.Count ? tmax : ticket_120.Count;
            tmax = tmax > ticket_180.Count ? tmax : ticket_180.Count;
            tmax = tmax > ticket_365.Count ? tmax : ticket_365.Count;

            hotNews = getNewsRandom(id);

            randowTicketF = GetRandowTicketF(14, fCityId, tCityId, 10);
            randowTicketT = GetRandowTicketT(14, fCityId, tCityId, 10);
            randowNews    = getQuanByType(ticketOne["toCityname"].ToString());
        }
        else
        {
            Response.Redirect("international.aspx");
        }
    }
示例#4
0
    protected void GetSearchTicket()
    {
        //从本地数据库查询
        DataSet ds = new DataSet();

        //查找航空公司名称  构造航空公司排序数组
        string str = @"select top 100 percent";

        str += " FY_Ticket.tid,FY_Ticket.untaxPrice,FY_Ticket.relayPort,FY_Ticket.tripType,";
        str += " FY_FromCity.cityCode as fromCityCode,";
        str += " FY_ToCity.cityCode as toCityCode,";
        str += " FY_Tax.tax,";
        str += " FY_FromCity.chName as fromCityname,FY_FromCity.fId,FY_Airline.aId,FY_ToCity.tId as toId,";
        str += " FY_ToCity.chName as toCityname,FY_Airline.airlineCode as airlineCode,FY_Airline.chName as airname, FY_Airline.smallPic as smallPic from FY_Ticket ";
        str += " left join FY_FromCity on FY_FromCity.fId=FY_Ticket.fromCity";
        str += " left join FY_ToCity on FY_ToCity.tId=FY_Ticket.toCity";
        str += " left join FY_Airline on FY_Airline.aId=FY_Ticket.airLine";
        str += " left join FY_Tax on (FY_Ticket.tripType =FY_Tax.taxType and FY_Ticket.airLine = FY_Tax.airline and FY_Ticket.toCity = FY_Tax.toCity and FY_Ticket.fromCity = FY_Tax.fromCity)";
        str += " where 1=1  ";

        //查找航空公司
        string strAirline = @"select  FY_Ticket.airLine,min(FY_Ticket.untaxPrice) as untaxPrice  ";

        strAirline += " from FY_Ticket";
        strAirline += " left join FY_FromCity on FY_FromCity.fId=FY_Ticket.fromCity";
        strAirline += " left join FY_ToCity on FY_ToCity.tId=FY_Ticket.toCity";
        strAirline += " left join FY_Tax on (FY_Ticket.airLine = FY_Tax.airline and FY_Ticket.toCity = FY_Tax.toCity and FY_Ticket.fromCity = FY_Tax.fromCity)";
        strAirline += " where 1=1  ";

        if (tripTypeInt != 2)
        {
            str        += " and (FY_Ticket.tripType=" + tripTypeInt + ")";
            strAirline += " and (FY_Ticket.tripType=" + tripTypeInt + ")";
        }

        if (fromCityId != 0)
        {
            str        += " and (FY_FromCity.fId=" + fromCityId + ")";
            strAirline += " and (FY_FromCity.fId=" + fromCityId + ")";
        }

        if (toCityNameStr != "")
        {
            str        += " and (FY_ToCity.chName like '%" + toCityNameStr + "%')";
            strAirline += " and (FY_ToCity.chName like '%" + toCityNameStr + "%')";
        }

        if (tripDateStr != "")
        {
            str        += " and (FY_Ticket.fromtripDate<='" + tripDateStr + "' and FY_Ticket.totripDate>='" + tripDateStr + "' )";
            strAirline += " and (FY_Ticket.fromtripDate<='" + tripDateStr + "' and FY_Ticket.totripDate>='" + tripDateStr + "' )";
        }

        if (tripDateStr != "" && backDateStr != "" && tripTypeInt != 0)
        {
            int day = (Convert.ToDateTime(backDateStr) - Convert.ToDateTime(tripDateStr)).Days;
            str        += " and DateDiff(d,FY_Ticket.fromtripDate,FY_Ticket.totripDate) >= " + day;
            strAirline += " and DateDiff(d,FY_Ticket.fromtripDate,FY_Ticket.totripDate) >= " + day;
        }

        str        += " and (FY_Ticket.tosaleDate>='" + DateTime.Now.ToString("yyyy-MM-dd") + "')";
        strAirline += " and (FY_Ticket.tosaleDate>='" + DateTime.Now.ToString("yyyy-MM-dd") + "')";

        if (airlineId != 0)
        {
            str += " and (FY_Airline.aId=" + airlineId + ")";
        }

        if (getorderStr != "")
        {
            str += " order by FY_Ticket." + getorderStr + " asc ,FY_Ticket.tId desc";
        }
        else
        {
            str += " order by FY_Ticket.untaxPrice asc ,FY_Ticket.tId desc";
        }

        ArrayList allAirlines = new ArrayList();

        strAirline += " group by FY_Ticket.airLine order by min(FY_Ticket.untaxPrice) asc";
        //查询航空公司
        DataSet dsStrAirLine = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, strAirline);

        if (dsStrAirLine != null)
        {
            foreach (DataRow drAifeiAirline in dsStrAirLine.Tables[0].Rows)
            {
                AiFeiAirline afa = new AiFeiAirline();
                afa.minPrice  = drAifeiAirline["untaxPrice"].ToString();
                afa.airlineId = drAifeiAirline["airLine"].ToString();

                string code = string.Empty;
                string pic  = string.Empty;
                afa.airlineName = ReadXmlHelper.GetAirLineNameByID(Convert.ToInt64(afa.airlineId), out code, out pic);
                afa.airlinePic  = pic;
                afa.airlineCode = code;
                //if(allAirlines.Count<11)
                allAirlines.Add(afa);
            }
        }

        //从爱飞网获得数据并排序
        AiFeiService aifeiService = new AiFeiService();
        //ArrayList = aifeiService.GlobalTicket(dpt, arr, toTime, reTime, cate);
        ///dpt  出发三字码   arr  到达三字码
        ///

        string arr = getToCityCodeByName(toCityNameStr);
        string dpt = getFromCityCodeByName(fromCityName);

        //string cate = "ALL";
        string cate = "SF";

        ArrayList aifeiTickets = new ArrayList();

        if (tripTypeInt == 0)
        {
            cate         = "DC";
            aifeiTickets = aifeiService.AiFeiTickets(dpt, arr, ajaxToTime, ajaxFromTime, cate, airlineId, ref allAirlines);//过滤航空公司
        }
        else if (tripTypeInt == 1)
        {
            cate         = "SF";
            aifeiTickets = aifeiService.AiFeiTickets(dpt, arr, ajaxToTime, ajaxFromTime, cate, airlineId, ref allAirlines);//过滤航空公司
        }
        else if (tripTypeInt == 2)
        {
            System.Threading.AutoResetEvent  resetEvent = new System.Threading.AutoResetEvent(false);
            AiFeiService.AiFeiTicketsHandler d1 = new AiFeiService.AiFeiTicketsHandler(aifeiService.AiFeiTickets);
            AiFeiService.AiFeiTicketsHandler d2 = new AiFeiService.AiFeiTicketsHandler(aifeiService.AiFeiTickets);
            IAsyncResult iar1 = null, iar2 = null;
            ArrayList    aifeiTickets2 = null;
            AsyncCallback back1 = delegate(IAsyncResult iar)
            {
                aifeiTickets = d1.EndInvoke(ref allAirlines, iar1);
                if (iar2 != null && iar2.IsCompleted)
                {
                    resetEvent.Set();
                }
            };

            AsyncCallback back2 = delegate(IAsyncResult iar)
            {
                aifeiTickets2 = d2.EndInvoke(ref allAirlines, iar2);
                if (iar1 != null && iar1.IsCompleted)
                {
                    resetEvent.Set();
                }
            };
            iar1 = d1.BeginInvoke(dpt, arr, ajaxToTime, ajaxFromTime, "SF", airlineId, ref allAirlines, back1, null);
            iar2 = d2.BeginInvoke(dpt, arr, ajaxToTime, ajaxFromTime, "DC", airlineId, ref allAirlines, back2, null);
            if (resetEvent.WaitOne(2000, true))
            {
                resetEvent.Close();
            }
            if (aifeiTickets2 != null)
            {
                for (int i = 0; i < aifeiTickets2.Count; i++)
                {
                    aifeiTickets.Add(aifeiTickets2[i]);
                }
            }
        }

        //获得爱飞机票列表
        ArrayList tickets        = new ArrayList();
        ArrayList feiYingTickets = new ArrayList();

        int aifeinum = Convert.ToInt32(this.hidd_aifeinum.Value);

        ds = SqlHelper.ExecuteDataset(SqlHelper.ConnString_select, CommandType.Text, str);

        //没数据 显示提示
        if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) && aifeiTickets.Count == 0)
        {
            this.panHaveValue2.Visible = false;
            this.panNoValue.Visible    = true;
            return;
        }
        else
        {
            this.panHaveValue2.Visible = true;
            this.panNoValue.Visible    = false;

            DataTable dt = ds.Tables[0];
            //遍历行
            foreach (DataRow dr in dt.Rows)
            {
                //遍历列
                AiFeiTicket aifeiTicket = new AiFeiTicket();
                aifeiTicket.ticketId        = dr["tid"].ToString().Trim();
                aifeiTicket.price           = Convert.ToInt32(dr["untaxPrice"].ToString());
                aifeiTicket.fromCity        = dr["fromCityName"].ToString();
                aifeiTicket.fromCityCode    = dr["fromCityCode"].ToString();
                aifeiTicket.fromCityId      = dr["fId"].ToString();
                aifeiTicket.toCity          = dr["toCityName"].ToString();
                aifeiTicket.toCityCode      = dr["toCityCode"].ToString();
                aifeiTicket.toCityId        = dr["toId"].ToString();
                aifeiTicket.airlineCode     = dr["airlineCode"].ToString();
                aifeiTicket.airline         = dr["airname"].ToString();
                aifeiTicket.airlineId       = dr["aId"].ToString();
                aifeiTicket.airlineSmallPic = dr["smallPic"].ToString();
                aifeiTicket.relayPort       = dr["relayPort"].ToString();
                aifeiTicket.sourceType      = "feiying";
                aifeiTicket.tripType        = dr["tripType"].ToString();//单程or往返
                //查询税费信息
                //aifeiTicket.tax = getTaxMessage(aifeiTicket.fromCityId, aifeiTicket.toCityId, aifeiTicket.airlineId, Convert.ToInt32(aifeiTicket.tripType));
                feiYingTickets.Add(aifeiTicket);
            }
        }

        if (getorderStr.Equals(""))
        {
            //排序飞瀛机票
            foreach (AiFeiTicket orderTicket in feiYingTickets)
            {
                if (tickets.Count == 0)
                {
                    tickets.Add(orderTicket);
                }
                else
                {
                    bool isEnd = false;
                    for (int i = 0; i < tickets.Count && !isEnd; i++)
                    {
                        AiFeiTicket aft = (AiFeiTicket)tickets[i];
                        if ((i + 1) == tickets.Count && orderTicket.price > aft.price)
                        {
                            tickets.Add(orderTicket);
                            isEnd = true;
                            break;
                        }
                        else if (orderTicket.price <= aft.price)
                        {
                            tickets.Insert(i, orderTicket);
                            isEnd = true;
                            break;
                        }
                    }
                }
            }

            //排序爱飞机票
            foreach (AiFeiTicket orderTicket in aifeiTickets)
            {
                if (tickets.Count == 0)
                {
                    tickets.Add(orderTicket);
                }
                else
                {
                    bool isEnd = false;
                    for (int i = 0; i < tickets.Count && !isEnd; i++)
                    {
                        AiFeiTicket aft = (AiFeiTicket)tickets[i];
                        if ((i + 1) == tickets.Count && orderTicket.price > aft.price)
                        {
                            tickets.Add(orderTicket);
                            isEnd = true;
                            break;
                        }
                        else if (orderTicket.price < aft.price)
                        {
                            tickets.Insert(i, orderTicket);
                            isEnd = true;
                            break;
                        }
                        else if (orderTicket.price == aft.price && orderTicket.airlineCode.Equals(aft.airlineCode))
                        {
                            isEnd = true;
                            break;
                        }
                    }
                }
            }
        }
        else if (getorderStr.Equals("airLine"))
        {
            //航空公司排序
            tickets = feiYingTickets;

            //排序爱飞机票
            foreach (AiFeiTicket orderTicket in aifeiTickets)
            {
                if (tickets.Count == 0)
                {
                    tickets.Add(orderTicket);
                }
                else
                {
                    bool isEnd = false;
                    for (int i = 0; i < tickets.Count && !isEnd; i++)
                    {
                        AiFeiTicket aft = (AiFeiTicket)tickets[i];
                        if ((i + 1) == tickets.Count && orderTicket.price > aft.price && orderTicket.airlineCode.Equals(aft.airlineCode))
                        {
                            tickets.Add(orderTicket);
                            isEnd = true;
                            break;
                        }
                        else if (orderTicket.price < aft.price && orderTicket.airlineCode.Equals(aft.airlineCode))
                        {
                            tickets.Insert(i, orderTicket);
                            isEnd = true;
                            break;
                        }
                        else if (orderTicket.price == aft.price && orderTicket.airlineCode.Equals(aft.airlineCode))
                        {
                            isEnd = true;
                            break;
                        }
                    }
                }
            }
        }

        //绑定航空公司
        Session["TicketsSessionKey_Airlines"] = allAirlines;

        //写入Session 分页使用
        Session["TicketsSessionKey_" + tripTypeInt + "_" + fromCityId + "_" + Server.HtmlEncode(toCityNameStr) + "_" + ajaxToTime + "_" + ajaxFromTime] = tickets;
        this.BindData(tickets);
    }
示例#5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        from = Request.QueryString["from"];
        to   = Request.QueryString["to"];
        string airline = Request.QueryString["airline"];

        totime   = Request.QueryString["totime"];
        fromtime = Request.QueryString["fromtime"];
        string ticketType = Request.QueryString["ticketType"];//机票类型  单程、往返

        AiFeiService afs = new AiFeiService();

        //清除过期记录
        afs.clearTimeOutLogs(from, to, airline);

        if (ticketType != null && ticketType.Equals("1"))
        {
            //往返
            FeiYingFlight toFlight   = afs.getFlightMsg2(from, to, airline, totime);
            FeiYingFlight backFlight = afs.getFlightMsg2(to, from, airline, fromtime);

            //System.Threading.AutoResetEvent resetEvent = new System.Threading.AutoResetEvent(false);
            //AiFeiService.GlobalFlight2Handler d1 = new AiFeiService.GlobalFlight2Handler(afs.GlobalFlight2);
            //AiFeiService.GlobalFlight2Handler d2 = new AiFeiService.GlobalFlight2Handler(afs.GlobalFlight2);
            //IAsyncResult iar1 = null, iar2 = null;
            //bool searchto = false, searchback = false;
            //AsyncCallback back1 = delegate(IAsyncResult iar)
            //{
            //    toFlight = d1.EndInvoke(iar1);
            //    if (!searchback || (iar2 != null && iar2.IsCompleted))
            //        resetEvent.Set();
            //};

            //AsyncCallback back2 = delegate(IAsyncResult iar)
            //{
            //    backFlight = d2.EndInvoke(iar2);
            //    if (!searchto || (iar1 != null && iar1.IsCompleted))
            //        resetEvent.Set();
            //};
            //if (toFlight == null)
            //{
            //    searchto = true;
            //    iar1 = d1.BeginInvoke(from, to, airline, "Y", 1, totime, back1, null);
            //}
            //if (backFlight == null)
            //{
            //    searchback = true;
            //    iar2 = d2.BeginInvoke(to, from, airline, "Y", 1, fromtime, back2, null);
            //}

            //if (toFlight == null || backFlight == null)
            //{
            //    if (resetEvent.WaitOne(30000, true))
            //        resetEvent.Close();
            //}

            ////远程
            //if (toFlight == null)
            //{
            //    //请求远程
            //    System.Threading.Thread thread = new System.Threading.Thread((System.Threading.ThreadStart)delegate
            //    {
            //        toFlight = afs.GlobalFlight2(from, to, airline, "Y", 1, totime);
            //    });
            //    thread.IsBackground = true;
            //    thread.Start();
            //}
            //if (backFlight == null)
            //{
            //    //请求远程
            //    System.Threading.Thread thread = new System.Threading.Thread((System.Threading.ThreadStart)delegate
            //    {
            //        backFlight = afs.GlobalFlight2(to, from, airline, "Y", 1, fromtime);
            //    });
            //    thread.IsBackground = true;
            //    thread.Start();
            //}

            if (toFlight == null)
            {
                this.InsertAiFeiLogs(from, to, airline, totime);
            }
            if (backFlight == null)
            {
                this.InsertAiFeiLogs(to, from, airline, fromtime);
            }

            //没有数据
            if (toFlight == null || backFlight == null)
            {
                Response.Write("false");
                Response.End();
                return;
            }

            StringBuilder str = new StringBuilder();
            str.Append("<div>");
            str.Append("<span class=\"aifeifrom\">" + printf_flights(toFlight, backFlight, "from", ticketType) + "</span>");
            str.Append("<span class=\"aifeito\">" + printf_flights(toFlight, backFlight, "to", ticketType) + "</span>");
            str.Append("<span class=\"aifeiline\">" + printf_flights(toFlight, backFlight, "line", ticketType) + "</span>");
            str.Append("<span class=\"relay\">" + printf_relay(toFlight, backFlight) + "</span>");
            if (string.IsNullOrEmpty(toFlight.airplan) && string.IsNullOrEmpty(backFlight.airplan))
            {
                str.Append("<span class=\"airplan\"></span>");
            }
            else if (!string.IsNullOrEmpty(toFlight.airplan) && !string.IsNullOrEmpty(backFlight.airplan))
            {
                str.Append("<span class=\"airplan\">" + (toFlight.airplan + "").Trim() + " / " + (backFlight.airplan + "").Trim() + "</span>");
            }
            else
            {
                str.Append("<span class=\"airplan\">" + (toFlight.airplan + "").Trim() + (backFlight.airplan + "").Trim() + "</span>");
            }

            str.Append("</div>");
            Response.Write(str.ToString());
            Response.End();
        }
        else if (ticketType != null && ticketType.Equals("0"))
        {
            FeiYingFlight toFlight = afs.getFlightMsg2(from, to, airline, totime);
            ////远程
            //if (toFlight == null)
            //{
            //    //请求远程
            //    System.Threading.Thread thread = new System.Threading.Thread((System.Threading.ThreadStart)delegate
            //    {
            //        toFlight = afs.GlobalFlight2(from, to, airline, "Y", 1, totime);
            //    });
            //    thread.IsBackground = true;
            //    thread.Start();
            //}

            //没有数据
            if (toFlight == null)
            {
                this.InsertAiFeiLogs(from, to, airline, totime);

                Response.Write("false");
                Response.End();
                return;
            }

            StringBuilder str = new StringBuilder();
            str.Append("<div>");
            str.Append("<span class=\"aifeifrom\">" + printf_flights(toFlight, null, "from", ticketType) + "</span>");
            str.Append("<span class=\"aifeito\">" + printf_flights(toFlight, null, "to", ticketType) + "</span>");
            str.Append("<span class=\"aifeiline\">" + printf_flights(toFlight, null, "line", ticketType) + "</span>");
            str.Append("<span class=\"relay\">" + printf_relay(toFlight, null) + "</span>");
            str.Append("<span class=\"airplan\">" + (toFlight.airplan + "").Trim() + "</span>");
            str.Append("</div>");
            Response.Write(str.ToString());
            Response.End();
        }
    }