Exemplo n.º 1
0
        /// <summary>
        /// Asynchronously initializes startup flow
        /// </summary>
        public async void StartAsync(StartupManager sm)
        {
            var startupResults = await sm.ManageStartupAsync();

            StartupManagerExitCode = startupResults;

            switch (startupResults)
            {
            case StartupManagerExitCode.Success:
                StatusNotifier.Print("Starting...");
                break;

            case StartupManagerExitCode.UpdateFailedButNotRequired:
                StatusNotifier.Print("Update not currently possible, starting installed version...");
                break;

            case StartupManagerExitCode.UpdateRequiredButFailed:
                // Configuration requires to make sure app is always most recent
                StatusNotifier.Print("Update not possible. Application cannot be started.");
                StatusNotifier.IsTryAgainVisible = true;
                MessageBox.Show(
                    messageBoxText: "Application could not be started. Check your network and try again.",
                    caption: "Application not started",
                    button: MessageBoxButton.OK,
                    icon: MessageBoxImage.Error);
                break;

            case StartupManagerExitCode.InstallationFailed:
                StatusNotifier.Print("Installation failed. Application cannot be started.");
                StatusNotifier.IsTryAgainVisible = true;
                MessageBox.Show(
                    messageBoxText: "Application could not be installed. Check your network and try again.",
                    caption: "Application not started",
                    button: MessageBoxButton.OK,
                    icon: MessageBoxImage.Error);
                break;

            default:
                break;
            }
            if (ConfigurationProvider.IsLoggerOn)
            {
                Logger.DumpToFile();
            }
            // close
            if (startupResults == StartupManagerExitCode.Success ||
                startupResults == StartupManagerExitCode.UpdateFailedButNotRequired)
            {
                StartupManager.StartProcess(ConfigurationProvider);
                CloseWithDelayAsync(2000);
            }
        }