Beispiel #1
0
        /// <summary>
        /// Async function to test if the needed docker images are loaded
        /// </summary>
        /// <returns>Task void</returns>
        private async Task TestDockerImagesAsync()
        {
            if (!await DockerModel.TestDockerImagesAsync())
            {
                await
                ShowDialogAsync(Properties.Resources.info_error, Properties.Resources.info_error_docker_container,
                                MessageDialogStyle.Affirmative);

                await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    mainWindowActions.Exit();
                }));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Function to test if docker is running
        /// </summary>
        private void TestDockerRunning()
        {
            var controller = ShowProgressDialogAsync(Properties.Resources.info_wait,
                                                     Properties.Resources.info_checking_dependencies, false,
                                                     new MetroDialogSettings {
                AnimateShow = true
            });

            controller.Wait();
            controller.Result.SetIndeterminate();

            Trace.WriteLine("Check for Docker.");
            //Check if docker is installed
            var docker = DockerModel.DockerInstalled();
            //Check if docker is running
            var dockerRunning = DockerModel.TestDockerRunningAsync();

            dockerRunning.Wait();

            controller.Result.CloseAsync();


            if (dockerRunning.Result)
            {
                Trace.WriteLine("Docker is running.");
                return;
            }


            if (!docker)
            {//If docker is not installed => close the program
                Trace.WriteLine(Properties.Resources.info_docker_not_installed);
                ShowDialogAsync(Properties.Resources.info_error,
                                Properties.Resources.info_docker_not_installed,
                                MessageDialogStyle.Affirmative).Wait();
                Application.Current.Dispatcher.BeginInvoke(new Action(() =>
                {
                    mainWindowActions.Exit();
                }));
            }
            //Try to start docker
            controller = ShowProgressDialogAsync(Properties.Resources.info_wait,
                                                 Properties.Resources.info_docker_starting, false,
                                                 new MetroDialogSettings {
                AnimateShow = true
            });
            controller.Wait();
            controller.Result.SetIndeterminate();

            Trace.WriteLine(Properties.Resources.info_docker_starting);

            var startVar = DockerModel.StartDockerAsync();

            startVar.Wait();
            controller.Result.CloseAsync();

            if (startVar.Result)
            {
                Trace.WriteLine("Start of Docker was successfull.");
                return;
            }
            //Something went wrong during start => exit program
            Trace.WriteLine("Start of Docker was not successfull.");
            //It didn't work
            ShowDialogAsync(Properties.Resources.info_error,
                            Properties.Resources.info_error_docker_container,
                            MessageDialogStyle.Affirmative).Wait();
            Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                mainWindowActions.Exit();
            }));
        }