public FileDataContract DownloadWholeAudioBook(DownloadWholeBookContract requestContract) { m_authorizationManager.AuthorizeBook(requestContract.BookId); var audioType = (AudioType)requestContract.RequestedAudioType; var book = m_bookVersionRepository.GetBookWithLastVersion(requestContract.BookId); FullBookRecording recording = m_bookVersionRepository.GetFullBookRecording(book.LastVersion.Id, audioType); if (recording == null) { var message = $"Cannot locate full book recording archive for book:'{requestContract.BookId}' of requested type:'{requestContract.RequestedAudioType}'"; if (m_log.IsErrorEnabled) { m_log.ErrorFormat(message); } throw new ArgumentException(message); } var stream = m_fileSystemManager.GetResource(book.Guid, book.LastVersion.VersionId, recording.FileName, ResourceType.Audio); return(new FileDataContract { FileName = recording.FileName, FileData = stream, MimeType = recording.MimeType, }); }
public FileDataContract DownloadWholeAudiobook(DownloadWholeBookContract requestContract) { try { return(Channel.DownloadWholeAudiobook(requestContract)); } catch (CommunicationException ex) { if (m_log.IsErrorEnabled) { m_log.ErrorFormat("{0} failed with: {1}", GetCurrentMethod(), ex); } throw; } catch (TimeoutException ex) { if (m_log.IsErrorEnabled) { m_log.ErrorFormat("{0} failed with: {1}", GetCurrentMethod(), ex); } throw; } catch (ObjectDisposedException ex) { if (m_log.IsErrorEnabled) { m_log.ErrorFormat("{0} failed with: {1}", GetCurrentMethod(), ex); } throw; } }
public FileResult DownloadAudioBook(long bookId, AudioTypeContract audioType) { var audioTrackContract = new DownloadWholeBookContract { BookId = bookId, RequestedAudioType = audioType }; using (var client = GetStreamingClient()) { var audioTrack = client.DownloadWholeAudiobook(audioTrackContract); var result = new FileStreamResult(audioTrack.FileData, audioTrack.MimeType) { FileDownloadName = audioTrack.FileName }; return(result); } }
public FileDataContract DownloadWholeAudiobook(DownloadWholeBookContract requestContract) { return(m_audioBookManager.DownloadWholeAudioBook(requestContract)); }