PIbd-22_Kamcharova_K.A_Reno.../RenovationWork/Program.cs

99 lines
4.3 KiB
C#
Raw Normal View History

2024-06-22 15:58:51 +04:00
using RenovationWorkBusinessLogic.MailWorker;
using RenovationWorkContracts.BindingModels;
2024-04-17 09:22:08 +04:00
using RenovationWorkBusinessLogic.BusinessLogics;
2024-05-25 21:23:11 +04:00
using RenovationWorkBusinessLogic.OfficePackage.Implements;
using RenovationWorkBusinessLogic.OfficePackage;
2024-04-17 09:22:08 +04:00
using RenovationWorkContracts.BusinessLogicsContracts;
using RenovationWorkContracts.StoragesContracts;
2024-04-17 09:29:02 +04:00
using RenovationWorkDatabaseImplement.Implements;
2024-04-17 09:22:08 +04:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2024-06-22 16:00:21 +04:00
using RenovationWorkContracts.DI;
2024-05-25 21:25:00 +04:00
using System;
2024-04-17 09:25:01 +04:00
2024-04-17 09:22:08 +04:00
namespace RenovationWorkView
{
2024-06-22 15:58:51 +04:00
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <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-06-22 16:00:21 +04:00
InitDependency();
2024-06-22 15:58:51 +04:00
try
{
2024-06-22 16:00:21 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-06-22 15:58:51 +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"])
});
var timer = new System.Threading.Timer(new
TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
2024-06-22 16:00:21 +04:00
var logger = DependencyManager.Instance.Resolve<ILogger>();
2024-06-22 15:58:51 +04:00
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
2024-06-22 16:00:21 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-06-22 15:58:51 +04:00
}
2024-06-22 16:00:21 +04:00
private static void InitDependency()
{
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
2024-04-17 09:22:08 +04:00
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
2024-06-22 16:00:21 +04:00
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IRepairLogic, RepairLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
DependencyManager.Instance.RegisterType<FormMain>();
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<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormReportRepairComponents>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
2024-06-22 15:58:51 +04:00
}
2024-06-22 16:00:21 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-06-22 15:58:51 +04:00
}
2024-04-17 09:22:08 +04:00
}