mirror of https://github.com/abpframework/abp
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.
148 lines
6.2 KiB
148 lines
6.2 KiB
using System.IO;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using MyCompanyName.MyProjectName.EntityFrameworkCore;
|
|
using MyCompanyName.MyProjectName.MultiTenancy;
|
|
using MyCompanyName.MyProjectName.Web;
|
|
using Swashbuckle.AspNetCore.Swagger;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Account.Web;
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
|
|
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
|
|
using Volo.Abp.AuditLogging.EntityFrameworkCore;
|
|
using Volo.Abp.Autofac;
|
|
using Volo.Abp.Data;
|
|
using Volo.Abp.EntityFrameworkCore;
|
|
using Volo.Abp.EntityFrameworkCore.SqlServer;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Identity.EntityFrameworkCore;
|
|
using Volo.Abp.Identity.Web;
|
|
using Volo.Abp.Localization;
|
|
using Volo.Abp.Modularity;
|
|
using Volo.Abp.MultiTenancy;
|
|
using Volo.Abp.PermissionManagement;
|
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
|
using Volo.Abp.PermissionManagement.Identity;
|
|
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
|
using Volo.Abp.TenantManagement;
|
|
using Volo.Abp.TenantManagement.EntityFrameworkCore;
|
|
using Volo.Abp.TenantManagement.Web;
|
|
using Volo.Abp.Threading;
|
|
using Volo.Abp.VirtualFileSystem;
|
|
|
|
namespace MyCompanyName.MyProjectName
|
|
{
|
|
[DependsOn(
|
|
typeof(MyProjectNameWebModule),
|
|
typeof(MyProjectNameApplicationModule),
|
|
typeof(MyProjectNameEntityFrameworkCoreModule),
|
|
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
|
|
typeof(AbpAutofacModule),
|
|
typeof(AbpAccountWebModule),
|
|
typeof(AbpEntityFrameworkCoreSqlServerModule),
|
|
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementApplicationModule),
|
|
typeof(AbpIdentityWebModule),
|
|
typeof(AbpIdentityApplicationModule),
|
|
typeof(AbpIdentityEntityFrameworkCoreModule),
|
|
typeof(AbpPermissionManagementDomainIdentityModule),
|
|
typeof(AbpTenantManagementWebModule),
|
|
typeof(AbpTenantManagementApplicationModule),
|
|
typeof(AbpTenantManagementEntityFrameworkCoreModule),
|
|
typeof(AbpAspNetCoreMvcUiBasicThemeModule)
|
|
)]
|
|
public class MyProjectNameWebUnifiedModule : AbpModule
|
|
{
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
{
|
|
var hostingEnvironment = context.Services.GetHostingEnvironment();
|
|
var configuration = context.Services.BuildConfiguration();
|
|
|
|
Configure<AbpDbContextOptions>(options =>
|
|
{
|
|
options.UseSqlServer();
|
|
});
|
|
|
|
if (hostingEnvironment.IsDevelopment())
|
|
{
|
|
Configure<VirtualFileSystemOptions>(options =>
|
|
{
|
|
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain.Shared", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationContractsModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameApplicationModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar)));
|
|
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar)));
|
|
});
|
|
}
|
|
|
|
context.Services.AddSwaggerGen(
|
|
options =>
|
|
{
|
|
options.SwaggerDoc("v1", new Info { Title = "MyProjectName API", Version = "v1" });
|
|
options.DocInclusionPredicate((docName, description) => true);
|
|
options.CustomSchemaIds(type => type.FullName);
|
|
});
|
|
|
|
Configure<AbpLocalizationOptions>(options =>
|
|
{
|
|
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
|
|
options.Languages.Add(new LanguageInfo("en", "en", "English"));
|
|
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)"));
|
|
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
|
|
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "Chinese"));
|
|
});
|
|
|
|
Configure<MultiTenancyOptions>(options =>
|
|
{
|
|
options.IsEnabled = MultiTenancyConsts.IsEnabled;
|
|
});
|
|
}
|
|
|
|
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
|
{
|
|
var app = context.GetApplicationBuilder();
|
|
|
|
if (context.GetEnvironment().IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
else
|
|
{
|
|
app.UseErrorPage();
|
|
app.UseHsts();
|
|
}
|
|
|
|
app.UseHttpsRedirection();
|
|
app.UseVirtualFiles();
|
|
|
|
app.UseSwagger();
|
|
app.UseSwaggerUI(options =>
|
|
{
|
|
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
|
|
});
|
|
|
|
app.UseAuthentication();
|
|
if (MultiTenancyConsts.IsEnabled)
|
|
{
|
|
app.UseMultiTenancy();
|
|
}
|
|
app.UseAbpRequestLocalization();
|
|
app.UseAuditing();
|
|
|
|
app.UseMvcWithDefaultRouteAndArea();
|
|
|
|
using (var scope = context.ServiceProvider.CreateScope())
|
|
{
|
|
AsyncHelper.RunSync(async () =>
|
|
{
|
|
await scope.ServiceProvider
|
|
.GetRequiredService<IDataSeeder>()
|
|
.SeedAsync();
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|