PIbd22_NikiforovaMV_Automob.../AutomobilePlant/Program.cs

97 lines
4.2 KiB
C#
Raw Permalink Normal View History

2024-04-17 10:13:26 +04:00
using AutomobilePlantBusinessLogic.BusinessLogics;
2024-06-22 22:30:26 +04:00
using AutomobilePlantBusinessLogic.MailWorker;
2024-05-11 13:39:57 +04:00
using AutomobilePlantBusinessLogic.OfficePackage;
using AutomobilePlantBusinessLogic.OfficePackage.Implements;
2024-06-22 22:30:26 +04:00
using AutomobilePlantContracts.BindingModels;
2024-04-17 10:13:26 +04:00
using AutomobilePlantContracts.BusinessLogicContracts;
using AutomobilePlantContracts.StorageContracts;
2024-05-11 13:35:30 +04:00
using AutomobilePlantDatabaseImplement.Implements;
2024-04-17 10:13:26 +04:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
namespace AutomobilePlant
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
2024-06-22 22:30:26 +04:00
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"])
});
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var logger = _serviceProvider.GetService<ILogger>();
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
private static void ConfigureServices(ServiceCollection services)
{
2024-04-17 10:13:26 +04:00
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ICarStorage, CarStorage>();
2024-06-22 22:23:42 +04:00
services.AddTransient<IClientStorage, ClientStorage>();
2024-06-22 22:27:59 +04:00
services.AddTransient<IImplementerStorage, ImplementerStorage>();
2024-06-22 22:30:26 +04:00
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
2024-04-17 10:17:17 +04:00
2024-06-22 22:30:26 +04:00
services.AddTransient<IComponentLogic, ComponentLogic>();
2024-04-17 10:13:26 +04:00
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ICarLogic, CarLogic>();
2024-05-11 13:39:57 +04:00
services.AddTransient<IReportLogic, ReportLogic>();
2024-06-22 22:23:42 +04:00
services.AddTransient<IClientLogic, ClientLogic>();
2024-06-22 22:27:59 +04:00
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
2024-06-22 22:30:26 +04:00
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
2024-05-11 13:39:57 +04:00
2024-06-22 22:30:26 +04:00
services.AddTransient<AbstractSaveToWord, SaveToWord>();
2024-05-11 13:39:57 +04:00
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
2024-04-17 10:17:17 +04:00
2024-06-22 22:30:26 +04:00
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<FormMain>();
2024-04-17 10:13:26 +04:00
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormCar>();
services.AddTransient<FormCarComponent>();
services.AddTransient<FormCars>();
2024-05-11 13:39:57 +04:00
services.AddTransient<FormReportCarComponents>();
services.AddTransient<FormReportOrder>();
2024-06-22 22:23:42 +04:00
services.AddTransient<FormClients>();
2024-06-22 22:27:59 +04:00
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
2024-06-22 22:30:26 +04:00
services.AddTransient<FormMails>();
}
2024-04-17 10:13:26 +04:00
}
}