|
|
|
|
using DS.WMS.JobService;
|
|
|
|
|
using DS.Module.HangfireModule;
|
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
|
|
|
|
using Autofac;
|
|
|
|
|
using DS.Module.AutofacModule;
|
|
|
|
|
using DS.Module.SqlSugar;
|
|
|
|
|
using DS.Module.UserModule;
|
|
|
|
|
using DS.Module.RedisModule;
|
|
|
|
|
using Hangfire;
|
|
|
|
|
using DS.WMS.Core.HangfireJob.Interface;
|
|
|
|
|
using DS.WMS.Core.HangfireJob.Method;
|
|
|
|
|
using Microsoft.AspNetCore.Http;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
using NLog.Web;
|
|
|
|
|
|
|
|
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
|
|
|
|
|
|
|
|
builder.Services.AddWindowsService(options =>
|
|
|
|
|
{
|
|
|
|
|
options.ServiceName = ".NET Work Service";
|
|
|
|
|
});
|
|
|
|
|
//ע<><D7A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
builder.Configuration
|
|
|
|
|
.AddJsonFile(path: "appsettings.json", optional: false, reloadOnChange: true)
|
|
|
|
|
.Build();
|
|
|
|
|
builder.Configuration.AddEnvironmentVariables();
|
|
|
|
|
|
|
|
|
|
builder.Logging.AddNLog("nlog.config");
|
|
|
|
|
//Autofacע<63><D7A2>
|
|
|
|
|
builder.ConfigureContainer(new AutofacServiceProviderFactory(), builder => builder.RegisterModule(new AutofacModuleRegister()));
|
|
|
|
|
|
|
|
|
|
//builder.Services.AddTransient<IProblemDetailsWriter, SampleProblemDetailsWriter>();
|
|
|
|
|
//builder.Services.AddExceptionHandler<GlobalExceptionsFilter>(); //ȫ<><C8AB><EFBFBD>쳣
|
|
|
|
|
builder.Services.AddControllers(options =>
|
|
|
|
|
{
|
|
|
|
|
options.Filters.Add<GlobalExceptionsFilter>();
|
|
|
|
|
});
|
|
|
|
|
builder.Services.AddUserModuleInstall(); //<2F>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
builder.Services.AddRedisModuleInstall();//redis
|
|
|
|
|
builder.Services.AddSqlSugarInstall();
|
|
|
|
|
builder.Services.AddSaasDbInstall();//<2F>ֿ<EFBFBD><D6BF><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//ע<><D7A2>hangfire
|
|
|
|
|
builder.Services.AddWorkServiceHangfireModuleInstall();
|
|
|
|
|
//Ӧ<><D3A6><EFBFBD><EFBFBD>Ϊ Windows <20><><EFBFBD><EFBFBD>
|
|
|
|
|
//builder.Services.AddWindowsService();
|
|
|
|
|
builder.Services.AddHostedService<WindowsBackgroundService>();
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD> BackgroundService <20>д<EFBFBD><D0B4><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
|
|
|
|
|
builder.Services.Configure<HostOptions>(hostOptions =>
|
|
|
|
|
{
|
|
|
|
|
hostOptions.BackgroundServiceExceptionBehavior = BackgroundServiceExceptionBehavior.Ignore;
|
|
|
|
|
hostOptions.ServicesStartConcurrently = true;
|
|
|
|
|
hostOptions.ServicesStopConcurrently = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var host = builder.Build();
|
|
|
|
|
|
|
|
|
|
host.Run();
|