PIbd-21_RazubaevSM_Plumbing.../PlumbingRepair/PlumbingRepairView/Program.cs

89 lines
3.8 KiB
C#
Raw Normal View History

2024-03-23 11:06:35 +04:00
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using PlumbingRepairBusinessLogic.BusinessLogics;
using PlumbingRepairContracts.BusinessLogicsContracts;
2024-04-12 19:30:31 +04:00
using PlumbingRepairBusinessLogic.OfficePackage;
using PlumbingRepairBusinessLogic.OfficePackage.Implements;
2024-05-02 22:08:35 +04:00
using PlumbingRepairBusinessLogic.MailWorker;
using PlumbingRepairContracts.BindingModels;
2024-05-16 17:00:28 +04:00
using PlumbingRepairContracts.DI;
2024-03-23 11:06:35 +04:00
2024-03-23 10:39:41 +04:00
namespace PlumbingRepairView
{
internal static class Program
{
2024-03-23 11:06:35 +04:00
2024-03-23 10:39:41 +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-16 17:00:28 +04:00
InitDependency();
2024-05-02 22:08:35 +04:00
try
{
2024-05-16 17:00:28 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-05-02 22:08:35 +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-03-23 11:06:35 +04:00
2024-05-02 22:08:35 +04:00
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
2024-05-16 17:00:28 +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-05-02 22:08:35 +04:00
}
2024-05-16 17:00:28 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-05-02 22:08:35 +04:00
}
2024-05-16 17:00:28 +04:00
private static void InitDependency()
{
DependencyManager.InitDependency();
2024-03-23 11:06:35 +04:00
2024-05-16 17:00:28 +04:00
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
2024-05-02 22:08:35 +04:00
2024-05-16 17:00:28 +04:00
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormWork>();
2024-05-16 19:02:46 +04:00
DependencyManager.Instance.RegisterType<FormWorkComponent>();
2024-05-16 17:00:28 +04:00
DependencyManager.Instance.RegisterType<FormWorks>();
2024-05-16 18:30:57 +04:00
DependencyManager.Instance.RegisterType<FormReportShopWorks>();
2024-05-16 17:00:28 +04:00
DependencyManager.Instance.RegisterType<FormReportWorkComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
2024-05-16 18:30:57 +04:00
DependencyManager.Instance.RegisterType<FormMail>();
2024-05-16 17:00:28 +04:00
DependencyManager.Instance.RegisterType<FormMails>();
2024-05-16 19:02:46 +04:00
DependencyManager.Instance.RegisterType<FormShops>();
DependencyManager.Instance.RegisterType<FormShop>();
2024-06-17 21:05:03 +04:00
DependencyManager.Instance.RegisterType<FormStoreReplenishment>();
2024-05-16 19:02:46 +04:00
2024-05-16 18:30:57 +04:00
2024-05-02 22:08:35 +04:00
}
2024-05-16 17:00:28 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
}
}