ISEbd-22_Baygulov_A.A._Sush.../SushiBar/SushiBarView/Program.cs

91 lines
4.7 KiB
C#
Raw Normal View History

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SushiBarContracts.BusinessLogicsContracts;
2024-06-01 17:37:58 +04:00
using System;
using SushiBarBusinessLogic.BusinessLogics;
2024-06-01 17:37:58 +04:00
using SushiBarDatabaseImplement.Implements;
using SushiBarContracts.StoragesContracts;
2024-06-01 17:37:58 +04:00
using SushiBarView;
using NLog.Extensions.Logging;
using SushiBarBusinessLogic.OfficePackage.Implements;
using SushiBarBusinessLogic.OfficePackage;
2024-05-03 23:18:28 +04:00
using SushiBarBusinessLogic;
2024-06-01 16:27:44 +04:00
using SushiBarBusinessLogic.MailWorker;
using SushiBarContracts.BindingModels;
2024-06-01 17:37:58 +04:00
using SushiBarContracts.DI;
namespace SushiBarView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary>
2024-03-14 21:54:43 +04:00
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
ApplicationConfiguration.Initialize();
2024-06-01 17:37:58 +04:00
InitDependency();
2024-06-01 16:27:44 +04:00
try
{
2024-06-01 17:37:58 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-06-01 16:27:44 +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-01 17:37:58 +04:00
var logger = DependencyManager.Instance.Resolve<ILogger>();
2024-06-01 16:27:44 +04:00
logger?.LogError(ex, "Mails Problem");
}
2024-06-01 17:37:58 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
}
2024-06-01 17:37:58 +04:00
private static void InitDependency()
{
DependencyManager.InitDependency();
2024-05-22 22:23:36 +04:00
2024-06-01 17:37:58 +04:00
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<ISushiLogic, SushiLogic>();
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<FormSushi>();
DependencyManager.Instance.RegisterType<FormSushiComponent>();
DependencyManager.Instance.RegisterType<FormSushis>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormReportSushiComponents>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
}
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-06-01 16:27:44 +04:00
}
2024-03-14 21:54:43 +04:00
}