PIbd-22_Shabunov_O.A._AutoW.../AutoWorkshopView/Program.cs

103 lines
4.4 KiB
C#
Raw Normal View History

2024-02-21 11:04:46 +04:00
using AutoWorkshopBusinessLogic.BusinessLogics;
2024-04-03 10:26:18 +04:00
using AutoWorkshopBusinessLogic.OfficePackage.Implements;
using AutoWorkshopBusinessLogic.OfficePackage;
2024-02-21 10:36:30 +04:00
using AutoWorkshopContracts.BusinessLogicContracts;
using AutoWorkshopContracts.StoragesContracts;
2024-03-20 11:06:47 +04:00
using AutoWorkshopDatabaseImplement.Implements;
2024-02-21 10:36:30 +04:00
using AutoWorkshopView.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
2024-02-21 11:04:46 +04:00
using NLog.Extensions.Logging;
2024-04-16 21:33:18 +04:00
using AutoWorkshopContracts.BusinessLogicsContracts;
2024-04-19 23:46:09 +04:00
using AutoWorkshopBusinessLogic.MailWorker;
using AutoWorkshopContracts.BindingModels;
2024-02-21 10:36:30 +04:00
2024-02-20 23:51:24 +04:00
namespace AutoWorkshopView
2024-02-06 22:59:42 +04:00
{
internal static class Program
{
2024-02-21 10:36:30 +04:00
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2024-02-06 22:59:42 +04:00
[STAThread]
static void Main()
{
2024-02-21 11:04:46 +04:00
ApplicationConfiguration.Initialize();
2024-02-21 10:36:30 +04:00
var Services = new ServiceCollection();
ConfigureServices(Services);
2024-04-19 23:46:09 +04:00
_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,
2024-04-20 19:02:55 +04:00
SmtpClientPort = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["SmtpClientPort"]),
2024-04-19 23:46:09 +04:00
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, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
Application.Run(_serviceProvider.GetRequiredService<MainForm>());
2024-02-21 10:36:30 +04:00
}
2024-04-19 23:46:09 +04:00
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.CheckMailAsync();
private static void ConfigureServices(ServiceCollection Services)
2024-02-21 10:36:30 +04:00
{
Services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
Services.AddTransient<IComponentStorage, ComponentStorage>();
Services.AddTransient<IOrderStorage, OrderStorage>();
2024-02-21 11:04:46 +04:00
Services.AddTransient<IRepairStorage, RepairStorage>();
2024-04-16 21:33:18 +04:00
Services.AddTransient<IClientStorage, ClientStorage>();
Services.AddTransient<IImplementerStorage, ImplementerStorage>();
2024-04-19 23:46:09 +04:00
Services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
2024-04-16 21:33:18 +04:00
2024-02-21 10:36:30 +04:00
Services.AddTransient<IComponentLogic, ComponentLogic>();
Services.AddTransient<IOrderLogic, OrderLogic>();
2024-02-21 11:04:46 +04:00
Services.AddTransient<IRepairLogic, RepairLogic>();
2024-04-03 10:26:18 +04:00
Services.AddTransient<IReportLogic, ReportLogic>();
2024-04-11 14:21:59 +04:00
Services.AddTransient<IClientLogic, ClientLogic>();
2024-04-16 21:33:18 +04:00
Services.AddTransient<IImplementerLogic, ImplementerLogic>();
Services.AddTransient<IWorkProcess, WorkModeling>();
2024-04-19 23:46:09 +04:00
Services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
2024-04-03 10:26:18 +04:00
2024-04-11 14:21:59 +04:00
Services.AddTransient<AbstractSaveToWord, SaveToWord>();
2024-04-03 10:26:18 +04:00
Services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
Services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
2024-04-19 23:46:09 +04:00
Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
2024-03-19 21:18:58 +04:00
2024-02-21 10:36:30 +04:00
Services.AddTransient<MainForm>();
2024-02-21 11:04:46 +04:00
Services.AddTransient<FormComponent>();
Services.AddTransient<FormComponents>();
Services.AddTransient<FormCreateOrder>();
Services.AddTransient<FormRepair>();
Services.AddTransient<FormRepairComponent>();
Services.AddTransient<FormRepairs>();
2024-04-03 10:26:18 +04:00
Services.AddTransient<FormReportRepairComponents>();
Services.AddTransient<FormReportOrders>();
2024-04-11 14:21:59 +04:00
Services.AddTransient<FormClients>();
2024-04-16 21:33:18 +04:00
Services.AddTransient<FormImplementers>();
Services.AddTransient<FormImplementer>();
2024-04-19 23:46:09 +04:00
Services.AddTransient<FormMail>();
2024-04-16 21:33:18 +04:00
}
2024-02-06 22:59:42 +04:00
}
2024-02-20 23:51:24 +04:00
}