2017-08-29 11:02:18 +02:00
|
|
|
|
using Microsoft.AspNetCore;
|
2016-09-06 17:09:19 -07:00
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
2017-09-13 14:53:06 +02:00
|
|
|
|
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
|
|
|
|
using Microsoft.eShopOnContainers.Services.Ordering.API.Infrastructure;
|
|
|
|
|
using Microsoft.eShopOnContainers.Services.Ordering.Infrastructure;
|
2017-10-11 16:26:44 +02:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2017-09-13 14:53:06 +02:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2017-08-29 12:03:20 +02:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2017-09-13 14:53:06 +02:00
|
|
|
|
using Microsoft.Extensions.Options;
|
2017-08-29 12:03:20 +02:00
|
|
|
|
using System.IO;
|
2016-09-06 17:09:19 -07:00
|
|
|
|
|
2016-09-07 13:52:26 -07:00
|
|
|
|
namespace Microsoft.eShopOnContainers.Services.Ordering.API
|
2016-09-06 17:09:19 -07:00
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2017-09-13 14:53:06 +02:00
|
|
|
|
BuildWebHost(args)
|
|
|
|
|
.MigrateDbContext<OrderingContext>((context, services) =>
|
|
|
|
|
{
|
|
|
|
|
var env = services.GetService<IHostingEnvironment>();
|
|
|
|
|
var settings = services.GetService<IOptions<OrderingSettings>>();
|
|
|
|
|
var logger = services.GetService<ILogger<OrderingContextSeed>>();
|
|
|
|
|
|
|
|
|
|
new OrderingContextSeed()
|
|
|
|
|
.SeedAsync(context, env, settings, logger)
|
|
|
|
|
.Wait();
|
|
|
|
|
})
|
|
|
|
|
.MigrateDbContext<IntegrationEventLogContext>((_,__)=>{})
|
|
|
|
|
.Run();
|
2017-08-29 11:02:18 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IWebHost BuildWebHost(string[] args) =>
|
2017-10-11 16:26:44 +02:00
|
|
|
|
WebHost.CreateDefaultBuilder(args)
|
2016-12-17 14:41:16 +01:00
|
|
|
|
.UseStartup<Startup>()
|
2017-08-29 12:03:20 +02:00
|
|
|
|
.UseHealthChecks("/hc")
|
|
|
|
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
2017-10-11 16:26:44 +02:00
|
|
|
|
.ConfigureAppConfiguration((builderContext, config) =>
|
|
|
|
|
{
|
|
|
|
|
config.AddJsonFile("settings.json");
|
|
|
|
|
config.AddEnvironmentVariables();
|
|
|
|
|
})
|
2017-08-29 12:03:20 +02:00
|
|
|
|
.ConfigureLogging((hostingContext, builder) =>
|
|
|
|
|
{
|
|
|
|
|
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
|
|
|
|
|
builder.AddConsole();
|
|
|
|
|
builder.AddDebug();
|
|
|
|
|
})
|
2017-10-11 16:26:44 +02:00
|
|
|
|
.UseApplicationInsights()
|
2016-09-06 17:09:19 -07:00
|
|
|
|
.Build();
|
|
|
|
|
}
|
|
|
|
|
}
|