Exemplo n.º 1
0
        private void UpdateProcessStatus(object op, Task task)
        {
            var op2 = (OperationInfo)op;

            op2.FinishedOn = DateTime.UtcNow;

            switch (task.Status)
            {
            case TaskStatus.RanToCompletion:
                op2.Status     = OperationStatus.Completed;
                op2.StatusInfo = string.Format("Scraping done. Torrents saved: {0}", op2.ExtraData["updated"]);
                break;

            case TaskStatus.Faulted:
                op2.Status = OperationStatus.Faulted;
                op2.Error  = task.Exception != null?task.Exception.ToString() : "Unexpected error";

                break;

            case TaskStatus.Canceled:
                op2.Status = OperationStatus.Cancelled;
                break;
            }

            var opsRepo = new OperationsRepository();

            this.UpdateOperationInfo(op2, opsRepo, true);
        }
Exemplo n.º 2
0
 public async System.Threading.Tasks.Task <OperationResult <Operation> > CreateOperation(Operation operation)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Operation> >(() =>
     {
         OperationResult <Operation> result = new OperationResult <Operation>();
         try
         {
             if (IsInCompany())
             {
                 operation.CompanyId = CurrentUser.CompanyId.Value;
                 Operation newOperation = OperationsRepository.CreateOrUpdate(operation);
                 if (newOperation.Id > 0)
                 {
                     result.SingleResult = newOperation;
                     result.Result = true;
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
        private bool _disposedValue; // To detect redundant calls

        public GererMesCompteTestContext(PostScenarioCleaner cleaner)
        {
            Cleaner       = cleaner;
            GmcClient     = new GererMesComptesClient(h => new LoggingHandler(h));
            GmcAccounts   = new AccountInfoRepository(GmcClient);
            GmcOperations = new OperationsRepository(GmcClient);
        }
Exemplo n.º 4
0
 public async System.Threading.Tasks.Task <OperationResult <Operation> > GetOperations(int pageSize, int pageNumber, bool descending)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Operation> >(() =>
     {
         OperationResult <Operation> result = new OperationResult <Operation>();
         try
         {
             if (IsInCompany())
             {
                 result.Count = OperationsRepository.Count("CompanyId = @CompanyId", new { CompanyId = CurrentUser.CompanyId.Value });
                 if (result.Count > 0)
                 {
                     result.MultipleResult = OperationsRepository.Search("CompanyId = @CompanyId",
                                                                         new { PageSize = pageSize, PageNumber = pageNumber, CompanyId = CurrentUser.CompanyId.Value }, descending);
                 }
                 result.Result = true;
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
Exemplo n.º 5
0
        public void Setup()
        {
            this.testDir = "TestFiles";
            Directory.CreateDirectory(this.testDir);

            var formatter = new BinaryFormatter();

            this.operationDataAccess      = new FormatterDataAccess <Operation>(formatter);
            this.operationIndexDataAccess =
                new FormatterDataAccess <OperationsIndex>(formatter);

            this.configurationMock = new Mock <IConfiguration>();
            var section = EConfigSection.SAROMSettings.ToString();

            this.configurationMock
            .Setup(c => c.GetSection(section)[EConfigKey.StoragePath.ToString()])
            .Returns(this.testDir);
            this.configurationMock
            .Setup(c => c.GetSection(section)[EConfigKey.FileExtension.ToString()])
            .Returns(".dat");
            this.configurationMock
            .Setup(c => c.GetSection(section)[EConfigKey.IndexFile.ToString()])
            .Returns(Path.Combine(this.testDir, "TestOperationIndex.dat"));

            this.repository = new OperationsRepository(
                operationDataAccess,
                operationIndexDataAccess,
                configurationMock.Object);
        }
Exemplo n.º 6
0
        public MainViewModel()
        {
            // Initialize Data layer
            var fs                          = new MyAccounts.Business.IO.WindowsFileSystem();
            var workingCopy                 = new WorkingCopy(fs, Properties.Settings.Default.WorkingFolder);
            var accountsRepository          = new AccountsRepository(workingCopy);
            var accountCommandRepository    = new AccountCommandRepository(workingCopy);
            var placesRepository            = new PlacesRepository();
            var placeProvider               = PlaceProvider.Load(placesRepository);
            var placeInfoResolver           = new PlaceInfoResolver(placeProvider);
            var operationPatternTransformer = new UnifiedAccountOperationPatternTransformer(placeInfoResolver);
            var operationsRepository        = new OperationsRepository(workingCopy, new CsvAccountOperationManager(), operationPatternTransformer);

            // Initialize Managers
            var operationsManager = new OperationsManager(App.CacheManager, operationsRepository);
            var accountsManager   = new AccountsManager(App.CacheManager, accountsRepository);
            var importManager     = new ImportManager(App.CacheManager, accountCommandRepository, operationsManager);

            // Initialize View Models

            BusyIndicator = new BusyIndicatorViewModel();

            ImportsManagerViewModel = new ImportsManagerViewModel(BusyIndicator, fs, importManager);

            OperationsManagerViewModel = new OperationsManagerViewModel(BusyIndicator, operationsManager, importManager);
            AccountsManagerViewModel   = new AccountsManagerViewModel(BusyIndicator, accountsManager, operationsManager, importManager);
            DashboardViewModel         = new DashboardViewModel(BusyIndicator);
            GmcManager       = new GmcManager(BusyIndicator, App.CacheManager, operationsManager);
            _settingsManager = new SettingsManager(App.CacheManager);

            MessengerInstance.Register <Properties.Settings>(this, OnSettingsUpdated);
            _asyncMessageReceiver = new AsyncMessageReceiver(MessengerInstance);
            _asyncMessageReceiver.RegisterAsync <AccountDataInvalidated>(this, data => Refresh());

            if (!IsInDesignMode)
            {
                LoadCommand    = new AsyncCommand(Load);
                RefreshCommand = new AsyncCommand(Refresh);
            }
            else
            {
                AccountsManagerViewModel.Accounts.Add(
                    new AccountViewModel
                {
                    Name   = "Blaise CC",
                    Status =
                    {
                        Operations            =          7,
                        Balance               = 2541.7345M,
                        LastImportedOperation = "2012-0001"
                    }
                });

                AccountsManagerViewModel.CurrentAccount = AccountsManagerViewModel.Accounts.First();
            }
        }
Exemplo n.º 7
0
 private void UpdateOperationInfo(OperationInfo op, OperationsRepository opsRepo, bool forceUpdate = false)
 {
     if (this.updateProgressInDatabase || forceUpdate)
     {
         var o = opsRepo.Find(op.Id);
         o.Info          = op;
         o.LastUpdatedOn = DateTime.UtcNow;
         opsRepo.Save(o);
     }
 }
        public async void Counts_Operations()
        {
            //Act
            var result = await OperationsRepository.Object.Count();

            var expected = Context.Operations.Count();

            //Assert
            result.Should()
            .Equals(expected);
            OperationsRepository.Verify();

            DbContextFactory.Destroy(Context);
        }
        public ClassificationStepsContext()
        {
            CsvAccountOperationManager = new CsvAccountOperationManager();
            Transformer = new UnifiedAccountOperationPatternTransformer(
                new PlaceInfoResolver(PlaceProvider.Load(new PlacesRepository())));
            WorkingCopy = new WorkingCopy(new FileSystemAdapter(new MockFileSystem()), @"c:\WorkingCopy");

            AccountCommandRepository = new AccountCommandRepository(WorkingCopy);
            var operationsRepository = new OperationsRepository(WorkingCopy, CsvAccountOperationManager, Transformer);

            var cacheManager = new CacheManager(new NoCache());

            OperationsManager = new OperationsManager(cacheManager, operationsRepository);
            ImportManager     = new ImportManager(cacheManager, AccountCommandRepository, OperationsManager);

            AccountId = Guid.NewGuid();
        }
        public async void Deletes_Operation_Successfully()
        {
            //Arrange
            var user      = Context.Users.First();
            var operation = Context.Operations.First();

            OperationsRepository.Setup(x => x.Delete(It.IsAny <DateTime>(), user.Id)).ReturnsAsync(true).Verifiable();

            //Act
            var result = await OperationsRepository.Object.Delete(operation.Date, user.Id);

            //Assert
            result.Should()
            .BeTrue();
            OperationsRepository.Verify();

            DbContextFactory.Destroy(Context);
        }
        public async void Starts_Sale_Process()
        {
            //Arrange
            var contact = new Contact
            {
                Id          = Guid.Empty,
                Name        = "Contact",
                Type        = "Client",
                Company     = "Contact co.",
                PhoneNumber = "000",
                Email       = "Contact@",
                Notes       = "ABC",
                Status      = "Inactive",
                Source      = "Social Media"
            };

            var user = new User
            {
                Id          = "1U",
                UserName    = "******",
                DisplayName = "TestUser ",
                Email       = "@test",
                Level       = "mid"
            };

            UserAccessor.Setup(x => x.GetLoggedUser()).ReturnsAsync(user).Verifiable();
            OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), user)).ReturnsAsync(true).Verifiable();
            Mediator.Setup(x => x.Send(It.IsAny <StartSaleProcessCommand>(), new CancellationToken()))
            .ReturnsAsync(Unit.Value);

            //Act
            var addContactCommand = new StartSaleProcessCommand(contact);
            var handler           = new StartSaleProcessCommandHandler(Context, UserAccessor.Object, OperationsRepository.Object);
            var result            = await handler.Handle(addContactCommand, new CancellationToken());

            //Assert
            result.Should()
            .BeOfType <Unit>()
            .Equals(Unit.Value);
            UserAccessor.Verify();
            OperationsRepository.Verify();

            DbContextFactory.Destroy(Context);
        }
Exemplo n.º 12
0
 public async System.Threading.Tasks.Task <OperationResult <Operation> > UpdateOperation(Operation operation)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Operation> >(() =>
     {
         OperationResult <Operation> result = new OperationResult <Operation>();
         try
         {
             if (IsInCompany(operation.CompanyId))
             {
                 result.Result = OperationsRepository.Update(operation);
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
        public async void Adds_New_Operation_Successfully()
        {
            //Arrange
            var user      = Context.Users.First();
            var operation = new Operation
            {
                Opportunity = true,
                Date        = DateTime.Now,
            };

            OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), user)).ReturnsAsync(true).Verifiable();

            //Act
            var result = await OperationsRepository.Object.Add(operation, user);

            //Assert
            result.Should()
            .BeTrue();
            OperationsRepository.Verify();

            DbContextFactory.Destroy(Context);
        }
Exemplo n.º 14
0
        private void UpdateMovies(MoviesRepository moviesRepo, OperationInfo op, OperationsRepository opsRepo)
        {
            op.StatusInfo = "Scraping movies";
            this.UpdateOperationInfo(op, opsRepo);

            var scraper = new ImdbScraper();

            var moviesScraped  = 0;
            var moviesToUpdate = moviesRepo.GetMoviesToUpdate();

            foreach (var movie in moviesToUpdate)
            {
                scraper.UpdateMovieDetails(movie);
                moviesRepo.Save(movie);

                moviesScraped++;
                op.ExtraData["moviesScraped"] = moviesScraped.ToString(CultureInfo.InvariantCulture);
                this.UpdateOperationInfo(op, opsRepo);

                op.CancellationTokenSource.Token.ThrowIfCancellationRequested();
            }
        }
        public async void Deletes_Order_Successfully()
        {
            //Arrange
            var order = Context.Orders.First();

            OperationsRepository.Setup(x => x.Delete(It.IsAny<DateTime>(), order.UserId)).ReturnsAsync(true).Verifiable();
            Mediator.Setup(x => x.Send(It.IsAny<DeleteOrderCommand>(), new CancellationToken()))
                .ReturnsAsync(Unit.Value);

            //Act
            var deleteOrderCommand = new DeleteOrderCommand(order.Client, order);
            var handler = new DeleteOrderCommandHandler(Context, OperationsRepository.Object);
            var result = await handler.Handle(deleteOrderCommand, new CancellationToken());

            //Assert
            result.Should()
                .BeOfType<Unit>()
                .Equals(Unit.Value);
            OperationsRepository.Verify();

            DbContextFactory.Destroy(Context);
        }
Exemplo n.º 16
0
        public static void Initialize(TestContext testContext)
        {
            IDbContext context = new DbContext();

            IRepository <Certificate, int>    certificatesRepository    = new CertificateRepository(context);
            IRepository <Company, int>        companiesRepository       = new CompaniesRepository(context);
            IRepository <Equipment, int>      equipmentsRepository      = new EquipmentRepository(context);
            IRepository <Event, int>          eventsRepository          = new EventsRepository(context);
            IRepository <Game, int>           gamesRepository           = new GamesRepository(context);
            IRepository <GameType, int>       gameTypesRepository       = new GameTypesRepository(context);
            IRepository <News, int>           newsRepository            = new NewsRepository(context);
            IRepository <Operation, int>      operationsRepository      = new OperationsRepository(context);
            IRepository <Playground, int>     playgroundsRepository     = new PlaygroundsRepository(context);
            IRepository <Task, int>           tasksRepository           = new TasksRepository(context);
            IRepository <EquipmentOrder, int> equipmentOrdersRepository = new EquipmentOrdersRepository(context);
            UserStore <IdentityUser>          userStore = new UserStore <IdentityUser>(context);
            RoleStore <IdentityRole>          roleStore = new RoleStore <IdentityRole>(context);

            _loggingService = new TestLoggingService();

            _manager = new PaintballManager(context,
                                            certificatesRepository,
                                            companiesRepository,
                                            equipmentsRepository,
                                            eventsRepository,
                                            gamesRepository,
                                            gameTypesRepository,
                                            newsRepository,
                                            operationsRepository,
                                            playgroundsRepository,
                                            equipmentOrdersRepository,
                                            tasksRepository,
                                            userStore,
                                            roleStore,
                                            _loggingService
                                            );

            _firstUser = _manager.UserStore.Users.FirstOrDefault();
        }
Exemplo n.º 17
0
        public void ProcessTorrentNews(int maxPages, string age, OperationInfo operation)
        {
            Task.Factory.StartNew(
                (op) =>
            {
                var op2 = (OperationInfo)op;
                op2.CancellationTokenSource.Token.ThrowIfCancellationRequested();

                op2.Status    = OperationStatus.Running;
                op2.StartedOn = DateTime.UtcNow;
                op2.ExtraData.Add("removed", "N/A");
                op2.ExtraData.Add("updated", "N/A");
                op2.ExtraData.Add("scraped", "N/A");
                op2.ExtraData.Add("moviesScraped", "N/A");
                op2.ExtraData.Add("unwantedMoviesRemoved", "N/A");
                op2.ExtraData.Add("scoresUpdated", "N/A");

                var torrentsRepo = new TorrentsRepository();
                var moviesRepo   = new MoviesRepository();

                var opsRepo = new OperationsRepository();
                var o       = new Operation {
                    Id = op2.Id, Info = op2, AddedOn = DateTime.UtcNow
                };
                opsRepo.Save(o);

                this.RemoveOldTorrents(op2, torrentsRepo, opsRepo);
                this.UpdateTorrents(maxPages, age, torrentsRepo, op2, moviesRepo, opsRepo);
                this.UpdateMovies(moviesRepo, op2, opsRepo);
                this.RemoveUnwantedTorrents(moviesRepo, torrentsRepo, op2, opsRepo);
                this.UpdateAwards(moviesRepo, torrentsRepo, op2, opsRepo);
            },
                operation,
                operation.CancellationTokenSource.Token)
            .ContinueWith(
                (task, op) => this.UpdateProcessStatus(op, task),
                operation);
        }
Exemplo n.º 18
0
        public void Setup()
        {
            this.configurationMock = new Mock <IConfiguration>();
            var section = EConfigSection.SAROMSettings.ToString();

            this.configurationMock
            .Setup(c => c.GetSection(section)[EConfigKey.StoragePath.ToString()])
            .Returns("./");
            this.configurationMock
            .Setup(c => c.GetSection(section)[EConfigKey.FileExtension.ToString()])
            .Returns(".sod");
            this.configurationMock
            .Setup(c => c.GetSection(section)[EConfigKey.IndexFile.ToString()])
            .Returns("TestOperationIndex.dat");

            this.dataAccessMock      = new Mock <IFileDataAccess <Operation> >();
            this.indexDataAccessMock = new Mock <IFileDataAccess <OperationsIndex> >();

            this.repository = new OperationsRepository(
                this.dataAccessMock.Object,
                this.indexDataAccessMock.Object,
                configurationMock.Object);
        }
Exemplo n.º 19
0
 public async System.Threading.Tasks.Task <OperationResult <Operation> > DeleteOperation(int id)
 {
     return(await System.Threading.Tasks.Task.Factory.StartNew <OperationResult <Operation> >(() =>
     {
         OperationResult <Operation> result = new OperationResult <Operation>();
         try
         {
             Operation operation = OperationsRepository.Read(id);
             if (operation != null)
             {
                 if (IsInCompany(operation.CompanyId))
                 {
                     result.Result = OperationsRepository.Delete(id);
                 }
             }
         }
         catch (Exception ex)
         {
             LoggingService.Log(ex);
         }
         return result;
     }));
 }
        public async void Adds_New_Order_Successfully()
        {
            //Arrange
            var contact = Context.Contacts.First();
            var user    = Context.Users.First();

            UserAccessor.Setup(x => x.GetLoggedUser()).ReturnsAsync(user);
            OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), user)).ReturnsAsync(true).Verifiable();
            Mediator.Setup(x => x.Send(It.IsAny <AddOrderCommand>(), new CancellationToken()))
            .ReturnsAsync(Unit.Value);

            //Act
            var addOrderCommand = new AddOrderCommand(contact, true, "test", 10, 100, "");
            var handler         = new AddOrderCommandHandler(Context, UserAccessor.Object, OperationsRepository.Object);
            var result          = await handler.Handle(addOrderCommand, new CancellationToken());

            //Assert
            result.Should()
            .BeOfType <Unit>()
            .Equals(Unit.Value);

            DbContextFactory.Destroy(Context);
        }
        public async void Closes_Order_Successfully()
        {
            //Arrange
            var order = Context.Orders.First();
            var user  = Context.Users.FirstOrDefault(x => x.Id == order.UserId);

            UserAccessor.Setup(x => x.GetLoggedUser()).ReturnsAsync(user).Verifiable();
            OperationsRepository.Setup(x => x.Add(It.IsAny <Operation>(), It.IsAny <User>())).ReturnsAsync(true).Verifiable();
            Mediator.Setup(x => x.Send(It.IsAny <CloseOrderCommand>(), new CancellationToken()))
            .ReturnsAsync(Unit.Value);

            //Act
            var closeOrderCommand = new CloseOrderCommand(order);
            var handler           = new CloseOrderCommandHandler(Context, UserAccessor.Object, OperationsRepository.Object);
            var result            = await handler.Handle(closeOrderCommand, new CancellationToken());

            //Assert
            result.Should()
            .BeOfType <Unit>()
            .Equals(Unit.Value);
            OperationsRepository.Verify();

            DbContextFactory.Destroy(Context);
        }
Exemplo n.º 22
0
        public HttpResponseMessage GetOperationsLog(string secret)
        {
            var opsRepo = new OperationsRepository();

            return(this.Request.CreateResponse(HttpStatusCode.Accepted, opsRepo.FindAll().OrderByDescending(item => item.AddedOn)));
        }
 public IMT_Operations(PDMHelpers.ILoggerManager loggerManager, OperationsRepository repository) : base(repository.Connection)
 {
     trace                 = loggerManager.CreateTracer(GetType());
     this.repository       = repository;
     this.repository.Trace = trace;
 }
Exemplo n.º 24
0
        private void UpdateAwards(MoviesRepository moviesRepo, TorrentsRepository torrentsRepo, OperationInfo op, OperationsRepository opsRepo)
        {
            op.StatusInfo = "Updating awards";
            this.UpdateOperationInfo(op, opsRepo);

            //Logic for updating Latest
            torrentsRepo.UpdateLatestToFalse();

            var moviesCache = new Dictionary <string, Movie>();
            var torrents    = torrentsRepo.GetAllSortedByImdbIdAndAddedOn();

            var     i = 0;
            string  previousImdbId = null;
            int     previousId     = 0;
            Torrent current        = null;

            foreach (var t in torrents)
            {
                current = t;

                //Logic for updating Latest
                if (previousImdbId != null)
                {
                    if (previousImdbId != current.ImdbId)
                    {
                        var previous = torrentsRepo.Find(previousId);
                        previous.Latest = true;
                        torrentsRepo.Save(previous);
                    }
                }

                previousImdbId = current.ImdbId;
                previousId     = current.Id;
                //

                var isDirty = false;

                Movie movie = null;
                if (current.HasImdbId())
                {
                    if (!moviesCache.TryGetValue(current.ImdbId, out movie))
                    {
                        movie = moviesRepo.Find(current.ImdbId);
                        moviesCache.Add(current.ImdbId, movie);
                    }
                }

                if (movie != null)
                {
                    current.ImdbAward       = this.GetValue(current.ImdbAward, movie.ImdbVotes >= 1000 && movie.ImdbRating >= 70, ref isDirty);
                    current.MetacriticAward = this.GetValue(current.MetacriticAward, movie.McMetascore >= 70, ref isDirty);
                }
                else
                {
                    current.ImdbAward       = this.GetValue(current.ImdbAward, false, ref isDirty);
                    current.MetacriticAward = this.GetValue(current.MetacriticAward, false, ref isDirty);
                }

                current.SuperPopularityAward = this.GetValue(current.SuperPopularityAward, current.Seed >= 3000 || current.CommentsCount >= 100, ref isDirty);
                current.PopularityAward      = this.GetValue(current.PopularityAward, !current.SuperPopularityAward && (current.Seed >= 1000 || current.CommentsCount >= 20), ref isDirty);

                current.Score = this.GetValue(current.Score, this.CalcScore(current), ref isDirty);

                if (isDirty)
                {
                    torrentsRepo.Save(current);
                }

                i++;

                op.ExtraData["scoresUpdated"] = i.ToString(CultureInfo.InvariantCulture);
                this.UpdateOperationInfo(op, opsRepo);
                op.CancellationTokenSource.Token.ThrowIfCancellationRequested();
            }

            //Logic for updating Latest
            if (current != null)
            {
                current.Latest = true;
                torrentsRepo.Save(current);
            }
        }
Exemplo n.º 25
0
        private void RemoveUnwantedTorrents(MoviesRepository moviesRepo, TorrentsRepository torrentsRepo, OperationInfo op, OperationsRepository opsRepo)
        {
            op.StatusInfo = "Removing unwanted torrents";
            this.UpdateOperationInfo(op, opsRepo);

            var i = 0;
            var moviesToRemove = moviesRepo.GetUnwantedMovies();

            foreach (var m in moviesToRemove)
            {
                torrentsRepo.RemoveByImdbId(m.Id);
                moviesRepo.Remove(m.Id);

                i++;

                op.ExtraData["unwantedMoviesRemoved"] = i.ToString(CultureInfo.InvariantCulture);
                this.UpdateOperationInfo(op, opsRepo);
                op.CancellationTokenSource.Token.ThrowIfCancellationRequested();
            }
        }
Exemplo n.º 26
0
        private void RemoveOldTorrents(OperationInfo op, TorrentsRepository torrentsRepo, OperationsRepository opsRepo)
        {
            op.StatusInfo = "Removing old torrents";

            this.UpdateOperationInfo(op, opsRepo);

            var torrentsRemoved = torrentsRepo.RemoveOldTorrents();

            op.ExtraData["removed"] = torrentsRemoved.ToString(CultureInfo.InvariantCulture);

            this.UpdateOperationInfo(op, opsRepo);
        }
Exemplo n.º 27
0
        private void UpdateTorrents(int maxPages, string age, TorrentsRepository torrentsRepo, OperationInfo op, MoviesRepository moviesRepo, OperationsRepository opsRepo)
        {
            var counter  = 0;
            var scraper  = new KassScraper(torrentsRepo, maxPages, age);
            var torrents = scraper.GetLatestTorrents(op, o => this.UpdateOperationInfo(o, opsRepo));

            foreach (var t in torrents)
            {
                torrentsRepo.Save(t);

                if (t.ImdbId != "NA")
                {
                    var movie = moviesRepo.Find(t.ImdbId);
                    if (movie == null)
                    {
                        var newMovie = new Movie {
                            Id = t.ImdbId
                        };
                        if (!string.IsNullOrEmpty(t.Poster))
                        {
                            newMovie.Poster = t.Poster;
                        }

                        moviesRepo.Save(newMovie);
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(t.Poster) && !t.Poster.Equals(movie.Poster))
                        {
                            movie.Poster = t.Poster;
                            moviesRepo.Save(movie);
                        }
                    }
                }

                counter++;
                op.ExtraData["updated"] = counter.ToString(CultureInfo.InvariantCulture);
                this.UpdateOperationInfo(op, opsRepo);

                op.CancellationTokenSource.Token.ThrowIfCancellationRequested();
            }
        }