public void SetInteractionWithActionResultDict_ErrorListVisibiltyIsVisible_ErrorListIsBuild_RaisesPropertyChanged()
        {
            var actionResultDict     = new ActionResultDict();
            var excpetedError        = _errorCodeInterpreter.GetErrorText(ErrorCode.Attachment_NoPdf, false);
            var oneErrorActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            actionResultDict.Add("RegionWithOneError", oneErrorActionResult);
            var twoErrorsActionResult = new ActionResult(ErrorCode.Attachment_NoPdf);

            twoErrorsActionResult.Add(ErrorCode.Attachment_NoPdf);
            actionResultDict.Add("RegionWithTwoErrors", twoErrorsActionResult);
            var interaction = new MessageInteraction("", "", MessageOptions.OK, MessageIcon.Info, actionResultDict);

            var propertyChangedList = new List <string>();

            _viewModel.PropertyChanged += (sender, args) => propertyChangedList.Add(args.PropertyName);

            _viewModel.SetInteraction(interaction);

            Assert.AreEqual("RegionWithOneError", _viewModel.ErrorList[0].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[0].Error);
            Assert.AreEqual("RegionWithTwoErrors", _viewModel.ErrorList[1].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[1].Error);
            Assert.AreEqual("RegionWithTwoErrors", _viewModel.ErrorList[2].Region);
            Assert.AreEqual(excpetedError, _viewModel.ErrorList[2].Error);

            Assert.AreEqual(Visibility.Visible, _viewModel.ErrorListVisibility);
            Assert.Contains(nameof(_viewModel.ErrorListVisibility), propertyChangedList);
        }
Пример #2
0
        private void ApplyActionResultOverview()
        {
            if (Interaction.ActionResultDict == null || Interaction.ActionResultDict)
            {
                ErrorListVisibility = Visibility.Collapsed;
                RaisePropertyChanged(nameof(ErrorListVisibility));
                return;
            }

            ErrorListVisibility = Visibility.Visible;
            RaisePropertyChanged(nameof(ErrorListVisibility));

            ErrorList = new List <ErrorWithRegion>();

            foreach (var profileNameActionResult in Interaction.ActionResultDict)
            {
                foreach (var error in profileNameActionResult.Value)
                {
                    var errorText = _errorCodeInterpreter.GetErrorText(error, false);
                    ErrorList.Add(new ErrorWithRegion(profileNameActionResult.Key, errorText));
                }
            }

            RaisePropertyChanged(nameof(ErrorList));

            var view             = (CollectionView)CollectionViewSource.GetDefaultView(ErrorList);
            var groupDescription = new PropertyGroupDescription(nameof(ErrorWithRegion.Region));

            view.GroupDescriptions.Add(groupDescription);
        }
        private DefectiveProfilesWindow(ActionResultDict actionResultDict)
            : this()
        {
            var errors = new List <ProfileError>();

            TranslationHelper.Instance.TranslatorInstance.Translate(this);

            if (actionResultDict.Count() > 1)
            {
                DefectiveProfilesText.Text = TranslationHelper.Instance.TranslatorInstance.GetTranslation(
                    "DefectiveProfilesWindow", "DefectiveProfiles", "Defective profiles:");
            }
            else
            {
                DefectiveProfilesText.Text = TranslationHelper.Instance.TranslatorInstance.GetTranslation(
                    "DefectiveProfilesWindow", "DefectiveProfile", "Defective profile:");
            }

            foreach (var profileNameActionResult in actionResultDict)
            {
                foreach (var error in profileNameActionResult.Value)
                {
                    var errorText = ErrorCodeInterpreter.GetErrorText(error, false);
                    errors.Add(new ProfileError(profileNameActionResult.Key, errorText));
                }
            }

            ProfileList.ItemsSource = errors;

            var view             = (CollectionView)CollectionViewSource.GetDefaultView(ProfileList.ItemsSource);
            var groupDescription = new PropertyGroupDescription("Profile");

            view.GroupDescriptions.Add(groupDescription);
        }
        public void SaveCommand_Execute_JobProfileIsNotValid_NotifyUserWithCorrectMessageInteraction()
        {
            var vm           = BuildViewModel();
            var job          = BuildJob(_pdfProfile);
            var faultyResult = new ActionResult(ErrorCode.Ftp_NoAccount); //Random error code, to make the profile invalid

            _profileChecker.ProfileCheck(job.Profile, job.Accounts).Returns(faultyResult);

            vm.ExecuteWorkflowStep(job);
            vm.SaveCommand.Execute(null);

            var interaction = _interactionRequest.AssertWasRaised <MessageInteraction>();

            Assert.AreEqual(_translation.DefectiveProfile, interaction?.Title, "interaction title");
            var messageSb = new StringBuilder();

            messageSb.AppendLine(_translation.GetProfileIsDefectiveMessage(job.Profile.Name, faultyResult));
            messageSb.AppendLine();
            messageSb.AppendLine(_errorCodeInterpreter.GetErrorText(faultyResult, true, "\u2022"));
            messageSb.AppendLine(_translation.EditOrSelectNewProfile);
            var message = messageSb.ToString();

            Assert.AreEqual(message, interaction?.Text, "interaction text");
            Assert.AreEqual(MessageOptions.OK, interaction?.Buttons, "interaction buttons");
            Assert.AreEqual(MessageIcon.Exclamation, interaction?.Icon, "interaction icon");
        }
Пример #5
0
        protected override bool EvaluateActionResult(ActionResult actionResult)
        {
            if (actionResult.Success)
            {
                return(true);
            }

            throw new COMException(ErrorCodeInterpreter.GetErrorText(actionResult[0], true));
        }
Пример #6
0
        public void Notify(ActionResult actionResult)
        {
            var title = _translator.GetTranslation("InteractiveWorkflow", "Error");

            var errorOccuredText     = _translator.GetTranslation("InteractiveWorkflow", "AnErrorOccured");
            var errorCodeInterpreter = new ErrorCodeInterpreter(_translator);
            var errorText            = errorCodeInterpreter.GetErrorText(actionResult[0], true);
            var message = $"{errorOccuredText}\r\n{errorText}";

            ShowMessage(message, title, MessageOptions.OK, MessageIcon.Error);
        }
Пример #7
0
        public void Notify(ActionResult actionResult)
        {
            var title = translation.Error;

            var errorOccuredText     = translation.AnErrorOccured;
            var errorCodeInterpreter = new ErrorCodeInterpreter(_translationFactory);
            var errorText            = errorCodeInterpreter.GetErrorText(actionResult[0], true);
            var message = $"{errorOccuredText}{System.Environment.NewLine}{errorText}";

            ShowMessage(message, title, MessageOptions.OK, MessageIcon.Error);
        }
Пример #8
0
        /// <summary>
        ///     Does the actual conversion process of the job
        /// </summary>
        private void DoConversion(Job job, string targetFilename)
        {
            DisableIrrelevantProfileSettings(job.Profile);

            try
            {
                if (job.JobInfo.SourceFiles.Count == 0)
                {
                    Logger.Info("COM: JobInfo has no source files and will be skipped");
                    return;
                }

                Logger.Trace("COM: Creating workflow");
                var errorNotifier = new ErrorNotifierCom();

                var workflow = _workflowFactory.BuildWorkflow(targetFilename, errorNotifier);

                Logger.Trace("COM: Running workflow");
                var workflowResult = workflow.RunWorkflow(job);

                if (workflowResult == WorkflowResult.Error)
                {
                    var errorCode = errorNotifier.Error[0];
                    throw new COMException(_errorCodeInterpreter.GetErrorText(errorCode, true));
                }

                if (workflowResult == WorkflowResult.AbortedByUser)
                {
                    Logger.Info("COM: The job '{0}' was aborted by the user.",
                                job.JobInfo.Metadata.Title);
                }

                if (workflowResult == WorkflowResult.Finished)
                {
                    IsSuccessful = true;
                }
            }
            catch (Exception e)
            {
                throw new COMException(e.Message);
            }
            finally
            {
                Logger.Trace("COM: Removing jobinfo from the queue.");
                _jobInfoQueue.Remove(job.JobInfo, true);

                IsFinished = true;

                JobFinished?.Invoke(this, EventArgs.Empty);
            }
        }
Пример #9
0
        protected override bool EvaluateActionResult(ActionResult actionResult)
        {
            if (actionResult.Success)
            {
                return(true);
            }
            var caption   = _translator.GetTranslation("InteractiveWorkflow", "Error", "Error");
            var opener    = _translator.GetTranslation("InteractiveWorkflow", "AnErrorOccured", "An error occured:");
            var errorText = ErrorCodeInterpreter.GetErrorText(actionResult[0], true);

            MessageWindow.ShowTopMost(opener + "\r\n" + errorText, caption, MessageWindowButtons.OK, MessageWindowIcon.Error);

            return(actionResult.Success);
        }
Пример #10
0
        private bool IsProfileValidAndNotifyUserIfNot()
        {
            var profileCheckResult = _profileChecker.ProfileCheck(_job.Profile, _job.Accounts);

            if (!profileCheckResult)
            {
                var title   = Translation.DefectiveProfile;
                var message = new StringBuilder();
                message.AppendLine(Translation.GetProfileIsDefectiveMessage(_job.Profile.Name, profileCheckResult));
                message.AppendLine();
                message.AppendLine(_errorCodeInterpreter.GetErrorText(profileCheckResult, true, "\u2022"));
                message.AppendLine(Translation.EditOrSelectNewProfile);
                var interaction = new MessageInteraction(message.ToString(), title, MessageOptions.OK, MessageIcon.Exclamation);
                _interactionRequest.Raise(interaction);
                return(false);
            }
            return(true);
        }
        protected override void HandleInteractionObjectChanged()
        {
            ProfileProblems = Interaction.ProfileProblems;

            ProfileErrors = new List <ProfileError>();

            foreach (var profileNameActionResult in Interaction.ProfileProblems)
            {
                foreach (var error in profileNameActionResult.Value)
                {
                    var errorText = _errorCodeInterpreter.GetErrorText(error, false);
                    ProfileErrors.Add(new ProfileError(profileNameActionResult.Key, errorText));
                }
            }

            RaisePropertyChanged(nameof(ProfileErrors));

            var view             = (CollectionView)CollectionViewSource.GetDefaultView(ProfileErrors);
            var groupDescription = new PropertyGroupDescription("Profile");

            view.GroupDescriptions.Add(groupDescription);
        }
        protected override void HandleInteractionObjectChanged()
        {
            ProfileProblems = Interaction.ProfileProblems;

            if (Interaction.ProfileProblems.Count > 1)
            {
                DefectiveProfilesText = _translator.GetTranslation(
                    "DefectiveProfilesWindow", "DefectiveProfiles");
            }
            else
            {
                DefectiveProfilesText = _translator.GetTranslation(
                    "DefectiveProfilesWindow", "DefectiveProfile");
            }

            RaisePropertyChanged(nameof(DefectiveProfilesText));

            ProfileErrors = new List <ProfileError>();

            var errorCodeInterpreter = new ErrorCodeInterpreter(_translator);

            foreach (var profileNameActionResult in Interaction.ProfileProblems)
            {
                foreach (var error in profileNameActionResult.Value)
                {
                    var errorText = errorCodeInterpreter.GetErrorText(error, false);
                    ProfileErrors.Add(new ProfileError(profileNameActionResult.Key, errorText));
                }
            }

            RaisePropertyChanged(nameof(ProfileErrors));

            var view             = (CollectionView)CollectionViewSource.GetDefaultView(ProfileErrors);
            var groupDescription = new PropertyGroupDescription("Profile");

            view.GroupDescriptions.Add(groupDescription);
        }
Пример #13
0
        public void AllErrorCodes_AreMappedByErrorCodeInterpreter()
        {
            var section = "ErrorCodes";

            var translator = new BasicTranslator(Path.Combine(_translationTestHelper.FindTranslationFolder(), "english.ini"));

            var errorCodes = translator.GetKeysForSection(section)
                             .Where(IsInt)
                             .Select(int.Parse)
                             .Select(x => (ErrorCode)x)
                             .ToList();

            Assert.IsTrue(errorCodes.Any(), $"There are no entries in the section [{section}]");

            var errorCodeInterpreter = new ErrorCodeInterpreter(translator);

            foreach (var errorCode in errorCodes)
            {
                Assert.IsTrue(Enum.IsDefined(typeof(ErrorCode), errorCode), $"The error code {(int)errorCode} is not defined");
                var message = errorCodeInterpreter.GetErrorText(errorCode, true);
                StringAssert.DoesNotContain("Default", message, $"Error code {errorCode} contains the word 'default', which indicates that it has not been translated.");
                StringAssert.DoesNotContain(translator.GetTranslation(section, "Default"), message, $"Error code {errorCode} has the default translation!");
            }
        }