2021-03-21 02:13:08 +08:00
|
|
|
|
using Autofac.Extensions.DependencyInjection;
|
2021-03-20 21:56:15 +08:00
|
|
|
|
using CC.Yi.DAL;
|
2021-03-20 14:12:24 +08:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2021-03-20 21:56:15 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2021-03-20 14:12:24 +08:00
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-03-23 13:58:44 +08:00
|
|
|
|
using NLog.Web;
|
2021-03-20 14:12:24 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CC.Yi.API
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2021-03-23 13:58:44 +08:00
|
|
|
|
var logger = NLog.Web.NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
|
|
|
|
|
|
try
|
2021-03-20 21:56:15 +08:00
|
|
|
|
{
|
2021-03-23 13:58:44 +08:00
|
|
|
|
logger.Debug("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Yi<59><69><EFBFBD><EFBFBD><EFBFBD>ܡ<EFBFBD><DCA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
|
var host = CreateHostBuilder(args).Build();
|
|
|
|
|
|
var scope = host.Services.CreateScope();
|
2021-03-20 21:56:15 +08:00
|
|
|
|
var services = scope.ServiceProvider;
|
2021-03-23 13:58:44 +08:00
|
|
|
|
var context = services.GetRequiredService<Model.DataContext>();//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|
|
|
|
|
DbContentFactory.Initialize(context);//<2F><><EFBFBD>þ<EFBFBD>̬<EFBFBD><EFBFBD><E0B7BD>ע<EFBFBD><D7A2>
|
|
|
|
|
|
host.Run();
|
|
|
|
|
|
logger.Info("Yi<59><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD>");
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
//NLog: catch setup errors
|
|
|
|
|
|
logger.Error(exception, "Stopped program because of exception");
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
finally
|
|
|
|
|
|
{
|
|
|
|
|
|
// Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
|
|
|
|
|
|
NLog.LogManager.Shutdown();
|
2021-03-20 21:56:15 +08:00
|
|
|
|
}
|
2021-03-23 13:58:44 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-03-20 14:12:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
|
|
|
|
|
Host.CreateDefaultBuilder(args)
|
|
|
|
|
|
.ConfigureWebHostDefaults(webBuilder =>
|
|
|
|
|
|
{
|
|
|
|
|
|
webBuilder.UseStartup<Startup>();
|
2021-03-23 13:58:44 +08:00
|
|
|
|
}).UseServiceProviderFactory(new AutofacServiceProviderFactory())
|
|
|
|
|
|
.ConfigureLogging(logging =>
|
|
|
|
|
|
{
|
|
|
|
|
|
// logging.ClearProviders(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF><EFBFBD>̨<EFBFBD><CCA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
logging.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace);
|
|
|
|
|
|
}).UseNLog();
|
|
|
|
|
|
|
2021-03-20 14:12:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|