PIbd-22_Shabunov_O.A._AutoW.../AutoWorkshopView/Program.cs

89 lines
3.8 KiB
C#
Raw Normal View History

2024-02-21 11:04:46 +04:00
using AutoWorkshopBusinessLogic.BusinessLogics;
2024-04-03 10:26:18 +04:00
using AutoWorkshopBusinessLogic.OfficePackage.Implements;
using AutoWorkshopBusinessLogic.OfficePackage;
2024-02-21 10:36:30 +04:00
using AutoWorkshopContracts.BusinessLogicContracts;
using AutoWorkshopView.Forms;
using Microsoft.Extensions.Logging;
2024-02-21 11:04:46 +04:00
using NLog.Extensions.Logging;
2024-04-16 21:33:18 +04:00
using AutoWorkshopContracts.BusinessLogicsContracts;
2024-04-19 23:46:09 +04:00
using AutoWorkshopBusinessLogic.MailWorker;
using AutoWorkshopContracts.BindingModels;
using AutoWorkshopContracts.DI;
2024-02-21 10:36:30 +04:00
2024-02-20 23:51:24 +04:00
namespace AutoWorkshopView
2024-02-06 22:59:42 +04:00
{
internal static class Program
{
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
InitDependency();
2024-02-21 10:36:30 +04:00
try
{
var MailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-04-19 23:46:09 +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-04-19 23:46:09 +04:00
});
var Timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var Logger = DependencyManager.Instance.Resolve<ILogger>();
2024-04-19 23:46:09 +04:00
Logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
Application.Run(DependencyManager.Instance.Resolve<MainForm>());
}
2024-02-21 10:36:30 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.CheckMailAsync();
2024-04-19 23:46:09 +04:00
private static void InitDependency()
{
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(Option =>
{
Option.SetMinimumLevel(LogLevel.Information);
Option.AddNLog("nlog.config");
});
2024-04-16 21:33:18 +04:00
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IRepairLogic, RepairLogic>();
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-04-03 10:26:18 +04:00
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
2024-03-19 21:18:58 +04:00
DependencyManager.Instance.RegisterType<MainForm>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormRepair>();
DependencyManager.Instance.RegisterType<FormRepairComponent>();
DependencyManager.Instance.RegisterType<FormRepairs>();
DependencyManager.Instance.RegisterType<FormReportRepairComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
}
}
2024-02-20 23:51:24 +04:00
}