private void OnUpdateFound(string version, string uri) { UpdateFound?.Invoke(this, new UpdateFoundEventArgs { Version = version, Uri = uri, }); }
public async void CheckForUpdates() { try { if (await Task.Run(() => _updateManager.SearchForUpdates())) { UpdateSize = _updateManager.TotalSize; NewVersion = Version.Parse(_updateManager.PackageConfigurations.Last().LiteralVersion).ToString(3); UpdateFound?.Invoke(this, EventArgs.Empty); } } catch (Exception) { // ignored } }
public static void CheckForUpdate(string branchName, VersionNumber currentVersion) { return; Task.Run(() => { try { var request = WebRequest.Create("https://fourtf.com/chatterino/version.json"); if (AppSettings.IgnoreSystemProxy) { request.Proxy = null; } using (var response = request.GetResponse()) using (var stream = response.GetResponseStream()) { var parser = new JsonParser(); dynamic json = parser.Parse(stream); dynamic branches = json["branches"]; foreach (var branch in branches) { if (branchName == (string)branch["name"]) { VersionNumber onlineVersion = VersionNumber.Parse(branch["version"]); string url = branch["url"]; if (onlineVersion.IsNewerThan(currentVersion)) { UpdateFound?.Invoke(null, new UpdateFoundEventArgs(onlineVersion, url)); } break; } } } } catch (Exception exc) { Console.WriteLine(exc.Log("updates")); } }); }
/// <summary> /// Does the Web Interface exist on the user's folder? /// If yes, check for outdated version /// TODO: redo update process /// </summary> public async Task <bool> CheckForUpdate() { var exists = _controller.Client.Exists("webint"); if (exists) { try { var lpath = Path.Combine(Common.AppdataFolder, @"version.ini"); await _controller.Client.Download("webint/version.ini", lpath); var currentversion = "0.2.3"; var wc = new WebClient(); wc.DownloadStringCompleted += (s, e) => { var vinfo = (WebInterfaceVersionInfo)JsonConvert.DeserializeObject(e.Result, typeof(WebInterfaceVersionInfo)); if (!vinfo.Uptodate) { UpdateFound.SafeInvoke(null, EventArgs.Empty); } else { Log.Write(l.Client, "Web Interface is up to date"); } File.Delete(lpath); }; var link = string.Format("http://ftpbox.org/webui.php?version={0}", currentversion); wc.DownloadStringAsync(new Uri(link)); } catch (Exception ex) { Log.Write(l.Warning, "Error with version checking"); ex.LogException(); } } return(exists); }
private void Client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) { try { // Try to get the headers string[] headers = e.Result.Split('\n'); // Create new instance of update info UpdateInfoArgs args = new UpdateInfoArgs(); args.Version = double.Parse(headers[0]); args.Type = headers[1].Replace("\r", ""); // Get the update item (either database or zip file) args.UpdateItem = headers[2]; // Invoke the update found event UpdateFound?.Invoke(this, args); } catch (Exception ex) { //throw new Exception("Unable to download update information. Server is either down or your computer does not have internet access."); } }
/// <summary> /// Download the user's webUI version file, compare the version with the latest one /// </summary> private void CheckForUpdate() { try { var lpath = Path.Combine(Common.AppdataFolder, @"version.ini"); _controller.Client.Download("webint/version.ini", lpath); var ini = new IniFile(lpath); var currentversion = ini.ReadValue("Version", "latest"); var wc = new WebClient(); wc.DownloadStringCompleted += (s, e) => { var vinfo = (WebInterfaceVersionInfo)JsonConvert.DeserializeObject(e.Result, typeof(WebInterfaceVersionInfo)); if (!vinfo.Uptodate) { UpdateFound.SafeInvoke(null, EventArgs.Empty); } else { Log.Write(l.Client, "Web Interface is up to date"); } File.Delete(lpath); }; var link = string.Format("http://ftpbox.org/webui.php?version={0}", currentversion); wc.DownloadStringAsync(new Uri(link)); } catch (Exception ex) { Log.Write(l.Warning, "Error with version checking"); Common.LogError(ex); } }