private (bool, string) PerformAutoUpdateDownload(IUpdateDescription update, string targetFolder, IProgressMonitor progressMonitor) { var fileDownloader = new GitHubFileDownloader(update.DirectDownloadUrl, targetFolder); fileDownloader.FileName = $"gobchat-{update.Version.Major}.{update.Version.Minor}.{update.Version.Patch}-{update.Version.PreRelease}.zip"; try { var downloadResult = fileDownloader.Download(progressMonitor); switch (downloadResult) { case GitHubFileDownloader.Result.Canceled: return(false, null); } } catch (DownloadFailedException ex) { logger.Error(ex); System.Windows.Forms.MessageBox.Show( StringFormat.Format(Resources.Module_Updater_Dialog_DownloadFailed_Text, ex.ToString()), Resources.Module_Updater_Dialog_DownloadFailed_Title, System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error ); return(false, null); } return(true, fileDownloader.FilePath); }
private UpdateFormDialog.UpdateType AskUser(IUpdateDescription update) { using (var notes = new UpdateFormDialog()) { notes.UpdateHeadText = StringFormat.Format(notes.UpdateHeadText, update.Version, GobchatContext.ApplicationVersion); notes.UpdateNotes = update.PatchNotes; notes.ShowDialog(); return(notes.UpdateRequest); } }
private bool PerformAutoUpdate(IDIContext container, IUpdateDescription update) { logger.Info("Performing auto update"); var uiManager = container.Resolve <IUIManager>(); var displayId = uiManager.CreateUIElement(() => { var f = new ProgressDisplayForm(); f.Show(); return(f); }); try { var progressDisplay = uiManager.GetUIElement <ProgressDisplayForm>(displayId); using (var progressMonitor = new ProgressMonitorAdapter(progressDisplay)) { var patchFolder = System.IO.Path.Combine(GobchatContext.ApplicationLocation, PatchFolder); (var downloadResult, var filePath) = PerformAutoUpdateDownload(update, patchFolder, progressMonitor); logger.Info($"Download complete: {downloadResult}"); if (!downloadResult) { return(false); } (var extractionResult, var unpackedArchive) = PerformAutoUpdateExtraction(filePath, patchFolder, progressMonitor); logger.Info($"Extraction complete {extractionResult}"); if (!extractionResult) { return(false); } PerformAutoUpdateInstall(unpackedArchive, progressMonitor); } return(true); } finally { uiManager.DisposeUIElement(displayId); } }