public int StartDownload(string address) { // put a record in the database. int id; using (IDownloadItemRepository repository = createRepository()) { var item = new DownloadItem() { Address = address, Status = DownloadStatus.Requested }; repository.Add(item); repository.SaveChanges(); // get the database generated id. id = item.Id; } eventBus.Notify(this, EventBusToken.DownlaodRequested); var channelFactory = new ChannelFactory <IDownloadService>("DLS"); var downloadService = channelFactory.CreateChannel(); using (downloadService as IDisposable) downloadService.Download(id); return(id); }
public DownloadItemController(ILogger <DownloadItemController> logger, IDownloadItemService service, IAuthorizationService authorizationService, IDownloadItemRepository repository) { this.logger = logger; this.service = service; this.authorizationService = authorizationService; this.repository = repository; }
public SendItemCompletedEmail(ITvShowSubscriptionRepository tvShowSubscriptionRepository, ISmtpService smtpService, ILogger <SendItemCompletedEmail> logger, IDownloadItemRepository downloadItemRepository, IOptions <NetpipsSettings> options) { this.tvShowSubscriptionRepository = tvShowSubscriptionRepository; this.smtpService = smtpService; this.logger = logger; this.downloadItemRepository = downloadItemRepository; settings = options.Value; }
public DownloadItemService(ILogger <DownloadItemService> logger, IServiceProvider serviceProvider, IOptions <NetpipsSettings> options, IDispatcher dispatcher, IDownloadItemRepository repository) { settings = options.Value; this.serviceProvider = serviceProvider; this.dispatcher = dispatcher; this.repository = repository; this.logger = logger; }
public void Download(int id) { using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Status = DownloadStatus.Delegated; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadedDelegated); ThreadPool.QueueUserWorkItem(ProcessQueueItem, id); }
public TorrentDoneController(ILogger <TorrentDoneController> logger, IDownloadItemRepository repository, IAuthorizationService authorizationService, ITorrentDaemonService torrentDaemonService, IDispatcher dispatcher) { this.logger = logger; this.authorizationService = authorizationService; this.torrentDaemonService = torrentDaemonService; this.repository = repository; this.dispatcher = dispatcher; }
private async void ProcessQueueItem(object status) { var id = (int)status; string address; using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Status = DownloadStatus.Downloading; address = item.Address; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadBegin); try { string value = await DownloadFile(address); using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Html = value; item.Status = DownloadStatus.Downloaded; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadComplete); } catch (Exception e) { using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Status = DownloadStatus.Errored; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadErrored); } }
public void Download(int id) { string address; using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Status = DownloadStatus.Downloading; address = item.Address; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadBegin); string value; if (DownloadFile(address, out value)) { using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Html = value; item.Status = DownloadStatus.Downloaded; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadComplete); } else { using (IDownloadItemRepository repository = createRepository()) { var item = repository.Get(id); item.Status = DownloadStatus.Errored; repository.SaveChanges(); } eventBus.Notify(this, EventBusToken.DownloadErrored); } }
public StatusController(IDownloadItemRepository repository) { this.repository = repository; }
public ArchiveDownloadItemsJob(ILogger <ArchiveDownloadItemsJob> logger, IDownloadItemRepository repository, IDownloadItemService service) { this.logger = logger; this.repository = repository; this.service = service; }
public ProcessDownloadItem(ILogger <ProcessDownloadItem> logger, IDownloadItemRepository repository, IMediaLibraryMover mediaLibraryMover) { this.logger = logger; this.repository = repository; this.mediaLibraryMover = mediaLibraryMover; }