public void GetLastNotProcessedPageDetails()
 {
     using (Dal db = new Dal())
     {
         OfferDetailsFetcherFactory factory = new AllegroOfferDetailsFetcherFactory();
         IOfferDetailsFetcher       fetcher = factory.GetOfferDetailsFetcher(1);
         fetcher.Run(db);
     }
 }
 public void GetLastNotProcessedOffersDoNotDeadLock(int offerCount)
 {
     using (Dal db = new Dal())
     {
         OfferDetailsFetcherFactory factory = new AllegroOfferDetailsFetcherFactory();
         IOfferDetailsFetcher       fetcher = factory.GetOfferDetailsFetcher(0);
         IEnumerable <Offer>        offers  = fetcher.GetLastNotProcessedOffers(db, offerCount);
         int offersCount = offers.Count();
         Assert.IsTrue(offersCount <= offerCount && offersCount > 0);
     }
 }
示例#3
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            int pararellTasks = 0;

            if (Program.AppArgs.Count() < 3)
            {
                #if DEBUG
                WebApiUserId  = 2;
                pararellTasks = 1;
                CategoryId    = 16520;
                //configure by hand
                #endif
                Console.WriteLine("Error, application MUST contain 2 arguments - user id and tasks count");
            }
            else
            {
                if (int.TryParse(Program.AppArgs[0], out _) && int.TryParse(Program.AppArgs[1], out _) && int.TryParse(Program.AppArgs[2], out _))
                {
                    int userId = int.Parse(Program.AppArgs[0]);
                    pararellTasks = int.Parse(Program.AppArgs[1]);
                    CategoryId    = int.Parse(Program.AppArgs[2]);
                    using (IDal db = new Dal())
                    {
                        int userCount =
                            (int)db.ExecuteScalar(
                                "SELECT COUNT(*) FROM WebApiUsers with (nolock) where Id = " + userId);
                        if (userCount == 0)
                        {
                            throw new Exception($"User with id {userId} cannot be fount");
                        }
                        else
                        {
                            WebApiUserId = userId;
                        }
                    }
                }
                else
                {
                    throw new Exception("User id cannot be parsed to int. Val: " + Program.AppArgs[0]);
                }
            }

            OfferDetailsFetcherFactory factory = new AllegroOfferDetailsFetcherFactory();
            IOfferDetailsFetcher       fetcher = factory.GetOfferDetailsFetcher(pararellTasks);
            using (Dal db = new Dal())
            {
                fetcher.Run(db);
            }
            lifetimeApp.StopApplication();
        }