|
|
|
@ -23,8 +23,7 @@ namespace test
|
|
|
|
public static IConfiguration Configuration { get; set; }
|
|
|
|
public static IConfiguration Configuration { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public static string HostingFullName { get; private set; }
|
|
|
|
public static string HostingFullName { get; private set; }
|
|
|
|
public static DbConnectionSettings DevDbSettings { get; private set; }
|
|
|
|
public static DbConnectionSettings DbSettings { get; private set; }
|
|
|
|
public static DbConnectionSettings TestDbSettings { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ILogger logger;
|
|
|
|
ILogger logger;
|
|
|
|
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
|
|
|
public Startup(IHostingEnvironment env, IApplicationEnvironment appEnv)
|
|
|
|
@ -50,11 +49,8 @@ namespace test
|
|
|
|
services.Configure<SiteSettings>(siteSettingsconf);
|
|
|
|
services.Configure<SiteSettings>(siteSettingsconf);
|
|
|
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
|
|
|
var smtpSettingsconf = Configuration.GetSection("Smtp");
|
|
|
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
|
|
|
services.Configure<SmtpSettings>(smtpSettingsconf);
|
|
|
|
var devCx = Configuration.GetSection("Data:DevConnection");
|
|
|
|
var dbSettingsconf = Configuration.GetSection("ConnectionStrings");
|
|
|
|
services.Configure<DevConnectionSettings>(devCx);
|
|
|
|
services.Configure<DbConnectionSettings>(dbSettingsconf);
|
|
|
|
var testCx = Configuration.GetSection("Data:TestConnection");
|
|
|
|
|
|
|
|
services.Configure<TestConnectionSettings>(testCx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
|
|
|
|
services.AddInstance(typeof(ILoggerFactory), new LoggerFactory());
|
|
|
|
services.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
|
|
|
services.AddTransient(typeof(IEmailSender), typeof(MailSender));
|
|
|
|
@ -70,7 +66,7 @@ namespace test
|
|
|
|
services.AddEntityFramework()
|
|
|
|
services.AddEntityFramework()
|
|
|
|
.AddNpgsql()
|
|
|
|
.AddNpgsql()
|
|
|
|
.AddDbContext<ApplicationDbContext>(
|
|
|
|
.AddDbContext<ApplicationDbContext>(
|
|
|
|
db => db.UseNpgsql(Startup.TestDbSettings.ConnectionString)
|
|
|
|
db => db.UseNpgsql(Startup.DbSettings.Default)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
|
|
|
services.AddTransient<Microsoft.Extensions.WebEncoders.UrlEncoder, UrlEncoder>();
|
|
|
|
@ -79,8 +75,7 @@ namespace test
|
|
|
|
|
|
|
|
|
|
|
|
public void Configure (IApplicationBuilder app, IHostingEnvironment env,
|
|
|
|
public void Configure (IApplicationBuilder app, IHostingEnvironment env,
|
|
|
|
IOptions<SiteSettings> siteSettings,
|
|
|
|
IOptions<SiteSettings> siteSettings,
|
|
|
|
IOptions<TestConnectionSettings> testCxOptions,
|
|
|
|
IOptions<DbConnectionSettings> cxOptions,
|
|
|
|
IOptions<DevConnectionSettings> devCxOptions,
|
|
|
|
|
|
|
|
ILoggerFactory loggerFactory)
|
|
|
|
ILoggerFactory loggerFactory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|
|
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|
|
|
@ -88,10 +83,10 @@ namespace test
|
|
|
|
logger = loggerFactory.CreateLogger<Startup>();
|
|
|
|
logger = loggerFactory.CreateLogger<Startup>();
|
|
|
|
logger.LogInformation(env.EnvironmentName);
|
|
|
|
logger.LogInformation(env.EnvironmentName);
|
|
|
|
|
|
|
|
|
|
|
|
TestDbSettings = testCxOptions.Value;
|
|
|
|
DbSettings = cxOptions.Value;
|
|
|
|
DevDbSettings = devCxOptions.Value;
|
|
|
|
logger.LogInformation($"default db : {DbSettings.Default}");
|
|
|
|
logger.LogInformation($"test db : {TestDbSettings.ConnectionString}");
|
|
|
|
logger.LogInformation($"test db : {DbSettings.Testing}");
|
|
|
|
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", TestDbSettings.ConnectionString);
|
|
|
|
AppDomain.CurrentDomain.SetData("YAVSC_DB_CONNECTION", DbSettings.Default);
|
|
|
|
|
|
|
|
|
|
|
|
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
|
|
|
|
var authConf = Configuration.GetSection("Authentication").GetSection("Yavsc");
|
|
|
|
var clientId = authConf.GetSection("ClientId").Value;
|
|
|
|
var clientId = authConf.GetSection("ClientId").Value;
|
|
|
|
|