Beispiel #1
0
        protected TokenReplacer GetTokenReplacer()
        {
            var tokenReplacerFactory = new TokenReplacerFactory();
            var tokenReplacer        = tokenReplacerFactory.BuildTokenReplacerWithoutOutputfiles(this);

            return(tokenReplacer);
        }
Beispiel #2
0
        /// <summary>
        ///     Runs the job and all actions
        /// </summary>
        public JobState RunJob()
        {
            Logger.Trace("Starting job");

            var calledJobCompleted = false;

            try
            {
                JobState = RunJobWork();

                if (JobState == JobState.Cancelled)
                {
                    Logger.Debug("Job cancelled by user");
                    return(JobState);
                }

                if (JobState == JobState.Failed)
                {
                    Logger.Error("Executing Ghostscript failed");
                    CallJobCompleted(false, JobError.Ghostscript);
                    calledJobCompleted = true;
                    return(JobState);
                }

                if (OutputFiles.Count == 0)
                {
                    JobState = JobState.Failed;
                    Logger.Error("No output files were created for unknown reason");
                    CallJobCompleted(false, JobError.Unknown);
                    calledJobCompleted = true;
                    return(JobState);
                }

                Logger.Trace("Created {0} output files.", OutputFiles.Count);
                var i = 1;
                foreach (var file in OutputFiles)
                {
                    Logger.Trace(i + ". Output file: {0}", file);
                    i++;
                }

                var factory = new TokenReplacerFactory();
                TokenReplacer = factory.BuildTokenReplacerWithOutputfiles(this);

                Logger.Trace("Starting Actions");

                CallActions();

                DoAutoCleanup();

                Logger.Trace("Job finished");
            }
            finally
            {
                if (!calledJobCompleted)
                {
                    Logger.Trace("Calling job completed event");
                    CallJobCompleted();
                }
            }

            return(JobState);
        }