/// <summary> /// Read the RSS feed to see if there is a Greenshot update /// </summary> public static void CheckAndAskForUpdate() { lock (LockObject) { var currentVersion = Assembly.GetExecutingAssembly().GetName().Version; // Test like this: // currentVersion = new Version("0.8.1.1198"); try { _latestGreenshot = null; ProcessRssInfo(currentVersion); if (_latestGreenshot != null) { MainForm.Instance.NotifyIcon.BalloonTipClicked += HandleBalloonTipClick; MainForm.Instance.NotifyIcon.BalloonTipClosed += CleanupBalloonTipClick; MainForm.Instance.NotifyIcon.ShowBalloonTip(10000, "Greenshot", Language.GetFormattedString(LangKey.update_found, "'" + _latestGreenshot.File + "'"), ToolTipIcon.Info); } CoreConfig.LastUpdateCheck = DateTime.Now; } catch (Exception e) { Log.Error().WriteLine(e, "An error occured while checking for updates, the error will be ignored: "); } } }
public void GetFeed(RssFile file) { var rssFormatter = RssParser.GetFeed(file.AtomLink); file.LastUpdateDate = rssFormatter.LastUpdatedTime; file.Description = rssFormatter.Description.Text; file.Language = rssFormatter.Language; file.Title = rssFormatter.Title.Text; foreach (SyndicationItem item in rssFormatter.Items) { RssItem rssItem = new RssItem { Title = item.Title.Text, Description = item.Summary.Text, PublishDate = item.PublishDate.DateTime, RssFileId = file.Id, Link = item.Id }; _rssItemRepository.AddRssItem(rssItem); } ListenServiceClient service = new ListenServiceClient(); service.FireDatabaseEvents(); }
private static void ProcessRssInfo(Version currentVersion) { // Reset latest Greenshot var rssFiles = RssHelper.ReadRss(); if (rssFiles == null) { return; } // Retrieve the current and latest greenshot foreach (var rssFile in rssFiles) { if (rssFile.File.StartsWith("Greenshot")) { // check for exe if (!rssFile.IsExe) { continue; } // do we have a version? if (rssFile.Version == null) { Log.Debug().WriteLine("Skipping unversioned exe {0} which is published at {1} : {2}", rssFile.File, rssFile.Pubdate.ToLocalTime(), rssFile.Link); continue; } // if the file is unstable, we will skip it when: // the current version is a release or release candidate AND check unstable is turned off. if (rssFile.IsAlpha) { // Skip if we shouldn't check unstables if (CoreConfigurationExtensions.BuildState == BuildStates.RELEASE && !CoreConfig.CheckForUnstable) { continue; } } // if the file is a release candidate, we will skip it when: // the current version is a release AND check unstable is turned off. if (rssFile.IsReleaseCandidate) { if (CoreConfigurationExtensions.BuildState == BuildStates.RELEASE && !CoreConfig.CheckForUnstable) { continue; } } // Compare versions var versionCompare = rssFile.Version.CompareTo(currentVersion); if (versionCompare > 0) { Log.Debug().WriteLine("Found newer Greenshot '{0}' with version {1} published at {2} : {3}", rssFile.File, rssFile.Version, rssFile.Pubdate.ToLocalTime(), rssFile.Link); if (_latestGreenshot == null || rssFile.Version.CompareTo(_latestGreenshot.Version) > 0) { _latestGreenshot = rssFile; if (rssFile.IsReleaseCandidate || rssFile.IsAlpha) { _downloadLink = VersionHistoryLink; } else { _downloadLink = StableDownloadLink; } } } else if (versionCompare < 0) { Log.Debug().WriteLine("Skipping older greenshot with version {0}", rssFile.Version); } else if (versionCompare == 0) { Log.Debug().WriteLine("Found current version as exe {0} with version {1} published at {2} : {3}", rssFile.File, rssFile.Version, rssFile.Pubdate.ToLocalTime(), rssFile.Link); } } } }