private void BlisshiveDownloadLogBtn_Click(object sender, EventArgs e) { if (this.blissHiveDownloadLogBtn.Text == "Start") { if (this.blissHiveDownloadHandler != null) { this.blissHiveDownloadHandler.CancelDownload(); this.blissHiveDownloadHandler.Cleanup(); } this.blissHiveDownloadHandler = new BlissHiveDownloadHandler(this); this.blissHiveDownloadHandler.StartDownload(); } else if (this.blissHiveDownloadLogBtn.Text == "Stop") { FTPController.GetInstance().blissHiveDownloader.StopDownload(); this.blissHiveDownloadHandler.CancelDownload(); } }
public override void StartDownload() { LinkedList <SettingsCategory> categories = SettingsController.GetInstance().LoadSettingsFile(OptionsForm.SettingsFileLocation); Boolean foundSettings = false; String IP = ""; String port = ""; String rootFolder = ""; NetworkCredential credential = null;// new NetworkCredential(); foreach (SettingsCategory category in categories) { if (category is FTPSettingsCategory) { FTPSettingsCategory ftpCategory = (FTPSettingsCategory)category; IP = ftpCategory.ip; port = ftpCategory.port; credential = new NetworkCredential(ftpCategory.username, ftpCategory.password); rootFolder = ftpCategory.rootFolder; foundSettings = true; } } if (foundSettings) { int errors = 0; if (IP.Length == 0) { MessageBox.Show("IP not set. See Options to set an IP."); errors++; } int portInt = 0; if (port.Length == 0 && !Int32.TryParse(port, out portInt)) { MessageBox.Show("Port not set or invalid. See Options to set a valid port."); errors++; } if (credential.UserName.Length == 0) { MessageBox.Show("Username not set. See Options to set a username."); errors++; } if (credential.Password.Length == 0) { MessageBox.Show("Password not set. See Options to set a password."); errors++; } if (errors == 0) { // try { FTPController.GetInstance().blissHiveDownloader = new LogFileDownloader(IP, port, credential, rootFolder, LogFileDownloader.LogFile.BlissHive); FTPController.GetInstance().blissHiveDownloader.progressUpdatedListeners += this.OnDownloadProgress; FTPController.GetInstance().blissHiveDownloader.downloadStoppedListeners += this.CancelDownload; FTPController.GetInstance().blissHiveDownloader.downloadFinishedListeners += this.FinishedDownload; FTPController.GetInstance().blissHiveDownloader.downloadFailedListeners += this.FailedDownload; this.dayzLogParserForm.SetStatusText(0, "Downloading blisshive.log.."); this.dayzLogParserForm.SetStatusText(1, ""); this.dayzLogParserForm.blissHiveDownloadLogBtn.Text = "Stop"; this.dayzLogParserForm.blissHivePlayerName.Text = "Downloading.."; /*} catch(WebException e){ * * }*/ } } else { MessageBox.Show("No FTP Settings found. Please add them in the Options menu."); } }