コード例 #1
0
        /// <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)
            {
                // Reset the most recent denied version
                Settings.Updates.MostRecentDeniedUpgrade = String.Empty;

                Uri forumUrl = new Uri(result.Release.TopicAddress);
                Uri installerUrl = new Uri(result.Release.PatchAddress);
                string updateMessage = result.Release.Message;
                string installArgs = result.Release.InstallerArgs;
                string md5Sum = result.Release.MD5Sum;
                string additionalArgs = result.Release.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);
        }
コード例 #2
0
        /// <summary>
        /// Serializes the patch file to string.
        /// </summary>
        /// <returns></returns>
        private string ExportPatchXml()
        {
            SerializablePatch serial = new SerializablePatch();

            ExportRelease(serial.Release);
            ExportReleases(serial.Releases);
            ExportDatafiles(serial.Datafiles);

            XmlDocument doc = (XmlDocument)Util.SerializeToXmlDocument(serial);
            return doc != null ? Util.GetXmlStringRepresentation(doc) : String.Empty;
        }