2024-02-06 23:13:36 +04:00
|
|
|
|
using FishFactory.Forms;
|
|
|
|
|
using FishFactoryContracts.BusinessLogicsContracts;
|
|
|
|
|
using FishFactoryBusinessLogic.BusinessLogic;
|
|
|
|
|
using FishFactoryContracts.StoragesContracts;
|
2024-05-12 12:56:51 +04:00
|
|
|
|
using FishFactoryDatabaseImplement.Implements;
|
2024-02-06 23:13:36 +04:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
2024-04-10 19:04:19 +04:00
|
|
|
|
using FishFactoryBusinessLogic.OfficePackage;
|
|
|
|
|
using FishFactoryBusinessLogic.OfficePackage.Implements;
|
2024-05-13 23:46:59 +04:00
|
|
|
|
using FishFactoryBusinessLogic.MailWorker;
|
|
|
|
|
using FishFactoryContracts.BindingModels;
|
2024-02-06 23:13:36 +04:00
|
|
|
|
|
2024-02-05 19:09:54 +04:00
|
|
|
|
namespace FishFactory
|
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
2024-02-06 23:13:36 +04:00
|
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
2024-02-05 19:09:54 +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-06 23:13:36 +04:00
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
|
|
|
|
|
2024-05-15 00:53:41 +04:00
|
|
|
|
var mailSender = _serviceProvider.GetService<AbstractMailWorker>();
|
|
|
|
|
try
|
2024-05-13 23:46:59 +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"])
|
|
|
|
|
});
|
|
|
|
|
// <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-06 23:13:36 +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<IComponentStorage, ComponentStorage>();
|
|
|
|
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
|
|
|
|
services.AddTransient<ICannedStorage, CannedStorage>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
services.AddTransient<IClientStorage, ClientStorage>();
|
2024-05-13 22:15:56 +04:00
|
|
|
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
2024-05-13 23:46:59 +04:00
|
|
|
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
|
2024-02-06 23:13:36 +04:00
|
|
|
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
|
|
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
|
services.AddTransient<ICannedLogic, CannedLogic>();
|
2024-05-13 22:15:56 +04:00
|
|
|
|
services.AddTransient<IClientLogic, ClientLogic>();
|
|
|
|
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
2024-05-13 23:46:59 +04:00
|
|
|
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
|
|
|
|
|
2024-04-03 11:13:23 +04:00
|
|
|
|
services.AddTransient<IReportLogic, ReportLogic>();
|
2024-05-13 22:15:56 +04:00
|
|
|
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
2024-05-13 23:46:59 +04:00
|
|
|
|
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
|
2024-04-10 19:04:19 +04:00
|
|
|
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
|
|
|
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
|
2024-02-06 23:13:36 +04:00
|
|
|
|
services.AddTransient<FormMain>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
services.AddTransient<FormCanneds>();
|
2024-02-06 23:13:36 +04:00
|
|
|
|
services.AddTransient<FormComponents>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
services.AddTransient<FormClients>();
|
2024-05-13 22:15:56 +04:00
|
|
|
|
services.AddTransient<FormImplementers>();
|
2024-05-13 23:46:59 +04:00
|
|
|
|
services.AddTransient<FormMails>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
|
2024-02-06 23:13:36 +04:00
|
|
|
|
services.AddTransient<FormCanned>();
|
2024-05-12 12:56:51 +04:00
|
|
|
|
services.AddTransient<FormComponent>();
|
2024-05-13 22:15:56 +04:00
|
|
|
|
services.AddTransient<FormImplementer>();
|
|
|
|
|
|
2024-05-12 12:56:51 +04:00
|
|
|
|
services.AddTransient<FormCreateOrder>();
|
2024-02-06 23:13:36 +04:00
|
|
|
|
services.AddTransient<FormCannedComponent>();
|
2024-04-03 11:13:23 +04:00
|
|
|
|
services.AddTransient<FormReportOrders>();
|
|
|
|
|
services.AddTransient<FormReportCannedComponents>();
|
2024-02-05 19:09:54 +04:00
|
|
|
|
}
|
2024-05-13 23:46:59 +04:00
|
|
|
|
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
2024-02-05 19:09:54 +04:00
|
|
|
|
}
|
|
|
|
|
}
|