2024-05-19 10:10:11 +04:00
|
|
|
|
using SoftwareInstallationContracts.BusinessLogicsContracts;
|
|
|
|
|
using SoftwareInstallationBusinessLogic.BusinessLogic;
|
|
|
|
|
using SoftwareInstallationContracts.StoragesContracts;
|
|
|
|
|
using SoftwareInstallationDatabaseImplement.Implements;
|
2024-04-07 16:54:02 +04:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using NLog.Extensions.Logging;
|
2024-04-07 17:40:43 +04:00
|
|
|
|
using SoftwareInstallationBusinessLogic.OfficePackage.Implements;
|
|
|
|
|
using SoftwareInstallationBusinessLogic.OfficePackage;
|
2024-05-19 10:10:11 +04:00
|
|
|
|
using SoftwareInstallationBusinessLogic.MailWorker;
|
|
|
|
|
using SoftwareInstallationContracts.BindingModels;
|
|
|
|
|
using SoftwareInstallationView;
|
2024-04-07 16:54:02 +04:00
|
|
|
|
|
2024-05-19 10:10:11 +04:00
|
|
|
|
namespace SoftwareInstallation.Forms
|
2024-04-07 16:21:01 +04:00
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
2024-04-07 16:54:02 +04:00
|
|
|
|
private static ServiceProvider? _serviceProvider;
|
|
|
|
|
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
2024-04-07 16:21:01 +04:00
|
|
|
|
/// <summary>
|
2024-04-07 17:05:30 +04:00
|
|
|
|
/// The main entry point for the application.
|
2024-04-07 16:21:01 +04:00
|
|
|
|
/// </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-04-07 16:54:02 +04:00
|
|
|
|
var services = new ServiceCollection();
|
|
|
|
|
ConfigureServices(services);
|
|
|
|
|
_serviceProvider = services.BuildServiceProvider();
|
2024-05-19 10:10:11 +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>");
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 16:54:02 +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<IPackageStorage, PackageStorage>();
|
2024-05-19 10:10:11 +04:00
|
|
|
|
services.AddTransient<IMessageInfoStorage, MessageInfoStorage>();
|
2024-04-07 17:40:43 +04:00
|
|
|
|
|
2024-04-07 16:54:02 +04:00
|
|
|
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
|
|
|
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
|
|
|
|
services.AddTransient<IPackageLogic, PackageLogic>();
|
2024-04-07 17:40:43 +04:00
|
|
|
|
services.AddTransient<IReportLogic, ReportLogic>();
|
2024-05-19 10:10:11 +04:00
|
|
|
|
services.AddTransient<IClientLogic, ClientLogic>();
|
|
|
|
|
services.AddTransient<IClientStorage, ClientStorage>();
|
|
|
|
|
services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
|
|
|
services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
|
|
|
|
services.AddTransient<IWorkProcess, WorkModeling>();
|
|
|
|
|
services.AddTransient<IMessageInfoLogic, MessageInfoLogic>();
|
2024-04-07 17:40:43 +04:00
|
|
|
|
|
2024-04-07 17:05:30 +04:00
|
|
|
|
services.AddTransient<FormMain>();
|
2024-04-07 16:54:02 +04:00
|
|
|
|
services.AddTransient<FormComponent>();
|
|
|
|
|
services.AddTransient<FormComponents>();
|
|
|
|
|
services.AddTransient<FormCreateOrder>();
|
2024-04-07 17:40:43 +04:00
|
|
|
|
services.AddTransient<FormSoftware>();
|
2024-04-07 16:54:02 +04:00
|
|
|
|
services.AddTransient<FormPackageComponent>();
|
2024-04-07 17:40:43 +04:00
|
|
|
|
services.AddTransient<FormSoftwares>();
|
|
|
|
|
services.AddTransient<FormReportSoftwareComponents>();
|
|
|
|
|
services.AddTransient<FormReportOrders>();
|
2024-05-19 10:10:11 +04:00
|
|
|
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
|
|
|
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
|
|
|
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
|
|
|
|
services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
|
|
|
services.AddTransient<FormClients>();
|
|
|
|
|
services.AddTransient<ImplementersForm>();
|
|
|
|
|
services.AddTransient<ImplementerForm>();
|
|
|
|
|
services.AddTransient<FormViewMail>();
|
2024-05-11 21:16:59 +04:00
|
|
|
|
|
2024-05-19 10:10:11 +04:00
|
|
|
|
}
|
|
|
|
|
private static void MailCheck(object obj) =>
|
|
|
|
|
ServiceProvider?.GetService<AbstractMailWorker>()?.MailCheck();
|
|
|
|
|
}
|
2024-04-07 16:21:01 +04:00
|
|
|
|
}
|