protected override void DoWorkflowWork(Job job)
        {
            job.OutputFilenameTemplate = _targetFileNameComposer.ComposeTargetFileName(job);

            var preCheck = _profileChecker.ProfileCheck(job.Profile, job.Accounts);

            if (!preCheck)
            {
                throw new ProcessingException("Invalid Profile", preCheck[0]);
            }

            job.Passwords = JobPasswordHelper.GetJobPasswords(job.Profile, job.Accounts);

            // Can throw ProcessingException
            _jobRunner.RunJob(job, _outputFileMover);

            WorkflowResult = WorkflowResult.Finished;
            OnJobFinished(EventArgs.Empty);
        }
Beispiel #2
0
        protected override void DoWorkflowWork(Job job)
        {
            var documentName   = job.JobInfo.Metadata.Title;
            var currentProfile = job.Profile;

            try
            {
                job.OutputFileTemplate = _targetFilePathComposer.ComposeTargetFilePath(job);

                var result = _profileChecker.CheckJob(job);
                if (!result)
                {
                    throw new ProcessingException("Invalid Profile", result[0]);
                }

                job.Passwords = JobPasswordHelper.GetJobPasswords(job.Profile, job.Accounts);

                job.CleanUpOnError = true;
                // Can throw ProcessingException. Use GetAwaiter().GetResult() to unwrap an occuring AggregateException.
                _jobRunner.RunJob(job, _outputFileMover).GetAwaiter().GetResult();

                WorkflowResult = WorkflowResult.Finished;
                OnJobFinished(EventArgs.Empty);

                documentName = Path.GetFileName(job.OutputFiles.First());

                if (currentProfile.ShowAllNotifications && !currentProfile.ShowOnlyErrorNotifications)
                {
                    _notificationService?.ShowInfoNotification(documentName, job.OutputFiles.First());
                }
            }
            catch (Exception)
            {
                if (currentProfile.ShowAllNotifications || currentProfile.ShowOnlyErrorNotifications)
                {
                    _notificationService?.ShowErrorNotification(documentName);
                }

                throw;
            }
        }