コード例 #1
0
ファイル: Shared.cs プロジェクト: marcellodash/xrns2xmod
        public static void CheckForUpdates(bool showMessageAnyway, WebProxy webProxy)
        {
            Task.Factory.StartNew(() => ServiceUpdater.CheckForUpdates(Globals.URI_UPDATER, webProxy)).ContinueWith(task =>
            {
                if (task.Result != null)
                {
                    ServiceUpdater.VersionInfo lastVersionInfo = task.Result;

                    Version productVersion = Shared.GetProductVersion();

                    if (lastVersionInfo.LatestVersion > productVersion)
                    {
                        DialogResult result = MessageBox.Show(String.Format("A new version ({0}) is avaible, do you want to go to the homepage?", lastVersionInfo.LatestVersion), "NEW VERSION", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                        if (result == DialogResult.Yes)
                        {
                            Process.Start(lastVersionInfo.LatestVersionUrl);
                        }
                    }
                    else if (showMessageAnyway)
                    {
                        MessageBox.Show(String.Format("This version is up to date", lastVersionInfo.LatestVersion), "No updates avaible", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    if (showMessageAnyway)
                    {
                        MessageBox.Show("Network error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            });
        }
コード例 #2
0
        void CheckForApplicationUpdates()
        {
            WebProxy proxy = null;

            if (enableProxy)
            {
                proxy             = new WebProxy(host, port);
                proxy.Credentials = new NetworkCredential(proxyUser, proxyPassword, proxyDomain);
            }

            ServiceUpdater updater = new ServiceUpdater(proxy);

            Task.Factory.StartNew(() =>
            {
                WpfPitchTuner.Business.ServiceUpdater.VersionInfo version = null;

                try
                {
                    version = updater.CheckForUpdates(UpdateUri);
                }
                catch (Exception)
                {
                }

                return(version);
            }).ContinueWith(o =>
            {
                WpfPitchTuner.Business.ServiceUpdater.VersionInfo lastVersionInfo = (WpfPitchTuner.Business.ServiceUpdater.VersionInfo)o.Result;

                if (lastVersionInfo != null)
                {
                    Version productVersion = Utility.GetProductVersion();

                    bool isVersionUpToDate = lastVersionInfo.LatestVersion <= productVersion;

                    RaiseEventInvoker(isVersionUpToDate ? SoftwareUpToDateEvent : SoftwareOutOfDateEvent, new DefaultEventArgs {
                        ObjArg = lastVersionInfo
                    });
                }
                else
                {
                    RaiseEventInvoker(NetworkErrorEvent);
                }
            });
        }