public DayZUpdater() { Installer = new DayZInstaller(); Installer.PropertyChanged += (sender, args) => { if (args.PropertyName == "IsRunning") { PropertyHasChanged("InstallButtonVisible"); } else if (args.PropertyName == "Status") { if (Installer.Status == "Install complete") { CheckForUpdates(); } } }; }
public TorrentUpdater(string torrentLink, DayZInstaller installer, DayZUpdater updater) { this.installer = installer; this.updater = updater; torrents = new List <TorrentManager>(); // This is where we will store the torrentmanagers if (!Directory.Exists(torrentsPath)) { Directory.CreateDirectory(torrentsPath); } else { Directory.Delete(torrentsPath, true); // Delete old torrents Directory.CreateDirectory(torrentsPath); } ExtendedWebClient wc = new ExtendedWebClient(new Uri(torrentLink)); try { var torrentLinks = torrentLink.Split(';'); int i = 1; foreach (string torrent in torrentLinks) { wc.DownloadFile(torrent, Path.Combine(torrentsPath, "DayZero-" + updater.LatestVersion + "-" + i + ".torrent")); i++; } } catch (Exception) { updater.Status = "Could not download torrent."; CalculatedGameSettings.Current.Update(); installer.Status = ""; installer.IsRunning = false; return; } // We need to cleanup correctly when the user closes the window by using ctrl-c // or an unhandled exception happens Console.CancelKeyPress += delegate { shutdown(); }; AppDomain.CurrentDomain.ProcessExit += delegate { shutdown(); }; AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); shutdown(); }; Thread.GetDomain().UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); shutdown(); }; }
public DayZUpdater() { Installer = new DayZInstaller(); Installer.PropertyChanged += (sender, args) => { if (args.PropertyName == "IsRunning") { PropertyHasChanged("InstallButtonVisible"); } else if (args.PropertyName == "Status") { if (Installer.Status == "Install complete") { CheckForUpdates(); } } }; string responseBody; if (!GameUpdater.HttpGet(dayZeroVersionUrl, out responseBody)) { Status = "Zombies.nu not responding"; return; } Version version; if (Version.TryParse(responseBody, out version)) { if (version.Equals(CalculatedGameSettings.Current.DayZVersion)) // If version is up to date. Seed. { string torrentUrl; if (!GameUpdater.HttpGet(dayZeroTorrentFileUrl, out torrentUrl)) { Status = "Zombies.nu not responding"; return; } TorrentUpdater seeder = new TorrentUpdater(torrentUrl); // Sets up launcher to start seeding current build. seeder.StartTorrents(1); } } }
public TorrentUpdater(string torrentLink, DayZInstaller installer, DayZUpdater updater) { this.installer = installer; this.updater = updater; torrents = new List<TorrentManager>(); // This is where we will store the torrentmanagers if (!Directory.Exists(torrentsPath)) Directory.CreateDirectory(torrentsPath); else { Directory.Delete(torrentsPath, true); // Delete old torrents Directory.CreateDirectory(torrentsPath); } ExtendedWebClient wc = new ExtendedWebClient(new Uri(torrentLink)); try { var torrentLinks = torrentLink.Split(';'); int i = 1; foreach (string torrent in torrentLinks) { wc.DownloadFile(torrent, Path.Combine(torrentsPath, "DayZero-" + updater.LatestVersion + "-" + i + ".torrent")); i++; } } catch (Exception) { updater.Status = "Could not download torrent."; CalculatedGameSettings.Current.Update(); installer.Status = ""; installer.IsRunning = false; return; } // We need to cleanup correctly when the user closes the window by using ctrl-c // or an unhandled exception happens Console.CancelKeyPress += delegate { shutdown(); }; AppDomain.CurrentDomain.ProcessExit += delegate { shutdown(); }; AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); shutdown(); }; Thread.GetDomain().UnhandledException += delegate(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject); shutdown(); }; }
public DayZUpdater() { Installer = new DayZInstaller(); Installer.PropertyChanged += (sender, args) => { if(args.PropertyName == "IsRunning") { PropertyHasChanged("InstallButtonVisible"); } else if(args.PropertyName == "Status") { if(Installer.Status == "Install complete") { CheckForUpdates(); } } }; string responseBody; if (!GameUpdater.HttpGet(dayZeroVersionUrl, out responseBody)) { Status = "Zombies.nu not responding"; return; } Version version; if (Version.TryParse(responseBody, out version)) { if (version.Equals(CalculatedGameSettings.Current.DayZVersion)) // If version is up to date. Seed. { string torrentUrl; if (!GameUpdater.HttpGet(dayZeroTorrentFileUrl, out torrentUrl)) { Status = "Zombies.nu not responding"; return; } TorrentUpdater seeder = new TorrentUpdater(torrentUrl); // Sets up launcher to start seeding current build. seeder.StartTorrents(1); } } }