【发布时间】:2017-08-17 11:11:09
【问题描述】:
我已经实现了一个 Windows 服务,它从数据库中获取电子邮件列表,并每 60 秒使用 .net 邮件发送它们。 我是使用存储库模式设计的,请看解决方案文件夹和项目的截图。Click to see the picture
问题:
- 就模式而言,我是否走在正确的轨道上?分离项目的结构,为每个存储库创建一个接口,为每个存储库创建一个服务。
- 如果某些业务逻辑与数据库无关,我还需要为它们创建一个存储库还是一个服务就足够了?
-
我有一个 SMTP 服务类,它正在实现 .net 邮件和发送电子邮件,当我发送每封电子邮件时,我需要更新数据库,我想知道将更新逻辑放在 SMTP 服务类中是否是好的做法?如下所示
public class SMTPService : ISMTPService { SmtpClient client; MailMessage newMessage; EmailService emailService; IEventLoggerService MailCheckerLog; public async Task SendEmail(tb_Email email) {...} void SendCompletedCallback(object sender, System.ComponentModel.AsyncCompletedEventArgs e, tb_Email email) { if (e.Cancelled) { } if (e.Error != null) { } else { email.DateSent = DateTime.Now; emailService.Update(email); } client.Dispose(); newMessage.Dispose(); }}
【问题讨论】:
标签: c# .net entity-framework windows-services console-application