Ejemplo 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);
        }
Ejemplo n.º 2
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());
        }