コード例 #1
0
        public async Task Run()
        {
            var rentalConnector = new TrademeRentalConnector(_logger);
            TrademeStatsRepository respository = new TrademeStatsRepository(_context);

            while (true)
            {
                IEnumerable <RentalListing> rentalListings = rentalConnector.GetListings();
                Stopwatch sw = Stopwatch.StartNew();
                sw.Start();
                foreach (var rentalListing in rentalListings)
                {
                    _logger.LogDebug($"Adding listing ID: {rentalListing.Id}");
                    respository.AddRentalListing(rentalListing);
                }

                respository.SaveChanges();
                sw.Stop();
                _logger.LogInformation($"Finished fetching listings, took {sw.Elapsed.TotalSeconds} seconds. Press enter to exit.");
                Thread.Sleep(600000);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            TraceListener          trace           = new ConsoleTraceListener();
            var                    rentalConnector = new TrademeRentalConnector("v1/Search/Property/Rental.json?", trace);
            TrademeStatsRepository respository     = new TrademeStatsRepository(new TrademeStatsContext());

            while (true)
            {
                IEnumerable <RentalListing> rentalListings = rentalConnector.GetListings();
                Stopwatch sw = Stopwatch.StartNew();
                sw.Start();
                foreach (var rentalListing in rentalListings)
                {
                    trace.WriteLine($"Adding listing ID: {rentalListing.ListingId}");
                    respository.AddRentalListing(rentalListing);
                }

                respository.SaveChanges();
                sw.Stop();
                trace.WriteLine($"Finished fetching listings, took {sw.Elapsed.TotalSeconds} seconds. Press enter to exit.");
                Thread.Sleep(600000);
            }
        }