/// <summary> /// Gets whether an update exists. /// </summary> /// <returns></returns> public static bool UpdateExists(string productName) { ProductName = productName; DeterminePatch(); if (UpdatePathsXml.IndexOf("<updatepatches") == 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(UpdatePathsXml); LatestVersion = doc.SelectSingleNode("updatepatches/@latest_version").InnerText; Slyce.Common.VersionNumberUtility.VersionNumberComparer comparer = new Slyce.Common.VersionNumberUtility.VersionNumberComparer(); if (comparer.Compare(CurrentVersion, LatestVersion) < 0) { return(true); } } return(false); }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { // Ensure that we get this reported to us. throw e.Error; } if (UpdatePathsXml.IndexOf("<updatepatches") == 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(UpdatePathsXml); LatestVersion = doc.SelectSingleNode("updatepatches/@latest_version").InnerText; Slyce.Common.VersionNumberUtility.VersionNumberComparer comparer = new Slyce.Common.VersionNumberUtility.VersionNumberComparer(); if (comparer.Compare(CurrentVersion, LatestVersion) >= 0) { webBrowser1.DocumentText = HtmlPageStart + string.Format("<b>You have the latest version: {0}</b>", CurrentVersion) + HtmlPageEnd; if (SilentMode) { this.Close(); } } else { //string productName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name.Replace(" ", "").ToLower(); webBrowser1.Navigate(string.Format("http://www.slyce.com/updates/archangel_release_notes_view.asp?currentversion={0}&latestversion={1}&productName={2}", CurrentVersion, LatestVersion, ProductName)); XmlNode node = doc.SelectSingleNode(string.Format(@"updatepatches/patch[@fromVersion='{0}']", CurrentVersion)); double filesizeInMb = 0; if (node == null) { // No patch update available. Download latest full install instead. IsPatch = false; PatchFile = doc.SelectSingleNode("updatepatches/@file").InnerText; FileSize = doc.SelectSingleNode("updatepatches/@filesize").InnerText; filesizeInMb = double.Parse(FileSize) / 1024 / 1024; MD5Checksum = doc.SelectSingleNode("updatepatches/@md5").InnerText; btnViewDetails.Text = string.Format("Download - {0:0.00}Mb", filesizeInMb); } else { IsPatch = true; PatchFile = node.SelectSingleNode("@file").InnerText; FileSize = node.SelectSingleNode("@filesize").InnerText; filesizeInMb = double.Parse(FileSize) / 1024 / 1024; MD5Checksum = node.SelectSingleNode("@md5").InnerText; btnViewDetails.Text = string.Format("Download patch - {0:0.00}Mb", filesizeInMb); } TempPath = Path.Combine(Path.GetTempPath(), PatchFile); lnkPatchFile.Text = "http://www.slyce.com/downloads/" + PatchFile; lblFileSize.Text = "(" + FileSize + ")"; btnViewDetails.Enabled = true; } } else { // Error downloading the patch definitions webBrowser1.DocumentText = HtmlPageStart + @"There was a problem connecting to the internet. <p/> Click here to check manually in your browser: <strong><a href=""http://www.slyce.com/downloads/"" target=""_blank"">www.slyce.com/downloads/</a><strong>" + HtmlPageEnd; } }
private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { if (e.Error != null) { // Ensure that we get this reported to us. throw e.Error; } if (UpdatePathsXml.IndexOf("<updatepatches") == 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(UpdatePathsXml); LatestVersion = doc.SelectSingleNode("updatepatches/@latest_version").InnerText; Slyce.Common.VersionNumberUtility.VersionNumberComparer comparer = new Slyce.Common.VersionNumberUtility.VersionNumberComparer(); if (comparer.Compare(CurrentVersion, LatestVersion) >= 0) { webBrowser1.DocumentText = HtmlPageStart + string.Format("<b>You have the latest version: {0}</b>", CurrentVersion) + HtmlPageEnd; if (SilentMode) { this.Close(); } } else { //string productName = System.Reflection.Assembly.GetEntryAssembly().GetName().Name.Replace(" ", "").ToLower(); webBrowser1.Navigate(string.Format("http://www.slyce.com/updates/archangel_release_notes_view.asp?currentversion={0}&latestversion={1}&productName={2}", CurrentVersion, LatestVersion, ProductName)); XmlNode node = doc.SelectSingleNode(string.Format(@"updatepatches/patch[@fromVersion='{0}']", CurrentVersion)); double filesizeInMb = 0; if (node == null) { // No patch update available. Download latest full install instead. IsPatch = false; PatchFile = doc.SelectSingleNode("updatepatches/@file").InnerText; FileSize = doc.SelectSingleNode("updatepatches/@filesize").InnerText; filesizeInMb = double.Parse(FileSize) / 1024 / 1024; MD5Checksum = doc.SelectSingleNode("updatepatches/@md5").InnerText; btnViewDetails.Text = string.Format("Download - {0:0.00}Mb", filesizeInMb); } else { IsPatch = true; PatchFile = node.SelectSingleNode("@file").InnerText; FileSize = node.SelectSingleNode("@filesize").InnerText; filesizeInMb = double.Parse(FileSize) / 1024 / 1024; MD5Checksum = node.SelectSingleNode("@md5").InnerText; btnViewDetails.Text = string.Format("Download patch - {0:0.00}Mb", filesizeInMb); } TempPath = Path.Combine(Path.GetTempPath(), PatchFile); lnkPatchFile.Text = "http://www.slyce.com/downloads/" + PatchFile; lblFileSize.Text = "(" + FileSize + ")"; btnViewDetails.Enabled = true; } } else { // Error downloading the patch definitions webBrowser1.DocumentText = HtmlPageStart + @"There was a problem connecting to the internet. <p/> Click here to check manually in your browser: <strong><a href=""http://www.slyce.com/downloads/"" target=""_blank"">www.slyce.com/downloads/</a><strong>" + HtmlPageEnd; } }
/// <summary> /// Gets whether an update exists. /// </summary> /// <returns></returns> public static bool UpdateExists(string productName) { ProductName = productName; DeterminePatch(); if (UpdatePathsXml.IndexOf("<updatepatches") == 0) { XmlDocument doc = new XmlDocument(); doc.LoadXml(UpdatePathsXml); LatestVersion = doc.SelectSingleNode("updatepatches/@latest_version").InnerText; Slyce.Common.VersionNumberUtility.VersionNumberComparer comparer = new Slyce.Common.VersionNumberUtility.VersionNumberComparer(); if (comparer.Compare(CurrentVersion, LatestVersion) < 0) return true; } return false; }