Revert "фиксик"

This reverts commit 30a05fea30.
This commit is contained in:
Вячеслав Иванов 2024-04-03 10:29:36 +04:00
parent 30a05fea30
commit 26dda0e2b2
10 changed files with 1057 additions and 1048 deletions

View File

@ -8,113 +8,113 @@ using System.Text.RegularExpressions;
namespace PizzeriaBusinessLogic.BusinessLogics
{
public class ClientLogic : IClientLogic
{
private readonly ILogger _logger;
private readonly IClientStorage _clientStorage;
public class ClientLogic : IClientLogic
{
private readonly ILogger _logger;
private readonly IClientStorage _clientStorage;
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
{
_logger = logger;
_clientStorage = clientStorage;
}
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
{
_logger = logger;
_clientStorage = clientStorage;
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation("ReadList. ClientId:{Id}", model?.Id);
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
{
_logger.LogInformation("ReadList. ClientId:{Id}", model?.Id);
var list = model == null ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ClientFio:{ClientFio}.Id:{ Id}", model.ClientFIO, model.Id);
var element = _clientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public ClientViewModel? ReadElement(ClientSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. ClientFio:{ClientFio}.Id:{ Id}", model.ClientFIO, model.Id);
var element = _clientStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
return element;
}
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Create(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Insert(model) == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
public bool Update(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Update(ClientBindingModel model)
{
CheckModel(model);
if (_clientStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_clientStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
public bool Delete(ClientBindingModel model)
{
CheckModel(model, false);
_logger.LogInformation("Delete. Id:{Id}", model.Id);
if (_clientStorage.Delete(model) == null)
{
_logger.LogWarning("Delete operation failed");
return false;
}
return true;
}
private void CheckModel(ClientBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ClientFIO))
{
throw new ArgumentNullException("Нет ФИО пользователя", nameof(model.ClientFIO));
}
if (string.IsNullOrEmpty(model.Email) || !Regex.IsMatch(model.Email, @"^[a-z0-9._%+-]+\@([a-z0-9-]+\.)+[a-z]{2,4}$"))
{
throw new ArgumentNullException("Не указана валидная почта", nameof(model.Email));
}
if (string.IsNullOrEmpty(model.Password) || !Regex.IsMatch(model.Password, @"^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9\n]).{10,50}$"))
{
throw new ArgumentNullException("Не указан правильный пароль", nameof(model.Password));
}
_logger.LogInformation("Client. ClientFIO:{ClientFIO}.Email:{Email}.Id:{Id}",
model.ClientFIO, model.Email, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel
{
ClientFIO = model.ClientFIO
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с таким именем уже есть");
}
}
}
private void CheckModel(ClientBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.ClientFIO))
{
throw new ArgumentNullException("Нет ФИО пользователя", nameof(model.ClientFIO));
}
if (string.IsNullOrEmpty(model.Email) || !Regex.IsMatch(model.Email, @"^[a-z0-9._%+-]+\@([a-z0-9-]+\.)+[a-z]{2,4}$"))
{
throw new ArgumentNullException("Не указана валидная почта", nameof(model.Email));
}
if (string.IsNullOrEmpty(model.Password) || !Regex.IsMatch(model.Password, @"^(?=.*[A-Za-z])(?=.*\d)(?=.*[^A-Za-z0-9\n]).{10,50}$"))
{
throw new ArgumentNullException("Не указан правильный пароль", nameof(model.Password));
}
_logger.LogInformation("Client. ClientFIO:{ClientFIO}.Email:{Email}.Id:{Id}",
model.ClientFIO, model.Email, model.Id);
var element = _clientStorage.GetElement(new ClientSearchModel
{
ClientFIO = model.ClientFIO
});
if (element != null && element.Id != model.Id)
{
throw new InvalidOperationException("Клиент с таким именем уже есть");
}
}
}
}

View File

@ -12,111 +12,111 @@ using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.BusinessLogics
{
public class MessageInfoLogic : IMessageInfoLogic
{
private readonly ILogger _logger;
private readonly IMessageInfoStorage _messageInfoStorage;
private readonly IClientStorage _clientStorage;
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage, IClientStorage clientStorage)
{
_logger = logger;
_messageInfoStorage = messageInfoStorage;
_clientStorage = clientStorage;
}
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId}.PageLength:{PageLength}.PageCount:{PageIndex}", model?.MessageId, model?.ClientId, model?.PageLength, model?.PageIndex);
var list = _messageInfoStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Create(MessageInfoBindingModel model)
{
CheckModel(model);
var message = _messageInfoStorage.Insert(model);
if (message == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
private void CheckModel(MessageInfoBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (string.IsNullOrEmpty(model.MessageId))
{
throw new ArgumentNullException("Не указан id сообщения", nameof(model.MessageId));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.SenderName))
{
throw new ArgumentNullException("Не указао имя отправителя(электронная почта)", nameof(model.SenderName));
}
if (string.IsNullOrEmpty(model.Subject))
{
throw new ArgumentNullException("Не указана темма", nameof(model.Subject));
}
if (string.IsNullOrEmpty(model.Body))
{
throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject));
}
_logger.LogInformation("MessageInfo. MessageId:{MessageId}.SenderName:{SenderName}.Subject:{Subject}.Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body);
var element = _clientStorage.GetElement(new ClientSearchModel
{
Email = model.SenderName
});
if (element == null)
{
_logger.LogWarning("Не удалоссь найти клиента, отправившего письмо с адреса Email:{Email}", model.SenderName);
}
else
{
model.ClientId = element.Id;
}
}
public class MessageInfoLogic : IMessageInfoLogic
{
private readonly ILogger _logger;
private readonly IMessageInfoStorage _messageInfoStorage;
private readonly IClientStorage _clientStorage;
public MessageInfoLogic(ILogger<MessageInfoLogic> logger, IMessageInfoStorage messageInfoStorage, IClientStorage clientStorage)
{
_logger = logger;
_messageInfoStorage = messageInfoStorage;
_clientStorage = clientStorage;
}
public List<MessageInfoViewModel>? ReadList(MessageInfoSearchModel? model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadList. MessageId:{MessageId}.ClientId:{ClientId}.PageLength:{PageLength}.PageCount:{PageIndex}", model?.MessageId, model?.ClientId, model?.PageLength, model?.PageIndex);
var list = _messageInfoStorage.GetFilteredList(model);
if (list == null)
{
_logger.LogWarning("ReadList return null list");
return null;
}
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
return list;
}
public bool Create(MessageInfoBindingModel model)
{
CheckModel(model);
var message = _messageInfoStorage.Insert(model);
if (message == null)
{
_logger.LogWarning("Insert operation failed");
return false;
}
return true;
}
private void CheckModel(MessageInfoBindingModel model, bool withParams = true)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
if (string.IsNullOrEmpty(model.MessageId))
{
throw new ArgumentNullException("Не указан id сообщения", nameof(model.MessageId));
}
if (!withParams)
{
return;
}
if (string.IsNullOrEmpty(model.SenderName))
{
throw new ArgumentNullException("Не указао имя отправителя(электронная почта)", nameof(model.SenderName));
}
if (string.IsNullOrEmpty(model.Subject))
{
throw new ArgumentNullException("Не указана темма", nameof(model.Subject));
}
if (string.IsNullOrEmpty(model.Body))
{
throw new ArgumentNullException("Не указан текст сообщения", nameof(model.Subject));
}
_logger.LogInformation("MessageInfo. MessageId:{MessageId}.SenderName:{SenderName}.Subject:{Subject}.Body:{Body}", model.MessageId, model.SenderName, model.Subject, model.Body);
var element = _clientStorage.GetElement(new ClientSearchModel
{
Email = model.SenderName
});
if (element == null)
{
_logger.LogWarning("Не удалоссь найти клиента, отправившего письмо с адреса Email:{Email}", model.SenderName);
}
else
{
model.ClientId = element.Id;
}
}
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. MessageId:{MessageId}", model?.MessageId);
var element = _messageInfoStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.MessageId);
return element;
}
public MessageInfoViewModel? ReadElement(MessageInfoSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
_logger.LogInformation("ReadElement. MessageId:{MessageId}", model?.MessageId);
var element = _messageInfoStorage.GetElement(model);
if (element == null)
{
_logger.LogWarning("ReadElement element not found");
return null;
}
_logger.LogInformation("ReadElement find. Id:{Id}", element.MessageId);
return element;
}
public bool Update(MessageInfoBindingModel model)
{
CheckModel(model, withParams: false);
if (_messageInfoStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
}
public bool Update(MessageInfoBindingModel model)
{
CheckModel(model, withParams: false);
if (_messageInfoStorage.Update(model) == null)
{
_logger.LogWarning("Update operation failed");
return false;
}
return true;
}
}
}

View File

@ -9,121 +9,121 @@ using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.MailWorker
{
public abstract class AbstractMailWorker
{
protected string _mailLogin = string.Empty;
protected string _mailPassword = string.Empty;
protected string _smtpClientHost = string.Empty;
protected int _smtpClientPort;
protected string _popHost = string.Empty;
protected int _popPort;
private readonly IMessageInfoLogic _messageInfoLogic;
private readonly ILogger _logger;
public abstract class AbstractMailWorker
{
protected string _mailLogin = string.Empty;
protected string _mailPassword = string.Empty;
protected string _smtpClientHost = string.Empty;
protected int _smtpClientPort;
protected string _popHost = string.Empty;
protected int _popPort;
private readonly IMessageInfoLogic _messageInfoLogic;
private readonly ILogger _logger;
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic)
{
_logger = logger;
_messageInfoLogic = messageInfoLogic;
}
public void MailConfig(MailConfigBindingModel config)
{
_mailLogin = config.MailLogin;
_mailPassword = config.MailPassword;
_smtpClientHost = config.SmtpClientHost;
_smtpClientPort = config.SmtpClientPort;
_popHost = config.PopHost;
_popPort = config.PopPort;
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword.Length, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
}
public async void MailSendAsync(MailSendInfoBindingModel info)
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
public AbstractMailWorker(ILogger<AbstractMailWorker> logger, IMessageInfoLogic messageInfoLogic)
{
_logger = logger;
_messageInfoLogic = messageInfoLogic;
}
public void MailConfig(MailConfigBindingModel config)
{
_mailLogin = config.MailLogin;
_mailPassword = config.MailPassword;
_smtpClientHost = config.SmtpClientHost;
_smtpClientPort = config.SmtpClientPort;
_popHost = config.PopHost;
_popPort = config.PopPort;
_logger.LogDebug("Config: {login}, {password}, {clientHost}, {clientPOrt}, {popHost}, {popPort}", _mailLogin, _mailPassword.Length, _smtpClientHost, _smtpClientPort, _popHost, _popPort);
}
public async void MailSendAsync(MailSendInfoBindingModel info)
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
{
return;
}
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
{
return;
}
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
{
return;
}
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text))
{
return;
}
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
await SendMailAsync(info);
}
public async void MailCheck()
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
_logger.LogDebug("Send Mail: {To}, {Subject}", info.MailAddress, info.Subject);
await SendMailAsync(info);
}
public async void MailCheck()
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
{
return;
}
if (string.IsNullOrEmpty(_popHost) || _popPort == 0)
{
return;
}
if (_messageInfoLogic == null)
{
return;
}
if (_messageInfoLogic == null)
{
return;
}
var list = await ReceiveMailAsync();
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
foreach (var mail in list)
{
_messageInfoLogic.Create(mail);
}
}
var list = await ReceiveMailAsync();
_logger.LogDebug("Check Mail: {Count} new mails", list.Count);
foreach (var mail in list)
{
_messageInfoLogic.Create(mail);
}
}
public async void MailSendReplyAsync(MailReplySendInfoBindingModel info)
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
public async void MailSendReplyAsync(MailReplySendInfoBindingModel info)
{
if (string.IsNullOrEmpty(_mailLogin) || string.IsNullOrEmpty(_mailPassword))
{
return;
}
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
{
return;
}
if (string.IsNullOrEmpty(_smtpClientHost) || _smtpClientPort == 0)
{
return;
}
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text) || string.IsNullOrEmpty(info.ParentMessageId))
{
return;
}
if (string.IsNullOrEmpty(info.MailAddress) || string.IsNullOrEmpty(info.Subject) || string.IsNullOrEmpty(info.Text) || string.IsNullOrEmpty(info.ParentMessageId))
{
return;
}
_logger.LogDebug("Send Mail as reply: {To}, {Subject}, {parentId}", info.MailAddress, info.Subject, info.ParentMessageId);
_logger.LogDebug("Send Mail as reply: {To}, {Subject}, {parentId}", info.MailAddress, info.Subject, info.ParentMessageId);
string? messageId = await SendMailAsync(info);
if (string.IsNullOrEmpty(messageId))
{
throw new InvalidOperationException("Непредвиденная ошибка при отправке сообщения в ответ");
}
if (_messageInfoLogic.Create(new MessageInfoBindingModel
{
MessageId = messageId,
DateDelivery = DateTime.Now,
SenderName = _mailLogin,
IsReply = true,
Subject = info.Subject,
Body = info.Text,
}))
{
_messageInfoLogic.Update(new MessageInfoBindingModel()
{
MessageId = info.ParentMessageId,
ReplyMessageId = messageId,
IsReaded = true
});
}
}
string? messageId = await SendMailAsync(info);
if (string.IsNullOrEmpty(messageId))
{
throw new InvalidOperationException("Непредвиденная ошибка при отправке сообщения в ответ");
}
if (_messageInfoLogic.Create(new MessageInfoBindingModel
{
MessageId = messageId,
DateDelivery = DateTime.Now,
SenderName = _mailLogin,
IsReply = true,
Subject = info.Subject,
Body = info.Text,
}))
{
_messageInfoLogic.Update(new MessageInfoBindingModel()
{
MessageId = info.ParentMessageId,
ReplyMessageId = messageId,
IsReaded = true
});
}
}
protected abstract Task<string?> SendMailAsync(MailSendInfoBindingModel info);
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
}
protected abstract Task<string?> SendMailAsync(MailSendInfoBindingModel info);
protected abstract Task<List<MessageInfoBindingModel>> ReceiveMailAsync();
}
}

View File

@ -13,92 +13,92 @@ using System.Threading.Tasks;
namespace PizzeriaBusinessLogic.MailWorker
{
public class MailKitWorker : AbstractMailWorker
{
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic) : base(logger, messageInfoLogic) { }
public class MailKitWorker : AbstractMailWorker
{
public MailKitWorker(ILogger<MailKitWorker> logger, IMessageInfoLogic messageInfoLogic) : base(logger, messageInfoLogic) { }
protected override async Task<string?> SendMailAsync(MailSendInfoBindingModel info)
{
string? resount = null;
using var objMailMessage = new MailMessage();
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
try
{
ConfigurateSmtpClient(objSmtpClient);
CreateMessage(objMailMessage, info);
protected override async Task<string?> SendMailAsync(MailSendInfoBindingModel info)
{
string? resount = null;
using var objMailMessage = new MailMessage();
using var objSmtpClient = new SmtpClient(_smtpClientHost, _smtpClientPort);
try
{
ConfigurateSmtpClient(objSmtpClient);
CreateMessage(objMailMessage, info);
if (info is MailReplySendInfoBindingModel replyInfo)
{
objMailMessage.Headers.Add("In-Reply-To", replyInfo.ParentMessageId);
objMailMessage.Headers.Add("References", replyInfo.ParentMessageId);
if (info is MailReplySendInfoBindingModel replyInfo)
{
objMailMessage.Headers.Add("In-Reply-To", replyInfo.ParentMessageId);
objMailMessage.Headers.Add("References", replyInfo.ParentMessageId);
string messageGuid = Guid.NewGuid().ToString();
objMailMessage.Headers.Add("Message-Id", messageGuid);
resount = messageGuid;
}
string messageGuid = Guid.NewGuid().ToString();
objMailMessage.Headers.Add("Message-Id", messageGuid);
resount = messageGuid;
}
await Task.Run(() => objSmtpClient.Send(objMailMessage));
}
catch (Exception)
{
throw;
}
return resount;
}
await Task.Run(() => objSmtpClient.Send(objMailMessage));
}
catch (Exception)
{
throw;
}
return resount;
}
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
{
var list = new List<MessageInfoBindingModel>();
using var client = new Pop3Client();
await Task.Run(() =>
{
try
{
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
client.Authenticate(_mailLogin, _mailPassword);
for (int i = 0; i < client.Count; i++)
{
var message = client.GetMessage(i);
foreach (var mail in message.From.Mailboxes)
{
list.Add(new MessageInfoBindingModel
{
DateDelivery = message.Date.DateTime,
MessageId = message.MessageId,
SenderName = mail.Address,
Subject = message.Subject,
Body = message.TextBody
});
}
}
}
catch (MailKit.Security.AuthenticationException)
{ }
finally
{
client.Disconnect(true);
}
});
return list;
}
protected override async Task<List<MessageInfoBindingModel>> ReceiveMailAsync()
{
var list = new List<MessageInfoBindingModel>();
using var client = new Pop3Client();
await Task.Run(() =>
{
try
{
client.Connect(_popHost, _popPort, SecureSocketOptions.SslOnConnect);
client.Authenticate(_mailLogin, _mailPassword);
for (int i = 0; i < client.Count; i++)
{
var message = client.GetMessage(i);
foreach (var mail in message.From.Mailboxes)
{
list.Add(new MessageInfoBindingModel
{
DateDelivery = message.Date.DateTime,
MessageId = message.MessageId,
SenderName = mail.Address,
Subject = message.Subject,
Body = message.TextBody
});
}
}
}
catch (MailKit.Security.AuthenticationException)
{ }
finally
{
client.Disconnect(true);
}
});
return list;
}
private void CreateMessage(MailMessage objMailMessage, MailSendInfoBindingModel info)
{
objMailMessage.From = new MailAddress(_mailLogin);
objMailMessage.To.Add(new MailAddress(info.MailAddress));
objMailMessage.Subject = info.Subject;
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
}
private void CreateMessage(MailMessage objMailMessage, MailSendInfoBindingModel info)
{
objMailMessage.From = new MailAddress(_mailLogin);
objMailMessage.To.Add(new MailAddress(info.MailAddress));
objMailMessage.Subject = info.Subject;
objMailMessage.Body = info.Text;
objMailMessage.SubjectEncoding = Encoding.UTF8;
objMailMessage.BodyEncoding = Encoding.UTF8;
}
private void ConfigurateSmtpClient(SmtpClient objSmtpClient)
{
private void ConfigurateSmtpClient(SmtpClient objSmtpClient)
{
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.EnableSsl = true;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
}
}
objSmtpClient.UseDefaultCredentials = false;
objSmtpClient.EnableSsl = true;
objSmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
objSmtpClient.Credentials = new NetworkCredential(_mailLogin, _mailPassword);
}
}
}

View File

@ -11,72 +11,72 @@ using System.Threading.Tasks;
namespace PizzeriaDatabaseImplement.Implements
{
public class MessageInfoStorage : IMessageInfoStorage
{
public List<MessageInfoViewModel> GetFullList()
{
using var context = new PizzeriaDatabase();
return context.MessageInfos.Select(x => x.GetViewModel).ToList();
}
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
{
if (!model.ClientId.HasValue && !model.PageLength.HasValue && !model.PageIndex.HasValue)
{
return new();
}
using var context = new PizzeriaDatabase();
IEnumerable<MessageInfo> request = context.MessageInfos.Where(x => !x.IsReply);
if (model.ClientId.HasValue)
request = request.Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId);
if (model.PageLength.HasValue)
{
int skipRows = model.PageIndex.HasValue ? (model.PageIndex.Value - 1) * model.PageLength.Value : 0;
request = request.Skip(skipRows).Take(model.PageLength.Value);
}
public class MessageInfoStorage : IMessageInfoStorage
{
public List<MessageInfoViewModel> GetFullList()
{
using var context = new PizzeriaDatabase();
return context.MessageInfos.Select(x => x.GetViewModel).ToList();
}
public List<MessageInfoViewModel> GetFilteredList(MessageInfoSearchModel model)
{
if (!model.ClientId.HasValue && !model.PageLength.HasValue && !model.PageIndex.HasValue)
{
return new();
}
using var context = new PizzeriaDatabase();
IEnumerable<MessageInfo> request = context.MessageInfos.Where(x => !x.IsReply);
if (model.ClientId.HasValue)
request = request.Where(x => x.ClientId.HasValue && x.ClientId == model.ClientId);
if (model.PageLength.HasValue)
{
int skipRows = model.PageIndex.HasValue ? (model.PageIndex.Value - 1) * model.PageLength.Value : 0;
request = request.Skip(skipRows).Take(model.PageLength.Value);
}
return request.Select(x => x.GetViewModel).ToList();
}
return request.Select(x => x.GetViewModel).ToList();
}
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
{
if (string.IsNullOrEmpty(model.MessageId))
{
return new();
}
using var context = new PizzeriaDatabase();
return context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
}
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
{
var newMessage = MessageInfo.Create(model);
if (newMessage == null)
{
return null;
}
using var context = new PizzeriaDatabase();
try
{
context.MessageInfos.Add(newMessage);
context.SaveChanges();
return newMessage.GetViewModel;
}
catch (Exception ex)
{
return null;
}
}
public MessageInfoViewModel? GetElement(MessageInfoSearchModel model)
{
if (string.IsNullOrEmpty(model.MessageId))
{
return new();
}
using var context = new PizzeriaDatabase();
return context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId)?.GetViewModel;
}
public MessageInfoViewModel? Insert(MessageInfoBindingModel model)
{
var newMessage = MessageInfo.Create(model);
if (newMessage == null)
{
return null;
}
using var context = new PizzeriaDatabase();
try
{
context.MessageInfos.Add(newMessage);
context.SaveChanges();
return newMessage.GetViewModel;
}
catch (Exception ex)
{
return null;
}
}
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
{
using var context = new PizzeriaDatabase();
var message = context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId);
if (message == null)
{
return null;
}
message.Update(context, model);
context.SaveChanges();
return message.GetViewModel;
}
}
public MessageInfoViewModel? Update(MessageInfoBindingModel model)
{
using var context = new PizzeriaDatabase();
var message = context.MessageInfos.FirstOrDefault(x => x.MessageId == model.MessageId);
if (message == null)
{
return null;
}
message.Update(context, model);
context.SaveChanges();
return message.GetViewModel;
}
}
}

View File

@ -1,182 +1,182 @@
namespace PizzeriaView
{
partial class FormLetter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
partial class FormLetter
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxEmail = new System.Windows.Forms.TextBox();
this.labelAdress = new System.Windows.Forms.Label();
this.labelSubject = new System.Windows.Forms.Label();
this.textBoxSubject = new System.Windows.Forms.TextBox();
this.labelBody = new System.Windows.Forms.Label();
this.textBoxBody = new System.Windows.Forms.TextBox();
this.buttonClose = new System.Windows.Forms.Button();
this.buttonReply = new System.Windows.Forms.Button();
this.labelDate = new System.Windows.Forms.Label();
this.textBoxDate = new System.Windows.Forms.TextBox();
this.buttonSend = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxEmail
//
this.textBoxEmail.Location = new System.Drawing.Point(72, 6);
this.textBoxEmail.Name = "textBoxEmail";
this.textBoxEmail.ReadOnly = true;
this.textBoxEmail.Size = new System.Drawing.Size(186, 27);
this.textBoxEmail.TabIndex = 0;
//
// labelAdress
//
this.labelAdress.AutoSize = true;
this.labelAdress.Location = new System.Drawing.Point(12, 9);
this.labelAdress.Name = "labelAdress";
this.labelAdress.Size = new System.Drawing.Size(54, 20);
this.labelAdress.TabIndex = 1;
this.labelAdress.Text = "Адрес:";
//
// labelSubject
//
this.labelSubject.AutoSize = true;
this.labelSubject.Location = new System.Drawing.Point(12, 55);
this.labelSubject.Name = "labelSubject";
this.labelSubject.Size = new System.Drawing.Size(47, 20);
this.labelSubject.TabIndex = 2;
this.labelSubject.Text = "Тема:";
//
// textBoxSubject
//
this.textBoxSubject.Location = new System.Drawing.Point(72, 52);
this.textBoxSubject.Name = "textBoxSubject";
this.textBoxSubject.ReadOnly = true;
this.textBoxSubject.Size = new System.Drawing.Size(552, 27);
this.textBoxSubject.TabIndex = 3;
//
// labelBody
//
this.labelBody.AutoSize = true;
this.labelBody.Location = new System.Drawing.Point(12, 96);
this.labelBody.Name = "labelBody";
this.labelBody.Size = new System.Drawing.Size(104, 20);
this.labelBody.TabIndex = 4;
this.labelBody.Text = "Текст письма:";
//
// textBoxBody
//
this.textBoxBody.Location = new System.Drawing.Point(12, 119);
this.textBoxBody.Multiline = true;
this.textBoxBody.Name = "textBoxBody";
this.textBoxBody.ReadOnly = true;
this.textBoxBody.Size = new System.Drawing.Size(612, 186);
this.textBoxBody.TabIndex = 5;
//
// buttonClose
//
this.buttonClose.Location = new System.Drawing.Point(491, 326);
this.buttonClose.Name = "buttonClose";
this.buttonClose.Size = new System.Drawing.Size(111, 39);
this.buttonClose.TabIndex = 6;
this.buttonClose.Text = "Закрыть";
this.buttonClose.UseVisualStyleBackColor = true;
this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
//
// buttonReply
//
this.buttonReply.Location = new System.Drawing.Point(290, 326);
this.buttonReply.Name = "buttonReply";
this.buttonReply.Size = new System.Drawing.Size(177, 39);
this.buttonReply.TabIndex = 7;
this.buttonReply.Text = "Ответить";
this.buttonReply.UseVisualStyleBackColor = true;
this.buttonReply.Click += new System.EventHandler(this.buttonReply_Click);
//
// labelDate
//
this.labelDate.AutoSize = true;
this.labelDate.Location = new System.Drawing.Point(278, 9);
this.labelDate.Name = "labelDate";
this.labelDate.Size = new System.Drawing.Size(127, 20);
this.labelDate.TabIndex = 8;
this.labelDate.Text = "Дата получения: ";
//
// textBoxDate
//
this.textBoxDate.Location = new System.Drawing.Point(411, 6);
this.textBoxDate.Name = "textBoxDate";
this.textBoxDate.ReadOnly = true;
this.textBoxDate.Size = new System.Drawing.Size(213, 27);
this.textBoxDate.TabIndex = 9;
//
// buttonSend
//
this.buttonSend.Location = new System.Drawing.Point(149, 326);
this.buttonSend.Name = "buttonSend";
this.buttonSend.Size = new System.Drawing.Size(109, 39);
this.buttonSend.TabIndex = 10;
this.buttonSend.Text = "Отправить";
this.buttonSend.UseVisualStyleBackColor = true;
this.buttonSend.Visible = false;
this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click);
//
// FormLetter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(636, 377);
this.Controls.Add(this.buttonSend);
this.Controls.Add(this.textBoxDate);
this.Controls.Add(this.labelDate);
this.Controls.Add(this.buttonReply);
this.Controls.Add(this.buttonClose);
this.Controls.Add(this.textBoxBody);
this.Controls.Add(this.labelBody);
this.Controls.Add(this.textBoxSubject);
this.Controls.Add(this.labelSubject);
this.Controls.Add(this.labelAdress);
this.Controls.Add(this.textBoxEmail);
this.Name = "FormLetter";
this.Text = "Письмо";
this.Load += new System.EventHandler(this.FormLetter_Load);
this.ResumeLayout(false);
this.PerformLayout();
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.textBoxEmail = new System.Windows.Forms.TextBox();
this.labelAdress = new System.Windows.Forms.Label();
this.labelSubject = new System.Windows.Forms.Label();
this.textBoxSubject = new System.Windows.Forms.TextBox();
this.labelBody = new System.Windows.Forms.Label();
this.textBoxBody = new System.Windows.Forms.TextBox();
this.buttonClose = new System.Windows.Forms.Button();
this.buttonReply = new System.Windows.Forms.Button();
this.labelDate = new System.Windows.Forms.Label();
this.textBoxDate = new System.Windows.Forms.TextBox();
this.buttonSend = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// textBoxEmail
//
this.textBoxEmail.Location = new System.Drawing.Point(72, 6);
this.textBoxEmail.Name = "textBoxEmail";
this.textBoxEmail.ReadOnly = true;
this.textBoxEmail.Size = new System.Drawing.Size(186, 27);
this.textBoxEmail.TabIndex = 0;
//
// labelAdress
//
this.labelAdress.AutoSize = true;
this.labelAdress.Location = new System.Drawing.Point(12, 9);
this.labelAdress.Name = "labelAdress";
this.labelAdress.Size = new System.Drawing.Size(54, 20);
this.labelAdress.TabIndex = 1;
this.labelAdress.Text = "Адрес:";
//
// labelSubject
//
this.labelSubject.AutoSize = true;
this.labelSubject.Location = new System.Drawing.Point(12, 55);
this.labelSubject.Name = "labelSubject";
this.labelSubject.Size = new System.Drawing.Size(47, 20);
this.labelSubject.TabIndex = 2;
this.labelSubject.Text = "Тема:";
//
// textBoxSubject
//
this.textBoxSubject.Location = new System.Drawing.Point(72, 52);
this.textBoxSubject.Name = "textBoxSubject";
this.textBoxSubject.ReadOnly = true;
this.textBoxSubject.Size = new System.Drawing.Size(552, 27);
this.textBoxSubject.TabIndex = 3;
//
// labelBody
//
this.labelBody.AutoSize = true;
this.labelBody.Location = new System.Drawing.Point(12, 96);
this.labelBody.Name = "labelBody";
this.labelBody.Size = new System.Drawing.Size(104, 20);
this.labelBody.TabIndex = 4;
this.labelBody.Text = "Текст письма:";
//
// textBoxBody
//
this.textBoxBody.Location = new System.Drawing.Point(12, 119);
this.textBoxBody.Multiline = true;
this.textBoxBody.Name = "textBoxBody";
this.textBoxBody.ReadOnly = true;
this.textBoxBody.Size = new System.Drawing.Size(612, 186);
this.textBoxBody.TabIndex = 5;
//
// buttonClose
//
this.buttonClose.Location = new System.Drawing.Point(491, 326);
this.buttonClose.Name = "buttonClose";
this.buttonClose.Size = new System.Drawing.Size(111, 39);
this.buttonClose.TabIndex = 6;
this.buttonClose.Text = "Закрыть";
this.buttonClose.UseVisualStyleBackColor = true;
this.buttonClose.Click += new System.EventHandler(this.buttonClose_Click);
//
// buttonReply
//
this.buttonReply.Location = new System.Drawing.Point(290, 326);
this.buttonReply.Name = "buttonReply";
this.buttonReply.Size = new System.Drawing.Size(177, 39);
this.buttonReply.TabIndex = 7;
this.buttonReply.Text = "Ответить";
this.buttonReply.UseVisualStyleBackColor = true;
this.buttonReply.Click += new System.EventHandler(this.buttonReply_Click);
//
// labelDate
//
this.labelDate.AutoSize = true;
this.labelDate.Location = new System.Drawing.Point(278, 9);
this.labelDate.Name = "labelDate";
this.labelDate.Size = new System.Drawing.Size(127, 20);
this.labelDate.TabIndex = 8;
this.labelDate.Text = "Дата получения: ";
//
// textBoxDate
//
this.textBoxDate.Location = new System.Drawing.Point(411, 6);
this.textBoxDate.Name = "textBoxDate";
this.textBoxDate.ReadOnly = true;
this.textBoxDate.Size = new System.Drawing.Size(213, 27);
this.textBoxDate.TabIndex = 9;
//
// buttonSend
//
this.buttonSend.Location = new System.Drawing.Point(149, 326);
this.buttonSend.Name = "buttonSend";
this.buttonSend.Size = new System.Drawing.Size(109, 39);
this.buttonSend.TabIndex = 10;
this.buttonSend.Text = "Отправить";
this.buttonSend.UseVisualStyleBackColor = true;
this.buttonSend.Visible = false;
this.buttonSend.Click += new System.EventHandler(this.buttonSend_Click);
//
// FormLetter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(636, 377);
this.Controls.Add(this.buttonSend);
this.Controls.Add(this.textBoxDate);
this.Controls.Add(this.labelDate);
this.Controls.Add(this.buttonReply);
this.Controls.Add(this.buttonClose);
this.Controls.Add(this.textBoxBody);
this.Controls.Add(this.labelBody);
this.Controls.Add(this.textBoxSubject);
this.Controls.Add(this.labelSubject);
this.Controls.Add(this.labelAdress);
this.Controls.Add(this.textBoxEmail);
this.Name = "FormLetter";
this.Text = "Письмо";
this.Load += new System.EventHandler(this.FormLetter_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
}
#endregion
#endregion
private TextBox textBoxEmail;
private Label labelAdress;
private Label labelSubject;
private TextBox textBoxSubject;
private Label labelBody;
private TextBox textBoxBody;
private Button buttonClose;
private Button buttonReply;
private Label labelDate;
private TextBox textBoxDate;
private Button buttonSend;
}
private TextBox textBoxEmail;
private Label labelAdress;
private Label labelSubject;
private TextBox textBoxSubject;
private Label labelBody;
private TextBox textBoxBody;
private Button buttonClose;
private Button buttonReply;
private Label labelDate;
private TextBox textBoxDate;
private Button buttonSend;
}
}

View File

@ -5,138 +5,148 @@ using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.SearchModels;
using PizzeriaContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace PizzeriaView
{
public partial class FormLetter : Form
{
private readonly ILogger _logger;
private readonly IMessageInfoLogic _logic;
private readonly AbstractMailWorker _worker;
public partial class FormLetter : Form
{
private readonly ILogger _logger;
private readonly IMessageInfoLogic _logic;
private readonly AbstractMailWorker _worker;
public MessageInfoViewModel? model;
public string? messageId;
public MessageInfoViewModel? model;
public string? messageId;
public FormLetter(ILogger<FormLetter> logger, IMessageInfoLogic logic, AbstractMailWorker worker)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_worker = worker;
}
public FormLetter(ILogger<FormLetter> logger, IMessageInfoLogic logic, AbstractMailWorker worker)
{
InitializeComponent();
_logger = logger;
_logic = logic;
_worker = worker;
}
private void FormLetter_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(messageId))
{
ReloadLetter();
return;
}
else if (model != null)
{
ConfigurateToCreateAnsver();
return;
}
_logger.LogError("Для формы не переданно сведений о письме, на которое отвечаем!");
DialogResult = DialogResult.Abort;
Close();
return;
}
private void FormLetter_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(messageId))
{
ReloadLetter();
return;
}
else if (model != null)
{
ConfigurateToCreateAnsver();
return;
}
_logger.LogError("Для формы не переданно сведений о письме, на которое отвечаем!");
DialogResult = DialogResult.Abort;
Close();
return;
}
private void ReloadLetter()
{
_logger.LogInformation("Загрузка существующего письма с id:{}", messageId);
model = _logic.ReadElement(new MessageInfoSearchModel
{
MessageId = messageId
});
if (model != null)
{
_logger.LogInformation("Письмо найдено");
textBoxEmail.Text = model.SenderName;
textBoxDate.Text = model.DateDelivery.ToString();
textBoxSubject.Text = model.Subject;
textBoxBody.Text = model.Body;
private void ReloadLetter()
{
_logger.LogInformation("Загрузка существующего письма с id:{}", messageId);
model = _logic.ReadElement(new MessageInfoSearchModel
{
MessageId = messageId
});
if (model != null)
{
_logger.LogInformation("Письмо найдено");
textBoxEmail.Text = model.SenderName;
textBoxDate.Text = model.DateDelivery.ToString();
textBoxSubject.Text = model.Subject;
textBoxBody.Text = model.Body;
if (model.IsReply)
{
_logger.LogInformation("Письмо само и есть ответ");
buttonReply.Visible = false;
}
else
{
if (!string.IsNullOrEmpty(model.ReplyMessageId))
{
_logger.LogInformation("У письма есть ответ.");
buttonReply.Text = "Прочитать ответ";
}
}
return;
}
_logger.LogWarning("Письмо с таким id не удалось найти");
DialogResult = DialogResult.Abort;
Close();
return;
}
if (model.IsReply)
{
_logger.LogInformation("Письмо само и есть ответ");
buttonReply.Visible = false;
}
else
{
if (!string.IsNullOrEmpty(model.ReplyMessageId))
{
_logger.LogInformation("У письма есть ответ.");
buttonReply.Text = "Прочитать ответ";
}
}
return;
}
_logger.LogWarning("Письмо с таким id не удалось найти");
DialogResult = DialogResult.Abort;
Close();
return;
}
private void ConfigurateToCreateAnsver()
{
textBoxEmail.Text = model.SenderName;
labelDate.Visible = false;
textBoxDate.Visible = false;
textBoxSubject.Text = $"re: {model.Subject}";
textBoxBody.ReadOnly = false;
buttonReply.Visible = false;
buttonSend.Visible = true;
_logger.LogInformation("Запущена форма создания нового письма - ответа");
}
private void ConfigurateToCreateAnsver()
{
textBoxEmail.Text = model.SenderName;
labelDate.Visible = false;
textBoxDate.Visible = false;
textBoxSubject.Text = $"re: {model.Subject}";
textBoxBody.ReadOnly = false;
buttonReply.Visible = false;
buttonSend.Visible = true;
_logger.LogInformation("Запущена форма создания нового письма - ответа");
}
private void buttonClose_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void buttonClose_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void buttonReply_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormLetter));
if (service is FormLetter form)
{
if (!string.IsNullOrEmpty(model.ReplyMessageId))
{
form.messageId = model.ReplyMessageId;
}
else
{
form.model = model;
}
private void buttonReply_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormLetter));
if (service is FormLetter form)
{
if (!string.IsNullOrEmpty(model.ReplyMessageId))
{
form.messageId = model.ReplyMessageId;
}
else
{
form.model = model;
}
if (form.ShowDialog() != DialogResult.Cancel)
{
buttonReply.Visible = false;
}
}
}
if (form.ShowDialog() != DialogResult.Cancel)
{
buttonReply.Visible = false;
}
}
}
private void buttonSend_Click(object sender, EventArgs e)
{
if (model == null)
{
return;
}
string subject = textBoxSubject.Text;
string text = textBoxBody.Text;
private void buttonSend_Click(object sender, EventArgs e)
{
if (model == null)
{
return;
}
string subject = textBoxSubject.Text;
string text = textBoxBody.Text;
Task.Run(() => _worker.MailSendReplyAsync(new MailReplySendInfoBindingModel
{
MailAddress = model.SenderName,
Subject = subject,
Text = text,
ParentMessageId = model.MessageId,
}));
DialogResult = DialogResult.OK;
Close();
}
}
Task.Run(() => _worker.MailSendReplyAsync(new MailReplySendInfoBindingModel
{
MailAddress = model.SenderName,
Subject = subject,
Text = text,
ParentMessageId = model.MessageId,
}));
DialogResult = DialogResult.OK;
Close();
}
}
}

View File

@ -1,133 +1,133 @@
namespace PizzeriaView
{
partial class FormMail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
partial class FormMail
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonOpen = new System.Windows.Forms.Button();
this.numericUpDownPage = new System.Windows.Forms.NumericUpDown();
this.buttonPreveous = new System.Windows.Forms.Button();
this.buttonNext = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPage)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.dataGridView);
this.panel1.Location = new System.Drawing.Point(3, 1);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(795, 431);
this.panel1.TabIndex = 0;
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(795, 431);
this.dataGridView.TabIndex = 2;
//
// buttonOpen
//
this.buttonOpen.Location = new System.Drawing.Point(806, 80);
this.buttonOpen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonOpen.Name = "buttonOpen";
this.buttonOpen.Size = new System.Drawing.Size(107, 31);
this.buttonOpen.TabIndex = 1;
this.buttonOpen.Text = "Прочитать";
this.buttonOpen.UseVisualStyleBackColor = true;
this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
//
// numericUpDownPage
//
this.numericUpDownPage.Location = new System.Drawing.Point(825, 287);
this.numericUpDownPage.Name = "numericUpDownPage";
this.numericUpDownPage.Size = new System.Drawing.Size(85, 27);
this.numericUpDownPage.TabIndex = 4;
this.numericUpDownPage.ValueChanged += new System.EventHandler(this.numericUpDownPage_ValueChanged);
//
// buttonPreveous
//
this.buttonPreveous.Location = new System.Drawing.Point(825, 323);
this.buttonPreveous.Name = "buttonPreveous";
this.buttonPreveous.Size = new System.Drawing.Size(39, 29);
this.buttonPreveous.TabIndex = 5;
this.buttonPreveous.Text = "<-";
this.buttonPreveous.UseVisualStyleBackColor = true;
this.buttonPreveous.Click += new System.EventHandler(this.buttonPreveous_Click);
//
// buttonNext
//
this.buttonNext.Location = new System.Drawing.Point(872, 323);
this.buttonNext.Name = "buttonNext";
this.buttonNext.Size = new System.Drawing.Size(39, 29);
this.buttonNext.TabIndex = 6;
this.buttonNext.Text = "->";
this.buttonNext.UseVisualStyleBackColor = true;
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
//
// FormMail
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(925, 428);
this.Controls.Add(this.buttonNext);
this.Controls.Add(this.buttonPreveous);
this.Controls.Add(this.numericUpDownPage);
this.Controls.Add(this.buttonOpen);
this.Controls.Add(this.panel1);
this.Name = "FormMail";
this.Text = "Письма";
this.Load += new System.EventHandler(this.FormMail_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPage)).EndInit();
this.ResumeLayout(false);
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel1 = new System.Windows.Forms.Panel();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonOpen = new System.Windows.Forms.Button();
this.numericUpDownPage = new System.Windows.Forms.NumericUpDown();
this.buttonPreveous = new System.Windows.Forms.Button();
this.buttonNext = new System.Windows.Forms.Button();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPage)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.dataGridView);
this.panel1.Location = new System.Drawing.Point(3, 1);
this.panel1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(795, 431);
this.panel1.TabIndex = 0;
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(795, 431);
this.dataGridView.TabIndex = 2;
//
// buttonOpen
//
this.buttonOpen.Location = new System.Drawing.Point(806, 80);
this.buttonOpen.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
this.buttonOpen.Name = "buttonOpen";
this.buttonOpen.Size = new System.Drawing.Size(107, 31);
this.buttonOpen.TabIndex = 1;
this.buttonOpen.Text = "Прочитать";
this.buttonOpen.UseVisualStyleBackColor = true;
this.buttonOpen.Click += new System.EventHandler(this.buttonOpen_Click);
//
// numericUpDownPage
//
this.numericUpDownPage.Location = new System.Drawing.Point(825, 287);
this.numericUpDownPage.Name = "numericUpDownPage";
this.numericUpDownPage.Size = new System.Drawing.Size(85, 27);
this.numericUpDownPage.TabIndex = 4;
this.numericUpDownPage.ValueChanged += new System.EventHandler(this.numericUpDownPage_ValueChanged);
//
// buttonPreveous
//
this.buttonPreveous.Location = new System.Drawing.Point(825, 323);
this.buttonPreveous.Name = "buttonPreveous";
this.buttonPreveous.Size = new System.Drawing.Size(39, 29);
this.buttonPreveous.TabIndex = 5;
this.buttonPreveous.Text = "<-";
this.buttonPreveous.UseVisualStyleBackColor = true;
this.buttonPreveous.Click += new System.EventHandler(this.buttonPreveous_Click);
//
// buttonNext
//
this.buttonNext.Location = new System.Drawing.Point(872, 323);
this.buttonNext.Name = "buttonNext";
this.buttonNext.Size = new System.Drawing.Size(39, 29);
this.buttonNext.TabIndex = 6;
this.buttonNext.Text = "->";
this.buttonNext.UseVisualStyleBackColor = true;
this.buttonNext.Click += new System.EventHandler(this.buttonNext_Click);
//
// FormMail
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(925, 428);
this.Controls.Add(this.buttonNext);
this.Controls.Add(this.buttonPreveous);
this.Controls.Add(this.numericUpDownPage);
this.Controls.Add(this.buttonOpen);
this.Controls.Add(this.panel1);
this.Name = "FormMail";
this.Text = "Письма";
this.Load += new System.EventHandler(this.FormMail_Load);
this.panel1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPage)).EndInit();
this.ResumeLayout(false);
}
}
#endregion
#endregion
private Panel panel1;
private DataGridView dataGridView;
private Button buttonOpen;
private NumericUpDown numericUpDownPage;
private Button buttonPreveous;
private Button buttonNext;
}
private Panel panel1;
private DataGridView dataGridView;
private Button buttonOpen;
private NumericUpDown numericUpDownPage;
private Button buttonPreveous;
private Button buttonNext;
}
}

View File

@ -17,99 +17,99 @@ using System.Windows.Forms;
namespace PizzeriaView
{
public partial class FormMail : Form
{
private readonly ILogger _logger;
private readonly IMessageInfoLogic _logic;
private int currentPage = 1;
private int pageLength = 2;
public partial class FormMail : Form
{
private readonly ILogger _logger;
private readonly IMessageInfoLogic _logic;
private int currentPage = 1;
private int pageLength = 2;
public FormMail(ILogger<FormMail> logger, IMessageInfoLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
public FormMail(ILogger<FormMail> logger, IMessageInfoLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void LoadData()
{
try
{
var list = _logic.ReadList(new MessageInfoSearchModel()
{
PageLength = pageLength,
PageIndex = currentPage
private void LoadData()
{
try
{
var list = _logic.ReadList(new MessageInfoSearchModel()
{
PageLength = pageLength,
PageIndex = currentPage
});
numericUpDownPage.Value = pageLength;
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["MessageId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ReplyMessageId"].Visible = false;
dataGridView.Columns["Reply"].Visible = false;
dataGridView.Columns["IsReply"].Visible = false;
dataGridView.Columns["Body"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка почтовых собщений");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки почтовых сообщений");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
});
numericUpDownPage.Value = pageLength;
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["MessageId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
dataGridView.Columns["ReplyMessageId"].Visible = false;
dataGridView.Columns["Reply"].Visible = false;
dataGridView.Columns["IsReply"].Visible = false;
dataGridView.Columns["Body"].AutoSizeMode =
DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка почтовых собщений");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки почтовых сообщений");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormMail_Load(object sender, EventArgs e)
{
LoadData();
}
private void FormMail_Load(object sender, EventArgs e)
{
LoadData();
}
private void buttonOpen_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count <= 0)
return;
private void buttonOpen_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count <= 0)
return;
var service = Program.ServiceProvider?.GetService(typeof(FormLetter));
if (service is FormLetter form)
{
string? messageId = dataGridView.SelectedRows[0].Cells["MessageId"].Value.ToString();
if (messageId == null) return;
form.messageId = messageId;
var service = Program.ServiceProvider?.GetService(typeof(FormLetter));
if (service is FormLetter form)
{
string? messageId = dataGridView.SelectedRows[0].Cells["MessageId"].Value.ToString();
if (messageId == null) return;
form.messageId = messageId;
if (!Convert.ToBoolean(dataGridView.SelectedRows[0].Cells["IsReaded"].Value))
{
_logic.Update(new MessageInfoBindingModel
{
MessageId = messageId,
IsReaded = true,
ReplyMessageId = dataGridView.SelectedRows[0].Cells["ReplyMessageId"].Value?.ToString()
});
}
if (!Convert.ToBoolean(dataGridView.SelectedRows[0].Cells["IsReaded"].Value))
{
_logic.Update(new MessageInfoBindingModel
{
MessageId = messageId,
IsReaded = true,
ReplyMessageId = dataGridView.SelectedRows[0].Cells["ReplyMessageId"].Value?.ToString()
});
}
form.ShowDialog();
LoadData();
}
}
form.ShowDialog();
LoadData();
}
}
private void buttonPreveous_Click(object sender, EventArgs e)
{
currentPage = Math.Max(1, currentPage - 1);
LoadData();
}
private void buttonPreveous_Click(object sender, EventArgs e)
{
currentPage = Math.Max(1, currentPage - 1);
LoadData();
}
private void buttonNext_Click(object sender, EventArgs e)
{
currentPage++;
LoadData();
}
private void buttonNext_Click(object sender, EventArgs e)
{
currentPage++;
LoadData();
}
private void numericUpDownPage_ValueChanged(object sender, EventArgs e)
{
pageLength = Math.Max(1, (int)numericUpDownPage.Value);
LoadData();
}
}
private void numericUpDownPage_ValueChanged(object sender, EventArgs e)
{
pageLength = Math.Max(1, (int)numericUpDownPage.Value);
LoadData();
}
}
}

View File

@ -4,112 +4,111 @@ using NLog.Extensions.Logging;
using PizzeriaBusinessLogic.BusinessLogics;
using PizzeriaBusinessLogic.MailWorker;
using PizzeriaContracts.BindingModels;
using PizzeriaBusinessLogic.OfficePackage.Implements;
using PizzeriaBusinessLogic.OfficePackage;
using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.StoragesContracts;
using PizzeriaDatabaseImplement.Implements;
using PizzeriaView;
using PizzeriaBusinessLogic.OfficePackage;
using Microsoft.EntityFrameworkCore.Design;
using PizzeriaBusinessLogic.OfficePackage.Implements;
namespace Pizzeria
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
try
{
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
});
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
try
{
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
mailSender?.MailConfig(new MailConfigBindingModel
{
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty,
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"])
});
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
logger?.LogError(ex, "Mails Problem");
}
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
logger?.LogError(ex, "Mails Problem");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPizzaStorage, PizzaStorage>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IPizzaStorage, PizzaStorage>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPizzaLogic, PizzaLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPizzaLogic, PizzaLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddTransient<IShopLogic, ShopLogic>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormPizza>();
services.AddTransient<FormPizzaComponent>();
services.AddTransient<FormPizzas>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormCreateSupply>();
services.AddTransient<FormSellPizza>();
services.AddTransient<FormMain>();
services.AddTransient<FormReportPizzaComponents>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormClients>();
services.AddTransient<EntityFrameworkDesignServicesBuilder>();
services.AddTransient<FormReportShop>();
services.AddTransient<FormReportGroupedOrders>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormMail>();
services.AddTransient<FormLetter>();
}
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormPizza>();
services.AddTransient<FormPizzaComponent>();
services.AddTransient<FormPizzas>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormCreateSupply>();
services.AddTransient<FormSellPizza>();
services.AddTransient<FormReportPizzaComponents>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormClients>();
services.AddTransient<EntityFrameworkDesignServicesBuilder>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormMail>();
services.AddTransient<FormReportShop>();
services.AddTransient<FormReportGroupedOrders>();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
}
}