/// <summary> /// Serializes the release info for the patch file. /// </summary> /// <param name="serialRelease">The serial release.</param> private void ExportRelease(SerializableRelease serialRelease) { if (GetAssemblyVersion().FileMajorPart == 2) { serialRelease.Date = dtpRelease.Value.ToString(DateTimeFormat, s_enUsCulture); serialRelease.Version = lblEVEMonVersion.Text; serialRelease.TopicAddress = rtbTopicUrl.Text; serialRelease.PatchAddress = String.Concat(rtbReleaseUrl.Text, String.Format(CultureConstants.InvariantCulture, InstallerFilename, GetAssemblyVersion().ProductVersion)); serialRelease.MD5Sum = lblMD5Sum.Text; serialRelease.InstallerArgs = InstallerArgs; serialRelease.AdditionalArgs = AdditionalArgs; serialRelease.Message = rtbReleaseMessage.Text.Trim(); return; } SerializablePatch patch = TryDeserializePatchXml(); if (patch == null) { return; } serialRelease.Date = patch.Release.Date; serialRelease.Version = patch.Release.Version; serialRelease.TopicAddress = patch.Release.TopicAddress; serialRelease.PatchAddress = patch.Release.PatchAddress; serialRelease.MD5Sum = patch.Release.MD5Sum; serialRelease.InstallerArgs = patch.Release.InstallerArgs; serialRelease.AdditionalArgs = patch.Release.AdditionalArgs; serialRelease.Message = patch.Release.Message; }
/// <summary> /// Serializes the release info for the patch file. /// </summary> /// <param name="serialRelease"></param> /// <returns></returns> private SerializableRelease ExportRelease(SerializableRelease serialRelease) { serialRelease.Date = dtpRelease.Value.ToString(dateTimeFormat, enUS_Culture); serialRelease.Version = lblEVEMonVersion.Text; serialRelease.TopicUrl = rtbTopicUrl.Text; serialRelease.Url = String.Concat(rtbReleaseUrl.Text, String.Format(installerFilename, lblEVEMonVersion.Text)); serialRelease.InstallerArgs = installerArgs; serialRelease.AdditionalArgs = additionalArgs; serialRelease.Message = rtbReleaseMessage.Text; return(serialRelease); }
/// <summary> /// Serializes the releases info for the patch file. /// </summary> /// <param name="serialReleases">The serial releases.</param> private void ExportReleases(IList <SerializableRelease> serialReleases) { SerializablePatch patch = TryDeserializePatchXml(); if (patch == null) { return; } foreach (SerializableRelease release in patch.Releases .Where(release => Version.Parse(release.Version).Major != GetAssemblyVersion().ProductMajorPart)) { serialReleases.Add(release); } if (patch.Releases.Any() && patch.Releases.All(release => Version.Parse(release.Version).Major != GetAssemblyVersion().ProductMajorPart)) { return; } var serialRelease = new SerializableRelease { Date = dtpRelease.Value.ToString(DateTimeFormat, s_enUsCulture), Version = lblEVEMonVersion.Text, TopicAddress = rtbTopicUrl.Text, PatchAddress = String.Concat(rtbReleaseUrl.Text, String.Format(CultureConstants.InvariantCulture, InstallerFilename, GetAssemblyVersion().ProductVersion)), MD5Sum = lblMD5Sum.Text, InstallerArgs = InstallerArgs, AdditionalArgs = AdditionalArgs, Message = rtbReleaseMessage.Text.Trim() }; serialReleases.Add(serialRelease); serialReleases.StableSort((release, serializableRelease) => String.Compare(release.Version, serializableRelease.Version, StringComparison.Ordinal)); }
/// <summary> /// Scans the update feed. /// </summary> /// <param name="result">The result.</param> private static void ScanUpdateFeed(SerializablePatch result) { Version currentVersion = Version.Parse(EveMonClient.FileVersionInfo.FileVersion); SerializableRelease newestRelease = result.Releases?.FirstOrDefault( release => Version.Parse(release.Version).Major == currentVersion.Major); Version newestVersion = (newestRelease != null) ? Version.Parse(newestRelease. Version) : currentVersion; Version mostRecentDeniedVersion = !string.IsNullOrEmpty(Settings.Updates. MostRecentDeniedUpgrade) ? new Version(Settings.Updates. MostRecentDeniedUpgrade) : new Version(); // Is the program out of date and user has not previously denied this version? if (currentVersion < newestVersion & mostRecentDeniedVersion < newestVersion) { // Quit if newest release is null // (Shouldn't happen but it's nice to be prepared) if (newestRelease == null) { return; } // Reset the most recent denied version Settings.Updates.MostRecentDeniedUpgrade = string.Empty; Uri forumUrl = new Uri(newestRelease.TopicAddress); Uri installerUrl = new Uri(newestRelease.PatchAddress); string updateMessage = newestRelease.Message; string installArgs = newestRelease.InstallerArgs; string md5Sum = newestRelease.MD5Sum; string additionalArgs = newestRelease.AdditionalArgs; bool canAutoInstall = !string.IsNullOrEmpty(installerUrl.AbsoluteUri) && !string.IsNullOrEmpty(installArgs); if (!string.IsNullOrEmpty(additionalArgs) && additionalArgs.Contains("%EVEMON_EXECUTABLE_PATH%")) { string appPath = Path.GetDirectoryName(Application.ExecutablePath); installArgs = $"{installArgs} {additionalArgs}"; installArgs = installArgs.Replace("%EVEMON_EXECUTABLE_PATH%", appPath); } // Requests a notification to subscribers and quit EveMonClient.OnUpdateAvailable(forumUrl, installerUrl, updateMessage, currentVersion, newestVersion, md5Sum, canAutoInstall, installArgs); return; } // New data files released? if (result.FilesHaveChanged) { // Requests a notification to subscribers EveMonClient.OnDataUpdateAvailable(result.ChangedDatafiles); return; } // Notify about a new major version Version newestMajorVersion = result.Releases?.Max(release => Version.Parse( release.Version)) ?? new Version(); SerializableRelease newestMajorRelease = result.Releases?.FirstOrDefault(release => Version.Parse(release.Version) == newestMajorVersion); if (newestMajorRelease == null) { return; } newestVersion = Version.Parse(newestMajorRelease.Version); Version mostRecentDeniedMajorUpgrade = !string.IsNullOrEmpty(Settings.Updates. MostRecentDeniedMajorUpgrade) ? new Version(Settings.Updates.MostRecentDeniedMajorUpgrade) : new Version(); // Is there is a new major version and the user has not previously denied it? if (currentVersion >= newestVersion | mostRecentDeniedMajorUpgrade >= newestVersion) { return; } // Reset the most recent denied version Settings.Updates.MostRecentDeniedMajorUpgrade = string.Empty; EveMonClient.OnUpdateAvailable(null, null, null, currentVersion, newestVersion, null, false, null); }