This commit is contained in:
Игорь Гордеев 2024-05-19 11:20:08 +04:00
commit c53ba4e90c
6 changed files with 29 additions and 28 deletions

View File

@ -26,26 +26,29 @@ namespace SushiBarView
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
InitDependency(); var services = new ServiceCollection();
try ConfigureServices(services);
{ _serviceProvider = services.BuildServiceProvider();
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>(); mailSender?.MailConfig(new MailConfigBindingModel try
{ {
MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty, var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty, mailSender?.MailConfig(new MailConfigBindingModel
SmtpClientHost = System.Configuration.ConfigurationManager.AppSettings["SmtpClientHost"] ?? string.Empty, {
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]), MailLogin = System.Configuration.ConfigurationManager.AppSettings["MailLogin"] ?? string.Empty,
PopHost = System.Configuration.ConfigurationManager.AppSettings["PopHost"] ?? string.Empty, MailPassword = System.Configuration.ConfigurationManager.AppSettings["MailPassword"] ?? string.Empty,
PopPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["PopPort"]) 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); var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
} }
catch (Exception ex) catch (Exception ex)
{ {
var logger = DependencyManager.Instance.Resolve<ILogger>(); var logger = _serviceProvider.GetService<ILogger>();
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"); logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
} }
Application.Run(DependencyManager.Instance.Resolve<FormMain>()); Application.Run(DependencyManager.Instance.Resolve<FormMain>());
} }

View File

@ -44,7 +44,7 @@ namespace SushiBarBusinessLogic.MailWorker
{ {
var list = new List<MessageInfoBindingModel>(); var list = new List<MessageInfoBindingModel>();
using var client = new Pop3Client(); using var client = new Pop3Client();
await Task.Run(() => await Task.Run(() =>
{ {
try try
{ {

View File

@ -11,6 +11,7 @@ namespace SushiBarFileImplement
private readonly string SushiFileName = "Sushi.xml"; private readonly string SushiFileName = "Sushi.xml";
private readonly string ClientFileName = "Client.xml"; private readonly string ClientFileName = "Client.xml";
private readonly string ImplementerFileName = "Implementer.xml"; private readonly string ImplementerFileName = "Implementer.xml";
private readonly string MessageInfoFileName = "MessageInfo.xml";
public List<Ingredient> Ingredients { get; private set; } public List<Ingredient> Ingredients { get; private set; }
public List<Order> Orders { get; private set; } public List<Order> Orders { get; private set; }
public List<Sushi> ListSushi { get; private set; } public List<Sushi> ListSushi { get; private set; }
@ -42,6 +43,7 @@ namespace SushiBarFileImplement
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!; Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!;
Messages = LoadData(MessageInfoFileName, "MessageInfo", x => MessageInfo.Create(x)!)!;
} }
private static List<T>? LoadData<T>(string filename, string xmlNodeName, private static List<T>? LoadData<T>(string filename, string xmlNodeName,
Func<XElement, T> selectFunction) Func<XElement, T> selectFunction)

View File

@ -1,4 +1,5 @@
using SushiBarContracts.BindingModels; using PrecastConcretePlantDataModels.Models;
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
using System; using System;

View File

@ -1,6 +1,4 @@
 using SushiBarContracts.BindingModels;
using SushiBarContracts.BindingModels;
using SushiBarContracts.SearchModels; using SushiBarContracts.SearchModels;
using SushiBarContracts.StoragesContracts; using SushiBarContracts.StoragesContracts;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;

View File

@ -1,8 +1,5 @@
 using SushiBarContracts.BindingModels;
using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models;
namespace SushiBarListImplement.Models namespace SushiBarListImplement.Models
{ {