public void AddDownload(DownloadItem argDownloadItem)
 {
     try {
     this.debugLogText.AddLine("Download Added: " + argDownloadItem.itemUri.ToString());
     this.AddItemToDownloadList(ref argDownloadItem);
       } catch (Exception exception) {
     MessageBox.Show("Error AddDownload.\r\n" + exception.Message);
       }
       this.ProcessDownloadList();
 }
 public void AddItemToDownloadList(ref DownloadItem argDownloadItem)
 {
     if (!argDownloadItem.isThread) {
     argDownloadItem.isInDownloadQueue = true;
     this.lstDownloadItemList.Add(argDownloadItem);
       } else {
     int index = 0;
     foreach (DownloadItem item in this.lstDownloadItemList) {
       if (!item.isThread) {
     break;
       }
       index++;
     }
     argDownloadItem.isInDownloadQueue = true;
     this.lstDownloadItemList.Insert(index, argDownloadItem);
       }
 }
 public void NotifyDownloadCompleted(DownloadItem argDownloadItem, DownloadStatus dlStatus)
 {
     try {
     this.currentDownloads--;
     foreach (DownloaderTask task in this.downloadTasks) {
       if (task.downloadItem == argDownloadItem) {
     this.downloadTasks.Remove(task);
     break;
       }
     }
     bool flag = true;
     if (dlStatus == DownloadStatus.CompletedSuccessfully) {
       this.debugLogText.AddLine("Download Finish: " + argDownloadItem.itemUri.ToString());
       argDownloadItem.completed = true;
       this.lstDownloadItemList.Remove(argDownloadItem);
     } else {
       if (dlStatus == DownloadStatus.Failed_404) {
     this.debugLogText.AddLine("Download 404'd:  " + argDownloadItem.itemUri.ToString());
     argDownloadItem.completed = true;
     this.lstDownloadItemList.Remove(argDownloadItem);
     if (!Settings.Default.deleteFailedDownloads) {
       goto Label_01C3;
     }
     try {
       File.Delete(argDownloadItem.fullPath);
       goto Label_01C3;
     } catch {
       goto Label_01C3;
     }
       }
       if (dlStatus == DownloadStatus.Cancelled) {
     this.debugLogText.AddLine("Download Cancel: " + argDownloadItem.itemUri.ToString());
     argDownloadItem.completed = false;
     this.lstDownloadItemList.Remove(argDownloadItem);
     if (!Settings.Default.deleteFailedDownloads) {
       goto Label_01C3;
     }
     try {
       File.Delete(argDownloadItem.fullPath);
       goto Label_01C3;
     } catch {
       goto Label_01C3;
     }
       }
       this.debugLogText.AddLine("Download FAILED: " + argDownloadItem.itemUri.ToString());
       if (argDownloadItem.retries < (Settings.Default.maxRetries - 1)) {
     argDownloadItem.started = false;
     argDownloadItem.retries++;
     this.lstDownloadItemList.Remove(argDownloadItem);
     this.AddItemToDownloadList(ref argDownloadItem);
     flag = false;
       }
       if (Settings.Default.deleteFailedDownloads) {
     try {
       File.Delete(argDownloadItem.fullPath);
     } catch {
     }
       }
     }
     Label_01C3:
     if (flag) {
       argDownloadItem.watchThread.NotifyDownloadCompleted(argDownloadItem, dlStatus);
     }
       } catch (Exception exception) {
     MessageBox.Show("Error NotifyDownloadComplete.\r\n" + exception.Message);
       }
 }
 public void NotifyDownloadSatus(DownloadItem argDownloadItem, long fileRemaining)
 {
 }
 public DownloaderTask(DownloadItem argDownloadItem, DownloadManager argDownloadManager, Mutex argMutex)
 {
     mutexNotify = argMutex;
       this.downloadItem = argDownloadItem;
       this.downloadManager = argDownloadManager;
 }
 public void PerformUpdate()
 {
     try {
     this.debugLogText.AddLine("Thread Performing Update: " + this.threadURL);
     if (!this.updatingHtml) {
       this.updatingHtml = true;
       this.threadStatus = 3;
       this.statLastUpdate = DateTime.Now;
       this.SetStatus();
       this.TryDeleteTargetHTML();
       DownloadItem argDownloadItem = new DownloadItem(this.threadURI, this.destFullPath, true, this, this.decuser, this.decpass);
       this.downloadManager.AddDownload(argDownloadItem);
     }
       } catch (Exception exception) {
     MessageBox.Show("Error in PerformUpdate.\r\n" + exception.Message);
       }
 }
 public void NotifyDownloadCompleted(DownloadItem argItem, DownloadStatus argDownloadStatus)
 {
     try {
     if (argItem.isThread) {
       if (argDownloadStatus == DownloadStatus.CompletedSuccessfully) {
     this.ProcessHtml(argItem.fullPath);
       } else if (argDownloadStatus == DownloadStatus.Failed_404) {
     this.thread404d = true;
     this.threadStatus = 4;
       } else {
     this.updatingHtml = false;
     this.threadStatus = 5;
       }
     } else if (argDownloadStatus == DownloadStatus.CompletedSuccessfully) {
       this.statDownloaded++;
     } else {
       this.statDownloadErrors++;
     }
     if (this.threadStatus != 5) {
       if (this.HaveItemsToDownload()) {
     this.threadStatus = 0;
       } else {
     this.threadStatus = 6;
       }
     }
     this.SetStatus(true);
       } catch (Exception exception) {
     MessageBox.Show("Error in NotifyDownloadComplete.\r\n" + exception.Message);
       }
 }