コード例 #1
0
        /// <summary>
        /// 解析航线信息
        /// </summary>
        /// <param name="strContent">航线内容</param>
        /// <param name="regexInstance">正则实例</param>
        /// <returns></returns>
        public IList <RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance)
        {
            if (string.IsNullOrEmpty(strContent) || regexInstance == null)
            {
                return(null);
            }

            CtripRegexExpression ctripRegex = (CtripRegexExpression)regexInstance;

            IList <string> valueList = RegexOperation.GetValuesByRegex(ctripRegex.GetSingleRowRegex(), strContent);

            IList <RouteInformation> routeInformationList = new List <RouteInformation>();
            RouteInformation         routeInformation;

            foreach (string strValue in valueList)
            {
                routeInformation = GetRouteInformation(strValue, ctripRegex);

                if (routeInformation != null)
                {
                    routeInformation.SeatList = GetSeatInformation(routeInformation, ctripRegex);

                    routeInformationList.Add(routeInformation);
                }
            }

            return(routeInformationList);
        }
コード例 #2
0
ファイル: AirLineHandle.cs プロジェクト: hkmujj/vin_zone_2009
        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)));
        }
コード例 #3
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);
        }
コード例 #4
0
        /// <summary>
        /// 解析航线信息
        /// </summary>
        /// <param name="strContent">航线内容</param>
        /// <param name="regexInstance">正则实例</param>
        /// <returns></returns>
        public IList <RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance)
        {
            if (string.IsNullOrEmpty(strContent) || regexInstance == null)
            {
                return(null);
            }

            ElongRegexEpression etripRegex = (ElongRegexEpression)regexInstance;
            //StringReader sr = new StringReader(strContent);
            IList <string> valueList = RegexOperation.GetValuesByRegex(etripRegex.GetSingleRowRegex(), strContent);

            IList <RouteInformation> ElongrouteInformationList = new List <RouteInformation>();
            RouteInformation         elongrouteInformation;

            foreach (string strValue in valueList)
            {
                elongrouteInformation = GetElongRouteInformation(strValue.ToString(), etripRegex);

                if (elongrouteInformation != null)
                {
                    ElongrouteInformationList.Add(elongrouteInformation);
                }
            }

            return(ElongrouteInformationList);
        }
コード例 #5
0
ファイル: AirLineHandle.cs プロジェクト: hkmujj/vin_zone_2009
        /// <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());
        }
コード例 #6
0
        public IRegexExpression Parse(string prefix_regex)
        {
            // Your Code here
            List<string> parsedList = prefix_regex.Split(new[] {' ' }).ToList();
            IRegexExpression root = recursiveParse(parsedList);

            return root;

            //throw new NotImplementedException();
        }
コード例 #7
0
        /// <summary>
        /// ����������Ϣ
        /// </summary>
        /// <param name="strContent">��������</param>
        /// <param name="regexInstance">����ʵ��</param>
        /// <returns></returns>
        public IList<RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance)
        {
            if (string.IsNullOrEmpty(strContent) || regexInstance == null)
                return null;

            VeryTripRegexExpression veryTripRegex = (VeryTripRegexExpression)regexInstance;

            string strUrl = GetRealQuestUrl(strContent, veryTripRegex);

            return CombineAllRoute(GetHtmlSource(strUrl), veryTripRegex);
        }
コード例 #8
0
        /// <summary>
        /// 解析航线信息
        /// </summary>
        /// <param name="strContent">航线内容</param>
        /// <param name="regexInstance">正则实例</param>
        /// <returns></returns>
        public IList <RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance)
        {
            if (string.IsNullOrEmpty(strContent) || regexInstance == null)
            {
                return(null);
            }

            VeryTripRegexExpression veryTripRegex = (VeryTripRegexExpression)regexInstance;

            string strUrl = GetRealQuestUrl(strContent, veryTripRegex);

            return(CombineAllRoute(GetHtmlSource(strUrl), veryTripRegex));
        }
コード例 #9
0
        /// <summary>
        /// ����������Ϣ
        /// </summary>
        /// <param name="strContent">��������</param>
        /// <param name="regexInstance">����ʵ��</param>
        /// <returns></returns>
        public IList<RouteInformation> ParseHtmlCode(string strContent, IRegexExpression regexInstance)
        {
            if (string.IsNullOrEmpty(strContent) || regexInstance == null)
                return null;

            ElongRegexEpression etripRegex = (ElongRegexEpression)regexInstance;
            //StringReader sr = new StringReader(strContent);
            IList<string> valueList = RegexOperation.GetValuesByRegex(etripRegex.GetSingleRowRegex(), strContent);

            IList<RouteInformation> ElongrouteInformationList = new List<RouteInformation>();
            RouteInformation elongrouteInformation;
                foreach (string strValue in valueList)
                {
                    elongrouteInformation = GetElongRouteInformation(strValue.ToString(), etripRegex);

                    if (elongrouteInformation != null)
                        ElongrouteInformationList.Add(elongrouteInformation);
                }

            return ElongrouteInformationList;
        }
コード例 #10
0
ファイル: AirLineHandle.cs プロジェクト: hkmujj/vin_zone_2009
        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);
        }
コード例 #11
0
 public SequenceExpression(IRegexExpression lC, IRegexExpression rC)
 {
     leftChild = lC; rightChild = rC;
 }
コード例 #12
0
 public RepetitionExpression(IRegexExpression c)
 {
     child = c;
 }
コード例 #13
0
 public AlternationExpression(IRegexExpression lC, IRegexExpression rC)
 {
     leftChild = lC; rightChild = rC;
 }