Exemplo n.º 1
0
        public void PrinterMapping_WithInvalidPrinter_SelectsDefaultProfile()
        {
            _settings.ApplicationSettings.PrinterMappings.Add(new PrinterMapping("InvalidPrinter", "Profile1"));

            var job = _jobBuilder.BuildJobFromJobInfo(_testHelper.JobInfo, _settings);

            Assert.AreEqual(_settings.ConversionProfiles[0], job.Profile, "Default profile should have been mapped");
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Process a single job
        /// </summary>
        /// <param name="jobInfo">The jobinfo to process</param>
        /// <returns>True if the job was processed. If the user decided to manage the print jobs instead, this returns false</returns>
        private void ProcessJob(JobInfo jobInfo)
        {
            _logger.Trace("Creating job workflow");

            var job = _jobBuilder.BuildJobFromJobInfo(jobInfo, _settingsProvider.Settings);

            var mode = DetermineMode(job);
            var workflow = _workflowFactory.CreateWorkflow(mode);

            _logger.Trace("Running workflow");
            var workflowResult = workflow.RunWorkflow(job);

            if (workflowResult != WorkflowResult.Finished)
            {
                if (workflowResult == WorkflowResult.AbortedByUser)
                {
                    _logger.Info("The job '{0}' was aborted by the user.",
                        job.JobInfo.Metadata.Title);
                }
                else
                {
                    _logger.Error("The job '{0}' terminated at step {1} and did not end successfully.",
                        job.JobInfo.Metadata.Title, workflowResult);
                }
            }
            else
            {
                _jobHistoryActiveRecord.Add(job);
            }
        }
        public void AuthorTemplateTest()
        {
            _th.GenerateGsJob(PSfiles.PDFCreatorTestpage, OutputFormat.Pdf);
            _th.JobInfo.Metadata.PrintJobAuthor = "Author from Job";

            _settings = new PdfCreatorSettings(null);
            _settings.ConversionProfiles.Add(_th.Job.Profile);
            _settings.ConversionProfiles[0].AutoSave.Enabled = true;
            _settings.ConversionProfiles[0].AutoSave.EnsureUniqueFilenames = false;
            _settings.ConversionProfiles[0].TargetDirectory = _th.TmpTestFolder;
            _settings.ConversionProfiles[0].FileNameTemplate = "AutoSaveTestOutput";
            _settings.ConversionProfiles[0].OutputFormat = OutputFormat.Pdf;
            _settings.ConversionProfiles[0].AuthorTemplate = "<PrintJobAuthor> + some text";

            var job = _jobBuilder.BuildJobFromJobInfo(_th.JobInfo, _settings);
            var autoSaveWorkflow = _workflowFactory.CreateWorkflow(WorkflowModeEnum.Autosave);

            autoSaveWorkflow.RunWorkflow(job);

            var pdf = new PdfReader(job.OutputFiles[0]);
            Assert.AreEqual("Author from Job + some text", pdf.Info["Author"], "Wrong author in PDF Metadata");
        }