131 lines
6.7 KiB
C#
Raw Normal View History

2024-02-01 10:43:41 +04:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using PizzeriaBusinessLogic.BusinessLogics;
2024-04-02 16:35:18 +04:00
using PizzeriaBusinessLogic.MailWorker;
using PizzeriaContracts.BindingModels;
2024-02-01 10:43:41 +04:00
using PizzeriaContracts.BusinessLogicsContracts;
using PizzeriaContracts.StoragesContracts;
2024-03-04 23:06:34 +04:00
using PizzeriaDatabaseImplement.Implements;
2024-02-01 10:43:41 +04:00
using PizzeriaView;
2024-04-03 12:18:51 +04:00
using PizzeriaBusinessLogic.OfficePackage;
2024-03-21 13:21:25 +04:00
using Microsoft.EntityFrameworkCore.Design;
2024-04-03 17:52:29 +04:00
using PizzeriaContracts.DI;
2024-04-03 12:18:51 +04:00
using PizzeriaBusinessLogic.OfficePackage.Implements;
2024-02-01 10:43:41 +04:00
namespace Pizzeria
2024-02-01 01:42:11 +04:00
{
internal static class Program
{
2024-02-01 10:43:41 +04:00
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
2024-02-01 01:42:11 +04:00
/// <summary>
2024-02-01 10:43:41 +04:00
/// The main entry point for the application.
2024-02-01 01:42:11 +04:00
/// </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-04-03 17:52:29 +04:00
InitDependency();
2024-04-02 21:34:50 +04:00
try
{
2024-04-03 17:52:29 +04:00
var mailSender = DependencyManager.Instance.Resolve<AbstractMailWorker>();
2024-04-02 21:34:50 +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-02 16:35:18 +04:00
2024-04-02 21:34:50 +04:00
var timer = new System.Threading.Timer(new TimerCallback(MailCheck!), null, 0, 100000);
}
catch (Exception ex)
{
2024-04-03 17:52:29 +04:00
var logger = DependencyManager.Instance.Resolve<ILogger>();
2024-04-02 21:34:50 +04:00
logger?.LogError(ex, "Mails Problem");
}
2024-04-03 17:52:29 +04:00
Application.Run(DependencyManager.Instance.Resolve<FormMain>());
2024-02-01 10:43:41 +04:00
}
2024-04-03 17:52:29 +04:00
private static void InitDependency()
2024-02-01 10:43:41 +04:00
{
2024-04-03 17:52:29 +04:00
DependencyManager.InitDependency();
DependencyManager.Instance.AddLogging(option =>
2024-02-01 10:43:41 +04:00
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
2024-04-03 17:52:29 +04:00
DependencyManager.Instance.RegisterType<IClientLogic, ClientLogic>();
DependencyManager.Instance.RegisterType<IComponentLogic, ComponentLogic>();
DependencyManager.Instance.RegisterType<IOrderLogic, OrderLogic>();
DependencyManager.Instance.RegisterType<IPizzaLogic, PizzaLogic>();
DependencyManager.Instance.RegisterType<IReportLogic, ReportLogic>();
DependencyManager.Instance.RegisterType<IImplementerLogic, ImplementerLogic>();
DependencyManager.Instance.RegisterType<IMessageInfoLogic, MessageInfoLogic>();
DependencyManager.Instance.RegisterType<IBackUpLogic, BackUpLogic>();
2024-03-15 00:47:16 +04:00
2024-04-03 17:52:29 +04:00
DependencyManager.Instance.RegisterType<AbstractSaveToWord, SaveToWord>();
DependencyManager.Instance.RegisterType<AbstractSaveToExcel, SaveToExcel>();
DependencyManager.Instance.RegisterType<AbstractSaveToPdf, SaveToPdf>();
DependencyManager.Instance.RegisterType<AbstractMailWorker, MailKitWorker>(true);
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
2024-04-03 12:18:51 +04:00
services.AddTransient<IShopStorage, ShopStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IComponentLogic, ComponentLogic>();
2024-04-03 12:18:51 +04:00
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IPizzaLogic, PizzaLogic>();
services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
services.AddTransient<IWorkProcess, WorkModeling>();
services.AddTransient<IShopLogic, ShopLogic>();
2024-03-15 00:47:16 +04:00
2024-04-03 17:52:29 +04:00
DependencyManager.Instance.RegisterType<IWorkProcess, WorkModeling>();
2024-03-15 00:47:16 +04:00
2024-04-03 17:52:29 +04:00
DependencyManager.Instance.RegisterType<FormMain>();
DependencyManager.Instance.RegisterType<FormComponent>();
DependencyManager.Instance.RegisterType<FormComponents>();
DependencyManager.Instance.RegisterType<FormCreateOrder>();
DependencyManager.Instance.RegisterType<FormPizza>();
DependencyManager.Instance.RegisterType<FormPizzaComponent>();
DependencyManager.Instance.RegisterType<FormPizzas>();
DependencyManager.Instance.RegisterType<FormReportOrders>();
DependencyManager.Instance.RegisterType<FormReportPizzaComponents>();
DependencyManager.Instance.RegisterType<FormClients>();
DependencyManager.Instance.RegisterType<FormImplementers>();
DependencyManager.Instance.RegisterType<FormImplementer>();
DependencyManager.Instance.RegisterType<FormMail>();
services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormPizza>();
services.AddTransient<FormPizzaComponent>();
services.AddTransient<FormPizzas>();
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormCreateSupply>();
services.AddTransient<FormSellPizza>();
2024-04-03 12:18:51 +04:00
services.AddTransient<FormMain>();
services.AddTransient<FormReportPizzaComponents>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormClients>();
services.AddTransient<EntityFrameworkDesignServicesBuilder>();
2024-04-03 12:18:51 +04:00
services.AddTransient<FormReportShop>();
services.AddTransient<FormReportGroupedOrders>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
services.AddTransient<FormMail>();
2024-04-03 12:18:51 +04:00
services.AddTransient<FormLetter>();
2024-03-22 10:07:28 +04:00
}
2024-04-02 16:35:18 +04:00
2024-04-03 17:52:29 +04:00
private static void MailCheck(object obj) => DependencyManager.Instance.Resolve<AbstractMailWorker>()?.MailCheck();
2024-02-01 01:42:11 +04:00
}
}