Пример #1
0
        public Dictionary <string, Dictionary <string, JOffer> > GetCarTrawlerRatesSingle(SearchFilters searchFilters, out SiteBase site)
        {
            Dictionary <int, Location> locations;

            using (RatesDBContext ctx = new RatesDBContext())
            {
                locations = ctx.Locations.ToDictionary(loc => loc.LocationId);
            }

            Trawler s = new Trawler(locations[searchFilters.Location].CtrStr);


            DateTime sDate = searchFilters.PuDate; //.AddHours(searchFilters.PuTime.Hours).AddMinutes(searchFilters.PuTime.Minutes);
            DateTime eDate = searchFilters.DoDate; //.AddHours(searchFilters.DoTime.Hours).AddMinutes(searchFilters.DoTime.Minutes);

            s.InitDate(sDate);

            int numOfIterations = (eDate - sDate).Days;

            List <string> links = s.GetGeneratedLinksByDate(sDate, eDate);

            site = s;

            List <JOffer> minOffers = new List <JOffer>();

            Dictionary <string, Dictionary <string, JOffer> > offerMap = new Dictionary <string, Dictionary <string, JOffer> >();

            for (int i = 0; i < links.Count; i++)
            {
                offerMap.Add(links[i], new Dictionary <string, JOffer>());
            }


            List <Thread> threads = new List <Thread>();

            //--- Start all threads
            for (int index = 0; index < links.Count; index++)
            {
                JSourceReader reader = new JSourceReader();
                offerMap[links.ElementAt(index)] =
                    reader.GetMap(reader.GetNorwRates(links.ElementAt(index)));
            }

            return(offerMap);
        }
Пример #2
0
        public Dictionary <string, Dictionary <string, JOffer> > GetScannerRates(SearchFilters searchFilters, out SiteBase site)
        {
            Dictionary <int, Location> locations;

            using (RatesDBContext ctx = new RatesDBContext())
            {
                locations = ctx.Locations.ToDictionary(loc => loc.LocationId);
            }

            Trawler s = new Trawler(locations[searchFilters.Location].SnrStr);


            DateTime sDate = searchFilters.PuDate.AddHours(searchFilters.PuTime.Hours).AddMinutes(searchFilters.PuTime.Minutes);
            DateTime eDate = searchFilters.DoDate.AddHours(searchFilters.DoTime.Hours).AddMinutes(searchFilters.DoTime.Minutes);

            s.InitDate(sDate);

            int numOfIterations = (eDate - sDate).Days;

            List <string> links     = s.GetGeneratedLinksByDate(sDate, eDate);
            List <JOffer> minOffers = new List <JOffer>();

            Dictionary <string, Dictionary <string, JOffer> > offerMap = new Dictionary <string, Dictionary <string, JOffer> >();

            for (int i = 0; i < links.Count; i++)
            {
                offerMap.Add(links[i], new Dictionary <string, JOffer>());
            }


            Func <object, int> action = (object obj) =>
            {
                int           i      = (int)obj;
                JSourceReader reader = new JSourceReader();
                offerMap[links.ElementAt(i)] = reader.GetMap(reader.GetNorwRates(links.ElementAt(i)));
                return(0);
            };

            RunThreads(action, links.Count);
            s.SetTitle("scanner");
            site = s;
            return(offerMap);
        }