Exemplo n.º 1
0
            public void Start()
            {
                if (_httpListener.IsListening)
                {
                    return;
                }

                var settings  = new PrintSettings();
                var portRange = GetPortRange(settings.HttpProxyServerPortRange);

                Platform.Log(LogLevel.Info, "Starting print server...");

                foreach (var port in portRange)
                {
                    if (!TryStartHttpListener(port, out _host))
                    {
                        continue;
                    }

                    Platform.Log(LogLevel.Info, "Print server started on port {0}.", port);

                    _listenerThread = new Thread(Listen)
                    {
                        IsBackground = true
                    };
                    _listenerThread.Start();
                    return;
                }
                throw new PrintException(string.Format("Unable to start HTTP print server on any port in range {0}.", portRange));
            }
Exemplo n.º 2
0
        private void RunConverter(string outputFilePath)
        {
            var settings = new PrintSettings();

            try
            {
                var sourceUrls = string.Join(" ", _pages.Select(p => p.ConverterUrl.ToString()));
                var arguments  = string.Format("{0} {1} {2}", settings.ConverterOptions, sourceUrls, outputFilePath);
                var startInfo  = new ProcessStartInfo(settings.ConverterProgram, arguments)
                {
                    UseShellExecute = false
                };
                var process = Process.Start(startInfo);
                var exited  = process.WaitForExit(settings.ConverterTimeout * 1000);

                if (!exited)
                {
                    SetError(string.Format("The converter program ({0}) timed out after {1} ms - printing aborted.",
                                           settings.ConverterProgram, settings.ConverterTimeout));
                }
            }
            catch (Win32Exception e)
            {
                SetError(
                    string.Format("{0}. Usually this means the converter program is not installed, or its location ({1}) is incorrectly configured.",
                                  e.Message,
                                  settings.ConverterProgram)
                    );
            }
        }
Exemplo n.º 3
0
			public void Start()
			{
				if (_httpListener.IsListening)
					return;

				var settings = new PrintSettings();
				var portRange = GetPortRange(settings.HttpProxyServerPortRange);
				Platform.Log(LogLevel.Info, "Starting print server...");

				foreach (var port in portRange)
				{
					if (!TryStartHttpListener(port, out _host))
						continue;

					Platform.Log(LogLevel.Info, "Print server started on port {0}.", port);

					_listenerThread = new Thread(Listen) { IsBackground = true };
					_listenerThread.Start();
					return;
				}
				throw new PrintException(string.Format("Unable to start HTTP print server on any port in range {0}.", settings.HttpProxyServerPortRange));
			}
Exemplo n.º 4
0
		private void RunConverter(string outputFilePath)
		{
			var settings = new PrintSettings();
			try
			{
				var sourceUrls = string.Join(" ", _pages.Select(p => p.ConverterUrl.ToString()));
				var arguments = string.Format("{0} {1} {2}", settings.ConverterOptions, sourceUrls, outputFilePath);
				var startInfo = new ProcessStartInfo(settings.ConverterProgram, arguments) {UseShellExecute = false};
				var process = Process.Start(startInfo);
				var exited = process.WaitForExit(settings.ConverterTimeout * 1000);

				if (!exited)
				{
					SetError(string.Format("The converter program ({0}) timed out after {1} ms - printing aborted.",
						settings.ConverterProgram, settings.ConverterTimeout));
				}

			}
			catch (Win32Exception e)
			{
				SetError(
					string.Format("{0}. Usually this means the converter program is not installed, or its location ({1}) is incorrectly configured.",
					e.Message,
					settings.ConverterProgram)
				);
			}
		}