100 lines
4.8 KiB
C#
Raw Normal View History

2024-03-22 19:10:17 +03:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using PrecastConcretePlantBusinessLogic.BusinessLogics;
2024-04-05 16:36:10 +03:00
using PrecastConcretePlantBusinessLogic.OfficePackage.Implements;
using PrecastConcretePlantBusinessLogic.OfficePackage;
2024-03-22 19:10:17 +03:00
using PrecastConcretePlantContracts.BusinessLogicsContracts;
using PrecastConcretePlantContracts.StoragesContracts;
2024-04-04 20:21:21 +03:00
using PrecastConcretePlantDatabaseImplement.Implements;
2024-03-22 19:10:17 +03:00
using System;
2024-05-02 19:47:10 +03:00
using ComputersShopBusinessLogic.BusinessLogics;
2024-05-03 00:02:06 +03:00
using PrecastConcretePlantBusinessLogic.MailWorker;
using PrecastConcretePlantContracts.BindingModels;
2024-03-22 19:10:17 +03:00
namespace PrecastConcretePlantView
{
internal static class Program
{
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <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();
var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
2024-05-03 00:02:06 +03: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"])
});
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>) => <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><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>");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
2024-03-22 19:10:17 +03: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<IReinforcedStorage, ReinforcedStorage>();
2024-04-18 19:50:43 +03:00
services.AddTransient<IClientStorage, ClientStorage>();
2024-05-02 19:47:10 +03:00
services.AddTransient<IImplementerStorage, ImplementerStorage>();
2024-05-03 00:02:06 +03:00
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
2024-03-22 19:10:17 +03:00
2024-05-02 19:47:10 +03:00
services.AddTransient<IComponentLogic, ComponentLogic>();
2024-03-22 19:10:17 +03:00
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IReinforcedLogic, ReinforcedLogic>();
2024-04-05 16:36:10 +03:00
services.AddTransient<IReportLogic, ReportLogic>();
2024-04-18 19:50:43 +03:00
services.AddTransient<IClientLogic, ClientLogic>();
2024-05-02 19:47:10 +03:00
services.AddTransient<IImplementerLogic, ImplementerLogic>();
services.AddTransient<IWorkProcess, WorkModelling>();
2024-05-03 00:02:06 +03:00
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
2024-04-05 16:36:10 +03:00
2024-05-02 19:47:10 +03:00
services.AddTransient<AbstractSaveToWord, SaveToWord>();
2024-04-05 16:36:10 +03:00
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
2024-05-03 00:02:06 +03:00
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
2024-03-22 19:10:17 +03:00
2024-05-03 00:02:06 +03:00
services.AddTransient<FormMain>();
2024-03-22 19:10:17 +03:00
services.AddTransient<FormComponent>();
services.AddTransient<FormComponentS>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormReinforced>();
services.AddTransient<FormReinforcedComponent>();
services.AddTransient<FormReinforcedS>();
2024-04-05 16:36:10 +03:00
services.AddTransient<FormReportReinforcedComponents>();
services.AddTransient<FormReportOrders>();
2024-04-18 19:50:43 +03:00
services.AddTransient<FormClients>();
2024-05-02 19:47:10 +03:00
services.AddTransient<FormImplementerS>();
services.AddTransient<FormImplementer>();
2024-05-03 00:02:06 +03:00
services.AddTransient<FormMail>();
2024-05-02 19:47:10 +03:00
}
2024-05-03 00:02:06 +03:00
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
}
2024-03-22 19:10:17 +03:00
}