2024-05-06 10:35:20 +04:00
|
|
|
|
using FlowerShopBusinessLogic.BusinessLogic;
|
2024-02-12 17:52:44 +04:00
|
|
|
|
using FlowerShopContracts.BusinessLogicsContracts;
|
|
|
|
|
using FlowerShopContracts.StoragesContracts;
|
2024-03-12 21:47:28 +04:00
|
|
|
|
using FlowerShopDatabaseImplement.Implements;
|
2024-02-13 21:55:59 +04:00
|
|
|
|
using ProjectFlowerShop;
|
2024-02-12 17:52:44 +04:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Drawing;
|
2024-03-26 20:44:18 +04:00
|
|
|
|
using FlowerShopBusinessLogic;
|
|
|
|
|
using FlowerShopBusinessLogic.OfficePackage.Implements;
|
|
|
|
|
using FlowerShopBusinessLogic.OfficePackage;
|
2024-05-06 10:35:20 +04:00
|
|
|
|
using FlowerShopBusinessLogic.MailWorker;
|
|
|
|
|
using FlowerShopContracts.BindingModels;
|
2024-02-12 17:52:44 +04:00
|
|
|
|
|
2024-02-08 13:26:42 +04:00
|
|
|
|
namespace ProjectFlowerShop
|
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
2024-02-12 17:52:44 +04:00
|
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
2024-02-08 13:26:42 +04:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The main entry point for the application.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[STAThread]
|
|
|
|
|
static void Main()
|
|
|
|
|
{
|
|
|
|
|
ApplicationConfiguration.Initialize();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
2024-05-06 10:35:20 +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"])
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var timer = new System.Threading.Timer(new
|
|
|
|
|
TimerCallback(MailCheck!), null, 0, 100000);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
var logger = _serviceProvider.GetService<ILogger>();
|
2024-05-06 11:51:17 +04:00
|
|
|
|
logger?.LogError(ex, "Ошибка работы с почтой");
|
2024-05-06 10:35:20 +04:00
|
|
|
|
}
|
|
|
|
|
Application.Run(_serviceProvider.GetRequiredService<MainForm>());
|
2024-02-08 13:26:42 +04:00
|
|
|
|
}
|
2024-02-12 17:52:44 +04:00
|
|
|
|
private static void ConfigureServices(ServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
services.AddLogging(option =>
|
|
|
|
|
{
|
|
|
|
|
option.SetMinimumLevel(LogLevel.Information);
|
|
|
|
|
option.AddNLog("nlog.config");
|
|
|
|
|
});
|
|
|
|
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
|
|
|
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
|
|
|
services.AddTransient<IFlowerStorage, FlowerStorage>();
|
2024-04-07 14:27:09 +04:00
|
|
|
|
services.AddTransient<IClientStorage, ClientStorage>();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
|
|
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
|
services.AddTransient<IFlowerLogic, FlowerLogic>();
|
2024-03-26 20:44:18 +04:00
|
|
|
|
services.AddTransient<IReportLogic, ReportLogic>();
|
2024-04-22 20:57:57 +04:00
|
|
|
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
|
|
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
|
|
|
|
services.AddTransient<IClientLogic, ClientLogic>();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
services.AddTransient<MainForm>();
|
2024-04-22 20:57:57 +04:00
|
|
|
|
services.AddTransient<IWorkProcess, WorkProcess>();
|
|
|
|
|
services.AddTransient<MainForm>();
|
|
|
|
|
services.AddTransient<ComponentForm>();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
services.AddTransient<FormComponents>();
|
|
|
|
|
services.AddTransient<FormCreateOrder>();
|
2024-02-28 14:41:07 +04:00
|
|
|
|
services.AddTransient<FormFlower>();
|
2024-02-27 17:21:18 +04:00
|
|
|
|
services.AddTransient<FormFlowerComponent>();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
services.AddTransient<FormFlowers>();
|
2024-04-07 14:10:31 +04:00
|
|
|
|
services.AddTransient<FormClients>();
|
2024-04-22 20:57:57 +04:00
|
|
|
|
services.AddTransient<ImplementersForm>();
|
|
|
|
|
services.AddTransient<ImplementerForm>();
|
|
|
|
|
services.AddTransient<FormReportFlowerComponent>();
|
2024-03-26 20:44:18 +04:00
|
|
|
|
services.AddTransient<FormReportOrders>();
|
2024-05-06 10:35:20 +04:00
|
|
|
|
services.AddTransient<FormViewMail>();
|
|
|
|
|
|
|
|
|
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
2024-03-26 20:44:18 +04:00
|
|
|
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
}
|
2024-05-06 10:35:20 +04:00
|
|
|
|
private static void MailCheck(object obj) =>ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
2024-02-12 17:52:44 +04:00
|
|
|
|
|
2024-05-06 10:35:20 +04:00
|
|
|
|
}
|
2024-02-12 17:52:44 +04:00
|
|
|
|
}
|