using System.IO; using System.Linq; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using MyCompanyName.MyProjectName.EntityFrameworkCore; using Swashbuckle.AspNetCore.Swagger; using Volo.Abp; using Volo.Abp.Account.Web; using Volo.Abp.AspNetCore.Modularity; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; 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.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.Threading; using Volo.Abp.VirtualFileSystem; namespace MyCompanyName.MyProjectName.DemoApp { [DependsOn( typeof(MyProjectNameWebModule), typeof(MyProjectNameApplicationModule), typeof(MyProjectNameEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpSettingManagementEntityFrameworkCoreModule), typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpEntityFrameworkCoreSqlServerModule), typeof(AbpAccountWebModule), typeof(AbpIdentityWebModule), typeof(AbpIdentityApplicationModule), typeof(AbpAutofacModule), typeof(AbpAspNetCoreMvcUiBasicThemeModule) )] public class DemoAppModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.BuildConfiguration(); Configure(options => { options.ConnectionStrings.Default = configuration.GetConnectionString("Default"); }); Configure(options => { options.UseSqlServer(); }); if (hostingEnvironment.IsDevelopment()) { Configure(options => { options.FileSets.ReplaceEmbeddedByPyhsical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPyhsical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Domain", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPyhsical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPyhsical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Application.Contracts", Path.DirectorySeparatorChar))); }); } context.Services.AddSwaggerGen( options => { options.SwaggerDoc("v1", new Info { Title = "MyProjectName API", Version = "v1" }); options.DocInclusionPredicate((docName, description) => true); }); Configure(options => { options.Languages.Add(new LanguageInfo("en", "en", "English")); //...add other languages }); } public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); if (context.GetEnvironment().IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseErrorPage(); } app.UseVirtualFiles(); app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API"); }); app.UseAuthentication(); app.UseAbpRequestLocalization(); app.UseAuditing(); app.UseMvc(routes => { routes.MapRoute( name: "defaultWithArea", template: "{area}/{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); AsyncHelper.RunSync(async () => { await context.ServiceProvider .GetRequiredService() .SeedAsync( "1q2w3E*", IdentityPermissions.GetAll().Union(MyProjectNamePermissions.GetAll()) ); }); } } }