Beispiel #1
0
		public void Download(OnDownloadProgressHandler ProgressEvent, OnDownloadFinishHandler FinishEvent) {
			OnDownloadProgress = ProgressEvent;
			OnDownloadFinish = FinishEvent;

			// Just delete a file
			if (this.Action == EPatchAction.DataDelete || this.Action == EPatchAction.GrfDelete) {
				if (OnDownloadFinish != null) {
					OnDownloadFinish(this, false);
				}
				return;
			}

			FilePath = Path.GetTempFileName();
			if (File.Exists(FilePath)) {
				File.Delete(FilePath);
			}


			TimeoutWebClient client = new TimeoutWebClient();
			client.BaseAddress = DownloadUrl;

			client.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(client_DownloadFileCompleted);
			client.DownloadProgressChanged += new System.Net.DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
			client.DownloadFileAsync(new Uri(DownloadUrl), FilePath, client);
		}
Beispiel #2
0
		public void DownloadStatus() {
			// Load info from CP xml export
			TimeoutWebClient web = new TimeoutWebClient();
			web.TimeOut = 5000;

			try {
				string statusData = web.DownloadString(StatusUrl);
				// Load xml data into our class
				XmlDocument doc = new XmlDocument();
				doc.LoadXml(statusData);
				// doc -> xml -> ServerStatus -> Group -> Server
				XmlNode node = doc.FirstChild.NextSibling.FirstChild.FirstChild;

				string loginServer = node.Attributes["loginServer"].Value.Trim();
				string charServer = node.Attributes["charServer"].Value.Trim();
				string mapServer = node.Attributes["mapServer"].Value.Trim();
				string woeActive = node.Attributes["woeActive"].Value.Trim();
				string playersOnline = node.Attributes["playersOnline"].Value.Trim();

				LoginServer = (loginServer == "1");
				CharServer = (charServer == "1");
				MapServer = (mapServer == "1");
				WoeActive = (woeActive == "1");
				PlayerCount = int.Parse(playersOnline);
			} catch {
				// Failed, assume servers are donw
				Reset();
			}
		}
Beispiel #3
0
		private bool DownloadFile(string Url, string SavePath) {
			try {
				TimeoutWebClient client = new TimeoutWebClient();
				client.TimeOut = 5000;
				client.DownloadFile(Url, SavePath);

				return true;
			} catch (Exception e) {
				System.Diagnostics.Debug.WriteLine(e);
				return false;
			}

		}