Beispiel #1
0
        private Task LaunchVersionCheck()
        {
            return(new Task(() =>
            {
                var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                var cvc = new GithubVersionChecker(currentVersion, "MsCrmTools", "XrmToolBox");

                cvc.Run();

                if (cvc.Cpi != null && !string.IsNullOrEmpty(cvc.Cpi.Version))
                {
                    if (currentOptions.LastUpdateCheck.Date != DateTime.Now.Date)
                    {
                        this.Invoke(new Action(() =>
                        {
                            var nvForm = new NewVersionForm(currentVersion, cvc.Cpi.Version, cvc.Cpi.Description, "MsCrmTools", "XrmToolBox", new Uri(cvc.Cpi.PackageUrl));
                            var result = nvForm.ShowDialog(this);
                            if (result == DialogResult.OK)
                            {
                                Close();
                            }
                        }));
                    }
                }

                currentOptions.LastUpdateCheck = DateTime.Now;
                currentOptions.Save();
            }));
        }
Beispiel #2
0
        private Task LaunchVersionCheck()
        {
            return(new Task(() =>
            {
                var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                var cvc = new GithubVersionChecker(currentVersion);

                cvc.Run();

                if (GithubVersionChecker.Cpi != null && !string.IsNullOrEmpty(GithubVersionChecker.Cpi.Version))
                {
                    if (currentOptions.LastUpdateCheck.Date != DateTime.Now.Date)
                    {
                        this.Invoke(new Action(() =>
                        {
                            var nvForm = new NewVersionForm(currentVersion, GithubVersionChecker.Cpi.Version, GithubVersionChecker.Cpi.Description);
                            nvForm.ShowDialog(this);
                        }));
                    }
                }

                currentOptions.LastUpdateCheck = DateTime.Now;
                currentOptions.Save();
            }));
        }
Beispiel #3
0
        private Task LaunchVersionCheck()
        {
            return(new Task(() =>
            {
                if (Options.DoNotCheckForUpdates == true)
                {
                    return;
                }

                blackScreen.SetWorkingMessage("Checking for XrmToolBox update...");

                var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                var cvc = new GithubVersionChecker(currentVersion, "MsCrmTools", "XrmToolBox");
                cvc.Run();

                if (!string.IsNullOrEmpty(cvc.Cpi?.Version))
                {
                    if (currentOptions.LastUpdateCheck.Date != DateTime.Now.Date)
                    {
                        Invoke(new Action(() =>
                        {
                            var nvForm = new NewVersionForm(currentVersion, cvc.Cpi.Version, cvc.Cpi.Description, "MsCrmTools", "XrmToolBox", new Uri(cvc.Cpi.PackageUrl));
                            var result = nvForm.ShowDialog(this);
                            if (result == DialogResult.OK)
                            {
                                Close();
                            }
                        }));
                    }
                }

                currentOptions.LastUpdateCheck = DateTime.Now;
                currentOptions.Save();
            }));
        }
        void UpdatesChecker_NewVersionIsAvailable(object sender, EventArgs e)
        {
            EventHandler handler = delegate {
                NewVersionForm.ShowForm();
            };

            BeginInvoke(handler);
        }
 /// <summary>
 ///   Checks if there are new updates for the program.
 /// </summary>
 internal static void CheckForUpdates()
 {
     using (var wc = new WebClient())
     {
         try
         {
             var info = JsonConvert.DeserializeObject <UpdateInfo>(wc.DownloadString(Constants.VersionUri));
             if (info.Date > Global.Version)
             {
                 var newDlg = new NewVersionForm(info);
                 newDlg.ShowDialog();
             }
         }
         catch (WebException)
         {
         }
         catch (FormatException)
         {
         }
     }
 }
        public static Task LaunchVersionCheck(string currentVersion, string ghUser, string ghRepo, string dlUrl, DateTime lastCheck, UserControl sender)
        {
            return(new Task(() =>
            {
                var cvc = new XrmToolBox.AppCode.GithubVersionChecker(currentVersion, ghUser, ghRepo);

                cvc.Run();

                if (cvc.Cpi != null && !string.IsNullOrEmpty(cvc.Cpi.Version))
                {
                    if (lastCheck != DateTime.Now.Date)
                    {
                        sender.Invoke(new Action(() =>
                        {
                            var nvForm = new NewVersionForm(currentVersion, cvc.Cpi.Version, cvc.Cpi.Description, ghUser, ghRepo, new Uri(string.Format(dlUrl, currentVersion)));
                            nvForm.ShowDialog(sender);
                        }));
                    }
                }
            }));
        }
Beispiel #7
0
        private void checkForUpdateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var worker = new BackgroundWorker();

            worker.DoWork += (s, evt) =>
            {
                var currentVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                var cvc            = new GithubVersionChecker(currentVersion, "MsCrmTools", "XrmToolBox");
                cvc.Run();

                evt.Result = cvc;
            };
            worker.RunWorkerCompleted += (s, evt) =>
            {
                GithubVersionChecker cvc = (GithubVersionChecker)evt.Result;
                var currentVersion       = Assembly.GetExecutingAssembly().GetName().Version.ToString();
                if (!string.IsNullOrEmpty(cvc.Cpi?.Version))
                {
                    Invoke(new Action(() =>
                    {
                        var nvForm = new NewVersionForm(currentVersion, cvc.Cpi.Version, cvc.Cpi.Description,
                                                        "MsCrmTools", "XrmToolBox", new Uri(cvc.Cpi.PackageUrl));
                        var result = nvForm.ShowDialog(this);
                        if (result == DialogResult.OK)
                        {
                            Close();
                        }
                    }));
                }
                else
                {
                    MessageBox.Show(this, "No update available!", "Information", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                currentOptions.LastUpdateCheck = DateTime.Now;
                currentOptions.Save();
            };
            worker.RunWorkerAsync();
        }
Beispiel #8
0
 /// <summary>
 ///   Checks if there are new updates for the program.
 /// </summary>
 internal static void CheckForUpdates()
 {
     using (var wc = new WebClient())
     {
         wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0");
         try
         {
             var info = JsonConvert.DeserializeObject <UpdateInfo>(wc.DownloadString(Constants.VersionUri));
             if (info.Date > Global.Version)
             {
                 var newDlg = new NewVersionForm(info);
                 newDlg.ShowDialog();
             }
         }
         catch (WebException)
         {
         }
         catch (FormatException)
         {
         }
     }
 }
Beispiel #9
0
        public static bool CheckForUpdates()
        {
            Properties.GUI.Settings.Default.LastCheckForUpdates = DateTime.UtcNow;
            Properties.GUI.Settings.Default.Save();

            string  teamcityURL = "http://teamcity.labkey.org";
            string  buildType   = Environment.Is64BitProcess ? "Bumbershoot_Windows_X86_64" : "ProteoWizard_Bumbershoot_Windows_X86";
            string  buildsURL   = String.Format("{0}/httpAuth/app/rest/buildTypes/id:{1}/builds?status=SUCCESS&count=1&guest=1", teamcityURL, buildType);
            string  latestArtifactURL;
            Version latestVersion;

            lock (webClient)
            {
                string xml        = webClient.DownloadString(buildsURL);
                int    startIndex = xml.IndexOf("id=");
                if (startIndex < 0)
                {
                    throw new InvalidDataException("build id not found in:\r\n" + xml);
                }
                int endIndex = xml.IndexOfAny("\"'".ToCharArray(), startIndex + 4);
                if (endIndex < 0)
                {
                    throw new InvalidDataException("not well formed xml:\r\n" + xml);
                }
                startIndex += 4; // skip the attribute name, equals, and opening quote
                string buildId = xml.Substring(startIndex, endIndex - startIndex);

                latestArtifactURL = String.Format("{0}/repository/download/{1}/{2}:id", teamcityURL, buildType, buildId);
                latestVersion     = new Version(webClient.DownloadString(latestArtifactURL + "/IDPICKER_VERSION?guest=1"));
            }

            Version currentVersion = new Version(Util.Version);

            if (currentVersion < latestVersion)
            {
                System.Collections.ObjectModel.Collection <SvnLogEventArgs> logItems = null;

                using (var client = new SvnClient())
                {
                    client.Authentication.Clear();
                    client.Authentication.DefaultCredentials = new NetworkCredential("anonsvn", "anonsvn");

                    try
                    {
                        client.GetLog(new Uri("svn://svn.code.sf.net/p/proteowizard/code/trunk/pwiz/pwiz_tools/Bumbershoot/idpicker/"),
                                      new SvnLogArgs(new SvnRevisionRange(currentVersion.Build, latestVersion.Build)),
                                      out logItems);
                    }
                    catch (Exception e)
                    {
                        HandleException(e);
                    }
                }

                IEnumerable <SvnLogEventArgs> filteredLogItems = logItems;

                string changeLog;
                if (logItems.IsNullOrEmpty())
                {
                    changeLog = "<unable to get change log>";
                }
                else
                {
                    // return if no important revisions have happened
                    filteredLogItems = logItems.Where(o => !filterRevisionLog(o.LogMessage).Trim().IsNullOrEmpty());
                    if (!filteredLogItems.IsNullOrEmpty())
                    {
                        var logEntries = filteredLogItems.Select(o => String.Format("Revision {0}:\r\n{1}",
                                                                                    o.Revision,
                                                                                    filterRevisionLog(o.LogMessage)));
                        changeLog = String.Join("\r\n\r\n", logEntries.ToArray());
                    }
                    else
                    {
                        changeLog = "Technical changes and bug fixes.";
                    }
                }

                MainWindow.Invoke(new MethodInvoker(() =>
                {
                    var form = new NewVersionForm(Application.ProductName,
                                                  currentVersion.ToString(),
                                                  latestVersion.ToString(),
                                                  changeLog)
                    {
                        Owner         = MainWindow,
                        StartPosition = FormStartPosition.CenterParent
                    };

                    if (form.ShowDialog() == DialogResult.Yes)
                    {
                        string archSuffix   = Environment.Is64BitProcess ? "x86_64" : "x86";
                        string guestAccess  = Application.ExecutablePath.Contains("build-nt-x86") ? "" : "?guest=1"; // don't log me out of TC session
                        string installerURL = String.Format("{0}/IDPicker-{1}-{2}.msi{3}", latestArtifactURL, latestVersion, archSuffix, guestAccess);
                        System.Diagnostics.Process.Start(installerURL);
                    }
                }));
                return(true);
            }
            return(false);
        }