예제 #1
0
        private async Task DownloadUpdateTask(ITaskProgress taskProgress)
        {
            try
            {
                if (!await updateService.DownloadLatestVersion(taskProgress))
                {
                    statusBar.PublishNotification(new PlainNotification(NotificationType.Warning,
                                                                        "Failed to download the update, update file got corrupted. Please try later."));
                    return;
                }
                statusBar.PublishNotification(new PlainNotification(NotificationType.Info,
                                                                    "Update ready to install. It will be installed on the next editor restart or when you click here",
                                                                    new AsyncAutoCommand(async() =>
                {
                    if (platformService.PlatformSupportsSelfInstall)
                    {
                        await updateService.CloseForUpdate();
                    }
                    else
                    {
                        await messageBoxService.ShowDialog(new MessageBoxFactory <bool>()
                                                           .SetTitle("Your platform doesn't support self updates")
                                                           .SetContent("Sadly, self updater is not available on your operating system yet.\n\nA new version of WoW Database Editor has been downloaded, but you have to manually copy new version to the Applications folder")
                                                           .Build());
                        var physPath = fileSystem.ResolvePhysicalPath(platformService.UpdateZipFilePath);

                        using Process open = new Process
                              {
                                  StartInfo =
                                  {
                                      FileName        = "open",
                                      Arguments       = "-R " + physPath.FullName,
                                      UseShellExecute = true
                                  }
                              };
                        open.Start();
                    }
                })));
            }
            catch (Exception e)
            {
                statusBar.PublishNotification(new PlainNotification(NotificationType.Error, "Error while checking for the updates: " + e.Message));
            }
        }