コード例 #1
0
        private async void UpdateButton_Click(object sender, RoutedEventArgs e)
        {
            statusTextBlock.Text = "Getting the latest update information...";

            var path = "http://localhost:5000/install/SampleApp.appinstaller";
            var info = await AutoUpdateManager.CheckForUpdatesAsync(path);

            if (!info.Succeeded)
            {
                statusTextBlock.Text = info.ErrorMessage;
                return;
            }

            if (!info.ShouldUpdate)
            {
                statusTextBlock.Text = "This app is already up-to-date :)";
                return;
            }

            // You can use info.MainBundleVersion to get the update version
            statusTextBlock.Text = $"New version: {info.MainBundleVersion}";

            var result = await AutoUpdateManager.TryToUpdateAsync(info);

            if (!result.Succeeded)
            {
                statusTextBlock.Text = result.ErrorMessage;
                return;
            }

            statusTextBlock.Text = $"Success! The app will be restarted soon, see you later!";
        }
コード例 #2
0
        private async Task <bool> DoApplicationUpdateIfRequired()
        {
            if (!ApplicationUpdateInformation.ShouldUpdate)
            {
                System.Diagnostics.Debug.WriteLine("DoApplicationUpdateIfRequired() was called, but there is no update for the app!");
                return(true);
            }

            var result = await AutoUpdateManager.TryToUpdateAsync(ApplicationUpdateInformation);

            if (!result.Succeeded)
            {
                UpdateLauncherButton.IsEnabled = true;
                await new ROR2ModManager.GenericDialogs.UpdateFailedDialog("Error Message: " + result.ErrorMessage).ShowAsync();
                Analytics.TrackEvent(AnalyticsEventNames.DwrandazUpdateManager, new Dictionary <string, string> {
                    { "event", "UpdateFailed" }, { "message", result.ErrorMessage }
                });
                System.Diagnostics.Debug.WriteLine("AutoUpdateManager The update failed");
                return(false);
            }
            return(true);
        }