コード例 #1
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);
     }
 }
コード例 #2
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);
        }