PIbd-22_Kamcharova_K.A_Reno.../RenovationWork/Program.cs

99 lines
4.4 KiB
C#
Raw Permalink Normal View History

2024-06-22 15:58:51 +04:00
using RenovationWorkBusinessLogic.MailWorker;
using RenovationWorkContracts.BindingModels;
2024-04-17 09:22:08 +04:00
using RenovationWorkBusinessLogic.BusinessLogics;
2024-05-25 21:23:11 +04:00
using RenovationWorkBusinessLogic.OfficePackage.Implements;
using RenovationWorkBusinessLogic.OfficePackage;
2024-04-17 09:22:08 +04:00
using RenovationWorkContracts.BusinessLogicsContracts;
using RenovationWorkContracts.StoragesContracts;
2024-04-17 09:29:02 +04:00
using RenovationWorkDatabaseImplement.Implements;
2024-04-17 09:22:08 +04:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2024-05-25 21:25:00 +04:00
using System;
2024-04-17 09:25:01 +04:00
2024-04-17 09:22:08 +04:00
namespace RenovationWorkView
{
2024-06-22 15:58:51 +04:00
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
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, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
}
private static void ConfigureServices(ServiceCollection services)
2024-04-17 09:22:08 +04:00
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IRepairStorage, RepairStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IRepairLogic, RepairLogic>();
2024-05-19 13:23:06 +04:00
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
2024-05-25 21:23:11 +04:00
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<IClientStorage, ClientStorage>();
2024-05-25 21:25:00 +04:00
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IImplementerStorage, ImplementerStorage>();
2024-06-22 15:58:51 +04:00
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
services.AddTransient<IWorkProcess, WorkModeling>();
2024-04-17 09:22:08 +04:00
services.AddTransient<FormMain>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormRepair>();
services.AddTransient<FormRepairComponent>();
services.AddTransient<FormRepairs>();
2024-05-19 13:23:06 +04:00
services.AddTransient<FormReportRepairComponents>();
services.AddTransient<FormReportOrders>();
2024-05-25 21:23:11 +04:00
services.AddTransient<FormClients>();
2024-05-25 21:25:00 +04:00
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
2024-06-22 15:58:51 +04:00
services.AddTransient<FormMail>();
}
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
}
2024-04-17 09:22:08 +04:00
}