2024-05-16 18:05:13 +04:00
|
|
|
|
using DinerContracts.BindingModels;
|
2024-02-24 21:32:11 +04:00
|
|
|
|
using DinerContracts.BusinessLogicsContacts;
|
2024-04-17 20:25:41 +04:00
|
|
|
|
using DinerContracts.BusinessLogicsContracts;
|
2024-05-15 19:47:11 +04:00
|
|
|
|
using DinerContracts.SearchModels;
|
2024-02-24 21:32:11 +04:00
|
|
|
|
using DinerContracts.StoragesContracts;
|
2024-04-03 16:55:56 +04:00
|
|
|
|
using DinerDataBaseImplement.Implements;
|
2024-02-24 21:32:11 +04:00
|
|
|
|
using DineryBusinessLogic.BusinessLogic;
|
2024-05-16 18:05:13 +04:00
|
|
|
|
using DineryBusinessLogic.MailWorker;
|
2024-04-17 20:25:41 +04:00
|
|
|
|
using DineryBusinessLogic.OfficePackage;
|
|
|
|
|
using DineryBusinessLogic.OfficePackage.Implements;
|
2024-02-24 21:32:11 +04:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
|
|
|
|
|
2024-02-01 14:14:03 +04:00
|
|
|
|
namespace DinerView
|
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
2024-02-24 21:32:11 +04:00
|
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
2024-02-01 14:14:03 +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-02-24 21:32:11 +04:00
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
2024-05-16 18:05:13 +04:00
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
|
|
|
|
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 = _serviceProvider.GetService<ILogger>();
|
|
|
|
|
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-24 21:32:11 +04:00
|
|
|
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConfigureServices(ServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddLogging(option =>
|
|
|
|
|
{
|
|
|
|
|
option.SetMinimumLevel(LogLevel.Information);
|
|
|
|
|
option.AddNLog("nlog.config");
|
|
|
|
|
});
|
|
|
|
|
services.AddTransient<IFoodStorage, FoodStorage>();
|
|
|
|
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
2024-05-13 16:49:39 +04:00
|
|
|
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
2024-02-24 21:32:11 +04:00
|
|
|
|
services.AddTransient<ISnackStorage, SnackStorage>();
|
2024-05-01 21:05:07 +04:00
|
|
|
|
services.AddTransient<IClientStorage, ClientStorage>();
|
2024-05-15 19:47:11 +04:00
|
|
|
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
2024-02-24 21:32:11 +04:00
|
|
|
|
|
2024-05-01 21:05:07 +04:00
|
|
|
|
services.AddTransient<IClientLogic, ClientLogic>();
|
2024-02-24 21:32:11 +04:00
|
|
|
|
services.AddTransient<IFoodLogic, FoodLogic>();
|
|
|
|
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
2024-05-13 16:49:39 +04:00
|
|
|
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
2024-02-24 21:32:11 +04:00
|
|
|
|
services.AddTransient<ISnackLogic, SnackLogic>();
|
2024-04-17 20:25:41 +04:00
|
|
|
|
services.AddTransient<IReportLogic, ReportLogic>();
|
2024-05-13 16:49:39 +04:00
|
|
|
|
services.AddTransient<IWorkProcess, WorkModelling>();
|
2024-05-15 19:47:11 +04:00
|
|
|
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
2024-04-17 20:25:41 +04:00
|
|
|
|
|
2024-05-16 18:05:13 +04:00
|
|
|
|
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
|
|
|
|
2024-05-15 19:47:11 +04:00
|
|
|
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
2024-04-17 20:25:41 +04:00
|
|
|
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
2024-02-24 21:32:11 +04:00
|
|
|
|
|
|
|
|
|
services.AddTransient<FormMain>();
|
|
|
|
|
services.AddTransient<FormFood>();
|
|
|
|
|
services.AddTransient<FormFoods>();
|
|
|
|
|
services.AddTransient<FormCreateOrder>();
|
|
|
|
|
services.AddTransient<FormSnack>();
|
|
|
|
|
services.AddTransient<FormSnackFood>();
|
2024-03-02 15:11:38 +04:00
|
|
|
|
services.AddTransient<FormSnacks>();
|
2024-04-17 21:54:16 +04:00
|
|
|
|
services.AddTransient<FormReportSnackFoods>();
|
|
|
|
|
services.AddTransient<FormReportOrders>();
|
2024-05-01 21:05:07 +04:00
|
|
|
|
services.AddTransient<FormClient>();
|
2024-05-13 21:06:39 +04:00
|
|
|
|
services.AddTransient<FormImplementers>();
|
|
|
|
|
services.AddTransient<FormImplementer>();
|
2024-05-16 18:05:13 +04:00
|
|
|
|
services.AddTransient<FormMail>();
|
2024-02-01 14:14:03 +04:00
|
|
|
|
}
|
2024-05-16 18:05:13 +04:00
|
|
|
|
|
|
|
|
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
|
|
|
|
|
|
|
|
|
}
|
2024-02-01 14:14:03 +04:00
|
|
|
|
}
|