mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
98 lines
3.4 KiB
98 lines
3.4 KiB
using System;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Account.Web;
|
|
using Volo.Abp.AspNetCore.Modularity;
|
|
using Volo.Abp.AspNetCore.Mvc.Bundling;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Identity.EntityFrameworkCore;
|
|
using Volo.Abp.Identity.Web;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.Permissions.EntityFrameworkCore;
|
|
|
|
namespace MicroserviceDemo.Web
|
|
{
|
|
[DependsOn(typeof(AbpAutofacModule))]
|
|
[DependsOn(typeof(AbpPermissionsEntityFrameworkCoreModule))]
|
|
[DependsOn(typeof(AbpIdentityHttpApiModule))]
|
|
[DependsOn(typeof(AbpIdentityWebModule))]
|
|
[DependsOn(typeof(AbpIdentityEntityFrameworkCoreModule))]
|
|
[DependsOn(typeof(AbpAccountWebModule))]
|
|
public class MicroservicesDemoWebModule : AbpModule
|
|
{
|
|
public override void PreConfigureServices(IServiceCollection services)
|
|
{
|
|
services.PreConfigure<IMvcBuilder>(builder =>
|
|
{
|
|
builder.AddViewLocalization(); //TODO: To the framework!
|
|
});
|
|
}
|
|
|
|
public override void ConfigureServices(IServiceCollection services)
|
|
{
|
|
var hostingEnvironment = services.GetSingletonInstance<IHostingEnvironment>();
|
|
var configuration = BuildConfiguration(hostingEnvironment);
|
|
|
|
services.Configure<DbConnectionOptions>(configuration);
|
|
|
|
services.Configure<AbpDbContextOptions>(options =>
|
|
{
|
|
options.Configure(context =>
|
|
{
|
|
if (context.ExistingConnection != null)
|
|
{
|
|
context.DbContextOptions.UseSqlServer(context.ExistingConnection);
|
|
}
|
|
else
|
|
{
|
|
context.DbContextOptions.UseSqlServer(context.ConnectionString);
|
|
}
|
|
});
|
|
});
|
|
|
|
services.Configure<BundlingOptions>(options =>
|
|
{
|
|
//TODO: To the framework!
|
|
options.ScriptBundles.Add("GlobalScripts", new[]
|
|
{
|
|
"/Abp/ApplicationConfigurationScript?_v=" + DateTime.Now.Ticks,
|
|
"/Abp/ServiceProxyScript?_v=" + DateTime.Now.Ticks
|
|
});
|
|
});
|
|
|
|
services.AddAssemblyOf<MicroservicesDemoWebModule>();
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
|
|
if (context.GetEnvironment().IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
app.UseVirtualFiles();
|
|
|
|
app.UseMvcWithDefaultRoute();
|
|
}
|
|
|
|
private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env)
|
|
{
|
|
var builder = new ConfigurationBuilder()
|
|
.SetBasePath(env.ContentRootPath)
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
|
|
|
|
return builder.Build();
|
|
}
|
|
}
|
|
}
|