diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs index 6d8f230..e497fb7 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -26,26 +26,29 @@ namespace SushiBarView // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - InitDependency(); - try - { - var mailSender = DependencyManager.Instance.Resolve(); 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 services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + try + { + var mailSender = _serviceProvider.GetService(); + 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 = DependencyManager.Instance.Resolve(); - logger?.LogError(ex, "<22><> <20><> <20> <20><>"); - } + var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000); + } + catch (Exception ex) + { + var logger = _serviceProvider.GetService(); + logger?.LogError(ex, "<22><> <20><> <20> <20><>"); + } Application.Run(DependencyManager.Instance.Resolve()); } diff --git a/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs b/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs index d396709..268fa2a 100644 --- a/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs +++ b/SushiBar/SushiBarBusinessLogic/MailWorker/MailKitWorker.cs @@ -44,7 +44,7 @@ namespace SushiBarBusinessLogic.MailWorker { var list = new List(); using var client = new Pop3Client(); - await Task.Run(() => + await Task.Run(() => { try { diff --git a/SushiBar/SushiBarFileImplement/DataFileSingleton.cs b/SushiBar/SushiBarFileImplement/DataFileSingleton.cs index f8bf6b3..1cf7549 100644 --- a/SushiBar/SushiBarFileImplement/DataFileSingleton.cs +++ b/SushiBar/SushiBarFileImplement/DataFileSingleton.cs @@ -11,6 +11,7 @@ namespace SushiBarFileImplement private readonly string SushiFileName = "Sushi.xml"; private readonly string ClientFileName = "Client.xml"; private readonly string ImplementerFileName = "Implementer.xml"; + private readonly string MessageInfoFileName = "MessageInfo.xml"; public List Ingredients { get; private set; } public List Orders { get; private set; } public List ListSushi { get; private set; } @@ -42,6 +43,7 @@ namespace SushiBarFileImplement Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; Implementers = LoadData(ImplementerFileName, "Implementer", x => Implementer.Create(x)!)!; + Messages = LoadData(MessageInfoFileName, "MessageInfo", x => MessageInfo.Create(x)!)!; } private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) diff --git a/SushiBar/SushiBarFileImplement/Models/MessageInfo.cs b/SushiBar/SushiBarFileImplement/Models/MessageInfo.cs index 62903ba..5ad2f0b 100644 --- a/SushiBar/SushiBarFileImplement/Models/MessageInfo.cs +++ b/SushiBar/SushiBarFileImplement/Models/MessageInfo.cs @@ -1,4 +1,5 @@ -using SushiBarContracts.BindingModels; +using PrecastConcretePlantDataModels.Models; +using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; using SushiBarDataModels.Models; using System; diff --git a/SushiBar/SushiBarListImplement/Implements/MessageInfoStorage.cs b/SushiBar/SushiBarListImplement/Implements/MessageInfoStorage.cs index e27abf4..820aa3a 100644 --- a/SushiBar/SushiBarListImplement/Implements/MessageInfoStorage.cs +++ b/SushiBar/SushiBarListImplement/Implements/MessageInfoStorage.cs @@ -1,6 +1,4 @@ - - -using SushiBarContracts.BindingModels; +using SushiBarContracts.BindingModels; using SushiBarContracts.SearchModels; using SushiBarContracts.StoragesContracts; using SushiBarContracts.ViewModels; diff --git a/SushiBar/SushiBarListImplement/Models/MessageInfo.cs b/SushiBar/SushiBarListImplement/Models/MessageInfo.cs index d3852a0..006a1e4 100644 --- a/SushiBar/SushiBarListImplement/Models/MessageInfo.cs +++ b/SushiBar/SushiBarListImplement/Models/MessageInfo.cs @@ -1,8 +1,5 @@ - - -using SushiBarContracts.BindingModels; +using SushiBarContracts.BindingModels; using SushiBarContracts.ViewModels; -using SushiBarDataModels.Models; namespace SushiBarListImplement.Models {