private static void OnCheckCompleted(SerializablePatch result, string errorMessage) { // If update manager has been disabled since the last // update was triggered quit out here if (!s_enabled) { s_checkScheduled = false; return; } // Was there an error ? if (!String.IsNullOrEmpty(errorMessage)) { // Logs the error and reschedule EveClient.Trace("UpdateManager: {0}", errorMessage); ScheduleCheck(s_frequency); return; } // No error, let's try to deserialize try { ScanUpdateFeed(result); } // An error occurred during the deserialization catch (InvalidOperationException exc) { ExceptionHandler.LogException(exc, true); } finally { // Reschedule ScheduleCheck(s_frequency); } EveClient.Trace("UpdateManager.OnCheckCompleted()"); }
private static void ScanUpdateFeed(SerializablePatch result) { Version currentVersion = Assembly.GetExecutingAssembly().GetName().Version; Version newestVersion = new Version(result.Release.Version); string forumUrl = result.Release.TopicUrl; string updateMessage = result.Release.Message; string installArgs = result.Release.InstallerArgs; string installerUrl = result.Release.Url; string additionalArgs = result.Release.AdditionalArgs; bool canAutoInstall = (!String.IsNullOrEmpty(installerUrl) && !String.IsNullOrEmpty(installArgs)); if (!String.IsNullOrEmpty(additionalArgs) && additionalArgs.Contains("%EVEMON_EXECUTABLE_PATH%")) { string appPath = Path.GetDirectoryName(Application.ExecutablePath); installArgs = String.Format(CultureConstants.DefaultCulture, "{0} {1}", installArgs, additionalArgs); installArgs = installArgs.Replace("%EVEMON_EXECUTABLE_PATH%", appPath); } // Is the program out of date ? if (newestVersion > currentVersion) { // Requests a notification to subscribers and quit EveClient.OnUpdateAvailable(forumUrl, installerUrl, updateMessage, currentVersion, newestVersion, canAutoInstall, installArgs); return; } if (result.FilesHaveChanged) { // Requests a notification to subscribers and quit EveClient.OnDataUpdateAvailable(forumUrl, result.ChangedDataFiles); return; } }
/// <summary> /// Serializes the patch file to string. /// </summary> /// <returns></returns> private string ExportPatchXml() { SerializablePatch serial = new SerializablePatch(); ExportRelease(serial.Release); ExportDatafiles(serial.Datafiles); var doc = Util.SerializeToXmlDocument(serial.GetType(), serial); return (doc != null ? Util.GetXMLStringRepresentation(doc) : String.Empty); }