PIbd-21_MasenkinMS_Aircraft.../AircraftPlant/AircraftPlantView/Program.cs

107 lines
4.7 KiB
C#
Raw Permalink Normal View History

2024-02-21 01:42:28 +04:00
using AircraftPlantBusinessLogic.BusinessLogics;
2024-03-25 00:53:24 +04:00
using AircraftPlantBusinessLogic.OfficePackage.Implements;
using AircraftPlantBusinessLogic.OfficePackage;
2024-02-21 01:42:28 +04:00
using AircraftPlantContracts.BusinessLogicsContracts;
using AircraftPlantContracts.StoragesContracts;
2024-03-10 01:33:27 +04:00
using AircraftPlantDatabaseImplement.Implements;
2024-02-21 01:42:28 +04:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
2024-05-04 22:30:27 +04:00
using AircraftPlantBusinessLogic.MailWorker;
using AircraftPlantContracts.BindingModels;
2024-05-13 02:01:32 +04:00
using AircraftPlantContracts.DependencyInjections;
2024-02-21 01:42:28 +04:00
2024-02-12 00:31:55 +04:00
namespace AircraftPlantView
{
internal static class Program
{
/// <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();
2024-05-13 02:01:32 +04:00
InitDependency();
2024-02-21 01:42:28 +04:00
2024-05-04 22:30:27 +04:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
try
{
2024-05-13 02:01:32 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-05-04 22:30:27 +04:00
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, 60000);
}
catch (Exception ex)
{
2024-05-13 02:01:32 +04:00
var logger = DependencyManager.Instance.Resolve<ILogger>();
2024-05-04 22:30:27 +04:00
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
2024-05-13 02:01:32 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-02-21 01:42:28 +04:00
}
/// <summary>
2024-05-13 02:01:32 +04:00
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-02-21 01:42:28 +04:00
/// </summary>
/// <param name="services"></param>
2024-05-13 02:01:32 +04:00
private static void InitDependency()
2024-02-21 01:42:28 +04:00
{
2024-05-13 02:01:32 +04:00
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
2024-02-21 01:42:28 +04:00
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
2024-05-13 02:01:32 +04:00
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IPlaneLogic, PlaneLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
2024-05-04 22:30:27 +04:00
2024-05-13 02:01:32 +04:00
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
2024-03-25 00:53:24 +04:00
2024-05-13 02:01:32 +04:00
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
2024-02-21 01:42:28 +04:00
2024-05-13 02:01:32 +04:00
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormPlane>();
DependencyManager.Instance.RegisterType<FormPlaneComponent>();
DependencyManager.Instance.RegisterType<FormPlanes>();
DependencyManager.Instance.RegisterType<FormReportPlaneComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormMail>();
2024-02-12 00:31:55 +04:00
}
2024-05-04 22:30:27 +04:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
/// <param name="obj"></param>
2024-05-13 02:01:32 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-02-12 00:31:55 +04:00
}
}