public void PipeServerCannotBeStarted_RetriesStartApplication()
        {
            _pipeServerManager.StartServer().Returns(false);

            var starter = BuildMaybePipedApplicationStarter(2);

            starter.SendMessageOrStartApplication(() => "", () => false, false);

            _pipeServerManager.Received(2).StartServer();
        }
Пример #2
0
        public void Initialize()
        {
            Logger.Trace("COM: Starting initialization process");

            _isComActive = true;

            if (IsServerInstanceRunning)
            {
                throw new InvalidOperationException("Access forbidden. An instance of PDFCreator is currently running.");
            }

            JobInfoQueue.OnNewJobInfo += (sender, eventArgs) => OnNewJob();

            Logger.Trace("COM: Starting pipe server thread");
            _pipeServerManager.StartServer();
        }
Пример #3
0
        private bool TryStartApplication(Func <bool> startApplication, bool startManagePrintJobs)
        {
            var success = false;

            try
            {
                _logger.Debug("Starting pipe server");

                success = _pipeServerManager.StartServer();

                if (!success)
                {
                    return(false);
                }

                _logger.Debug("Reloading settings");
                // Settings may have changed as this may have not been the only instance till now
                _settingsManager.LoadAllSettings();

                if (startManagePrintJobs)
                {
                    _jobInfoQueueManager.ManagePrintJobs();
                }

                _logger.Debug("Finding spooled jobs");

                var spooledJobs = _spooledJobFinder.GetJobs();
                _jobInfoQueue.Add(spooledJobs);

                success = startApplication();
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "There was an error while starting the application");
                success = false;
                throw;
            }
            finally
            {
                if (!success)
                {
                    _pipeServerManager.Shutdown();
                }
            }
            return(success);
        }
Пример #4
0
        public void Initialize()
        {
            Logger.Trace("COM: Starting initialization process");

            _isComActive = true;

            var startupCheck = _startupConditionChecker.CheckStartupConditions();

            if (!startupCheck.Item1)
            {
                throw new InvalidOperationException("Can't initialize the COM interface! " + startupCheck.Item2);
            }

            if (IsServerInstanceRunning)
            {
                throw new InvalidOperationException("Access forbidden. An instance of PDFCreator is currently running.");
            }

            JobInfoQueue.OnNewJobInfo += (sender, eventArgs) => OnNewJob();

            Logger.Trace("COM: Starting pipe server thread");
            _pipeServerManager.StartServer();
        }