Beispiel #1
0
        void prov_DownloadCompleted(ISearchProvider provider, NzbItem item, string TempFileName, string ErrorMessage)
        {
            try
            {
                if (TempFileName != null && ErrorMessage == null)
                {
                    if (!_NzbItems.Contains(item)) //nothing to do?
                        throw new Exception("NzbItem not contained within list");

                    //combine existing NZB's with eachother
                    CombineNZBs(_CombinedTempFileName, TempFileName);

                    _NzbItems.Remove(item);
                    _DownloadedNzbItems.Add(item);
                    EnableControls(true);

                    if (_NzbItems.Count > 0) //still items left to download?
                    {
                        _prov.DownloadNZB_Async(_NzbItems[0]);
                        return; //wait until next is downloaded
                    }

                    Global.HandleDownloadedNZB(_CombinedTempFileName, txtFriendlyName.Text, cboCategories.Text);

                    foreach(NzbItem DownloadedItem in _DownloadedNzbItems)
                        provider.MarkAsDownloaded(DownloadedItem);

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                    return; //we're done
                }
            }
            catch(Exception e)
            {
                ErrorMessage = e.Message;
            }

            if (ErrorMessage != null)
            {
                //we need to start over, so do cleanup, reset to start
                _NzbItems.AddRange(_DownloadedNzbItems);
                _DownloadedNzbItems.Clear();
                if (File.Exists(_CombinedTempFileName))
                    File.Delete(_CombinedTempFileName);

                MessageBox.Show(ErrorMessage);
            }

            EnableControls(false);
        }
Beispiel #2
0
        void UpdateLatestDownload(NzbItem item)
        {
            long PostedTicks = item.PostedDate.Ticks;
            if (_provider.SearchParams.LatestDownload < PostedTicks)
            {
                _provider.SearchParams.LatestDownload = PostedTicks;
                bool HasBeenUpdated = false;
                SearchSettings parms;

                foreach (ToolStripItem mnuItem in mnuFavorites.Items)
                {
                    if ((parms = mnuItem.Tag as SearchSettings) != null)
                    {
                        if (parms.LatestDownload < _provider.SearchParams.LatestDownload && parms.Text == _provider.SearchParams.Text)
                        {
                            parms.LatestDownload = _provider.SearchParams.LatestDownload;
                            HasBeenUpdated = true;
                        }
                    }
                }

                if (HasBeenUpdated)
                    NzbSearcher.Config.Save();
            }
        }