Beispiel #1
0
        /// <summary>
        /// Start up the application using a fake Healthchecks service (for testing).
        /// </summary>
        private static void StartupWithMockService(AppConfig config)
        {
            var service   = new FileBasedHealthTrayService(@"Testing\checks.json");
            var dashboard = new DashboardWindow(service, config);

            dashboard.Show();
        }
Beispiel #2
0
        /// <summary>
        /// Start up the application using the live Healthchecks service (for release).
        /// </summary>
        private static void StartupWithLiveService(AppConfig config)
        {
            var apiUrl     = config.Get <string>("healthchecks-api-url");
            var apiKeySalt = config.Get <string>("healthtray-salt");

            IHealthTrayService service = null;
            bool goToSettings          = false;

            if (string.IsNullOrWhiteSpace(apiUrl) || string.IsNullOrWhiteSpace(apiKeySalt))
            {
                service = new StubHealthTrayService(new List <Check>());
                if (MessageBox.Show("It looks like you haven't set an API URL and/or key yet. Enter one now?", "First run?", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                {
                    goToSettings = true;
                }
            }
            else
            {
                try
                {
                    var apiKey = Crypto.Decrypt(config.Get <string>("healthchecks-api-key"), apiKeySalt);
                    service = new HealthTrayService(apiUrl, apiKey);
                }
                catch
                {
                    service      = new StubHealthTrayService(new List <Check>());
                    goToSettings = true; //settings page should inform user about the decryption error
                }
            }

            var dashboard = new DashboardWindow(service, config);

            dashboard.Show();

            if (goToSettings)
            {
                new ShowSettingsCommand().Execute(null);
            }
        }