protected override bool QueryEmailSmtpPassword() { if (!string.IsNullOrEmpty(Job.Profile.EmailSmtp.Password)) { Job.Passwords.SmtpPassword = Job.Profile.EmailSmtp.Password; return(true); } var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.Skip, Job.Profile.EmailSmtp.Address, Job.Profile.EmailSmtp.Recipients); pwWindow.ShowDialogTopMost(); if (pwWindow.Response == SmtpPasswordResponse.OK) { Job.Passwords.SmtpPassword = pwWindow.SmtpPassword; return(true); } if (pwWindow.Response == SmtpPasswordResponse.Skip) { Job.Profile.EmailSmtp.Enabled = false; Logger.Info("User skipped Smtp Password. Smtp Email disabled."); return(true); } Cancel = true; Logger.Warn("Cancelled the SMTP dialog. No PDF will be created."); WorkflowStep = WorkflowStep.AbortedByUser; return(false); }
private void SetPasswordButton_OnClick(object sender, RoutedEventArgs e) { var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.Remove); pwWindow.SmtpPassword = Password; pwWindow.ShowDialogTopMost(); if (pwWindow.Response == SmtpPasswordResponse.OK) { Password = pwWindow.SmtpPassword; } else if (pwWindow.Response == SmtpPasswordResponse.Remove) { Password = ""; } }
protected override void RetypeSmtpPassword(object sender, QueryPasswordEventArgs e) { Logger.Debug("Launched E-mail password Form"); var pwWindow = new SmtpPasswordWindow(SmtpPasswordMiddleButton.None, Job.Profile.EmailSmtp.Address, Job.Profile.EmailSmtp.Recipients); pwWindow.SmtpPassword = Job.Passwords.SmtpPassword; pwWindow.Message = _translator.GetTranslation("InteractiveWorkflow", "RetypeSmtpPwMessage", "Could not authenticate at server.\r\nPlease check your password and verify that you have a working internet connection."); if (pwWindow.ShowDialogTopMost() == SmtpPasswordResponse.OK) { Job.Passwords.SmtpPassword = pwWindow.SmtpPassword; e.Cancel = false; } else { e.Cancel = true; Logger.Warn("Cancelled the SMTP dialog. No PDF will be created."); WorkflowStep = WorkflowStep.AbortedByUser; } }
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); } }