Exemplo n.º 1
0
        public async void AsyncCheckForUpdates()
        {
            using (var client = new HttpClient())
            {
                var values = new Dictionary <string, string>
                {
                    { "uid", Properties.Settings.Default.UID },
                    { "version", Application.ProductVersion.Replace(".", "") }
                };

                var content = new FormUrlEncodedContent(values);

                try
                {
                    var response = await client.PostAsync("http://saistudio.tk/version.php", content);

                    var responseString = await response.Content.ReadAsStringAsync();

                    UpdateData result = JsonConvert.DeserializeObject <UpdateData>(responseString);

                    if (result.result == UpdateResult.NewVersion)
                    {
                        DialogResult res =
                            PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Update",
                                                                       "New version",
                                                                       "New Visual SAI Studio is avaliable. Do you want to download it now? SAI will close.",
                                                                       "",
                                                                       "",
                                                                       "",
                                                                       "",
                                                                       "Download now|Show changelog|Download later",
                                                                       PSTaskDialog.eTaskDialogButtons.Cancel,
                                                                       PSTaskDialog.eSysIcons.Question, PSTaskDialog.eSysIcons.Information);


                        if (PSTaskDialog.cTaskDialog.CommandButtonResult == 0)
                        {
                            if (System.IO.File.Exists("SAIUpdater.exe"))
                            {
                                Process.Start("SAIUpdater.exe");
                                Application.Exit();
                            }
                            else
                            {
                                MessageBox.Show("Updater not found!");
                            }
                        }
                        else if (PSTaskDialog.cTaskDialog.CommandButtonResult == 1)
                        {
                            Forms.ChangelogForm changelog = new Forms.ChangelogForm();
                            changelog.Show();
                        }
                    }
                }
                catch (Exception)
                {
                    // no internet
                }
            }
        }
Exemplo n.º 2
0
        public async void AsyncCheckForUpdates()
        {
            using (var client = new HttpClient())
            {
                var values = new Dictionary<string, string>
                {
                   { "uid", Properties.Settings.Default.UID },
                   { "version", Application.ProductVersion.Replace(".","") }
                };

                var content = new FormUrlEncodedContent(values);

                try
                {
                    var response = await client.PostAsync("http://saistudio.tk/version.php", content);

                    var responseString = await response.Content.ReadAsStringAsync();

                    UpdateData result = JsonConvert.DeserializeObject<UpdateData>(responseString);

                    if (result.result == UpdateResult.NewVersion)
                    {
                        DialogResult res =
                          PSTaskDialog.cTaskDialog.ShowTaskDialogBox("Update",
                                                    "New version",
                                                    "New Visual SAI Studio is avaliable. Do you want to download it now? SAI will close.",
                                                    "",
                                                    "",
                                                    "",
                                                    "",
                                                    "Download now|Show changelog|Download later",
                                                    PSTaskDialog.eTaskDialogButtons.Cancel,
                                                    PSTaskDialog.eSysIcons.Question, PSTaskDialog.eSysIcons.Information);


                        if (PSTaskDialog.cTaskDialog.CommandButtonResult == 0)
                        {
                            if (System.IO.File.Exists("SAIUpdater.exe"))
                            {
                                Process.Start("SAIUpdater.exe");
                                Application.Exit();
                            }
                            else
                            {
                                MessageBox.Show("Updater not found!");
                            }
                        } else if (PSTaskDialog.cTaskDialog.CommandButtonResult == 1)
                        {
                            Forms.ChangelogForm changelog = new Forms.ChangelogForm();
                            changelog.Show();
                        }
                    }

                }
                catch (Exception)
                {
                    
                    // no internet
                }



            }
        }