private static void loadOutputFiles(BinaryReader reader) { // Clear current list of output files OutputFiles.Clear(); // Get number of output files int count = reader.ReadInt32(); // For each output file for (int i = 0; i < count; i++) { // Get output file string file = reader.ReadString(); // Add output file to list OutputFiles.Add(file); } }
#pragma warning restore CS0067 protected override JobState RunJobWork() { SetThreadName(); OutputFiles.Clear(); SetUpActions(); var converter = new XpsConverter(JobInfo); var path = Path.Combine(JobTempOutputFolder, JobTempFileName + Path.GetExtension(OutputFilenameTemplate)); converter.Convert(path); //PDFProcessor.process MoveOutputFile(path); JobState = JobState.Succeeded; return(JobState); }
/// <summary> /// Run the Job /// </summary> protected override JobState RunJobWork() { try { if (string.IsNullOrEmpty(Thread.CurrentThread.Name)) { Thread.CurrentThread.Name = "JobWorker"; } } catch (InvalidOperationException) { } try { _ghostScript.Output += Ghostscript_Output; OnJobCompleted += (sender, args) => _ghostScript.Output -= Ghostscript_Output; OutputFiles.Clear(); Logger.Trace("Setting up actions"); SetUpActions(); Logger.Debug("Starting Ghostscript Job"); OutputDevice device; switch (Profile.OutputFormat) { case OutputFormat.PdfA1B: case OutputFormat.PdfA2B: case OutputFormat.PdfX: case OutputFormat.Pdf: device = new PdfDevice(this); break; case OutputFormat.Png: device = new PngDevice(this); break; case OutputFormat.Jpeg: device = new JpegDevice(this); break; case OutputFormat.Tif: device = new TiffDevice(this); break; case OutputFormat.Txt: device = new TextDevice(this); break; default: throw new Exception("Illegal OutputFormat specified"); } Logger.Trace("Output format is: {0}", Profile.OutputFormat.ToString()); _ghostScript.Output += Ghostscript_Logging; var success = _ghostScript.Run(device, JobTempFolder); _ghostScript.Output -= Ghostscript_Logging; Logger.Trace("Finished Ghostscript execution"); if (!success) { var errorMessage = ExtractGhostscriptErrors(GhostscriptOutput); Logger.Error("Ghostscript execution failed: " + errorMessage); ErrorMessage = errorMessage; JobState = JobState.Failed; return(JobState); } ProcessOutput(); Logger.Trace("Moving output files to final location"); MoveOutputFiles(); Logger.Trace("Finished Ghostscript Job"); JobState = JobState.Succeeded; return(JobState); } catch (ProcessingException) { JobState = JobState.Failed; throw; } catch (DeviceException) { JobState = JobState.Failed; throw; } catch (Exception ex) { JobState = JobState.Failed; Logger.Error("There was an error while converting the Job {0}: {1}", JobInfo.InfFile, ex); throw; } }