public Task HandleAsync(ItemDownloaded broadcasted) { logger.LogInformation("[HandleAsync] handling DownloadItemDownloaded event for: " + broadcasted.DownloadItemId); var item = repository.Find(broadcasted.DownloadItemId); // mark item as processing item = repository.Find(item.Id); item.DownloadedAt = DateTime.Now; item.State = DownloadState.Processing; repository.Update(item); logger.LogInformation($"[Processing] [{item.Name}]"); var movedFiles = new List <MediaItem>(); try { movedFiles = mediaLibraryMover.ProcessDownloadItem(item); } catch (System.Exception e) { logger.LogError("ProcessDownloadItem Failed to process download items"); logger.LogError(e.Message); } // mark item as completed item = repository.Find(item.Id); item.MovedFiles = movedFiles; item.CompletedAt = DateTime.Now; item.State = DownloadState.Completed; repository.Update(item); return(Task.CompletedTask); }
public ObjectResult Get([Required] string token) { var item = repository.Find(token); if (item == null) { return(StatusCode(404, DownloadItemActionError.ItemNotFound)); } service.ComputeDownloadProgress(item); return(Ok(item)); }
public Task HandleAsync(ItemDownloaded broadcasted) { logger.LogInformation("SendItemCompletedEmail START"); var item = downloadItemRepository.Find(broadcasted.DownloadItemId); if (tvShowSubscriptionRepository.IsSubscriptionDownload(item, out var subscribedUsersEmails)) { logger.LogInformation("Item was downloaded by a subscription"); logger.LogInformation($"Sending email to [{string.Join(",", subscribedUsersEmails)}]"); NotifySubscribedUsers(item, subscribedUsersEmails); } else { logger.LogInformation($"Item was manually downloaded by {item.Owner.Email}"); NotifyOwner(item); } logger.LogInformation("SendItemCompletedEmail END"); return(Task.CompletedTask); }