ISEbd-21_Agliullov.D.A._Con.../Confectionery/Program.cs

88 lines
3.9 KiB
C#
Raw Normal View History

using ConfectioneryDatabaseImplement.Implements;
using ConfectioneryDatabaseImplement;
using ConfectioneryBusinessLogic.BusinessLogics;
using ConfectioneryContracts.BusinessLogicsContracts;
using ConfectioneryContracts.DI;
using NLog.Extensions.Logging;
2023-03-01 16:42:58 +04:00
using ConfectioneryBusinessLogic;
using ConfectioneryBusinessLogic.OfficePackage.Implements;
using ConfectioneryBusinessLogic.OfficePackage;
2023-03-13 21:33:49 +04:00
using ConfectioneryBusinessLogic.MailWorker;
using ConfectioneryContracts.BindingModels;
using Microsoft.Extensions.Logging;
namespace ConfectioneryView
2023-01-30 06:05:58 +04:00
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
2023-01-30 06:05:58 +04:00
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPIsettings or default font,
2023-01-30 06:05:58 +04:00
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
InitDependency();
2023-03-13 21:33:49 +04:00
try
{
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2023-03-13 21:33:49 +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"])
});
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
var logger = DependencyManager.Instance.Resolve<ILogger>();
2023-03-13 21:33:49 +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<FormMain>());
}
private static void InitDependency()
{
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormPastry>();
DependencyManager.Instance.RegisterType<FormPastryComponent>();
DependencyManager.Instance.RegisterType<FormViewPastry>();
DependencyManager.Instance.RegisterType<FormReportPastryComponents>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormViewClients>();
DependencyManager.Instance.RegisterType<FormViewImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormViewMail>();
DependencyManager.Instance.RegisterType<FormReportShopPastries>();
DependencyManager.Instance.RegisterType<FormReportGroupOrders>();
DependencyManager.Instance.RegisterType<FormShop>();
DependencyManager.Instance.RegisterType<FormViewShops>();
DependencyManager.Instance.RegisterType<FormSellPastry>();
DependencyManager.Instance.RegisterType<FormReplyMail>();
DependencyManager.Instance.RegisterType<FormAddPastryInShop>();
2023-01-30 06:05:58 +04:00
}
2023-03-13 21:33:49 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2023-03-13 21:33:49 +04:00
}
2023-01-30 06:05:58 +04:00
}