Ejemplo n.º 1
0
        /// <summary>Check for a newer version of the SuperPuTTY Application</summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Log.Info("Checking for application update");
            try {
                httpRequest httpUpdateRequest = new httpRequest();
                httpUpdateRequest.MakeRequest("https://api.github.com/repos/jimradford/superputty/releases/latest", delegate (bool success, string content)
                {
                    if (success)
                    {
                        DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(GitRelease));
                        MemoryStream ms = new MemoryStream(Encoding.ASCII.GetBytes(content));
                        GitRelease latest = (GitRelease)js.ReadObject(ms);
                        ms.Close();

                        if (!latest.version.Trim().Contains(SuperPuTTY.Version))
                        {
                            Log.Info("New Application version found! " + latest.version);

                            if (MessageBox.Show("An updated version of SuperPuTTY (" + latest.version + ") is Available Would you like to visit the download page to upgrade?",
                                "SuperPutty Update Found",
                                MessageBoxButtons.YesNo,
                                MessageBoxIcon.Question,
                                MessageBoxDefaultButton.Button1,
                                MessageBoxOptions.DefaultDesktopOnly) == DialogResult.Yes)
                            {
                                Process.Start(latest.release_url);
                            }
                        }
                        else
                        {
                            if (sender.ToString().Equals(checkForUpdatesToolStripMenuItem.Text))
                            {
                                MessageBox.Show("You are running the latest version of SuperPutty", "SuperPuTTY Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("There was an error while checking for updates. Please try again later.", "Error during update check", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        Log.Warn("An Error occurred trying to check for program updates: " + content);                        
                    }
                });
            }
            catch (System.Net.WebException ex)
            {
                Log.Warn("An Exception occurred while trying to check for program updates: " + ex.ToString());
            }
        }
Ejemplo n.º 2
0
        private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Log.Info("Checking for application update");
            httpRequest r = new httpRequest();
            r.MakeRequest("https://api.github.com/repos/jimradford/superputty/releases/latest", delegate(bool success, string content)
            {
                if (success)
                {
                    DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(GitRelease));
                    MemoryStream ms = new MemoryStream(System.Text.ASCIIEncoding.ASCII.GetBytes(content));
                    GitRelease  latest = (GitRelease)js.ReadObject(ms);
                    ms.Close();

                    if (!latest.version.Trim().Contains(SuperPuTTY.Version))
                    {
                        Log.Info("New Application version found! " + latest.version);

                        if (MessageBox.Show("An updated version of SuperPuTTY (" + latest.version + ") is Available Would you like to visit the download page to upgrade?",
                            "SuperPutty Update Found",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1,
                            MessageBoxOptions.DefaultDesktopOnly) == System.Windows.Forms.DialogResult.Yes)
                        {
                            Process.Start(latest.release_url);
                        }
                    }
                    else
                    {
                        if (sender.ToString().Equals(checkForUpdatesToolStripMenuItem.Text))
                        {
                            MessageBox.Show("You are running the latest version of SuperPutty", "SuperPuTTY Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                else
                {
                    // error occurred while making api request
                    var foo = r;
                    Console.WriteLine(r);
                }
            });
        }
Ejemplo n.º 3
0
        private void checkForUpdatesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Log.Info("Checking for application update");
            httpRequest r = new httpRequest();
            r.MakeRequest("https://code.google.com/p/superputty/wiki/Downloads?" + SuperPuTTY.Version, delegate(bool success, string content)
            {
                if (success)
                {
                    if (!content.Contains("Current stable version (" + SuperPuTTY.Version + "):"))
                    {
                        Log.Info("New Application version found! " + content.TrimEnd());

                        if (MessageBox.Show("An updated version of SuperPuTTY is Available Would you like to visit the download page?",
                            "SuperPutty Update Found",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question,
                            MessageBoxDefaultButton.Button1,
                            MessageBoxOptions.DefaultDesktopOnly) == System.Windows.Forms.DialogResult.Yes)
                        {
                            Process.Start("https://code.google.com/p/superputty/wiki/Downloads");
                        }
                    }
                    else
                    {
                        if (sender.ToString().Equals(checkForUpdatesToolStripMenuItem.Text))
                        {
                            MessageBox.Show("You are running the latest version of SuperPutty", "SuperPuTTY Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            });

        }