public void PrinterMapping_EmptyMappingWithAutoSave_CreatesAutoSaveWorkflow()
        {
            _settings.ConversionProfiles[0].AutoSave.Enabled = true;
            var workflow = WorkflowFactory.CreateWorkflow(_testHelper.JobInfo, _settings);

            Assert.True(workflow is AutoSaveWorkflow, "AutoSaveWorkflow was expected");
        }
        public void PrinterMapping_WithInvalidPrinter_SelectsDefaultProfile()
        {
            _settings.ApplicationSettings.PrinterMappings.Add(new PrinterMapping("InvalidPrinter", "Profile1"));

            ConversionWorkflow workflow = WorkflowFactory.CreateWorkflow(_testHelper.JobInfo, _settings);

            Assert.AreEqual(_settings.ConversionProfiles[0], workflow.Job.Profile, "Default profile should have been mapped");
        }
        public void PrinterMapping_WithProfileMappingWithOtherCasing_PreselectsProfile()
        {
            _settings.ApplicationSettings.PrinterMappings.Add(new PrinterMapping("pdfcreator", "Profile1"));

            ConversionWorkflow workflow = WorkflowFactory.CreateWorkflow(_testHelper.JobInfo, _settings);

            Assert.AreEqual(_settings.ConversionProfiles[1], workflow.Job.Profile, "Profile1 should have been mapped");
        }
Beispiel #4
0
        public void CreateConversionWorkflowTest_NoMapping_TwoProfiles_NoneIsDefault_NoneIsLastUsedProfile_ReturnWorkflowWithFirstProfile()
        {
            _settings.ApplicationSettings.LastUsedProfileGuid = "NoneOfTheProfileGuids";

            _settings.ConversionProfiles.Add(_autosaveProfile);
            _settings.ConversionProfiles.Add(_interactiveProfile);
            _workflow = WorkflowFactory.CreateWorkflow(_th.JobInfo, _settings);
            Assert.AreEqual(_autosaveProfile, _workflow.Job.Profile, "Wrong Profile in Job of workflow.");
        }
Beispiel #5
0
        public void CreateConversionWorkflowTest_PrinterMappingToProfile_ReturnWorkflowWithMappedProfile()
        {
            _settings.ApplicationSettings.PrinterMappings.Add(_autosaveProfileMapping);
            _settings.ApplicationSettings.PrinterMappings.Add(_interactiveProfileMapping);
            _settings.ConversionProfiles.Add(_autosaveProfile);
            _settings.ConversionProfiles.Add(_interactiveProfile);

            _th.JobInfo.SourceFiles[0].PrinterName = _autosaveProfileMapping.PrinterName;
            _workflow = WorkflowFactory.CreateWorkflow(_th.JobInfo, _settings);
            Assert.AreEqual(_autosaveProfile, _workflow.Job.Profile, "Wrong Profile in Job of workflow.");
        }
        private static void StartEchoWorkflow()
        {
            var client = new AmazonSimpleWorkflowClient();

            var activity = WorkflowFactory.CreateActivity <string, string>("echo", Echo, 60, 10, 10, 20)
                           .Complete();
            var workflow = WorkflowFactory.CreateWorkflow("theburningmonk.com", "echo_cs", "1")
                           .Attach(activity)
                           .Complete();

            workflow.Start(client);
        }
Beispiel #7
0
        public void CreateConversionWorkflowTest_PrinterIsNotListedInMapping_ReturnWorkflowWithDefaultProfile()
        {
            _settings.ApplicationSettings.PrinterMappings.Add(_autosaveProfileMapping);
            _settings.ApplicationSettings.PrinterMappings.Add(_interactiveProfileMapping);
            _settings.ConversionProfiles.Add(_autosaveProfile); //For this test the default profile must not be the first in list!
            _interactiveProfile.Guid = "DefaultGuid";
            _settings.ConversionProfiles.Add(_interactiveProfile);

            _th.JobInfo.SourceFiles[0].PrinterName = "PrinterNameNotInMapping";

            _workflow = WorkflowFactory.CreateWorkflow(_th.JobInfo, _settings);
            Assert.AreEqual(_interactiveProfile, _workflow.Job.Profile, "Wrong Profile in Job of workflow.");
        }
Beispiel #8
0
        public void CreateConversionWorkflowTest_PrinterMappingToInvalidProfile_ReturnWorkflowWithDefaultProfile()
        {
            _settings.ApplicationSettings.PrinterMappings.Add(_autosaveProfileMapping);
            _settings.ApplicationSettings.PrinterMappings.Add(_interactiveProfileMapping);
            const string somePrinterName    = "somePrinterName";
            const string someProfileGuid    = "someProfileNotInProfilesListGuid";
            var          somePrinterMapping = new PrinterMapping(somePrinterName, someProfileGuid);

            _settings.ApplicationSettings.PrinterMappings.Add(somePrinterMapping);
            _settings.ConversionProfiles.Add(_autosaveProfile); //For this test the default profile must not be the first in list!
            _interactiveProfile.Guid = "DefaultGuid";
            _settings.ConversionProfiles.Add(_interactiveProfile);

            _th.JobInfo.SourceFiles[0].PrinterName = somePrinterName;

            _workflow = WorkflowFactory.CreateWorkflow(_th.JobInfo, _settings);
            Assert.AreEqual(_interactiveProfile, _workflow.Job.Profile, "Wrong Profile in Job of workflow.");
        }
Beispiel #9
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(IJobInfo jobInfo)
        {
            _logger.Trace("Creating job workflow");
            var cw = WorkflowFactory.CreateWorkflow(jobInfo, SettingsHelper.Settings);

            _logger.Trace("Running workflow");
            cw.RunWorkflow();

            if (cw.WorkflowStep != WorkflowStep.Finished)
            {
                if (cw.WorkflowStep == WorkflowStep.AbortedByUser)
                {
                    _logger.Info("The job '{0}' was aborted by the user.",
                                 cw.Job.JobInfo.Metadata.Title, cw.WorkflowStep);
                }
                else
                {
                    _logger.Error("The job '{0}' terminated at step {1} and did not end successfully.",
                                  cw.Job.JobInfo.Metadata.Title, cw.WorkflowStep);
                }
            }
        }
        private static void StartCountHtmlElementsWorkflow()
        {
            var client = new AmazonSimpleWorkflowClient();

            var echo = WorkflowFactory.CreateActivity <string, string>("echo", Echo, 60, 10, 10, 20)
                       .Complete();
            var countDiv = WorkflowFactory.CreateActivity <string, int>("count_divs", address => CountMatches("<div", address), 60, 10, 10, 20)
                           .WithDescription("count the number of <div> elements")
                           .Complete();
            var countScripts = WorkflowFactory.CreateActivity <string, int>("count_scripts", address => CountMatches("<script", address), 60, 10, 10, 20)
                               .WithDescription("count the number of <script> elements")
                               .Complete();
            var countSpans = WorkflowFactory.CreateActivity <string, int>("count_spans", address => CountMatches("<span", address), 60, 10, 10, 20)
                             .WithDescription("count the number of <span> elements")
                             .Complete();

            var workflow = WorkflowFactory.CreateWorkflow("theburningmonk.com", "count_html_elements_cs", "1")
                           .Attach(echo)
                           .Attach(new[] { countDiv, countScripts, countSpans }, MatchesReducer)
                           .Attach(echo)
                           .Complete();

            workflow.Start(client);
        }
Beispiel #11
0
 public void CreateConversionWorkflowTest_SingleProfileInteractive_ReturnInteractiveWorkflow()
 {
     _settings.ConversionProfiles.Add(_interactiveProfile);
     _workflow = WorkflowFactory.CreateWorkflow(_th.JobInfo, _settings);
     Assert.IsInstanceOf <InteractiveWorkflow>(_workflow, "Wrong type of workflow.");
 }