public UpdateDialog(UpdateManifest manifest) : this() { //Setup this.manifest = manifest; notesRichTextBox.AppendText(manifest.ReleaseNotes); downloadButton.Enabled = true; }
private void GetUpdateInfo() { _manifestXml = HttpGetString(_manifestUrl); if (_manifestXml == null) { throw new ApplicationException("No Manifest."); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.PreserveWhitespace = true; xmlDoc.LoadXml(_manifestXml); // Verify the signature of the signed XML. var csp = new RSACryptoServiceProvider(); csp.FromXmlString(_publicKeyXml); if (!VerifyXml(xmlDoc, csp)) { _LastException = new ApplicationException("There is an invalid XML signature on the Manifest."); _updateManifest.UpdateIsAvailableAndValid = false; return; } XmlSerializer s = new XmlSerializer(typeof(UpdateManifest)); using (var sr = new StringReader(_manifestXml)) { _updateManifest = (UpdateManifest)s.Deserialize(new System.Xml.XmlTextReader(sr)); _updateManifest.UpdateIsAvailableAndValid = false; } return; }
public void ChooseBestDiffFullTest() { mockDownloader.Setup(a => a.DownloadString(It.IsAny <string>())).Returns(stringManifest); var update = new Updater(mockApp.Object, mockDownloader.Object); var manifest = new UpdateManifest() { LatestVersion = new Version(4, 21), Packages = new List <UpdateManifest.Package>() { new UpdateManifest.Package() { BaseVersion = new Version("4.21"), FileName = "421.exe" }, new UpdateManifest.Package() { BaseVersion = new Version("4.12"), FileName = "412to42.exe" }, new UpdateManifest.Package() { BaseVersion = new Version("4.1"), FileName = "41to42.exe" } } }; var ver = new Version("4.9"); var package = update.GetUpdatePackage(manifest, ver); Assert.AreEqual(manifest.LatestVersion, package.BaseVersion); Assert.AreEqual("421.exe", package.FileName); }
public static void Main(string[] args) { //TODO PFAD ANGEBEN BEI UPDATE var updateApp = @"C:\Users\Daniel\RiderProjects\Launcher\HomeState.Updater\bin\x64\Release\HomeState.Updater.exe"; var launcherApp = @"C:\Users\Daniel\RiderProjects\Launcher\HomeState.Launcher\bin\x64\Release\HomeState.Launcher.exe"; var updaterAppInfo = FileVersionInfo.GetVersionInfo(updateApp); var launcherAppInfo = FileVersionInfo.GetVersionInfo(launcherApp); var manifest = new UpdateManifest { UpdaterVersion = updaterAppInfo.FileVersion, UpdaterHash = BytesToString(GetHashSha256(updateApp)), UpdaterFile = "http://launcher.homestate.de/Launcher.exe", LauncherVersion = launcherAppInfo.FileVersion, LauncherHash = BytesToString(GetHashSha256(launcherApp)), LauncherArchive = "http://launcher.homestate.de/Update.zip" }; var xs = new XmlSerializer(typeof(UpdateManifest)); TextWriter txtWriter = new StreamWriter(Environment.CurrentDirectory + "\\update.xml"); xs.Serialize(txtWriter, manifest); txtWriter.Close(); }
public void ChooseBestDiffPassTest() { var update = new Updater(mockApp.Object, mockDownloader.Object); var manifest = new UpdateManifest() { LatestVersion = new Version(4, 21), Packages = new List <UpdateManifest.Package>() { new UpdateManifest.Package() { BaseVersion = new Version("4.21"), FileName = "421.exe" }, new UpdateManifest.Package() { BaseVersion = new Version("4.2"), FileName = "42to42.exe" }, new UpdateManifest.Package() { BaseVersion = new Version("4.1"), FileName = "41to42.exe" } } }; var ver = new Version("4.2.0.0"); var package = update.GetUpdatePackage(manifest, ver); Assert.AreEqual(ver.ToString(2), package.BaseVersion.ToString()); Assert.AreEqual("42to42.exe", package.FileName); }
/// <summary> /// Installs an update. Shows an error message if the installation failed. /// </summary> /// <param name="manifest">The update manifest for of the update to install.</param> public async Task InstallUpdateAsync(UpdateManifest manifest) { var fileName = await _updateService.DownloadInstallerAsync(manifest); string error = null; if (fileName == null) { error = Strings.ErrorInstallerDownload; } else { var executeResult = _updateService.ExecuteInstaller(fileName); if (!executeResult) { error = Strings.ErrorInstallerExecution; } } if (error != null) { _eventAggregator.GetEvent <MessageBoxEvent>().Publish(new MessageBoxEventArgs { Title = Strings.Error, Message = error, Type = MessageBoxType.Error, IsModal = true }); } }
public void ReadXml(XmlReader reader) { bool in_urls = false; reader.MoveToNextAttribute(); if (reader.Name == "status") { status = reader.Value; } while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { if (!in_urls) { if (reader.Name == "urls") { urls = new List <UpdateUrl>(); in_urls = true; } else if (reader.Name == "manifest") { manifest = new UpdateManifest(); XmlReader s = reader.ReadSubtree(); s.Read(); manifest.ReadXml(s); s.Close(); } } else if (reader.Name == "url") { UpdateUrl uu = new UpdateUrl(); XmlReader s = reader.ReadSubtree(); s.Read(); uu.ReadXml(s); s.Close(); urls.Add(uu); } } else if (reader.NodeType == XmlNodeType.EndElement) { if (reader.Name == "urls") { in_urls = false; } } } }
public void Run() { List <TableUpdate> tablesUpdate = BuildTablesUpdate(); Opts.AppSettings opt = AppContext.Settings.AppSettings; var inc = new UpdateIncrement(AppContext.TableManager.DataUpdates.CreateUniqID(), opt.DataGeneration); string incFileName = inc.ID.ToString("X"); string incFilePath = System.IO.Path.Combine(AppPaths.DataUpdateFolder, incFileName); UpdateEngin.SaveTablesUpdate(tablesUpdate, incFilePath); AppContext.AccessPath.GetDataProvider(InternalTablesID.INCREMENT).Insert(inc); foreach (TableUpdate tu in tablesUpdate) { AppContext.TableManager.SetTableGeneration(tu.TableID, tu.PostGeneration); } AppContext.TableManager.Transactions.Reset(); string dataMainfest = AppPaths.DataManifestPath; UpdateEngin.UpdateDataManifest(dataMainfest, new UpdateURI(incFileName, opt.DataGeneration)); if (opt.DataGeneration++ == 0) { opt.UpdateKey = (uint)DateTime.Now.Ticks; } AppContext.Settings.Save(); string manifestFile = AppPaths.ManifestPath; try { IUpdateManifest oldManifest = UpdateEngin.ReadUpdateManifest(manifestFile); var newManifest = new UpdateManifest(opt.UpdateKey, opt.DataGeneration, oldManifest.Versions); UpdateEngin.WriteUpdateManifest(newManifest, manifestFile); } catch { UpdateEngin.WriteUpdateManifest(new UpdateManifest(opt.UpdateKey, opt.DataGeneration), manifestFile); } }
/// <summary> /// Shows a confirmation to check if the user wants to install an available application update. /// </summary> /// <param name="manifest">The update manifest of the available update.</param> public void ShowUpdateAvailable(UpdateManifest manifest) { var message = string.Format(Strings.UpdateAvailableMessageFormat, manifest.Description); _eventAggregator .GetEvent <MessageBoxEvent>() .Publish(new MessageBoxEventArgs { Callback = async result => { if (result) { await InstallUpdateAsync(manifest); } }, IsModal = true, Message = message, Title = Strings.UpdateAvailable, Type = MessageBoxType.Question }); }
private static bool DownloadUpdater() { App.Logger.Log("[UPDATE] - Downloading updater"); try { using (WebClient client = new WebClient()) { client.Headers.Add(HttpRequestHeader.UserAgent, "NPCMaker"); string content = client.DownloadString(UpdaterReleasesUrl); UpdateManifest manifest = JsonConvert.DeserializeObject <UpdateManifest>(content); byte[] data = client.DownloadData(manifest.assets[0].browser_download_url); using (FileStream fs = new FileStream(Path.Combine(AppConfig.Directory, "updater.exe"), FileMode.Create)) { fs.Write(data, 0, data.Length); } return(true); } } catch (Exception ex) { App.Logger.LogException("[UPDATE] - Could not download updater!", ex: ex); return(false); } }
private void UploadAppUpdates_Click(object sender, EventArgs e) { var filesNames = new Dictionary <AppArchitecture_t, string> { { AppArchitecture_t.Win7SP1, WIN7SP1_UPDATE_FILENAME }, { AppArchitecture_t.Win7SP1X64, WIN7SP1X64_UPADTE_FILENAME }, { AppArchitecture_t.WinXP, WINXP_UPADTE_FILENAME } }; var waitDlg = new Jobs.ProcessingDialog(); Action run = () => { KeyIndexer ndxer = AppContext.AccessPath.GetKeyIndexer(InternalTablesID.APP_UPDATE); var seq = (from AppUpdate up in ndxer.Source.Enumerate() where up.DeployTime == AppUpdate.NOT_YET select up).ToArray(); //maj app manifest + manifest global Dictionary <AppArchitecture_t, string> appManifest; try { appManifest = UpdateEngin.ReadAppManifest(AppPaths.AppManifestPath); } catch (Exception ex) { TextLogger.Warning(ex.Message); appManifest = new Dictionary <AppArchitecture_t, string>(); } IUpdateManifest gManifest; try { gManifest = UpdateEngin.ReadUpdateManifest(AppPaths.ManifestPath); } catch (Exception ex) { TextLogger.Warning(ex.Message); gManifest = new UpdateManifest(0, 0); } var netEngin = new NetEngin(AppContext.Settings.NetworkSettings); foreach (AppUpdate up in seq) { gManifest.Versions[up.AppArchitecture] = up.Version; appManifest[up.AppArchitecture] = filesNames[up.AppArchitecture]; string srcFileName = up.ID.ToString("X"); string destFileName = filesNames[up.AppArchitecture]; string dst = Urls.AppUpdateDirURL + destFileName; waitDlg.Message = $"Transfert du fichier {destFileName}. Cette opération peut durer plusieurs minutes."; netEngin.Upload(dst, Path.Combine(AppPaths.AppUpdateFolder, srcFileName)); up.DeployTime = DateTime.Now; ndxer.Source.Replace(ndxer.IndexOf(up.ID), up); } waitDlg.Message = "Transfert du manifest des applications..."; UpdateEngin.WriteAppManifest(AppPaths.AppManifestPath, appManifest); netEngin.Upload(Urls.AppManifestURL, AppPaths.AppManifestPath); waitDlg.Message = "Transfert du manifest global..."; UpdateEngin.WriteUpdateManifest(gManifest, AppPaths.ManifestPath); netEngin.Upload(Urls.ManifestURL, AppPaths.ManifestPath); }; Action onSucces = () => { m_tsbUploadAppUpdates.Enabled = false; waitDlg.Dispose(); }; Action <Task> onErr = t => { waitDlg.Dispose(); this.ShowError(t.Exception.InnerException.Message); TextLogger.Error(t.Exception.InnerException.Message); }; var task = new Task(run, TaskCreationOptions.LongRunning); task.OnSuccess(onSucces); task.OnError(onErr); task.Start(); waitDlg.ShowDialog(this); }
public object Post(OmahaClient request) { ILog log = LogManager.GetLogger(GetType()); log.Info("Client is : " + Request.UserAgent); //log.Debug("Query is : " + Request.GetRawBody()); //log.Debug("Query is : " + Request.InputStream.Length + " is at " + Request.InputStream.Position); //log.Debug("?? " + Request.QueryString); if (Request.ContentType == null || Request.ContentType == "") { string rb = Request.GetRawBody(); XmlTextReader sxtr = new XmlTextReader(new StringReader(rb)); //log.Warn("Thus, have " + request.protocol + " and " + rb); log.Warn("No ContentType supplied. Reparsing data as xml."); request = client_serializer.ReadObject(sxtr) as OmahaClient; } //else // log.Info("Client Content Type was " + Request.ContentType); if (Request.AcceptTypes == null) { log.Warn("No Accept Types - forcing application/xml out."); } else { foreach (string accepttype in base.Request.AcceptTypes) { log.Info("Accepts: " + accepttype); } } if (Request.AcceptTypes == null) { Request.ResponseContentType = "application/xml"; } //log.Warn("Response Content Type: " + Request.ResponseContentType); OmahaClientResponse resp = new OmahaClientResponse(); resp.protocol = "3.0"; resp.server = "oto-test"; DateTime beginning_of_day = DateTime.Now.Date; resp.daystart = new DayStart { elapsed_seconds = (uint)(DateTime.Now - beginning_of_day).TotalSeconds }; resp.app_results = new List <AppInfoResult>(); if (request.apps != null) { foreach (AppInfoRequest app_req in request.apps) { log.Info("Checking " + app_req.appid); AppInfoResult app_res = new AppInfoResult(); app_res.appid = app_req.appid; app_res.status = "ok"; if (app_req.ping != null) { app_res.ping = new PingResult { status = "ok" } } ; if (app_req.events != null && app_req.events.Count > 0) { app_res.event_responses = new List <EventResponse>(); foreach (EventReport event_rep in app_req.events) { app_res.event_responses.Add(new EventResponse { status = "ok" }); } } if (app_req.data != null && app_req.data.Count > 0) { app_res.data_results = new List <DataResult>(); foreach (DataRequest data_req in app_req.data) { DataResult dtd_res = new DataResult(); if (data_req.index != null) { dtd_res.index = data_req.index; } if (data_req.name != null) { dtd_res.name = data_req.name; } dtd_res.status = "ok"; app_res.data_results.Add(dtd_res); } } if (app_req.updatecheck != null) { if (app_req.version != null) { app_req.version = app_req.version.ToUpper(); } UpdateResult update_result = null; DataStore.App matched = DataStore.DataStore.Instance().KnownApps.SingleOrDefault(k_app => k_app.guid == app_req.appid); if (matched == null || matched.current == null || !VersionShouldUpdate(app_req.version, matched.current.version)) { if (matched == null) { log.Info("Requested unknown application " + app_req.appid); } else if (matched.current == null) { log.Warn("Requested application " + app_req.appid + " has no active version!"); } else { log.Info(app_req.appid + " version \"" + app_req.version + "\" had no update"); } update_result = new UpdateResult { status = "noupdate" }; } else { log.Info(app_req.appid + " had an update"); UpdateManifest update_manifest = new UpdateManifest { version = matched.current.version, updated_packages = matched.current.package.Select <DataStore.AppPackage, UpdatePackage>( ap => new UpdatePackage { hash = ap.hash, name = ap.name, required = ap.required ? "true" : "false", size = ap.size }).ToList(), update_actions = matched.current.actions == null ? null : matched.current.actions.Select <DataStore.AppAction, UpdateAction>( aa => new UpdateAction { on_event = aa.on_event, arguments = aa.arguments, run = aa.run, onsuccess = aa.on_success, version = aa.version }).ToList() }; List <UpdateUrl> url_list = matched.current.url_locations.Select <string, UpdateUrl>(url_string => new UpdateUrl { codebase = url_string }).ToList(); update_result = new UpdateResult { status = "ok", urls = url_list, manifest = update_manifest }; } app_res.updatecheck = update_result; } resp.app_results.Add(app_res); } } else { log.Info("No Apps Requested"); } return(resp); }
private object UpdateAvailable(UpdateManifest updateManifest) { _updateHandler.ShowUpdateAvailable(updateManifest); return(true); }