Пример #1
0
        public Server(Action <string> logger, CancellationToken cancelToken, Configuration config)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            this.logger      = logger;
            this.cancelToken = cancelToken;
            this.config      = config;

            string programFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            this.jobConverter   = new JobConverter(this.logger, programFolder, this.config.OutputFolder);
            this.printJobReader = new PrintJobReader(this.logger, this.cancelToken);
            this.snmpAgent      = new SnmpPrinterAgent(this.logger);
            if (!this.config.VirtualOnly)
            {
                this.postScriptPrinter = new PostScriptPrinter(this.logger, programFolder, this.cancelToken);
                this.conversionKind    = JobConversionKind.PostScript;
            }
            else
            {
                this.conversionKind = JobConversionKind.Pdf;
            }
            this.createJobPropertyMappings();
        }
Пример #2
0
        public string Convert(string pclFilePath, JobConversionKind conversionKind)
        {
            if (pclFilePath == null)
            {
                throw new ArgumentNullException("pclFilePath");
            }
            var p  = new Process();
            var si = p.StartInfo;

            si.FileName = Path.Combine(this.programFolder, JobConverter.EXE_NAME);

            string outputFile = Path.Combine(this.pdfOutputFolder, Path.ChangeExtension(Path.GetFileName(pclFilePath), JobConverter.retrieveJobExtension(conversionKind)));

            si.UseShellExecute = false;
            si.CreateNoWindow  = true;
            si.Arguments       = String.Format(JobConverter.ARGUMENTS, JobConverter.retrieveJobDevice(conversionKind), JobConverter.backwards2ForwardSlashes(outputFile), JobConverter.backwards2ForwardSlashes(pclFilePath));
            this.logger.Invoke(String.Format("Starting pcl6.exe process for conversion to {0}...", conversionKind));
            p.Start();
            p.WaitForExit();
            if (p.ExitCode != 0)
            {
                throw new Exception(String.Format("pcl6.exe returned with abnormal return code {0}", p.ExitCode));
            }
            this.logger.Invoke("pcl6.exe exited normally");
            return(outputFile);
        }
        public Server(Action<string> logger, CancellationToken cancelToken, Configuration config)
        {
            if(logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }
            this.logger = logger;
            this.cancelToken = cancelToken;
            this.config = config;

            string programFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            this.jobConverter = new JobConverter(this.logger, programFolder, this.config.OutputFolder);
            this.printJobReader = new PrintJobReader(this.logger, this.cancelToken);
            this.snmpAgent = new SnmpPrinterAgent(this.logger);
            if (!this.config.VirtualOnly)
            {
                this.postScriptPrinter = new PostScriptPrinter(this.logger, programFolder, this.cancelToken);
                this.conversionKind = JobConversionKind.PostScript;
            }
            else
            {
                this.conversionKind = JobConversionKind.Pdf;
            }
            this.createJobPropertyMappings();
        }