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
     }
 }
Exemple #3
0
        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"));
                }
            });
        }
        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.");
            }
        }