74 lines
2.9 KiB
C#
74 lines
2.9 KiB
C#
using BusinessLogic.BusinessLogic;
|
|
using BusinessLogic.MailWorker;
|
|
using BusinessLogic.OfficePackage;
|
|
using BusinessLogic.OfficePackage.Implements;
|
|
using Contracts.BusinessLogicsContracts;
|
|
using Contracts.StoragesContracts;
|
|
using DatabaseImplement.Implements;
|
|
using ImplementerApp;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
builder.Services.AddControllersWithViews().AddRazorRuntimeCompilation();
|
|
|
|
builder.Logging.SetMinimumLevel(LogLevel.Trace);
|
|
builder.Logging.AddLog4Net("log4net.config");
|
|
|
|
builder.Services.AddTransient<IImplementerStorage, ImplementerStorage>();
|
|
builder.Services.AddTransient<IDetailStorage, DetailStorage>();
|
|
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
|
builder.Services.AddTransient<IProductionStorage, ProductionStorage>();
|
|
builder.Services.AddTransient<IMachineStorage, MachineStorage>();
|
|
builder.Services.AddTransient<IWorkshopStorage, WorkshopStorage>();
|
|
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
|
builder.Services.AddTransient<IImplementerReportLogic, ImplementerReportLogic>();
|
|
builder.Services.AddTransient<IDetailLogic, DetailLogic>();
|
|
builder.Services.AddTransient<IProductionLogic, ProductionLogic>();
|
|
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
|
builder.Services.AddTransient<IMachineLogic, MachineLogic>();
|
|
builder.Services.AddTransient<IWorkshopLogic, WorkshopLogic>();
|
|
builder.Services.AddTransient<AbstractSaveToExcelImplementer, SaveToExcelImplementer>();
|
|
builder.Services.AddTransient<AbstractSaveToWordImplementer, SaveToWordImplementer>();
|
|
builder.Services.AddTransient<AbstractSaveToPdfImplementer, SaveToPdfImplementer>();
|
|
builder.Services.AddSingleton<AbstractMailWorker, MailKitWorker>();
|
|
builder.Services.AddTransient<ImplementerData>();
|
|
|
|
builder.Services.AddSession(options =>
|
|
{
|
|
options.IdleTimeout = TimeSpan.FromMinutes(30);
|
|
options.Cookie.HttpOnly = true;
|
|
options.Cookie.IsEssential = true;
|
|
});
|
|
|
|
var app = builder.Build();
|
|
|
|
var mailSender = app.Services.GetService<AbstractMailWorker>();
|
|
mailSender?.MailConfig(new()
|
|
{
|
|
MailLogin = builder.Configuration?.GetSection("MailLogin")?.Value?.ToString() ?? string.Empty,
|
|
MailPassword = builder.Configuration?.GetSection("MailPassword")?.Value?.ToString() ?? string.Empty,
|
|
SmtpClientHost = builder.Configuration?.GetSection("SmtpClientHost")?.Value?.ToString() ?? string.Empty,
|
|
SmtpClientPort = Convert.ToInt32(builder.Configuration?.GetSection("SmtpClientPort")?.Value?.ToString()),
|
|
PopHost = builder.Configuration?.GetSection("PopHost")?.Value?.ToString() ?? string.Empty,
|
|
PopPort = Convert.ToInt32(builder.Configuration?.GetSection("PopPort")?.Value?.ToString())
|
|
|
|
});
|
|
|
|
if (!app.Environment.IsDevelopment())
|
|
{
|
|
app.UseExceptionHandler("/Home/Error");
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
app.UseSession();
|
|
app.UseAuthorization();
|
|
|
|
app.MapControllerRoute(
|
|
name: "default",
|
|
pattern: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
app.Run(); |