Esempio n. 1
0
 public void ShowUpdateResults(UpdateCheckResults results)
 {
     if (results.UpdateExists) {
         var message = String.Format("A new version of BioLink ({3}.{4}.{5}) is available for download!\n\nClick the button below to visit the download site.", results.CurrentMajor, results.CurrentMinor, results.CurrentBuild, results.UpdateMajor, results.UpdateMinor, results.UpdateBuild);
         lblMessage.Text = message;
         btnVisitSite.Visibility = System.Windows.Visibility.Visible;
         btnVisitSite.Click +=new RoutedEventHandler((s,e) => {
            BioLink.Client.Utilities.SystemUtils.ShellExecute(results.UpdateLink);
         });
     } else {
         var message = "There is no new version of BioLink to download at this time.";
         lblMessage.Text = message;
     }
 }
Esempio n. 2
0
        public UpdateCheckResults CheckForUpdates(IProgressObserver progress)
        {
            // Get the running apps version to compare...
            // We need to use the parent window because its the main application assembly version we want, not this plugin.
            var v = PluginManager.Instance.ParentWindow.GetType().Assembly.GetName().Version;

            var results = new UpdateCheckResults {
                CurrentMajor = v.Major, CurrentMinor = v.Minor, CurrentBuild = v.Revision, UpdateExists = false, UpdateLink = ""
            };

            if (progress != null)
            {
                progress.ProgressStart("Checking for updates...");
            }
            Config.SetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            var updateURL = Config.GetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            try {
                if (progress != null)
                {
                    progress.ProgressMessage("Contacting update site...");
                }
                var reader = XmlReader.Create(updateURL);
                var feed   = SyndicationFeed.Load(reader);

                if (progress != null)
                {
                    progress.ProgressMessage("Checking update site data...");
                }

                var pattern = new Regex(@"BioLinkInstaller-(\d+)[.](\d+)[.](\d+)[.]exe");
                foreach (SyndicationItem item in feed.Items)
                {
                    foreach (var link in item.Links)
                    {
                        var m = pattern.Match(link.Uri.AbsoluteUri);
                        if (m.Success)
                        {
                            bool updateExists = false;
                            var  major        = Int32.Parse(m.Groups[1].Value);
                            var  minor        = Int32.Parse(m.Groups[2].Value);
                            var  build        = Int32.Parse(m.Groups[3].Value);

                            if (major > results.CurrentMajor)
                            {
                                updateExists = true;
                            }
                            else if (major == results.CurrentMajor)
                            {
                                if (minor > results.CurrentMinor)
                                {
                                    updateExists = true;
                                }
                                else if (minor == results.CurrentMinor)
                                {
                                    updateExists = build > results.CurrentBuild;
                                }
                            }

                            if (updateExists)
                            {
                                results.UpdateMajor  = major;
                                results.UpdateMinor  = minor;
                                results.UpdateBuild  = build;
                                results.UpdateExists = true;
                                results.UpdateLink   = link.Uri.AbsoluteUri;

                                return(results);
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                GlobalExceptionHandler.Handle(ex);
            } finally {
                if (progress != null)
                {
                    progress.ProgressEnd("Update check complete.");
                }
            }

            return(results);
        }
Esempio n. 3
0
        public UpdateCheckResults CheckForUpdates(IProgressObserver progress)
        {
            // Get the running apps version to compare...
            // We need to use the parent window because its the main application assembly version we want, not this plugin.
            var v = PluginManager.Instance.ParentWindow.GetType().Assembly.GetName().Version;

            var results = new UpdateCheckResults { CurrentMajor = v.Major, CurrentMinor = v.Minor, CurrentBuild = v.Revision, UpdateExists = false, UpdateLink = "" };
            if (progress != null) {
                progress.ProgressStart("Checking for updates...");
            }
            Config.SetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            var updateURL = Config.GetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            try {
                if (progress != null) {
                    progress.ProgressMessage("Contacting update site...");
                }
                var reader = XmlReader.Create(updateURL);
                var feed = SyndicationFeed.Load(reader);

                if (progress != null) {
                    progress.ProgressMessage("Checking update site data...");
                }

                var pattern = new Regex(@"BioLinkInstaller-(\d+)[.](\d+)[.](\d+)[.]exe");
                foreach (SyndicationItem item in feed.Items) {
                    foreach (var link in item.Links) {
                        var m = pattern.Match(link.Uri.AbsoluteUri);
                        if (m.Success) {
                            bool updateExists = false;
                            var major = Int32.Parse(m.Groups[1].Value);
                            var minor = Int32.Parse(m.Groups[2].Value);
                            var build = Int32.Parse(m.Groups[3].Value);

                            if (major > results.CurrentMajor) {
                                updateExists = true;
                            } else if (major == results.CurrentMajor) {
                                if (minor > results.CurrentMinor) {
                                    updateExists = true;
                                } else if (minor == results.CurrentMinor) {
                                    updateExists = build > results.CurrentBuild;
                                }
                            }

                            if (updateExists) {
                                results.UpdateMajor = major;
                                results.UpdateMinor = minor;
                                results.UpdateBuild = build;
                                results.UpdateExists = true;
                                results.UpdateLink = link.Uri.AbsoluteUri;

                                return results;
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                GlobalExceptionHandler.Handle(ex);
            } finally {
                if (progress != null) {
                    progress.ProgressEnd("Update check complete.");
                }
            }

            return results;
        }