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 DefectiveProfilesViewModel(ITranslationUpdater translationUpdater, ErrorCodeInterpreter errorCodeInterpreter) : base(translationUpdater)
        {
            _errorCodeInterpreter = errorCodeInterpreter;

            SaveCommand   = new DelegateCommand(SaveCommandExecute);
            CancelCommand = new DelegateCommand(CancelCommandExecute);
        }
        public DefectiveProfilesWindowViewModel(DefectiveProfilesWindowTranslation translation, ErrorCodeInterpreter errorCodeInterpreter)
        {
            _translation          = translation;
            _errorCodeInterpreter = errorCodeInterpreter;

            IgnoreErrorsCommand = new DelegateCommand(IgnoreErrorsExecute);
        }
 public void Setup()
 {
     _soundPlayer          = Substitute.For <ISoundPlayer>();
     _errorCodeInterpreter = new ErrorCodeInterpreter(new TranslationFactory());
     _clipboardService     = Substitute.For <IClipboardService>();
     _viewModel            = new MessageViewModel(new DesignTimeTranslationUpdater(), _soundPlayer, _errorCodeInterpreter, _clipboardService);
 }
 public CheckProfileCommand(IProfileChecker profileChecker, ICurrentSettingsProvider currentSettingsProvider, IInteractionRequest interactionRequest, ErrorCodeInterpreter errorCodeInterpreter)
 {
     _profileChecker          = profileChecker;
     _currentSettingsProvider = currentSettingsProvider;
     _interactionRequest      = interactionRequest;
     _errorCodeInterpreter    = errorCodeInterpreter;
     CanExecuteChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #6
0
        public PrintJobViewModel(
            ISettingsProvider settingsProvider,
            ITranslationUpdater translationUpdater,
            IJobInfoQueue jobInfoQueue,
            IFileNameQuery saveFileQuery,
            IInteractionRequest interactionRequest,
            IProfileChecker profileChecker,
            ErrorCodeInterpreter errorCodeInterpreter,
            ICommandLocator commandsLocator,
            IEventAggregator eventAggregator,
            ISelectedProfileProvider selectedProfileProvider,
            ITempFolderProvider tempFolderProvider,
            IPathUtil pathUtil,
            IFile file,
            IGpoSettings gpoSettings)
            : base(translationUpdater)
        {
            GpoSettings              = gpoSettings;
            _settingsProvider        = settingsProvider;
            _saveFileQuery           = saveFileQuery;
            _profileChecker          = profileChecker;
            _interactionRequest      = interactionRequest;
            _errorCodeInterpreter    = errorCodeInterpreter;
            _selectedProfileProvider = selectedProfileProvider;
            _file = file;
            _tempFolderProvider = tempFolderProvider;
            _pathUtil           = pathUtil;

            SaveCommand            = new DelegateCommand(SaveExecute);
            SendByEmailCommand     = new DelegateCommand(EmailExecute);
            MergeCommand           = new DelegateCommand(MergeExecute);
            CancelCommand          = new DelegateCommand(CancelExecute);
            SetOutputFormatCommand = new DelegateCommand <OutputFormat>(SetOutputFormatExecute);
            BrowseFileCommand      = new DelegateCommand(BrowseFileExecute);

            SetupEditProfileCommand(commandsLocator, eventAggregator);

            var settings = settingsProvider.Settings?.CopyAndPreserveApplicationSettings();

            Profiles = settings?.ConversionProfiles;

            jobInfoQueue.OnNewJobInfo += (sender, args) => UpdateNumberOfPrintJobsHint(jobInfoQueue.Count);
            UpdateNumberOfPrintJobsHint(jobInfoQueue.Count);

            var profileListView = CollectionViewSource.GetDefaultView(Profiles);

            if (profileListView != null)
            {
                profileListView.CurrentChanged += (sender, args) =>
                {
                    if (Job != null)
                    {
                        OutputFormat = ((ConversionProfile)profileListView.CurrentItem).OutputFormat;
                    }
                };
            }
        }
Beispiel #7
0
        protected override bool EvaluateActionResult(ActionResult actionResult)
        {
            if (actionResult.Success)
            {
                return(true);
            }

            throw new COMException(ErrorCodeInterpreter.GetErrorText(actionResult[0], true));
        }
Beispiel #8
0
 public PrintJobAdapter(ISettingsProvider settingsProvider, IComWorkflowFactory workflowFactory, ThreadPool threadPool, IJobInfoQueue jobInfoQueue, ErrorCodeInterpreter errorCodeInterpreter, IDirectory directory, IPathUtil pathUtil)
 {
     _settingsProvider     = settingsProvider;
     _workflowFactory      = workflowFactory;
     _threadPool           = threadPool;
     _jobInfoQueue         = jobInfoQueue;
     _errorCodeInterpreter = errorCodeInterpreter;
     _directory            = directory;
     _pathUtil             = pathUtil;
 }
Beispiel #9
0
 public SmtpTestEmailAssistant(SmtpSettingsAndActionControlTranslation translation, IInteractionInvoker interactionInvoker, IFile file,
                               ISmtpMailAction smtpMailAction, IPath path, IMailSignatureHelper mailSignatureHelper, ErrorCodeInterpreter errorCodeInterpreter)
 {
     _file                 = file;
     _translation          = translation;
     _interactionInvoker   = interactionInvoker;
     _smtpMailAction       = smtpMailAction;
     _path                 = path;
     _mailSignatureHelper  = mailSignatureHelper;
     _errorCodeInterpreter = errorCodeInterpreter;
 }
Beispiel #10
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);
        }
Beispiel #11
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);
        }
 protected TestMailAssistantBase(ITranslationUpdater translationUpdater, ITokenHelper tokenHelper,
                                 ITestFileDummyHelper testFileDummyHelper, ICheckable mailAction,
                                 ErrorCodeInterpreter errorCodeInterpreter, IInteractionRequest interactionRequest)
 {
     translationUpdater.RegisterAndSetTranslation(tf => Translation = tf.UpdateOrCreateTranslation(Translation));
     _testFileDummyHelper  = testFileDummyHelper;
     _mailAction           = mailAction;
     _errorCodeInterpreter = errorCodeInterpreter;
     InteractionRequest    = interactionRequest;
     _tokenHelper          = tokenHelper;
 }
Beispiel #13
0
        public MessageViewModel(ITranslationUpdater translationUpdater, ISoundPlayer soundPlayer,
                                ErrorCodeInterpreter errorCodeInterpreter, IClipboardService clipboardService) : base(translationUpdater)
        {
            _soundPlayer          = soundPlayer;
            _errorCodeInterpreter = errorCodeInterpreter;
            _clipboardService     = clipboardService;

            LeftButtonCommand   = new DelegateCommand(ButtonLeftExecute);
            MiddleButtonCommand = new DelegateCommand(MiddleButtonExecute, MiddleButtonCanExecute);
            RightButtonCommand  = new DelegateCommand(RightButtonExecute, RightButtonCanExecute);
        }
Beispiel #14
0
 public SmtpTestEmailAssistant(ITranslationUpdater translationUpdater, IInteractionRequest interactionRequest, IFile file,
                               ISmtpMailAction smtpMailAction, IPath path, IMailSignatureHelper mailSignatureHelper, ErrorCodeInterpreter errorCodeInterpreter, IInteractionInvoker interactionInvoker)
 {
     _interactionRequest = interactionRequest;
     _file = file;
     translationUpdater.RegisterAndSetTranslation(tf => _translation = tf.UpdateOrCreateTranslation(_translation));
     _smtpMailAction       = smtpMailAction;
     _path                 = path;
     _mailSignatureHelper  = mailSignatureHelper;
     _errorCodeInterpreter = errorCodeInterpreter;
     _interactionInvoker   = interactionInvoker;
 }
Beispiel #15
0
        public void InterpretTest()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

            string temp1 = Resources.ERR001;

            Assert.AreEqual(Resources.ERR001, ErrorCodeInterpreter.Interpret(1));
            Assert.AreEqual(Resources.ERR600, ErrorCodeInterpreter.Interpret(600));
            Assert.AreEqual(Resources.ERR610, ErrorCodeInterpreter.Interpret(610));
            Assert.AreEqual(Resources.ERR615, ErrorCodeInterpreter.Interpret(615));
            Assert.AreEqual(Resources.ERR620, ErrorCodeInterpreter.Interpret(620));
        }
        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);
        }
        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);
        }
Beispiel #18
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!");
            }
        }
Beispiel #19
0
        private string GetErrorMessage(ErrorCode errorCode)
        {
            var errorCodeInterpreter = new ErrorCodeInterpreter(_translator);

            return(errorCodeInterpreter.GetFirstErrorText(new ActionResult(errorCode), withNumber: false));
        }
Beispiel #20
0
 public ClientTestMailAssistant(ITranslationUpdater translationUpdater, ITokenHelper tokenHelper,
                                ITestFileDummyHelper testFileDummyHelper, IEMailClientAction mailAction,
                                ErrorCodeInterpreter errorCodeInterpreter, IInteractionRequest interactionRequest)
     : base(translationUpdater, tokenHelper, testFileDummyHelper, mailAction, errorCodeInterpreter, interactionRequest)
 {
 }
 public SmtpTestMailAssistant(ITranslationUpdater translationUpdater, IInteractionRequest interactionRequest,
                              ISmtpMailAction smtpMailAction, ErrorCodeInterpreter errorCodeInterpreter, ITokenHelper tokenHelper,
                              ITestFileDummyHelper testFileDummyHelper)
     : base(translationUpdater, tokenHelper, testFileDummyHelper, smtpMailAction, errorCodeInterpreter, interactionRequest)
 {
 }
Beispiel #22
0
        private void SendTestMailButton_OnClick(object sender, RoutedEventArgs e)
        {
            var smtpMailAction = new SmtpMailAction(MailSignatureHelper.ComposeMailSignature(CurrentProfile.EmailSmtp));

            var currentProfile = ((ActionsTabViewModel)DataContext).CurrentProfile.Copy();

            #region check profile
            var result = smtpMailAction.Check(currentProfile);
            if (!result.Success)
            {
                var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail");
                var message = ErrorCodeInterpreter.GetFirstErrorText(result, true);
                MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error);
                return;
            }
            #endregion

            #region create job
            string tempFolder    = Path.GetTempPath();
            string tmpTestFolder = Path.Combine(tempFolder, "PdfCreatorTest\\SendSmtpTestmail");
            Directory.CreateDirectory(tmpTestFolder);
            string tmpInfFile = Path.Combine(tmpTestFolder, "SmtpTest.inf");

            var sb = new StringBuilder();
            sb.AppendLine("[1]");
            sb.AppendLine("SessionId=1");
            sb.AppendLine("WinStation=Console");
            sb.AppendLine("UserName=SampleUser1234");
            sb.AppendLine("ClientComputer=\\PC1");
            sb.AppendLine("PrinterName=PDFCreator");
            sb.AppendLine("JobId=1");
            sb.AppendLine("DocumentTitle=SmtpTest");
            sb.AppendLine("");

            File.WriteAllText(tmpInfFile, sb.ToString(), Encoding.GetEncoding("Unicode"));

            JobTranslations jobTranslations = new JobTranslations();
            jobTranslations.EmailSignature = MailSignatureHelper.ComposeMailSignature(true);

            var tempFolderProvider = new StaticTempFolderProvider(Path.Combine(Path.GetTempPath(), "PDFCreator"));

            var job = new GhostscriptJob(new JobInfo(tmpInfFile), new ConversionProfile(), tempFolderProvider, jobTranslations);

            job.Profile = currentProfile;
            #endregion

            #region add password
            if (string.IsNullOrEmpty(Password))
            {
                var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.None, currentProfile.EmailSmtp.Address, currentProfile.EmailSmtp.Recipients);
                if (pwWindow.ShowDialogTopMost() != SmtpPasswordResponse.OK)
                {
                    Directory.Delete(tmpTestFolder, true);
                    return;
                }
                job.Passwords.SmtpPassword = pwWindow.SmtpPassword;
            }
            else
            {
                job.Passwords.SmtpPassword = Password;
            }
            #endregion

            #region add testfile
            string testFile = (Path.Combine(tmpTestFolder, "testfile.txt"));
            File.WriteAllText(testFile, @"PDFCreator", Encoding.GetEncoding("Unicode"));
            job.OutputFiles.Add(testFile);
            #endregion

            LogManager.GetCurrentClassLogger().Info("Send test mail over smtp.");
            result = smtpMailAction.ProcessJob(job);
            Directory.Delete(tmpTestFolder, true);

            if (!result.Success)
            {
                var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail",
                                                                                           "Send test mail");
                var message = ErrorCodeInterpreter.GetFirstErrorText(result, true);
                MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error);
            }
            else
            {
                var caption = TranslationHelper.Instance.TranslatorInstance.GetTranslation("SmtpEmailActionSettings", "SendTestMail", "Send test mail");
                var message = TranslationHelper.Instance.TranslatorInstance.GetFormattedTranslation("SmtpEmailActionSettings", "TestMailSent",
                                                                                                    "Test mail sent to {0}.", job.Profile.EmailSmtp.Recipients);
                MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Info);
            }
        }
 /// <summary>
 /// 覆盖ToString为类似"(ERR001) 错误详细信息"这种格式
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(string.Format("(ERR{0}) {1}", ErrorCode.ToString("d3"), ErrorCodeInterpreter.Interpret(ErrorCode)));
 }