PIbd22_NikiforovaMV_Automob.../AutomobilePlant/Program.cs

90 lines
4.0 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;
2024-06-22 22:32:20 +04:00
using AutomobilePlantContracts.DI;
2024-04-17 10:13:26 +04:00
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
{
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
2024-06-22 22:32:20 +04:00
InitDependency();
2024-04-17 10:13:26 +04:00
2024-06-22 22:30:26 +04:00
try
{
2024-06-22 22:32:20 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-06-22 22:30:26 +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"])
});
2024-06-22 22:32:20 +04:00
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-06-22 22:30:26 +04:00
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
2024-06-22 22:32:20 +04:00
var logger = DependencyManager.Instance.Resolve<ILogger>();
2024-06-22 22:30:26 +04:00
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
2024-06-22 22:32:20 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-06-22 22:30:26 +04:00
}
2024-06-22 22:32:20 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-06-22 22:30:26 +04:00
2024-06-22 22:32:20 +04:00
private static void InitDependency()
2024-06-22 22:30:26 +04:00
{
2024-06-22 22:32:20 +04:00
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
2024-04-17 10:17:17 +04:00
2024-06-22 22:32:20 +04:00
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ICarLogic, CarLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
2024-05-11 13:39:57 +04:00
2024-06-22 22:32:20 +04:00
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
2024-04-17 10:17:17 +04:00
2024-06-22 22:32:20 +04:00
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(isSingle: true);
2024-06-22 22:30:26 +04:00
2024-06-22 22:32:20 +04:00
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormCar>();
DependencyManager.Instance.RegisterType<FormCarComponent>();
DependencyManager.Instance.RegisterType<FormCars>();
DependencyManager.Instance.RegisterType<FormReportCarComponents>();
DependencyManager.Instance.RegisterType<FormReportOrder>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMails>();
2024-06-22 22:30:26 +04:00
}
2024-06-22 22:32:20 +04:00
}
2024-04-17 10:13:26 +04:00
}