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(); }
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(); }
private static string retrieveJobDevice(JobConversionKind kind) { switch (kind) { case JobConversionKind.Pdf: return("pdfwrite"); case JobConversionKind.PostScript: return("pswrite"); default: throw new Exception("Unknown job conversion kind: " + kind); } }
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; }
private static string retrieveJobExtension(JobConversionKind kind) { switch (kind) { case JobConversionKind.Pdf: return "pdf"; case JobConversionKind.PostScript: return "ps"; default: throw new Exception("Unknown job conversion kind: " + kind); } }