111 lines
4.5 KiB
C#
Raw Normal View History

2023-02-13 22:22:24 +04:00
using LawFirmBusinessLogic.BusinessLogics;
2023-03-27 19:39:11 +04:00
using LawFirmBusinessLogic.OfficePackage.Implements;
using LawFirmBusinessLogic.OfficePackage;
2023-02-13 22:22:24 +04:00
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.StoragesContracts;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
2023-03-28 01:05:56 +04:00
using LawFirmDatabaseImplement.Implements;
2023-04-25 00:17:59 +04:00
using LawFirmBusinessLogic.MailWorker;
using LawFirmContracts.BindingModels;
2023-02-13 22:22:24 +04:00
namespace LawFirmView
{
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();
2023-04-25 00:17:59 +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>");
}
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
2023-02-13 22:22:24 +04:00
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddLogging(option =>
{
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
services.AddTransient<IBlankStorage, BlankStorage>();
services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<IDocumentStorage, DocumentStorage>();
2023-03-28 01:05:56 +04:00
services.AddTransient<IClientStorage, ClientStorage>();
2023-04-11 00:22:09 +04:00
services.AddTransient<IImplementerStorage, ImplementerStorage>();
2023-04-25 00:17:59 +04:00
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
2023-02-13 22:22:24 +04:00
2023-04-11 00:22:09 +04:00
services.AddTransient<IBlankLogic, BlankLogic>();
2023-02-13 22:22:24 +04:00
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<IDocumentLogic, DocumentLogic>();
2023-03-27 19:39:11 +04:00
services.AddTransient<IReportLogic, ReportLogic>();
2023-03-28 01:05:56 +04:00
services.AddTransient<IClientLogic, ClientLogic>();
2023-04-11 00:22:09 +04:00
services.AddTransient<IImplementerLogic, ImplementerLogic>();
2023-04-25 00:17:59 +04:00
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
2023-04-11 00:22:09 +04:00
services.AddTransient<IWorkProcess, WorkModeling>();
2023-03-27 19:39:11 +04:00
2023-04-11 00:22:09 +04:00
services.AddTransient<AbstractSaveToWord, SaveToWord>();
2023-03-27 19:39:11 +04:00
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
2023-04-25 00:17:59 +04:00
services.AddTransient<AbstractMailWorker, MailKitWorker>();
2023-02-13 22:22:24 +04:00
2023-04-25 00:17:59 +04:00
services.AddTransient<FormMain>();
2023-02-13 22:22:24 +04:00
services.AddTransient<FormBlank>();
services.AddTransient<FormBlanks>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormDocument>();
services.AddTransient<FormDocumentBlank>();
services.AddTransient<FormDocuments>();
services.AddTransient<FormReportDocumentBlanks>();
services.AddTransient<FormReportOrders>();
2023-03-28 01:05:56 +04:00
services.AddTransient<FormViewClients>();
2023-04-11 00:22:09 +04:00
services.AddTransient<FormViewImplementers>();
services.AddTransient<FormImplementer>();
2023-04-25 00:17:59 +04:00
services.AddTransient<FormMails>();
2023-04-11 00:22:09 +04:00
}
2023-04-25 00:17:59 +04:00
private static void MailCheck(object obj) => ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
}
2023-02-13 22:22:24 +04:00
}