Exemplo n.º 1
0
        private IList <RouteInformation> RequestRoute(string strDeparture, string strArrival, DateTime?departureTime)
        {
            FactoryContribution factoryContribution = new FactoryContribution();

            IRouteFactory routeFactory = factoryContribution.CreateFactory();

            if (routeFactory == null)
            {
                return(null);
            }

            IRouteOperation routeOperation = routeFactory.CreateRouteInstance();

            IRegexExpression regexExpression = routeFactory.CreateRouteRegex();

            string strUrl = routeOperation.GetRequestUrl(strDeparture, strArrival, departureTime);

            if (string.IsNullOrEmpty(strUrl))
            {
                return(null);
            }

            string strContent = routeOperation.GetHtmlContent(strUrl);

            IList <RouteInformation> routeInformationList = routeOperation.ParseHtmlCode(strContent, regexExpression);

            return(routeInformationList);
        }
Exemplo n.º 2
0
        public string RouteTest(string strDeparture, string strArrival, DateTime?departureTime, string strFlightNo)
        {
            FactoryContribution factoryContribution = new FactoryContribution();

            IRouteFactory routeFactory = factoryContribution.CreateFactory();

            if (routeFactory == null)
            {
                return(string.Empty);
            }

            IRouteOperation routeOperation = routeFactory.CreateRouteInstance();

            IRegexExpression regexExpression = routeFactory.CreateRouteRegex();

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

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

            string strUrl = CommonOperation.GetConfigValueByKey(Constant.CCTRIPPATH);

            if (!string.IsNullOrEmpty(strFlightNo))
            {
                strUrl = CommonOperation.GetConfigValueByKey(Constant.CCTRIPSUBURL);
            }

            return(routeOperation.GetHtmlContent(string.Format(strUrl, strDeparture, strArrival, departureTime.Value.ToString("yyyy-MM-dd"), strFlightNo)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 执行相应请求
        /// </summary>
        /// <param name="strDeparture">出发地</param>
        /// <param name="strArrival">到达地</param>
        /// <param name="departureTime">出发时间</param>
        private static void RequestInvoke(string strDeparture, string strArrival, DateTime?departureTime)
        {
            FactoryContribution factoryContribution = new FactoryContribution();

            IRouteFactory routeFactory = factoryContribution.CreateFactory();

            if (routeFactory == null)
            {
                return;
            }

            IRouteOperation routeOperation = routeFactory.CreateRouteInstance();

            IRegexExpression regexExpression = routeFactory.CreateRouteRegex();

            string strUrl = routeOperation.GetRequestUrl(strDeparture, strArrival, departureTime);

            if (string.IsNullOrEmpty(strUrl))
            {
                return;
            }

            string strContent = routeOperation.GetHtmlContent(strUrl);

            IList <RouteInformation> routeInformationList = routeOperation.ParseHtmlCode(strContent, regexExpression);

            CompareCtripLowestPrice(routeInformationList, routeOperation.GetSourceType());
        }
Exemplo n.º 4
0
        private static void ElongInvoke(string strUrl)
        {
            FactoryContribution factoryContribution = new FactoryContribution();

            IRouteFactory routeFactory = factoryContribution.CreateFactory();

            if (routeFactory == null)
            {
                return;
            }

            IRouteOperation routeOperation = routeFactory.CreateRouteInstance();

            IRegexExpression regexExpression = routeFactory.CreateRouteRegex();

            string strContent = routeOperation.GetHtmlContent(strUrl);

            IList <RouteInformation> routeInformationList = routeOperation.ParseHtmlCode(strContent, regexExpression);

            CompareElongLowestPrice(routeInformationList);
        }