예제 #1
0
        public void Terminate()
        {
            DeregisterEvents();

            if (SessionIsRunning)
            {
                StopSession();
            }

            logger.Unsubscribe(runtimeWindow);
            runtimeWindow?.Close();

            splashScreen = uiFactory.CreateSplashScreen(appConfig);
            splashScreen.Show();

            logger.Log(string.Empty);
            logger.Info("Initiating shutdown procedure...");

            var success = bootstrapSequence.TryRevert() == OperationResult.Success;

            if (success)
            {
                logger.Info("Application successfully finalized.");
                logger.Log(string.Empty);
            }
            else
            {
                logger.Info("Shutdown procedure failed!");
                logger.Log(string.Empty);

                messageBox.Show(TextKey.MessageBox_ShutdownError, TextKey.MessageBox_ShutdownErrorTitle, icon: MessageBoxIcon.Error, parent: splashScreen);
            }

            splashScreen.Close();
        }
        private void Browser_ConfigurationDownloadFinished(bool success, string filePath = null)
        {
            if (success)
            {
                var communication = runtime.RequestReconfiguration(filePath);

                if (communication.Success)
                {
                    logger.Info($"Sent reconfiguration request for '{filePath}' to the runtime.");

                    splashScreen = uiFactory.CreateSplashScreen(appConfig);
                    splashScreen.SetIndeterminate();
                    splashScreen.UpdateStatus(TextKey.OperationStatus_InitializeSession, true);
                    splashScreen.Show();
                }
                else
                {
                    logger.Error($"Failed to communicate reconfiguration request for '{filePath}'!");
                    messageBox.Show(TextKey.MessageBox_ReconfigurationError, TextKey.MessageBox_ReconfigurationErrorTitle, icon: MessageBoxIcon.Error);
                }
            }
            else
            {
                logger.Error($"Failed to download configuration file '{filePath}'!");
                messageBox.Show(TextKey.MessageBox_ConfigurationDownloadError, TextKey.MessageBox_ConfigurationDownloadErrorTitle, icon: MessageBoxIcon.Error);
            }
        }
예제 #3
0
        internal bool TryStart()
        {
            logger.Info("Initiating startup procedure...");

            operations.ActionRequired  += Operations_ActionRequired;
            operations.ProgressChanged += Operations_ProgressChanged;
            operations.StatusChanged   += Operations_StatusChanged;

            splashScreen.Show();
            splashScreen.BringToForeground();

            var success = operations.TryPerform() == OperationResult.Success;

            if (success)
            {
                RegisterEvents();
                ShowShell();
                AutoStartApplications();

                var communication = runtime.InformClientReady();

                if (communication.Success)
                {
                    logger.Info("Application successfully initialized.");
                    logger.Log(string.Empty);
                }
                else
                {
                    success = false;
                    logger.Error("Failed to inform runtime that client is ready!");
                }
            }
            else
            {
                logger.Info("Application startup aborted!");
                logger.Log(string.Empty);
            }

            splashScreen.Hide();

            return(success);
        }
        internal bool TryStart()
        {
            logger.Info("Initiating startup procedure...");

            bootstrapSequence.ProgressChanged += BootstrapSequence_ProgressChanged;
            bootstrapSequence.StatusChanged   += BootstrapSequence_StatusChanged;
            sessionSequence.ActionRequired    += SessionSequence_ActionRequired;
            sessionSequence.ProgressChanged   += SessionSequence_ProgressChanged;
            sessionSequence.StatusChanged     += SessionSequence_StatusChanged;

            splashScreen.Show();
            splashScreen.BringToForeground();


            var initialized = bootstrapSequence.TryPerform() == OperationResult.Success;

            if (initialized)
            {
                RegisterEvents();

                RegisterCustomUrlProtocol(appConfig.SebUriScheme);
                RegisterCustomUrlProtocol(appConfig.SebUriSchemeSecure);

                logger.Info("Application successfully initialized.");
                logger.Log(string.Empty);
                logger.Subscribe(runtimeWindow);
                splashScreen.Hide();

                StartSession();
            }
            else
            {
                logger.Info("Application startup aborted!");
                logger.Log(string.Empty);

                messageBox.Show(TextKey.MessageBox_StartupError, TextKey.MessageBox_StartupErrorTitle, icon: MessageBoxIcon.Error, parent: splashScreen);
            }

            return(initialized && SessionIsRunning);
        }
예제 #5
0
        public bool TryStart()
        {
            logger.Info("Initiating startup procedure...");

            runtimeWindow = uiFactory.CreateRuntimeWindow(appConfig);
            splashScreen  = uiFactory.CreateSplashScreen(appConfig);

            bootstrapSequence.ProgressChanged += BootstrapSequence_ProgressChanged;
            bootstrapSequence.StatusChanged   += BootstrapSequence_StatusChanged;
            sessionSequence.ActionRequired    += SessionSequence_ActionRequired;
            sessionSequence.ProgressChanged   += SessionSequence_ProgressChanged;
            sessionSequence.StatusChanged     += SessionSequence_StatusChanged;

            splashScreen.Show();

            var initialized = bootstrapSequence.TryPerform() == OperationResult.Success;

            if (initialized)
            {
                RegisterEvents();

                logger.Info("Application successfully initialized.");
                logger.Log(string.Empty);
                logger.Subscribe(runtimeWindow);
                splashScreen.Close();

                StartSession();
            }
            else
            {
                logger.Info("Application startup aborted!");
                logger.Log(string.Empty);

                messageBox.Show(TextKey.MessageBox_StartupError, TextKey.MessageBox_StartupErrorTitle, icon: MessageBoxIcon.Error, parent: splashScreen);
            }

            return(initialized && SessionIsRunning);
        }
예제 #6
0
        /// <summary>
        /// Sets up and runs the application. The run method shall block until the application is shut down
        /// </summary>
        public int Run()
        {
            using (ComponentContainer ComponentContainer = new ComponentContainer(this.componentRepository))
            {
                ISplashScreen SplashScreen = ComponentContainer.TryResolveInstance <ISplashScreen>() ?? new SplashDummy();

                SplashScreen.Show();
                IApplicationMain ApplicationMain;

                try
                {
                    this.ResolveModules(ComponentContainer);
                    ApplicationMain = ComponentContainer.ResolveInstance <IApplicationMain>(status => SplashScreen.SetStatus(status));
                }
                finally
                {
                    SplashScreen.Hide();
                }

                //Get Main Module
                return(ApplicationMain.Run(ComponentContainer));
            }
        }
예제 #7
0
        public void Run(string[] args)
        {
            var(requestedSteps, variableOverrides, filePath, isVerbose) = CommandLineParser.Parse(args);
            if (isVerbose)
            {
                _logger.EnableVerbosity();
            }

            _splashScreen.Show();

            if (requestedSteps.Length == 0 && variableOverrides.Length > 0)
            {
                throw new MissingRequiredStepException("Please specify a step when passing variable overrides.");
            }

            _logger.LogHeadline("Input:");
            _logger.Log($"Requested steps:");
            _logger.Log($"  {string.Join(" -> ", requestedSteps)}");
            _logger.Log("Variable overrides:");
            foreach (var(k, v) in variableOverrides)
            {
                _logger.Log($"  {string.Join("=", k, v)}");
            }
            _logger.Log($"Pipeline file override: '{filePath}'");
            _logger.Log("");

            _logger.LogHeadline("Pipeline file:");
            var pipelineFilePath = filePath;  // ?? _fileSystem.GetPathForLocalFile("pipe.line");

            if (!string.IsNullOrWhiteSpace(pipelineFilePath))
            {
                _logger.Log($"Looking for pipeline file at '{pipelineFilePath}'");
                if (!_fileSystem.DoesFileExists(pipelineFilePath))
                {
                    throw new FileNotFoundException($"Unable to locate a pipeline file at {pipelineFilePath}");
                }
            }
            else
            {
                var defaultFilePaths = new[]
                {
                    _fileSystem.GetPathForLocalFile("Pipeline"),
                    _fileSystem.GetPathForLocalFile("pipeline"),
                };

                pipelineFilePath = defaultFilePaths.FirstOrDefault(path => _fileSystem.DoesFileExists(path));
                if (string.IsNullOrWhiteSpace(pipelineFilePath))
                {
                    throw new FileNotFoundException($"Unable to locate a pipeline file at default locations {string.Join(" or ", defaultFilePaths)}");
                }

                _logger.Log($"Looking for pipeline file at '{pipelineFilePath}'");
            }

            _logger.Log("");

            var pipelineFile      = ReadPipelineFileFrom(pipelineFilePath);
            var executionPipeline = BuildExecutionPipelineFrom(requestedSteps, pipelineFile).ToArray();
            var finalVariables    = BuildFinalVariablesFrom(variableOverrides, pipelineFile);
            var command           = CreateCommand(finalVariables);

            _logger.LogHeadline("Variables:");
            foreach (var(k, v) in finalVariables)
            {
                _logger.Log(string.Join("=", k, v));
            }
            _logger.Log("");

            _logger.LogHeadline("Steps to execute:");
            _logger.Log(string.Join(" -> ", executionPipeline.Select(x => x.Name)));
            _logger.Log("");

            foreach (var step in executionPipeline)
            {
                _logger.LogHeadline($"Executing step '{step.Name}':");

                foreach (var action in step.Actions)
                {
                    var shell = command.Shell;

                    _logger.Log($"shell={shell}");
                    _logger.Log($"action={action}");

                    var finalAction = _variableHelper.ExpandVariables(finalVariables, action);
                    var arguments   = command.PrepareArguments(finalAction);

                    _commandLineExecutor.Execute(shell, arguments);
                    _logger.Log("");
                }
            }
        }