Ejemplo n.º 1
0
 internal void Add(NzbSegment newSegment)
 {
     lock (this.Segments)
     {
         lock (newSegment)
         {
             this.Segments.Add(newSegment);
             this.SizeInBytes += newSegment.SizeInBytes;
         }
     }
 }
        public NzbDownloadJob(string downloadDirectory, string temporaryDirectory, NzbSegment segment, Action<NzbDownloadJob> callWhenDone)
        {
            ArgumentChecker.ThrowIfNullOrWhitespace("downloadDirectory", downloadDirectory);
            ArgumentChecker.ThrowIfNullOrWhitespace("temporaryDirectory", temporaryDirectory);
            ArgumentChecker.ThrowIfNull("segment", segment);
            ArgumentChecker.ThrowIfNull("callWhenDone", callWhenDone);

            this.DownloadDirectory = downloadDirectory;
            this.TemporaryDirectory = temporaryDirectory;
            this.Segment = segment;
            this.CallWhenDone = callWhenDone;
        }
 public NzbSegmentDownloadFailedException(NzbSegment segment, string message, Exception innerException)
     : base(message, innerException)
 {
 }
 public NzbSegmentDownloadFailedException(NzbSegment segment, string message)
     : base(message)
 {
 }
 public NzbSegmentDownloadFailedException(NzbSegment segment)
     : base()
 {
 }
        public string DownloadSegment(NzbSegment segment)
        {
            string downloadedArticle = null;

            foreach (var currentGroup in segment.Groups)
            {
                _nntpParser.JoinGroup(currentGroup);

                var getBodyCommand = new NzbServerGetBodyCommand(segment.Id);

                _nntpParser.TrySendCommand(getBodyCommand);

                try
                {
                    downloadedArticle = _nntpParser.DownloadArticle(segment.Id);

                    return downloadedArticle;
                }
                catch (NzbArticleNotFoundException)
                {
                }
                catch (NzbArticleDownloadFailedException)
                {
                    throw new NzbSegmentDownloadFailedException(segment);
                }
            }

            throw new NzbSegmentDownloadFailedException(segment);
        }