Exemplo n.º 1
0
        /// <summary>
        /// 获取解析各公司的地址
        /// </summary>
        /// <returns></returns>
        private static string GetWebAddress()
        {
            FlightLowestPrice CElowerstPrice = new FlightLowestPrice();
            string            strDeparture   = lowestPrice.Departure;

            if (strDeparture.ToUpper().Equals("PEK") || strDeparture.ToUpper().Equals("NAY"))
            {
                strDeparture = "BJS";
            }

            string strArrival = lowestPrice.Arrival;

            if (strArrival.ToUpper().Equals("PEK") || strArrival.ToUpper().Equals("NAY"))
            {
                strArrival = "BJS";
            }
            if (Constant.CCTRIPPATH == "CTRIPPATH")
            {
                string URL = "http://flights.ctrip.com/Domestic/ShowFareFirst.aspx?DCity1=" + strDeparture + "&ACity1=" + strArrival + "&DCityName1=&ACityName1=&DDate1=" + lowestPrice.DepartureTime.Value.ToShortDateString() + "&ClassType=&PassengerQuantity=1&SendTicketCity=&Airline=&PassengerType=ADU&FlightSearchType=S&";
                return(URL);
            }
            else if (Constant.CCTRIPPATH == "ETRIPPATH")
            {
                string url = "http://flight.elong.com/cn_list_" + strDeparture + "_" + strArrival + "_" +
                             CElowerstPrice.DepartureTime.Value.ToString("yyyy-MM-dd") + "_Y.html";
                return(url);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 处理最低度价航线
        /// </summary>
        public static void HandleAirLine()
        {
            while (true)
            {
                //线程是否启动
                if ("YES" == AIRLINETHREADING)
                {
                    try
                    {
                        lowestPrice = GetFlightLowestPrice();

                        if (!IsExistLowestPrice(lowestPrice.LowestPriceId))
                        {
                            CreateQuest(lowestPrice);
                        }
                    }
                    catch (Exception ex)
                    {
                        //WriteLog(ex,lowestPrice);
                    }
                }

                Thread.Sleep(TIMEINTERVAL);
            }
        }
Exemplo n.º 3
0
        private static void CreateQuest(FlightLowestPrice lowestPrice)
        {
            if (lowestPrice == null)
            {
                return;
            }

            if (!lowestPrice.DepartureTime.HasValue)
            {
                return;
            }

            #region 原来
            //string strDeparture = lowestPrice.Departure;
            //if (strDeparture.ToUpper().Equals("PEK") || strDeparture.ToUpper().Equals("NAY"))
            //    strDeparture = "BJS";

            //string strArrival = lowestPrice.Arrival;
            //if (strArrival.ToUpper().Equals("PEK") || strArrival.ToUpper().Equals("NAY"))
            //    strArrival = "BJS";

            //string URL = "http://flights.ctrip.com/Domestic/ShowFareFirst.aspx?DCity1=" + strDeparture + "&ACity1=" + strArrival + "&DCityName1=&ACityName1=&DDate1=" + lowestPrice.DepartureTime.Value.ToShortDateString() + "&ClassType=&PassengerQuantity=1&SendTicketCity=&Airline=&PassengerType=ADU&FlightSearchType=S&";
            #endregion

            #region

            /*
             * if (Constant.CCTRIPPATH == "CTRIPPATH")
             * {
             *  CtripInvoke(GetWebAddress());
             * }
             * else if (Constant.CCTRIPPATH == "ETRIPPATH")
             * {
             *  ElongInvoke(GetWebAddress());
             * }
             * */
            #endregion

            #region 现在
            RequestInvoke(lowestPrice.Departure, lowestPrice.Arrival, lowestPrice.DepartureTime);
            #endregion
        }
Exemplo n.º 4
0
        /// <summary>
        /// 异常记录
        /// </summary>
        /// <param name="ex">异常</param>
        /// <param name="lowestPrice">最低价实例</param>
        private static void WriteLog(Exception ex, FlightLowestPrice lowestPrice)
        {
            string strDirectory = CommonOperation.GetConfigValueByKey(Constant.CDIRECTORY);

            if (!Directory.Exists(strDirectory))
            {
                Directory.CreateDirectory(strDirectory);
            }

            if (!strDirectory.EndsWith("/"))
            {
                strDirectory += "/";
            }

            string strPath = strDirectory + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";

            StringBuilder sbContent = new StringBuilder();

            if (lowestPrice != null)
            {
                sbContent.AppendLine("Id:" + lowestPrice.LowestPriceId
                                     + " 出发地:" + lowestPrice.Departure
                                     + " 到达地:" + lowestPrice.Arrival
                                     + " 起飞时间:" + lowestPrice.DepartureTime.Value.ToString());
            }

            sbContent.AppendLine("源:" + ex.Source + " 消息:" + ex.Message + " 栈:" + ex.StackTrace);

            using (FileStream fileStream = new FileStream(strPath, FileMode.OpenOrCreate, FileAccess.Write))
            {
                using (StreamWriter streamWriter = new StreamWriter(fileStream))
                {
                    streamWriter.Write(sbContent.ToString());

                    streamWriter.Close();
                }

                fileStream.Close();
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 添加最低价格
        /// </summary>
        public bool AddLowestPrice(FlightLowestPrice lowestPrice)
        {
            //创建命令对象
            OracleCommand oracleCommand = DSCRM.DBA.GetOraCommand();

            //构建sql插入语句
            StringBuilder sbInsertSql = new StringBuilder();

            sbInsertSql.Append(" insert into T_TP_FLIGHT_LOWEST_PRICE( LOWEST_PRICE_ID,DEPARTURE,ARRIVAL,CREATE_DATE,LOWEST_PRICE,DEPARTURE_TIME,ARRIVAL_TIME,AIRLINER,FLIGHT,CABIN) ");
            sbInsertSql.Append(" values (:LOWEST_PRICE_ID,:DEPARTURE,:ARRIVAL,:CREATE_DATE,:LOWEST_PRICE,:DEPARTURE_TIME,:ARRIVAL_TIME,:AIRLINER,:FLIGHT,:CABIN) ");

            oracleCommand.CommandText = sbInsertSql.ToString();

            // 装载参数
            DBUtil.AddParameter(oracleCommand, "LOWEST_PRICE_ID", (Int32)CommonDBFunction.GenerateIdentity("T_TP_FLIGHT_LOWEST_PRICE"));
            DBUtil.AddParameter(oracleCommand, "DEPARTURE", lowestPrice.Departure);
            DBUtil.AddParameter(oracleCommand, "ARRIVAL", lowestPrice.Arrival);
            DBUtil.AddParameter(oracleCommand, "CREATE_DATE", lowestPrice.CreateDate);
            DBUtil.AddParameter(oracleCommand, "LOWEST_PRICE", lowestPrice.LowestPrice);
            DBUtil.AddParameter(oracleCommand, "DEPARTURE_TIME", lowestPrice.DepartureTime);
            DBUtil.AddParameter(oracleCommand, "ARRIVAL_TIME", lowestPrice.ArrivalTime);
            DBUtil.AddParameter(oracleCommand, "AIRLINER", lowestPrice.Airliner);
            DBUtil.AddParameter(oracleCommand, "FLIGHT", lowestPrice.Flight);
            DBUtil.AddParameter(oracleCommand, "CABIN", lowestPrice.Cabin);

            int count = 0;

            //捕获异常
            try
            {
                count = DSCRM.DBA.ExecuteNonQuery(oracleCommand);
            }
            catch
            {
            }

            return(count > 0);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 查询最低价
        /// </summary>
        /// <returns></returns>
        public FlightLowestPrice QueryLowestPrice()
        {
            string strSql = "select * from t_TP_Flight_Lowest_Price where rownum < 2 order by lowest_price_id desc ";

            FlightLowestPrice lowestPrice = new FlightLowestPrice();

            //创建命令对象
            OracleCommand oracleCommand = DSCRM.DBA.GetOraCommand();

            oracleCommand.CommandText = strSql;

            //执行完关闭连接
            using (OracleDataReader oracleDataReader = oracleCommand.ExecuteReader(CommandBehavior.CloseConnection))
            {
                //读取数据成功返回true
                if (oracleDataReader.Read())
                {
                    lowestPrice.LowestPriceId = Convert.ToInt32(oracleDataReader["LOWEST_PRICE_ID"]);

                    if (oracleDataReader["DEPARTURE"] != DBNull.Value)
                    {
                        lowestPrice.Departure = Convert.ToString(oracleDataReader["DEPARTURE"]);
                    }

                    if (oracleDataReader["ARRIVAL"] != DBNull.Value)
                    {
                        lowestPrice.Arrival = Convert.ToString(oracleDataReader["ARRIVAL"]);
                    }

                    if (oracleDataReader["CREATE_DATE"] != DBNull.Value)
                    {
                        lowestPrice.CreateDate = Convert.ToDateTime(oracleDataReader["CREATE_DATE"]);
                    }

                    if (oracleDataReader["LOWEST_PRICE"] != DBNull.Value)
                    {
                        lowestPrice.LowestPrice = Convert.ToDouble(oracleDataReader["LOWEST_PRICE"]);
                    }

                    if (oracleDataReader["DEPARTURE_TIME"] != DBNull.Value)
                    {
                        lowestPrice.DepartureTime = Convert.ToDateTime(oracleDataReader["DEPARTURE_TIME"]);
                    }

                    if (oracleDataReader["ARRIVAL_TIME"] != DBNull.Value)
                    {
                        lowestPrice.ArrivalTime = Convert.ToDateTime(oracleDataReader["ARRIVAL_TIME"]);
                    }

                    if (oracleDataReader["AIRLINER"] != DBNull.Value)
                    {
                        lowestPrice.Airliner = Convert.ToString(oracleDataReader["AIRLINER"]);
                    }

                    if (oracleDataReader["FLIGHT"] != DBNull.Value)
                    {
                        lowestPrice.Flight = Convert.ToString(oracleDataReader["FLIGHT"]);
                    }

                    if (oracleDataReader["CABIN"] != DBNull.Value)
                    {
                        lowestPrice.Cabin = Convert.ToString(oracleDataReader["CABIN"]);
                    }
                }
            }

            return(lowestPrice);
        }
        //public RedefineWebBrowserDocumentCompletedEventArgs(FlightLowestPrice lowestPrice)
        //{
        //    this.RedefineWebBrowserDocumentCompletedEventArgs(lowestPrice, base.Url);
        //}

        //public RedefineWebBrowserDocumentCompletedEventArgs()
        //{

        //}

        public RedefineWebBrowserDocumentCompletedEventArgs(FlightLowestPrice lowestPrice, Uri url)
            : base(url)
        {
            this.lowestPrice = lowestPrice;
        }