private async void ShowAboutWindow() { using (var mgr = new UpdateManager("http://arkmanager.teamitf.co.uk/iNGen/Releases/", "iNGen")) { try { UpdateInfo updateInfo = await mgr.CheckForUpdate(); if (updateInfo.FutureReleaseEntry != null) { if (updateInfo.CurrentlyInstalledVersion != null) { XElement xelement = XElement.Load("http://arkmanager.teamitf.co.uk/iNGen/version.xml"); StringReader reader = new StringReader(xelement.ToString()); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Models.AppUpdates)); Models.AppUpdates appUpdates = (Models.AppUpdates)xmlSerializer.Deserialize(reader); string changes = MakeChangeLog(appUpdates); var updateDialog = new Views.AboutApp(updateInfo, changes) { Owner = this }; var result = updateDialog.ShowDialog(); if (result == false) { return; } CheckForUpdates(); } } } catch (Exception ex) { } } }
private string MakeChangeLog(Models.AppUpdates application) { StringBuilder changelog = new StringBuilder(); changelog.Append("<h1><strong>Application Change Log</strong></h1>"); var logs = application.AppUpdate.OrderByDescending(a => a.Version); foreach (var item in logs) { changelog.Append("<p> </p>"); changelog.AppendFormat("<h3><strong>Version: {0}</strong></h3>", item.Version); changelog.Append(item.ChangeNotes); } return(changelog.ToString()); }
private async void CheckForUpdates() { using (var mgr = new UpdateManager("http://arkmanager.teamitf.co.uk/iNGen/Releases/", "iNGen")) { SquirrelAwareApp.HandleEvents( onInitialInstall: v => mgr.CreateShortcutForThisExe(), onAppUpdate: v => mgr.CreateShortcutForThisExe(), onAppUninstall: v => mgr.RemoveShortcutForThisExe()); try { UpdateInfo updateInfo = await mgr.CheckForUpdate(); if (updateInfo.FutureReleaseEntry != null) { if (updateInfo.CurrentlyInstalledVersion != null) { XElement xelement = XElement.Load("http://arkmanager.teamitf.co.uk/iNGen/version.xml"); StringReader reader = new StringReader(xelement.ToString()); System.Xml.Serialization.XmlSerializer xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(Models.AppUpdates)); Models.AppUpdates appUpdates = (Models.AppUpdates)xmlSerializer.Deserialize(reader); string changes = MakeChangeLog(appUpdates); if (updateInfo.CurrentlyInstalledVersion.Version == updateInfo.FutureReleaseEntry.Version) { return; } var updateDialog = new Views.AppUpdate(updateInfo, changes) { Owner = this }; var result = updateDialog.ShowDialog(); if (result == false) { return; } await mgr.UpdateApp(); var oldPath = System.IO.Path.Combine(mgr.RootAppDirectory, "app-" + updateInfo.CurrentlyInstalledVersion.Version.ToString(), "UserData"); var newPath = System.IO.Path.Combine(mgr.RootAppDirectory, "app-" + updateInfo.FutureReleaseEntry.Version.ToString(), "UserData"); DirectoryInfo d = new DirectoryInfo(oldPath); var files = d.GetFiles(); foreach (var file in files) { file.CopyTo(System.IO.Path.Combine(newPath, file.Name), true); } MessageBox.Show("iNGen Has been Updated. Please Re-Launch It."); Application.Current.Shutdown(0); } else { await mgr.UpdateApp(); MessageBox.Show("iNGen Has been Updated. Please Re-Launch It."); Application.Current.Shutdown(0); } } } catch (Exception ex) { Console.WriteLine("Checking for Updates Failed: " + ex.Message); } } }