logic added

This commit is contained in:
2021-02-04 22:45:41 +01:00
parent e5098c02d9
commit bf57e3a983
11 changed files with 150 additions and 28 deletions

View File

@@ -4,6 +4,7 @@ using Massmailer.Shared.Model;
using PubSub;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -15,16 +16,15 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Massmailer.UI
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainView : Window
{
private readonly Hub hub = new Hub();
private SmtpSettings smtpSettings;
private MassmailerProject project;
private string selectedFilePath = string.Empty;
public MainView()
{
@@ -60,12 +60,41 @@ namespace Massmailer.UI
"10@test.local"
};
await mailer.SendMailsAsync(recipients, "Hello World Subject", "Hello World Body");
var project = new MassmailerProject();
project.Recipients.Add(new MassmailerRecipient { Address = "1@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "2@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "3@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "4@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "5@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "6@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "7@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "8@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "9@test.local" });
project.Recipients.Add(new MassmailerRecipient { Address = "10@test.local" });
project.Subject = "Hello World Subject";
project.Body = "Hello World Body";
await mailer.SendMailsAsync(project);
var result = "";
foreach (var recipient in project.Recipients)
{
result += $"{recipient.Address} - {recipient.IsSent} - {recipient.SentDate}\r\n";
}
MassmailerProjectLogic.Save(project, "project.json");
MessageBox.Show(result);
}
private void MailSentEventHandler(MailSentEvent mailSentEvent)
{
this.BtnSend.Content = $"mail sent: {mailSentEvent.Recipient} at {mailSentEvent.Timestamp}";
}
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
this.smtpSettings = await SmtpSettingsLogic.Load(Path.Combine(Environment.CurrentDirectory, Constants.SmtpSettingsFileName));
}
}
}