Ejemplo n.º 1
0
        /// <summary>
        /// Queue a download action.
        /// </summary>
        /// <param name="client">Source remote client.</param>
        /// <param name="dataStore">Destination data source.</param>
        public void QueueDownload(RemoteClient client, DataStore dataStore)
        {
            if (_downloadActions.Count(x => x.Client.Address.RawUrl == client.Address.RawUrl) > 0 && _downloadActions.Count(x => x.Store.Location == dataStore.Location) > 0)
            {
                throw new InvalidOperationException("This operation is already queued");
            }

            DownloadAction action = new DownloadAction(client, dataStore);

            _downloadActions.Add(action);
            action.DownloadStarted   += action_DownloadStarted;
            action.DownloadFailed    += action_DownloadFailed;
            action.DownloadCompleted += action_DownloadCompleted;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Starts the download process.
 /// </summary>
 public virtual void Start()
 {
     if (IsDownloading)
     {
         throw new InvalidOperationException("Download Already in Progress!");
     }
     onDownloadStarted(new DownloadEventArgs(_downloadActions.Count));
     IsDownloading = true;
     foreach (var item in _downloadActions)
     {
         _currentAction = item;
         item.Start();
     }
     IsDownloading = !IsDownloading;
     onDownloadCompleted(new DownloadEventArgs(_downloadActions.Count, _itemsCompleted, _itemsFailed));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a new DataDownloader instance
 /// </summary>
 internal DataDownloader()
 {
     _downloadActions = new List <DownloadAction>();
     _itemsCompleted  = 0; _itemsFailed = 0;
     _currentAction   = null;
 }