PIbd-23_Starostin_I.K._Ship.../ShipyardView/Program.cs

91 lines
4.1 KiB
C#
Raw Normal View History

2024-04-27 18:23:55 +04:00
using Microsoft.Extensions.DependencyInjection;
using ShipyardBusinessLogic.BusinessLogics;
using ShipyardContracts.BusinessLogicsContracts;
using ShipyardContracts.StoragesContracts;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
using ShipyardBusinessLogic;
2024-04-27 19:25:06 +04:00
using ShipyardDatabaseImplement.Implements;
2024-06-02 16:47:06 +04:00
using ShipyardContracts.BusinessLogicContracts;
using ShipyardBusinessLogic.OfficePackage.Implements;
using ShipyardBusinessLogic.OfficePackage;
2024-06-02 17:22:09 +04:00
using ShipyardContracts.StorageContracts;
using ShipyardDatabaseImplement;
2024-06-02 18:36:35 +04:00
using ShipyardContracts.BindingModels;
2024-06-21 21:44:27 +04:00
using ShipyardBusinessLogic.MailWorker;
using ShipyardContracts.DI;
2024-04-27 18:23:55 +04:00
namespace ShipyardView
{
2024-06-21 21:44:27 +04:00
internal static class Program
{
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
var services = new ServiceCollection();
InitDependency();
2024-06-02 18:36:35 +04:00
try
{
2024-06-21 21:44:27 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-06-02 18:36:35 +04:00
mailSender?.MailConfig(new MailConfigBindingModel
{
2024-06-21 21:44:27 +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-06-02 18:36:35 +04:00
});
2024-06-21 21:44:27 +04:00
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
2024-06-02 18:36:35 +04:00
}
catch (Exception ex)
{
2024-06-21 21:44:27 +04:00
var logger = DependencyManager.Instance.Resolve<ILogger>();
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
2024-06-02 18:36:35 +04:00
}
2024-06-21 21:44:27 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-06-02 17:22:09 +04:00
}
2024-06-21 21:44:27 +04:00
private static void InitDependency()
{
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IShipLogic, ShipLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<ImplementerForm>();
DependencyManager.Instance.RegisterType<ImplementersForm>();
DependencyManager.Instance.RegisterType<ClientsForm>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormShip>();
DependencyManager.Instance.RegisterType<FormShipComponent>();
DependencyManager.Instance.RegisterType<FormShips>();
DependencyManager.Instance.RegisterType<FormReportShipComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<ViewMailForm>();
}
private static void MailCheck(object obj) =>
DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-06-02 18:36:35 +04:00
}
2024-04-27 18:23:55 +04:00
}