DocSpace-client/products/ASC.People/Server/Program.cs

110 lines
4.0 KiB
C#
Raw Normal View History

2020-07-03 11:47:27 +00:00
using System;
2019-11-15 08:47:56 +00:00
using System.Collections.Generic;
using System.IO;
2020-07-03 11:47:27 +00:00
using ASC.Api.Core;
using ASC.Api.Core.Auth;
using ASC.Api.Core.Middleware;
using ASC.Common;
using ASC.Common.Logging;
using ASC.Common.Threading.Progress;
using ASC.Common.Threading.Workers;
using ASC.Data.Reassigns;
using ASC.Employee.Core.Controllers;
using ASC.Web.Core.Users;
using Microsoft.AspNetCore.Authentication;
2019-05-15 14:56:09 +00:00
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
2020-07-03 11:47:27 +00:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
2019-05-15 14:56:09 +00:00
namespace ASC.People
{
public class Program
{
public static void Main(string[] args)
2019-10-21 12:33:02 +00:00
{
CreateHostBuilder(args).Build().Run();
2019-05-15 14:56:09 +00:00
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
2020-02-17 08:58:14 +00:00
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
2019-08-15 12:04:42 +00:00
.ConfigureAppConfiguration((hostingContext, config) =>
{
var buided = config.Build();
var path = buided["pathToConf"];
if (!Path.IsPathRooted(path))
{
path = Path.GetFullPath(Path.Combine(hostingContext.HostingEnvironment.ContentRootPath, path));
}
config.SetBasePath(path);
config
2019-11-15 08:47:56 +00:00
.AddInMemoryCollection(new Dictionary<string, string>
{
{"pathToConf", path}
})
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
.AddJsonFile("storage.json")
2019-08-23 12:49:23 +00:00
.AddJsonFile("kafka.json")
2019-11-14 09:21:15 +00:00
.AddJsonFile($"kafka.{hostingContext.HostingEnvironment.EnvironmentName}.json", true)
2020-06-04 13:26:31 +00:00
.AddEnvironmentVariables()
.AddCommandLine(args);
2020-07-03 11:47:27 +00:00
}).ConfigureServices((hostContext, services)=>
{
services.AddAuthentication("cookie")
.AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a => { })
.AddScheme<AuthenticationSchemeOptions, ConfirmAuthHandler>("confirm", a => { });
var diHelper = new DIHelper(services);
diHelper
.AddConfirmAuthHandler()
.AddCookieAuthHandler()
.AddCultureMiddleware()
.AddIpSecurityFilter()
.AddPaymentFilter()
.AddProductSecurityFilter()
.AddTenantStatusFilter();
diHelper.Configure<WorkerQueue<ResizeWorkerItem>>(r =>
{
r.workerCount = 2;
r.waitInterval = (int)TimeSpan.FromSeconds(30).TotalMilliseconds;
r.errorCount = 1;
r.stopAfterFinsih = true;
});
diHelper.Configure<ProgressQueue<ReassignProgressItem>>(r =>
{
r.workerCount = 1;
r.waitInterval = (int)TimeSpan.FromMinutes(5).TotalMilliseconds;
r.removeAfterCompleted = true;
r.stopAfterFinsih = false;
r.errorCount = 0;
});
diHelper.Configure<ProgressQueue<RemoveProgressItem>>(r =>
{
r.workerCount = 1;
r.waitInterval = (int)TimeSpan.FromMinutes(5).TotalMilliseconds;
r.removeAfterCompleted = true;
r.stopAfterFinsih = false;
r.errorCount = 0;
});
diHelper.AddNLogManager("ASC.Api", "ASC.Web");
diHelper
.AddPeopleController()
.AddGroupController();
})
;
2019-05-15 14:56:09 +00:00
}
}