program edited
This commit is contained in:
parent
422b08deee
commit
d038e94079
@ -9,6 +9,8 @@ using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using JewelryStoreBusinessLogic.OfficePackage;
|
||||
using JewelryStoreBusinessLogic.OfficePackage.Implements;
|
||||
using JewelryStoreBusinessLogic.MailWorker;
|
||||
using JewelryStoreContracts.BindingModels;
|
||||
|
||||
namespace JewelryStore
|
||||
{
|
||||
@ -29,6 +31,27 @@ namespace JewelryStore
|
||||
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, "Îøèáêà ðàáîòû ñ ïî÷òîé");
|
||||
}
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
@ -43,9 +66,11 @@ namespace JewelryStore
|
||||
services.AddTransient<IJewelStorage, JewelStorage>();
|
||||
services.AddTransient<IClientStorage, ClientStorage>();
|
||||
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
||||
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
||||
|
||||
|
||||
services.AddTransient<IWorkProcess, WorkModeling>();
|
||||
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
||||
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
@ -53,6 +78,7 @@ namespace JewelryStore
|
||||
services.AddTransient<IClientLogic, ClientLogic>();
|
||||
services.AddTransient<IReportLogic, ReportLogic>();
|
||||
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
||||
|
||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||
@ -71,6 +97,6 @@ namespace JewelryStore
|
||||
services.AddTransient<FormImplementer>();
|
||||
services.AddTransient<FormImplementers>();
|
||||
}
|
||||
|
||||
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user