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); }