partial void DeleteEpisode(Episode instance);
 partial void UpdateEpisode(Episode instance);
 partial void InsertEpisode(Episode instance);
示例#4
0
        /// <summary>
        /// Updates the DB episode.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <param name="e">The db episode.</param>
        /// <exception cref="Uncas.PodCastPlayer.Repository.RepositoryException"></exception>
        private void UpdateDBEpisode(
            Episode episode,
            DBEpisode e)
        {
            e.Date = episode.Date;
            e.Description = episode.Description;
            e.DownloadedBytes =
                episode.DownloadedBytes;
            e.FileName = episode.FileName;
            e.FileSizeInBytes =
                episode.FileSizeInBytes;
            e.MediaUrl = episode.MediaUrl.ToString();
            e.PendingDownload =
                episode.PendingDownload;
            e.Title = episode.Title;

            try
            {
                this.DB.Update<DBEpisode>(e);
            }
            catch (Exception ex)
            {
                // TODO: EXCEPTION: Unknown SubSonic exception
                throw new RepositoryException(
                    "Error updating episode",
                    ex);
            }
        }
示例#5
0
        /// <summary>
        /// Updates the episode.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <exception cref="Uncas.PodCastPlayer.Repository.RepositoryException"></exception>
        public void UpdateEpisode(
            Episode episode)
        {
            DBEpisode e;
            try
            {
                e = this.DB.Single<DBEpisode>(
                    episode.Id);
            }
            catch (Exception ex)
            {
                // TODO: EXCEPTION: Unknown SubSonic exception
                throw new RepositoryException(
                    "Error retrieving episode",
                    ex);
            }

            if (e == null)
            {
                return;
            }

            this.UpdateDBEpisode(episode, e);
        }
示例#6
0
        /// <summary>
        /// Downloads the episode.
        /// </summary>
        /// <param name="episode">The episode.</param>
        /// <exception cref="Uncas.PodCastPlayer.Utility.UtilityException"></exception>
        /// <exception cref="Uncas.PodCastPlayer.Repository.RepositoryException"></exception>
        /// <exception cref="Uncas.PodCastPlayer.AppServices.ServiceException"></exception>
        private void DownloadEpisode(
            Episode episode)
        {
            Debug.Assert(
                episode != null,
                "A non-null episode is required internally.");
            var fileName = episode.FileName;
            var relativeFolderPath =
                Path.Combine(
                "PodCasts",
                episode.PodCast.Name);
            var absoluteFolderPath =
                Path.Combine(
                    Environment.GetFolderPath(
                        Environment.SpecialFolder.MyMusic),
                    relativeFolderPath);
            var filePath =
                Path.Combine(
                    absoluteFolderPath,
                    fileName);

            // Gets stream:
            var podCastStream =
                this.Downloader.GetEpisodeStream(
                episode.MediaUrl);

            // Saves stream:
            var downloadedBytes =
                this.saver.SaveStream(
                filePath,
                podCastStream.Length,
                podCastStream.Stream);

            // Returns info about how it all went:
            var mediaInfo =
                new EpisodeMediaInfo
                {
                    FileSizeInBytes = podCastStream.Length,
                    DownloadedBytes = downloadedBytes
                };

            episode.MediaInfo = mediaInfo;
            episode.PendingDownload =
                !mediaInfo.DownloadCompleted;

            this.EpisodeRepository.UpdateEpisode(episode);
        }