コード例 #1
0
        public void AddDownload(NzbDownload download, string downloadDirectory, string temporaryDirectory)
        {
            ArgumentChecker.ThrowIfNull("download", download);
            ArgumentChecker.ThrowIfNullOrWhitespace("downloadDirectory", downloadDirectory);
            ArgumentChecker.ThrowIfNullOrWhitespace("temporaryDirectory", temporaryDirectory);

            lock (download)
            {
                string downloadFullpath = Path.Combine(downloadDirectory, download.DownloadDirectory);

                foreach (var currentPart in download.Parts)
                {
                    foreach (var currentSegment in currentPart.Segments)
                    {
                        var job = new NzbDownloadJob(downloadFullpath, temporaryDirectory, currentSegment, SegmentDownloadedCheckpoint);

                        _downloadQueue.EnqueueJob(job);
                    }
                }
            }

            lock (_downloads)
            {
                _downloads.Add(download);
            }
        }
コード例 #2
0
        public NzbDownload Parse()
        {
            var newDownload = new NzbDownload(_nzbFilename);

            var nzbFileXmlNodes = this.GetXmlNodesFromNzbFile(_nzbFilename);

            foreach (XmlNode currentNzbFileXmlNode in nzbFileXmlNodes.Where(node => node.Name.Equals("file", StringComparison.OrdinalIgnoreCase)))
            {
                NzbPart newPart = ParsePart(currentNzbFileXmlNode);

                newPart.Parent = newDownload;

                newDownload.Add(newPart);
            }

            return newDownload;
        }
コード例 #3
0
 public void RemoveDownload(NzbDownload download)
 {
     lock (download)
     {
         foreach (var currentPart in download.Parts)
         {
             lock (currentPart)
             {
                 foreach (var currentSegment in currentPart.Segments)
                 {
                     lock (currentSegment)
                     {
                         currentSegment.Status = NzbSegmentStatus.Discarded;
                     }
                 }
             }
         }
     }
 }