protected bool showUpdateDialog(Stream file) { Version currentVersion = callingAssembly.GetName().Version; XmlDocument xDoc = new XmlDocument(); xDoc.Load(updateFilePath); XmlNodeList modules = xDoc.GetElementsByTagName("download"); XmlNodeList versions = xDoc.GetElementsByTagName("version"); Version newVersion = new Version( int.Parse(versions[0].Attributes["maj"].Value), int.Parse(versions[0].Attributes["min"].Value), int.Parse(versions[0].Attributes["bld"].Value)); if (currentVersion.CompareTo(newVersion) < 0) { Logger.Instance.log("New Version available: " + newVersion.ToString()); XmlNodeList messages = xDoc.GetElementsByTagName("message"); XmlNodeList links = xDoc.GetElementsByTagName("link"); String name = modules[0].Attributes["name"].Value; String link = links[0].InnerText; String message = messages[0].InnerText; this.zipFileURL = link; notification = new Notification(name, message, newVersion.ToString(), callingAssembly, this); notification.AbortUpdateEvent += new Notification.AbortUpdate(notification_AbortUpdateEvent); notification.StartUpdateEvent += new Notification.StartUpdate(startUpdate); Logger.Instance.log("Version: " + newVersion); Logger.Instance.log("Message: " + message); Logger.Instance.log("Link: " + link); if (notification.ShowDialog() == DialogResult.No) { notification.Dispose(); return false; } else { notification.Dispose(); string backupDir = appPath + "\\" + BACKUP_FOLDER_NAME; File.Create(backupDir + "\\" + "success"); this.restartApp(); return true; } } return true; #region other XML parser //XmlReaderSettings settings = new XmlReaderSettings(); //settings.ConformanceLevel = ConformanceLevel.Fragment; //settings.IgnoreWhitespace = true; //settings.IgnoreComments = true; //using (XmlReader reader = XmlReader.Create(file, settings)) //{ // while (reader.Read()) // { // if (reader.IsStartElement()) // { // if (reader.IsEmptyElement) // Logger.Instance.log(reader.Name); // else // { // Logger.Instance.log(reader.Name); // reader.Read(); // Read the start tag. // if (reader.IsStartElement()) // Handle nested elements. // Logger.Instance.log("\r\n"+ reader.Name); // Logger.Instance.log(reader.ReadString()); //Read the text content of the element. // } // } // } //} #endregion }
public void AddObserver(Notification ev) { ev.AbortUpdateEvent += new Notification.AbortUpdate(Notification_AbortUpdateEvent); }