2024-02-06 12:37:25 +04:00
|
|
|
|
using GiftShopBusinessLogic.BusinessLogics;
|
2024-04-07 10:17:23 +04:00
|
|
|
|
using GiftShopBusinessLogic.OfficePackage.Implements;
|
|
|
|
|
using GiftShopBusinessLogic.OfficePackage;
|
2024-02-06 12:37:25 +04:00
|
|
|
|
using GiftShopContracts.BusinessLogicsContracts;
|
|
|
|
|
using GiftShopContracts.StoragesContracts;
|
2024-04-07 10:15:40 +04:00
|
|
|
|
using GiftShopDatabaseImplement.Implements;
|
2024-02-06 12:37:25 +04:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
2024-05-16 10:17:58 +04:00
|
|
|
|
using GiftShopBusinessLogic.MailWorker;
|
|
|
|
|
using GiftShopContracts.BindingModels;
|
2024-02-06 12:37:25 +04:00
|
|
|
|
|
|
|
|
|
namespace GiftShopView
|
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
|
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
|
|
|
|
[STAThread]
|
|
|
|
|
static void Main()
|
|
|
|
|
{
|
|
|
|
|
ApplicationConfiguration.Initialize();
|
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
2024-05-16 10:17:58 +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>();
|
|
|
|
|
logger?.LogError(ex, "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
2024-02-06 12:37:25 +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<IGiftStorage, GiftStorage>();
|
2024-04-09 17:02:29 +04:00
|
|
|
|
services.AddTransient<IClientStorage, ClientStorage>();
|
2024-05-16 10:17:58 +04:00
|
|
|
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
|
|
|
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
|
|
|
|
|
|
|
|
|
services.AddTransient<IClientLogic, ClientLogic>();
|
2024-02-06 12:37:25 +04:00
|
|
|
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
|
|
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
|
services.AddTransient<IGiftLogic, GiftLogic>();
|
2024-04-07 10:17:23 +04:00
|
|
|
|
services.AddTransient<IReportLogic, ReportLogic>();
|
2024-05-16 10:17:58 +04:00
|
|
|
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
|
|
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
|
|
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
|
|
|
|
|
|
|
|
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
2024-04-07 10:17:23 +04:00
|
|
|
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
2024-05-16 10:17:58 +04:00
|
|
|
|
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
2024-04-07 10:17:23 +04:00
|
|
|
|
|
2024-05-16 10:17:58 +04:00
|
|
|
|
services.AddTransient<FormMain>();
|
2024-02-06 12:37:25 +04:00
|
|
|
|
services.AddTransient<FormComponent>();
|
|
|
|
|
services.AddTransient<FormComponents>();
|
|
|
|
|
services.AddTransient<FormCreateOrder>();
|
|
|
|
|
services.AddTransient<FormGift>();
|
|
|
|
|
services.AddTransient<FormGiftComponent>();
|
|
|
|
|
services.AddTransient<FormGifts>();
|
2024-04-07 10:17:23 +04:00
|
|
|
|
services.AddTransient<FormReportOrders>();
|
|
|
|
|
services.AddTransient<FormReportGiftComponents>();
|
2024-04-09 17:02:29 +04:00
|
|
|
|
services.AddTransient<FormClients>();
|
2024-05-16 10:17:58 +04:00
|
|
|
|
services.AddTransient<FormImplementer>();
|
|
|
|
|
services.AddTransient<FormImplementers>();
|
|
|
|
|
services.AddTransient<FormMails>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
|
|
|
|
}
|
2024-02-06 12:37:25 +04:00
|
|
|
|
}
|