2024-05-03 02:48:43 +04:00
|
|
|
|
using MotorPlantContracts.BusinessLogicsContracts;
|
2024-02-09 02:29:42 +04:00
|
|
|
|
using MotorPlantContracts.StoragesContracts;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
2024-02-09 23:17:38 +04:00
|
|
|
|
using MotorPlantBusinessLogic.BusinessLogics;
|
2024-03-09 01:59:54 +04:00
|
|
|
|
using MotorPlantDatabaseImplement.Implements;
|
2024-04-04 10:05:15 +04:00
|
|
|
|
using MotorPlantBusinessLogic.OfficePackage.Implements;
|
|
|
|
|
using MotorPlantBusinessLogic.OfficePackage;
|
|
|
|
|
using MotorPlantBusinessLogic;
|
2024-04-19 12:13:42 +04:00
|
|
|
|
using MotorPlantBusinessLogic.BusinessLogic;
|
2024-05-03 02:48:43 +04:00
|
|
|
|
using MotorPlantBusinessLogic.MailWorker;
|
|
|
|
|
using MotorPlantContracts.BindingModels;
|
2024-05-17 02:50:58 +04:00
|
|
|
|
using MotorPlantContracts.DI;
|
2024-02-09 02:29:42 +04:00
|
|
|
|
|
2024-02-23 17:15:41 +04:00
|
|
|
|
namespace MotorPlantView.Forms
|
2024-02-05 22:51:36 +04:00
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
2024-02-09 02:29:42 +04:00
|
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
2024-02-05 22:51:36 +04:00
|
|
|
|
/// <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-17 02:50:58 +04:00
|
|
|
|
InitDependency();
|
2024-05-03 02:48:43 +04:00
|
|
|
|
try
|
|
|
|
|
{
|
2024-05-17 02:50:58 +04:00
|
|
|
|
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
|
2024-05-03 02:48:43 +04:00
|
|
|
|
mailSender?.MailConfig(new MailConfigBindingModel
|
|
|
|
|
{
|
2024-05-17 02:50:58 +04:00
|
|
|
|
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-05-03 02:48:43 +04:00
|
|
|
|
});
|
2024-05-17 02:50:58 +04:00
|
|
|
|
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
|
2024-05-03 02:48:43 +04:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
2024-05-17 02:50:58 +04:00
|
|
|
|
var logger = DependencyManager.Instance.Resolve<ILogger>();
|
|
|
|
|
logger?.LogError(ex, "Mails Problem");
|
2024-05-03 02:48:43 +04:00
|
|
|
|
}
|
2024-05-17 02:50:58 +04:00
|
|
|
|
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
|
2024-02-09 02:29:42 +04:00
|
|
|
|
}
|
2024-05-17 02:50:58 +04:00
|
|
|
|
private static void InitDependency()
|
2024-02-09 02:29:42 +04:00
|
|
|
|
{
|
2024-05-17 02:50:58 +04:00
|
|
|
|
DependencyManager.InitDependency();
|
|
|
|
|
|
|
|
|
|
DependencyManager.Instance.AddLogging(option =>
|
2024-02-09 02:29:42 +04:00
|
|
|
|
{
|
|
|
|
|
option.SetMinimumLevel(LogLevel.Information);
|
|
|
|
|
option.AddNLog("nlog.config");
|
|
|
|
|
});
|
2024-05-17 02:50:58 +04:00
|
|
|
|
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IEngineLogic, EngineLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
|
2024-02-23 17:15:41 +04:00
|
|
|
|
|
2024-05-17 02:50:58 +04:00
|
|
|
|
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>();
|
2024-02-23 17:15:41 +04:00
|
|
|
|
|
2024-05-17 02:50:58 +04:00
|
|
|
|
DependencyManager.Instance.RegisterType<FormMain>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormComponent>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormComponents>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormCreateOrder>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormEngine>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormEngineComponent>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormEngines>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormReportEngineComponents>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormReportOrders>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormClients>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<ImplementersForm>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<ImplementerForm>();
|
|
|
|
|
DependencyManager.Instance.RegisterType<FormViewMail>();
|
2024-05-03 00:33:06 +04:00
|
|
|
|
}
|
2024-05-17 02:50:58 +04:00
|
|
|
|
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
|
2024-02-05 22:51:36 +04:00
|
|
|
|
}
|
|
|
|
|
}
|