Browse Source

use file-scoped namespacing for module template

pull/10696/head
Ahmet Çotur 4 years ago
parent
commit
d1d9c47cde
  1. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostAutoMapperProfile.cs
  2. 17
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostBundleContributor.cs
  3. 127
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostModule.cs
  4. 9
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostBrandingProvider.cs
  5. 51
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostMenuContributor.cs
  6. 25
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/Program.cs
  7. 33
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContext.cs
  8. 31
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContextFactory.cs
  9. 43
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenuContributor.cs
  10. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenus.cs
  11. 1391
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20211105130007_Initial.cs
  12. 333
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBlazorHostModule.cs
  13. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBrandingProvider.cs
  14. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameComponentBase.cs
  15. 7
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Pages/Index.razor.cs
  16. 65
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Program.cs
  17. 19
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Startup.cs
  18. 15
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Host.Shared/MultiTenancy/MultiTenancyConsts.cs
  19. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs
  20. 21
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContext.cs
  21. 31
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContextFactory.cs
  22. 271
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs
  23. 63
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs
  24. 19
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs
  25. 33
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs
  26. 31
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs
  27. 469
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs
  28. 2528
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20211105130012_Initial.cs
  29. 325
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  30. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs
  31. 63
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs
  32. 19
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Startup.cs
  33. 7
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs
  34. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs
  35. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs
  36. 69
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs
  37. 337
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs
  38. 21
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs
  39. 13
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs
  40. 63
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Program.cs
  41. 19
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Startup.cs
  42. 33
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs
  43. 31
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs
  44. 1391
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20211105130018_Initial.cs
  45. 247
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs
  46. 11
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml.cs
  47. 67
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs
  48. 19
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Startup.cs
  49. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs
  50. 11
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameRemoteServiceConsts.cs
  51. 21
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs
  52. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs
  53. 11
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/ISampleAppService.cs
  54. 11
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/SampleDto.cs
  55. 13
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs
  56. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs
  57. 29
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs
  58. 43
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/Samples/SampleAppService.cs
  59. 19
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs
  60. 21
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebAssembly/MyProjectNameBlazorWebAssemblyModule.cs
  61. 29
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs
  62. 15
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs
  63. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs
  64. 47
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs
  65. 11
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs
  66. 43
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs
  67. 9
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameErrorCodes.cs
  68. 13
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDbProperties.cs
  69. 15
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs
  70. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs
  71. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs
  72. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/IMyProjectNameDbContext.cs
  73. 33
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs
  74. 41
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs
  75. 23
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs
  76. 31
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs
  77. 11
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameController.cs
  78. 37
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs
  79. 45
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Samples/SampleController.cs
  80. 23
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerModule.cs
  81. 15
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerPipelineBuilder.cs
  82. 15
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/IMyProjectNameMongoDbContext.cs
  83. 25
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContext.cs
  84. 13
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContextExtensions.cs
  85. 21
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs
  86. 27
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs
  87. 15
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs
  88. 17
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs
  89. 67
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
  90. 11
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs
  91. 19
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs
  92. 15
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs
  93. 15
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs
  94. 39
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppService_Tests.cs
  95. 15
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs
  96. 23
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs
  97. 23
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleManager_Tests.cs
  98. 15
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs
  99. 53
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs
  100. 15
      templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper;
namespace MyCompanyName.MyProjectName.Blazor.Host
namespace MyCompanyName.MyProjectName.Blazor.Host;
public class MyProjectNameBlazorHostAutoMapperProfile : Profile
{
public class MyProjectNameBlazorHostAutoMapperProfile : Profile
public MyProjectNameBlazorHostAutoMapperProfile()
{
public MyProjectNameBlazorHostAutoMapperProfile()
{
//Define your AutoMapper configuration here for the Blazor project.
}
//Define your AutoMapper configuration here for the Blazor project.
}
}

17
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostBundleContributor.cs

@ -1,17 +1,16 @@
using Volo.Abp.Bundling;
namespace MyCompanyName.MyProjectName.Blazor.Host
namespace MyCompanyName.MyProjectName.Blazor.Host;
public class MyProjectNameBlazorHostBundleContributor : IBundleContributor
{
public class MyProjectNameBlazorHostBundleContributor : IBundleContributor
public void AddScripts(BundleContext context)
{
public void AddScripts(BundleContext context)
{
}
}
public void AddStyles(BundleContext context)
{
context.Add("main.css", true);
}
public void AddStyles(BundleContext context)
{
context.Add("main.css", true);
}
}

127
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameBlazorHostModule.cs

@ -18,84 +18,83 @@ using Volo.Abp.SettingManagement.Blazor.WebAssembly;
using Volo.Abp.TenantManagement.Blazor.WebAssembly;
using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Blazor.Host
namespace MyCompanyName.MyProjectName.Blazor.Host;
[DependsOn(
typeof(AbpAutofacWebAssemblyModule),
typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule),
typeof(AbpAccountApplicationContractsModule),
typeof(AbpIdentityBlazorWebAssemblyModule),
typeof(AbpTenantManagementBlazorWebAssemblyModule),
typeof(AbpSettingManagementBlazorWebAssemblyModule),
typeof(MyProjectNameBlazorWebAssemblyModule)
)]
public class MyProjectNameBlazorHostModule : AbpModule
{
[DependsOn(
typeof(AbpAutofacWebAssemblyModule),
typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule),
typeof(AbpAccountApplicationContractsModule),
typeof(AbpIdentityBlazorWebAssemblyModule),
typeof(AbpTenantManagementBlazorWebAssemblyModule),
typeof(AbpSettingManagementBlazorWebAssemblyModule),
typeof(MyProjectNameBlazorWebAssemblyModule)
)]
public class MyProjectNameBlazorHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();
var environment = context.Services.GetSingletonInstance<IWebAssemblyHostEnvironment>();
var builder = context.Services.GetSingletonInstance<WebAssemblyHostBuilder>();
ConfigureAuthentication(builder);
ConfigureHttpClient(context, environment);
ConfigureBlazorise(context);
ConfigureRouter(context);
ConfigureUI(builder);
ConfigureMenu(context);
ConfigureAutoMapper(context);
}
ConfigureAuthentication(builder);
ConfigureHttpClient(context, environment);
ConfigureBlazorise(context);
ConfigureRouter(context);
ConfigureUI(builder);
ConfigureMenu(context);
ConfigureAutoMapper(context);
}
private void ConfigureRouter(ServiceConfigurationContext context)
private void ConfigureRouter(ServiceConfigurationContext context)
{
Configure<AbpRouterOptions>(options =>
{
Configure<AbpRouterOptions>(options =>
{
options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly;
});
}
options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly;
});
}
private void ConfigureMenu(ServiceConfigurationContext context)
private void ConfigureMenu(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameHostMenuContributor(context.Services.GetConfiguration()));
});
}
options.MenuContributors.Add(new MyProjectNameHostMenuContributor(context.Services.GetConfiguration()));
});
}
private void ConfigureBlazorise(ServiceConfigurationContext context)
{
context.Services
.AddBootstrap5Providers()
.AddFontAwesomeIcons();
}
private void ConfigureBlazorise(ServiceConfigurationContext context)
{
context.Services
.AddBootstrap5Providers()
.AddFontAwesomeIcons();
}
private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
private static void ConfigureAuthentication(WebAssemblyHostBuilder builder)
{
builder.Services.AddOidcAuthentication(options =>
{
builder.Services.AddOidcAuthentication(options =>
{
builder.Configuration.Bind("AuthServer", options.ProviderOptions);
options.ProviderOptions.DefaultScopes.Add("MyProjectName");
});
}
builder.Configuration.Bind("AuthServer", options.ProviderOptions);
options.ProviderOptions.DefaultScopes.Add("MyProjectName");
});
}
private static void ConfigureUI(WebAssemblyHostBuilder builder)
{
builder.RootComponents.Add<App>("#ApplicationContainer");
}
private static void ConfigureUI(WebAssemblyHostBuilder builder)
{
builder.RootComponents.Add<App>("#ApplicationContainer");
}
private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment)
private static void ConfigureHttpClient(ServiceConfigurationContext context, IWebAssemblyHostEnvironment environment)
{
context.Services.AddTransient(sp => new HttpClient
{
context.Services.AddTransient(sp => new HttpClient
{
BaseAddress = new Uri(environment.BaseAddress)
});
}
BaseAddress = new Uri(environment.BaseAddress)
});
}
private void ConfigureAutoMapper(ServiceConfigurationContext context)
private void ConfigureAutoMapper(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameBlazorHostModule>();
});
}
options.AddMaps<MyProjectNameBlazorHostModule>();
});
}
}

9
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostBrandingProvider.cs

@ -1,9 +1,8 @@
using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName.Blazor.Host
namespace MyCompanyName.MyProjectName.Blazor.Host;
public class MyProjectNameHostBrandingProvider : DefaultBrandingProvider
{
public class MyProjectNameHostBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
public override string AppName => "MyProjectName";
}

51
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/MyProjectNameHostMenuContributor.cs

@ -4,40 +4,39 @@ using Microsoft.Extensions.Configuration;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.UI.Navigation;
using Volo.Abp.Account.Localization;
namespace MyCompanyName.MyProjectName.Blazor.Host
namespace MyCompanyName.MyProjectName.Blazor.Host;
public class MyProjectNameHostMenuContributor : IMenuContributor
{
public class MyProjectNameHostMenuContributor : IMenuContributor
{
private readonly IConfiguration _configuration;
private readonly IConfiguration _configuration;
public MyProjectNameHostMenuContributor(IConfiguration configuration)
{
_configuration = configuration;
}
public MyProjectNameHostMenuContributor(IConfiguration configuration)
{
_configuration = configuration;
}
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.User)
{
if (context.Menu.Name == StandardMenus.User)
{
await ConfigureUserMenuAsync(context);
}
await ConfigureUserMenuAsync(context);
}
}
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{
var accountStringLocalizer = context.GetLocalizer<AccountResource>();
private Task ConfigureUserMenuAsync(MenuConfigurationContext context)
{
var accountStringLocalizer = context.GetLocalizer<AccountResource>();
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem(
"Account.Manage",
accountStringLocalizer["ManageYourProfile"],
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}",
icon: "fa fa-cog",
order: 1000,
null).RequireAuthenticated());
context.Menu.AddItem(new ApplicationMenuItem(
"Account.Manage",
accountStringLocalizer["ManageYourProfile"],
$"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}",
icon: "fa fa-cog",
order: 1000,
null).RequireAuthenticated());
return Task.CompletedTask;
}
return Task.CompletedTask;
}
}

25
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Host/Program.cs

@ -1,24 +1,23 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
namespace MyCompanyName.MyProjectName.Blazor.Host
namespace MyCompanyName.MyProjectName.Blazor.Host;
public class Program
{
public class Program
public static async Task Main(string[] args)
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var application = builder.AddApplication<MyProjectNameBlazorHostModule>(options =>
{
options.UseAutofac();
});
var application = builder.AddApplication<MyProjectNameBlazorHostModule>(options =>
{
options.UseAutofac();
});
var host = builder.Build();
var host = builder.Build();
await application.InitializeAsync(host.Services);
await application.InitializeAsync(host.Services);
await host.RunAsync();
}
await host.RunAsync();
}
}

33
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContext.cs

@ -8,27 +8,26 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore;
public class UnifiedDbContext : AbpDbContext<UnifiedDbContext>
{
public class UnifiedDbContext : AbpDbContext<UnifiedDbContext>
public UnifiedDbContext(DbContextOptions<UnifiedDbContext> options)
: base(options)
{
public UnifiedDbContext(DbContextOptions<UnifiedDbContext> options)
: base(options)
{
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureTenantManagement();
modelBuilder.ConfigureMyProjectName();
}
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureTenantManagement();
modelBuilder.ConfigureMyProjectName();
}
}

31
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/EntityFrameworkCore/UnifiedDbContextFactory.cs

@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.EntityFrameworkCore;
public class UnifiedDbContextFactory : IDesignTimeDbContextFactory<UnifiedDbContext>
{
public class UnifiedDbContextFactory : IDesignTimeDbContextFactory<UnifiedDbContext>
public UnifiedDbContext CreateDbContext(string[] args)
{
public UnifiedDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<UnifiedDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
var builder = new DbContextOptionsBuilder<UnifiedDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
return new UnifiedDbContext(builder.Options);
}
return new UnifiedDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
return builder.Build();
}
}

43
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenuContributor.cs

@ -5,35 +5,34 @@ using Volo.Abp.SettingManagement.Blazor.Menus;
using Volo.Abp.TenantManagement.Blazor.Navigation;
using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{
public class MyProjectNameMenuContributor : IMenuContributor
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
if (context.Menu.Name == StandardMenus.Main)
{
if (context.Menu.Name == StandardMenus.Main)
{
await ConfigureMainMenuAsync(context);
}
await ConfigureMainMenuAsync(context);
}
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
var administration = context.Menu.GetAdministration();
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
var administration = context.Menu.GetAdministration();
if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
if (MultiTenancyConsts.IsEnabled)
{
administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1);
}
else
{
administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName);
}
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3);
administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2);
administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3);
return Task.CompletedTask;
}
return Task.CompletedTask;
}
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Menus/MyProjectNameMenus.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Menus;
public class MyProjectNameMenus
{
public class MyProjectNameMenus
{
private const string Prefix = "MyProjectName";
private const string Prefix = "MyProjectName";
//Add your menu items here...
//Add your menu items here...
}
}

1391
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Migrations/20211105130007_Initial.cs

File diff suppressed because it is too large

333
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBlazorHostModule.cs

@ -50,208 +50,207 @@ using Volo.Abp.Threading;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host
namespace MyCompanyName.MyProjectName.Blazor.Server.Host;
[DependsOn(
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpIdentityBlazorServerModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementBlazorServerModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpSettingManagementBlazorServerModule),
typeof(AbpSettingManagementApplicationModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(MyProjectNameBlazorServerModule)
)]
public class MyProjectNameBlazorHostModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpSwashbuckleModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreComponentsServerBasicThemeModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpIdentityBlazorServerModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementBlazorServerModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpSettingManagementBlazorServerModule),
typeof(AbpSettingManagementApplicationModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(MyProjectNameBlazorServerModule)
)]
public class MyProjectNameBlazorHostModule: AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(
typeof(MyProjectNameResource),
typeof(MyProjectNameDomainModule).Assembly,
typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameApplicationModule).Assembly,
typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameBlazorHostModule).Assembly
);
});
}
options.AddAssemblyResource(
typeof(MyProjectNameResource),
typeof(MyProjectNameDomainModule).Assembly,
typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameApplicationModule).Assembly,
typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameBlazorHostModule).Assembly
);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AbpBundlingOptions>(options =>
{
Configure<AbpBundlingOptions>(options =>
{
// MVC UI
options.StyleBundles.Configure(
BasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
BasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/global-styles.css");
}
);
//BLAZOR UI
options.StyleBundles.Configure(
BlazorBasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/blazor-global-styles.css");
BlazorBasicThemeBundles.Styles.Global,
bundle =>
{
bundle.AddFiles("/blazor-global-styles.css");
//You can remove the following line if you don't use Blazor CSS isolation for components
bundle.AddFiles("/MyCompanyName.MyProjectName.Blazor.Server.Host.styles.css");
}
);
});
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
});
}
);
});
if(hostingEnvironment.IsDevelopment())
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
Configure<AbpVirtualFileSystemOptions>(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<MyProjectNameBlazorHostModule>(hostingEnvironment.ContentRootPath);
});
}
context.Services.AddAbpSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
});
Configure<AbpLocalizationOptions>(options =>
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("it", "it", "Italian", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
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<MyProjectNameBlazorHostModule>(hostingEnvironment.ContentRootPath);
});
}
Configure<AbpMultiTenancyOptions>(options =>
context.Services.AddAbpSwaggerGen(
options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
context.Services
.AddBootstrap5Providers()
.AddFontAwesomeIcons();
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("it", "it", "Italian", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
Configure<AbpRouterOptions>(options =>
{
options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly;
});
context.Services
.AddBootstrap5Providers()
.AddFontAwesomeIcons();
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
Configure<AbpRouterOptions>(options =>
{
options.AppAssembly = typeof(MyProjectNameBlazorHostModule).Assembly;
});
#if DEBUG
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif
}
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var env = context.GetEnvironment();
var app = context.GetApplicationBuilder();
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var env = context.GetEnvironment();
var app = context.GetApplicationBuilder();
app.UseAbpRequestLocalization();
app.UseAbpRequestLocalization();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
app.UseHttpsRedirection();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseConfiguredEndpoints();
app.UseUnitOfWork();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseConfiguredEndpoints();
using (var scope = context.ServiceProvider.CreateScope())
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(async () =>
{
AsyncHelper.RunSync(async () =>
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
});
}
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
});
}
}
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.DependencyInjection;
using Volo.Abp.Ui.Branding;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host
namespace MyCompanyName.MyProjectName.Blazor.Server.Host;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
public override string AppName => "MyProjectName";
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/MyProjectNameComponentBase.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Components;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host
namespace MyCompanyName.MyProjectName.Blazor.Server.Host;
public abstract class MyProjectNameComponentBase : AbpComponentBase
{
public abstract class MyProjectNameComponentBase : AbpComponentBase
protected MyProjectNameComponentBase()
{
protected MyProjectNameComponentBase()
{
LocalizationResource = typeof(MyProjectNameResource);
}
LocalizationResource = typeof(MyProjectNameResource);
}
}

7
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Pages/Index.razor.cs

@ -1,6 +1,5 @@
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Pages
namespace MyCompanyName.MyProjectName.Blazor.Server.Host.Pages;
public partial class Index
{
public partial class Index
{
}
}

65
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Program.cs

@ -5,53 +5,52 @@ using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host
namespace MyCompanyName.MyProjectName.Blazor.Server.Host;
public class Program
{
public class Program
public static int Main(string[] args)
{
public static int Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
public static IHostBuilder CreateHostBuilder(string[] args) =>
Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}

19
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Blazor.Server.Host/Startup.cs

@ -2,18 +2,17 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace MyCompanyName.MyProjectName.Blazor.Server.Host
namespace MyCompanyName.MyProjectName.Blazor.Server.Host;
public class Startup
{
public class Startup
public void ConfigureServices(IServiceCollection services)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameBlazorHostModule>();
}
services.AddApplication<MyProjectNameBlazorHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.InitializeApplication();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.InitializeApplication();
}
}

15
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Host.Shared/MultiTenancy/MultiTenancyConsts.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName.MultiTenancy
namespace MyCompanyName.MyProjectName.MultiTenancy;
public static class MultiTenancyConsts
{
public static class MultiTenancyConsts
{
/* Enable/disable multi-tenancy in a single point
* to test your module with multi-tenancy.
*/
public const bool IsEnabled = false;
}
/* Enable/disable multi-tenancy in a single point
* to test your module with multi-tenancy.
*/
public const bool IsEnabled = false;
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs

@ -1,13 +1,12 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName.Controllers
namespace MyCompanyName.MyProjectName.Controllers;
public class HomeController : AbpController
{
public class HomeController : AbpController
public ActionResult Index()
{
public ActionResult Index()
{
return Redirect("~/swagger");
}
return Redirect("~/swagger");
}
}

21
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContext.cs

@ -1,21 +1,20 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class MyProjectNameHttpApiHostMigrationsDbContext : AbpDbContext<MyProjectNameHttpApiHostMigrationsDbContext>
{
public class MyProjectNameHttpApiHostMigrationsDbContext : AbpDbContext<MyProjectNameHttpApiHostMigrationsDbContext>
public MyProjectNameHttpApiHostMigrationsDbContext(DbContextOptions<MyProjectNameHttpApiHostMigrationsDbContext> options)
: base(options)
{
public MyProjectNameHttpApiHostMigrationsDbContext(DbContextOptions<MyProjectNameHttpApiHostMigrationsDbContext> options)
: base(options)
{
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigureMyProjectName();
}
modelBuilder.ConfigureMyProjectName();
}
}

31
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/EntityFrameworkCore/MyProjectNameHttpApiHostMigrationsDbContextFactory.cs

@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class MyProjectNameHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameHttpApiHostMigrationsDbContext>
{
public class MyProjectNameHttpApiHostMigrationsDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameHttpApiHostMigrationsDbContext>
public MyProjectNameHttpApiHostMigrationsDbContext CreateDbContext(string[] args)
{
public MyProjectNameHttpApiHostMigrationsDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<MyProjectNameHttpApiHostMigrationsDbContext>()
.UseSqlServer(configuration.GetConnectionString("MyProjectName"));
var builder = new DbContextOptionsBuilder<MyProjectNameHttpApiHostMigrationsDbContext>()
.UseSqlServer(configuration.GetConnectionString("MyProjectName"));
return new MyProjectNameHttpApiHostMigrationsDbContext(builder.Options);
}
return new MyProjectNameHttpApiHostMigrationsDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
return builder.Build();
}
}

271
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs

@ -33,166 +33,165 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.Swashbuckle;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameHttpApiHostModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(MyProjectNameHttpApiModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameHttpApiHostModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
public override void ConfigureServices(ServiceConfigurationContext context)
Configure<AbpDbContextOptions>(options =>
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
options.UseSqlServer();
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
Configure<AbpMultiTenancyOptions>(options =>
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
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)));
});
}
if (hostingEnvironment.IsDevelopment())
context.Services.AddAbpSwaggerGenWithOAuth(
configuration["AuthServer:Authority"],
new Dictionary<string, string>
{
Configure<AbpVirtualFileSystemOptions>(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)));
});
}
context.Services.AddAbpSwaggerGenWithOAuth(
configuration["AuthServer:Authority"],
new Dictionary<string, string>
{
{"MyProjectName", "MyProjectName API"}
},
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo {Title = "MyProjectName API", Version = "v1"});
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
Configure<AbpLocalizationOptions>(options =>
},
options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
Configure<AbpDistributedCacheOptions>(options =>
context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(options =>
{
options.KeyPrefix = "MyProjectName:";
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = "MyProjectName";
});
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
Configure<AbpDistributedCacheOptions>(options =>
{
options.KeyPrefix = "MyProjectName:";
});
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
context.Services.AddCors(options =>
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
options.AddDefaultPolicy(builder =>
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
var configuration = context.GetConfiguration();
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
options.OAuthScopes("MyProjectName");
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
var configuration = context.GetConfiguration();
options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]);
options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]);
options.OAuthScopes("MyProjectName");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
}

63
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs

@ -6,51 +6,50 @@ using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Program
{
public class Program
public static int Main(string[] args)
{
public static int Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}

19
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs

@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Startup
{
public class Startup
public void ConfigureServices(IServiceCollection services)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameHttpApiHostModule>();
}
services.AddApplication<MyProjectNameHttpApiHostModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}

33
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContext.cs

@ -8,27 +8,26 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class IdentityServerHostMigrationsDbContext : AbpDbContext<IdentityServerHostMigrationsDbContext>
{
public class IdentityServerHostMigrationsDbContext : AbpDbContext<IdentityServerHostMigrationsDbContext>
public IdentityServerHostMigrationsDbContext(DbContextOptions<IdentityServerHostMigrationsDbContext> options)
: base(options)
{
public IdentityServerHostMigrationsDbContext(DbContextOptions<IdentityServerHostMigrationsDbContext> options)
: base(options)
{
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigureIdentityServer();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureTenantManagement();
}
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigureIdentityServer();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureTenantManagement();
}
}

31
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs

@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class IdentityServerHostMigrationsDbContextFactory : IDesignTimeDbContextFactory<IdentityServerHostMigrationsDbContext>
{
public class IdentityServerHostMigrationsDbContextFactory : IDesignTimeDbContextFactory<IdentityServerHostMigrationsDbContext>
public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args)
{
public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<IdentityServerHostMigrationsDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
var builder = new DbContextOptionsBuilder<IdentityServerHostMigrationsDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
return new IdentityServerHostMigrationsDbContext(builder.Options);
}
return new IdentityServerHostMigrationsDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
return builder.Build();
}
}

469
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/IdentityServer/IdentityServerDataSeedContributor.cs

@ -18,60 +18,60 @@ using ApiResource = Volo.Abp.IdentityServer.ApiResources.ApiResource;
using ApiScope = Volo.Abp.IdentityServer.ApiScopes.ApiScope;
using Client = Volo.Abp.IdentityServer.Clients.Client;
namespace MyCompanyName.MyProjectName.IdentityServer
namespace MyCompanyName.MyProjectName.IdentityServer;
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency
{
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency
private readonly IApiResourceRepository _apiResourceRepository;
private readonly IApiScopeRepository _apiScopeRepository;
private readonly IClientRepository _clientRepository;
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder;
private readonly IGuidGenerator _guidGenerator;
private readonly IPermissionDataSeeder _permissionDataSeeder;
private readonly IConfiguration _configuration;
private readonly ICurrentTenant _currentTenant;
public IdentityServerDataSeedContributor(
IClientRepository clientRepository,
IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IIdentityResourceDataSeeder identityResourceDataSeeder,
IGuidGenerator guidGenerator,
IPermissionDataSeeder permissionDataSeeder,
IConfiguration configuration,
ICurrentTenant currentTenant)
{
private readonly IApiResourceRepository _apiResourceRepository;
private readonly IApiScopeRepository _apiScopeRepository;
private readonly IClientRepository _clientRepository;
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder;
private readonly IGuidGenerator _guidGenerator;
private readonly IPermissionDataSeeder _permissionDataSeeder;
private readonly IConfiguration _configuration;
private readonly ICurrentTenant _currentTenant;
public IdentityServerDataSeedContributor(
IClientRepository clientRepository,
IApiResourceRepository apiResourceRepository,
IApiScopeRepository apiScopeRepository,
IIdentityResourceDataSeeder identityResourceDataSeeder,
IGuidGenerator guidGenerator,
IPermissionDataSeeder permissionDataSeeder,
IConfiguration configuration,
ICurrentTenant currentTenant)
{
_clientRepository = clientRepository;
_apiResourceRepository = apiResourceRepository;
_apiScopeRepository = apiScopeRepository;
_identityResourceDataSeeder = identityResourceDataSeeder;
_guidGenerator = guidGenerator;
_permissionDataSeeder = permissionDataSeeder;
_configuration = configuration;
_currentTenant = currentTenant;
}
_clientRepository = clientRepository;
_apiResourceRepository = apiResourceRepository;
_apiScopeRepository = apiScopeRepository;
_identityResourceDataSeeder = identityResourceDataSeeder;
_guidGenerator = guidGenerator;
_permissionDataSeeder = permissionDataSeeder;
_configuration = configuration;
_currentTenant = currentTenant;
}
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
[UnitOfWork]
public virtual async Task SeedAsync(DataSeedContext context)
{
using (_currentTenant.Change(context?.TenantId))
{
using (_currentTenant.Change(context?.TenantId))
{
await _identityResourceDataSeeder.CreateStandardResourcesAsync();
await CreateApiResourcesAsync();
await CreateApiScopesAsync();
await CreateClientsAsync();
}
await _identityResourceDataSeeder.CreateStandardResourcesAsync();
await CreateApiResourcesAsync();
await CreateApiScopesAsync();
await CreateClientsAsync();
}
}
private async Task CreateApiScopesAsync()
{
await CreateApiScopeAsync("MyProjectName");
}
private async Task CreateApiScopesAsync()
{
await CreateApiScopeAsync("MyProjectName");
}
private async Task CreateApiResourcesAsync()
private async Task CreateApiResourcesAsync()
{
var commonApiUserClaims = new[]
{
var commonApiUserClaims = new[]
{
"email",
"email_verified",
"name",
@ -80,57 +80,57 @@ namespace MyCompanyName.MyProjectName.IdentityServer
"role"
};
await CreateApiResourceAsync("MyProjectName", commonApiUserClaims);
}
await CreateApiResourceAsync("MyProjectName", commonApiUserClaims);
}
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims)
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims)
{
var apiResource = await _apiResourceRepository.FindByNameAsync(name);
if (apiResource == null)
{
var apiResource = await _apiResourceRepository.FindByNameAsync(name);
if (apiResource == null)
{
apiResource = await _apiResourceRepository.InsertAsync(
new ApiResource(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
foreach (var claim in claims)
{
if (apiResource.FindClaim(claim) == null)
{
apiResource.AddUserClaim(claim);
}
}
return await _apiResourceRepository.UpdateAsync(apiResource);
apiResource = await _apiResourceRepository.InsertAsync(
new ApiResource(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
private async Task<ApiScope> CreateApiScopeAsync(string name)
foreach (var claim in claims)
{
var apiScope = await _apiScopeRepository.FindByNameAsync(name);
if (apiScope == null)
if (apiResource.FindClaim(claim) == null)
{
apiScope = await _apiScopeRepository.InsertAsync(
new ApiScope(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
apiResource.AddUserClaim(claim);
}
}
return await _apiResourceRepository.UpdateAsync(apiResource);
}
return apiScope;
private async Task<ApiScope> CreateApiScopeAsync(string name)
{
var apiScope = await _apiScopeRepository.FindByNameAsync(name);
if (apiScope == null)
{
apiScope = await _apiScopeRepository.InsertAsync(
new ApiScope(
_guidGenerator.Create(),
name,
name + " API"
),
autoSave: true
);
}
private async Task CreateClientsAsync()
return apiScope;
}
private async Task CreateClientsAsync()
{
var commonScopes = new[]
{
var commonScopes = new[]
{
"email",
"openid",
"profile",
@ -140,185 +140,184 @@ namespace MyCompanyName.MyProjectName.IdentityServer
"MyProjectName"
};
var configurationSection = _configuration.GetSection("IdentityServer:Clients");
var configurationSection = _configuration.GetSection("IdentityServer:Clients");
//Web Client
var webClientId = configurationSection["MyProjectName_Web:ClientId"];
if (!webClientId.IsNullOrWhiteSpace())
{
var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/');
/* MyProjectName_Web client is only needed if you created a tiered
* solution. Otherwise, you can delete this client. */
await CreateClientAsync(
name: webClientId,
scopes: commonScopes,
grantTypes: new[] { "hybrid" },
secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{webClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc",
frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout",
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
);
}
//Web Client
var webClientId = configurationSection["MyProjectName_Web:ClientId"];
if (!webClientId.IsNullOrWhiteSpace())
{
var webClientRootUrl = configurationSection["MyProjectName_Web:RootUrl"].EnsureEndsWith('/');
//Console Test / Angular Client
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"];
if (!consoleAndAngularClientId.IsNullOrWhiteSpace())
{
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/');
await CreateClientAsync(
name: consoleAndAngularClientId,
scopes: commonScopes,
grantTypes: new[] { "password", "client_credentials", "authorization_code" },
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(),
requireClientSecret: false,
redirectUri: webClientRootUrl,
postLogoutRedirectUri: webClientRootUrl,
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
);
}
/* MyProjectName_Web client is only needed if you created a tiered
* solution. Otherwise, you can delete this client. */
// Blazor Client
var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"];
if (!blazorClientId.IsNullOrWhiteSpace())
{
var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/');
await CreateClientAsync(
name: blazorClientId,
scopes: commonScopes,
grantTypes: new[] { "authorization_code" },
secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(),
requireClientSecret: false,
redirectUri: $"{blazorRootUrl}/authentication/login-callback",
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback",
corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") }
);
}
await CreateClientAsync(
name: webClientId,
scopes: commonScopes,
grantTypes: new[] { "hybrid" },
secret: (configurationSection["MyProjectName_Web:ClientSecret"] ?? "1q2w3e*").Sha256(),
redirectUri: $"{webClientRootUrl}signin-oidc",
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc",
frontChannelLogoutUri: $"{webClientRootUrl}Account/FrontChannelLogout",
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
);
}
// Swagger Client
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"];
if (!swaggerClientId.IsNullOrWhiteSpace())
{
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/');
await CreateClientAsync(
name: swaggerClientId,
scopes: commonScopes,
grantTypes: new[] { "authorization_code" },
secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(),
requireClientSecret: false,
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") }
);
}
//Console Test / Angular Client
var consoleAndAngularClientId = configurationSection["MyProjectName_App:ClientId"];
if (!consoleAndAngularClientId.IsNullOrWhiteSpace())
{
var webClientRootUrl = configurationSection["MyProjectName_App:RootUrl"]?.TrimEnd('/');
await CreateClientAsync(
name: consoleAndAngularClientId,
scopes: commonScopes,
grantTypes: new[] { "password", "client_credentials", "authorization_code" },
secret: (configurationSection["MyProjectName_App:ClientSecret"] ?? "1q2w3e*").Sha256(),
requireClientSecret: false,
redirectUri: webClientRootUrl,
postLogoutRedirectUri: webClientRootUrl,
corsOrigins: new[] { webClientRootUrl.RemovePostFix("/") }
);
}
private async Task<Client> CreateClientAsync(
string name,
IEnumerable<string> scopes,
IEnumerable<string> grantTypes,
string secret = null,
string redirectUri = null,
string postLogoutRedirectUri = null,
string frontChannelLogoutUri = null,
bool requireClientSecret = true,
bool requirePkce = false,
IEnumerable<string> permissions = null,
IEnumerable<string> corsOrigins = null)
// Blazor Client
var blazorClientId = configurationSection["MyProjectName_Blazor:ClientId"];
if (!blazorClientId.IsNullOrWhiteSpace())
{
var client = await _clientRepository.FindByClientIdAsync(name);
if (client == null)
{
client = await _clientRepository.InsertAsync(
new Client(
_guidGenerator.Create(),
name
)
{
ClientName = name,
ProtocolType = "oidc",
Description = name,
AlwaysIncludeUserClaimsInIdToken = true,
AllowOfflineAccess = true,
AbsoluteRefreshTokenLifetime = 31536000, //365 days
var blazorRootUrl = configurationSection["MyProjectName_Blazor:RootUrl"].TrimEnd('/');
await CreateClientAsync(
name: blazorClientId,
scopes: commonScopes,
grantTypes: new[] { "authorization_code" },
secret: configurationSection["MyProjectName_Blazor:ClientSecret"]?.Sha256(),
requireClientSecret: false,
redirectUri: $"{blazorRootUrl}/authentication/login-callback",
postLogoutRedirectUri: $"{blazorRootUrl}/authentication/logout-callback",
corsOrigins: new[] { blazorRootUrl.RemovePostFix("/") }
);
}
// Swagger Client
var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"];
if (!swaggerClientId.IsNullOrWhiteSpace())
{
var swaggerRootUrl = configurationSection["MyProjectName_Swagger:RootUrl"].TrimEnd('/');
await CreateClientAsync(
name: swaggerClientId,
scopes: commonScopes,
grantTypes: new[] { "authorization_code" },
secret: configurationSection["MyProjectName_Swagger:ClientSecret"]?.Sha256(),
requireClientSecret: false,
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
corsOrigins: new[] { swaggerRootUrl.RemovePostFix("/") }
);
}
}
private async Task<Client> CreateClientAsync(
string name,
IEnumerable<string> scopes,
IEnumerable<string> grantTypes,
string secret = null,
string redirectUri = null,
string postLogoutRedirectUri = null,
string frontChannelLogoutUri = null,
bool requireClientSecret = true,
bool requirePkce = false,
IEnumerable<string> permissions = null,
IEnumerable<string> corsOrigins = null)
{
var client = await _clientRepository.FindByClientIdAsync(name);
if (client == null)
{
client = await _clientRepository.InsertAsync(
new Client(
_guidGenerator.Create(),
name
)
{
ClientName = name,
ProtocolType = "oidc",
Description = name,
AlwaysIncludeUserClaimsInIdToken = true,
AllowOfflineAccess = true,
AbsoluteRefreshTokenLifetime = 31536000, //365 days
AccessTokenLifetime = 31536000, //365 days
AuthorizationCodeLifetime = 300,
IdentityTokenLifetime = 300,
RequireConsent = false,
FrontChannelLogoutUri = frontChannelLogoutUri,
RequireClientSecret = requireClientSecret,
RequirePkce = requirePkce
},
autoSave: true
);
}
IdentityTokenLifetime = 300,
RequireConsent = false,
FrontChannelLogoutUri = frontChannelLogoutUri,
RequireClientSecret = requireClientSecret,
RequirePkce = requirePkce
},
autoSave: true
);
}
foreach (var scope in scopes)
foreach (var scope in scopes)
{
if (client.FindScope(scope) == null)
{
if (client.FindScope(scope) == null)
{
client.AddScope(scope);
}
client.AddScope(scope);
}
}
foreach (var grantType in grantTypes)
foreach (var grantType in grantTypes)
{
if (client.FindGrantType(grantType) == null)
{
if (client.FindGrantType(grantType) == null)
{
client.AddGrantType(grantType);
}
client.AddGrantType(grantType);
}
}
if (!secret.IsNullOrEmpty())
if (!secret.IsNullOrEmpty())
{
if (client.FindSecret(secret) == null)
{
if (client.FindSecret(secret) == null)
{
client.AddSecret(secret);
}
client.AddSecret(secret);
}
}
if (redirectUri != null)
if (redirectUri != null)
{
if (client.FindRedirectUri(redirectUri) == null)
{
if (client.FindRedirectUri(redirectUri) == null)
{
client.AddRedirectUri(redirectUri);
}
client.AddRedirectUri(redirectUri);
}
}
if (postLogoutRedirectUri != null)
if (postLogoutRedirectUri != null)
{
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null)
{
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null)
{
client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
}
client.AddPostLogoutRedirectUri(postLogoutRedirectUri);
}
}
if (permissions != null)
{
await _permissionDataSeeder.SeedAsync(
ClientPermissionValueProvider.ProviderName,
name,
permissions,
null
);
}
if (permissions != null)
{
await _permissionDataSeeder.SeedAsync(
ClientPermissionValueProvider.ProviderName,
name,
permissions,
null
);
}
if (corsOrigins != null)
if (corsOrigins != null)
{
foreach (var origin in corsOrigins)
{
foreach (var origin in corsOrigins)
if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null)
{
if (!origin.IsNullOrWhiteSpace() && client.FindCorsOrigin(origin) == null)
{
client.AddCorsOrigin(origin);
}
client.AddCorsOrigin(origin);
}
}
return await _clientRepository.UpdateAsync(client);
}
return await _clientRepository.UpdateAsync(client);
}
}

2528
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Migrations/20211105130012_Initial.cs

File diff suppressed because it is too large

325
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs

@ -49,198 +49,197 @@ using Volo.Abp.TenantManagement.EntityFrameworkCore;
using Volo.Abp.Threading;
using Volo.Abp.UI.Navigation.Urls;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementApplicationModule),
typeof(AbpSettingManagementHttpApiModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpFeatureManagementHttpApiModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameIdentityServerModule : AbpModule
{
[DependsOn(
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityServerEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpSettingManagementApplicationModule),
typeof(AbpSettingManagementHttpApiModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpFeatureManagementHttpApiModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameIdentityServerModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
context.Services.AddAbpSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
Configure<AbpLocalizationOptions>(options =>
context.Services.AddAbpSwaggerGen(
options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
Configure<AbpAuditingOptions>(options =>
{
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
Configure<AbpAuditingOptions>(options =>
{
//options.IsEnabledForGetRequests = true;
options.ApplicationName = "AuthServer";
});
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
});
});
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = configuration["AuthServer:ApiName"];
});
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
});
Configure<AbpDistributedCacheOptions>(options =>
context.Services.AddAuthentication()
.AddJwtBearer(options =>
{
options.KeyPrefix = "MyProjectName:";
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.Audience = configuration["AuthServer:ApiName"];
});
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
Configure<AbpDistributedCacheOptions>(options =>
{
options.KeyPrefix = "MyProjectName:";
});
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
context.Services.AddCors(options =>
context.Services.AddCors(options =>
{
options.AddDefaultPolicy(builder =>
{
options.AddDefaultPolicy(builder =>
{
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
builder
.WithOrigins(
configuration["App:CorsOrigins"]
.Split(",", StringSplitOptions.RemoveEmptyEntries)
.Select(o => o.RemovePostFix("/"))
.ToArray()
)
.WithAbpExposedHeaders()
.SetIsOriginAllowedToAllowWildcardSubdomains()
.AllowAnyHeader()
.AllowAnyMethod()
.AllowCredentials();
});
});
#if DEBUG
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif
}
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseErrorPage();
app.UseHsts();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseErrorPage();
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
app.UseHttpsRedirection();
app.UseCorrelationId();
app.UseStaticFiles();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
app.UseJwtTokenMiddleware();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseAbpRequestLocalization();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
app.UseAbpRequestLocalization();
app.UseIdentityServer();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
SeedData(context);
}
SeedData(context);
}
private void SeedData(ApplicationInitializationContext context)
private void SeedData(ApplicationInitializationContext context)
{
AsyncHelper.RunSync(async () =>
{
AsyncHelper.RunSync(async () =>
using (var scope = context.ServiceProvider.CreateScope())
{
using (var scope = context.ServiceProvider.CreateScope())
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
}
});
}
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs

@ -1,11 +1,10 @@
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace MyCompanyName.MyProjectName.Pages
namespace MyCompanyName.MyProjectName.Pages;
public class IndexModel : AbpPageModel
{
public class IndexModel : AbpPageModel
public void OnGet()
{
public void OnGet()
{
}
}
}
}

63
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Program.cs

@ -6,51 +6,50 @@ using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Program
{
public class Program
public static int Main(string[] args)
{
public static int Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}

19
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/Startup.cs

@ -4,18 +4,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Startup
{
public class Startup
public void ConfigureServices(IServiceCollection services)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameIdentityServerModule>();
}
services.AddApplication<MyProjectNameIdentityServerModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}

7
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs

@ -1,9 +1,8 @@
using Volo.Abp.AspNetCore.Mvc.Authentication;
namespace MyCompanyName.MyProjectName.Controllers
namespace MyCompanyName.MyProjectName.Controllers;
public class AccountController : ChallengeAccountController
{
public class AccountController : ChallengeAccountController
{
}
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs

@ -1,11 +1,10 @@
using Volo.Abp.Ui.Branding;
using Volo.Abp.DependencyInjection;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
[Dependency(ReplaceServices = true)]
public class MyProjectNameBrandingProvider : DefaultBrandingProvider
{
public override string AppName => "MyProjectName";
}
public override string AppName => "MyProjectName";
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs

@ -1,12 +1,11 @@
using AutoMapper;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class MyProjectNameWebAutoMapperProfile : Profile
{
public class MyProjectNameWebAutoMapperProfile : Profile
public MyProjectNameWebAutoMapperProfile()
{
public MyProjectNameWebAutoMapperProfile()
{
//Define your AutoMapper configuration here for the Web project.
}
//Define your AutoMapper configuration here for the Web project.
}
}

69
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs

@ -9,48 +9,47 @@ using Volo.Abp.Authorization.Permissions;
using Volo.Abp.UI.Navigation;
using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class MyProjectNameWebHostMenuContributor : IMenuContributor
{
public class MyProjectNameWebHostMenuContributor : IMenuContributor
private readonly IConfiguration _configuration;
public MyProjectNameWebHostMenuContributor(IConfiguration configuration)
{
private readonly IConfiguration _configuration;
_configuration = configuration;
}
public MyProjectNameWebHostMenuContributor(IConfiguration configuration)
public Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.User)
{
_configuration = configuration;
AddLogoutItemToMenu(context);
}
public Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.User)
{
AddLogoutItemToMenu(context);
}
return Task.CompletedTask;
}
return Task.CompletedTask;
}
private void AddLogoutItemToMenu(MenuConfigurationContext context)
{
var l = context.GetLocalizer<MyProjectNameResource>();
private void AddLogoutItemToMenu(MenuConfigurationContext context)
{
var l = context.GetLocalizer<MyProjectNameResource>();
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Manage",
l["MyAccount"],
$"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage",
icon: "fa fa-cog",
order: int.MaxValue - 1001,
null,
"_blank"
).RequireAuthenticated());
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Logout",
l["Logout"],
"~/Account/Logout",
"fas fa-power-off",
order: int.MaxValue - 1000
).RequireAuthenticated());
}
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Manage",
l["MyAccount"],
$"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage",
icon: "fa fa-cog",
order: int.MaxValue - 1001,
null,
"_blank"
).RequireAuthenticated());
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Logout",
l["Logout"],
"~/Account/Logout",
"fas fa-power-off",
order: int.MaxValue - 1000
).RequireAuthenticated());
}
}

337
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs

@ -50,213 +50,212 @@ using Volo.Abp.UI;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameWebModule),
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpHttpClientWebModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpIdentityWebModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(AbpFeatureManagementWebModule),
typeof(AbpFeatureManagementHttpApiClientModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpTenantManagementHttpApiClientModule),
typeof(AbpPermissionManagementHttpApiClientModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebHostModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameWebModule),
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule),
typeof(AbpAspNetCoreMvcClientModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAutofacModule),
typeof(AbpCachingStackExchangeRedisModule),
typeof(AbpHttpClientWebModule),
typeof(AbpHttpClientIdentityModelWebModule),
typeof(AbpIdentityWebModule),
typeof(AbpIdentityHttpApiClientModule),
typeof(AbpFeatureManagementWebModule),
typeof(AbpFeatureManagementHttpApiClientModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpTenantManagementHttpApiClientModule),
typeof(AbpPermissionManagementHttpApiClientModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebHostModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(
typeof(MyProjectNameResource),
typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameWebHostModule).Assembly
);
});
}
options.AddAssemblyResource(
typeof(MyProjectNameResource),
typeof(MyProjectNameDomainSharedModule).Assembly,
typeof(MyProjectNameApplicationContractsModule).Assembly,
typeof(MyProjectNameWebHostModule).Assembly
);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
public override void ConfigureServices(ServiceConfigurationContext context)
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureMenu(configuration);
ConfigureCache(configuration);
ConfigureUrls(configuration);
ConfigureAuthentication(context, configuration);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureSwaggerServices(context.Services);
ConfigureMultiTenancy();
ConfigureDataProtection(context, configuration, hostingEnvironment);
}
ConfigureMenu(configuration);
ConfigureCache(configuration);
ConfigureUrls(configuration);
ConfigureAuthentication(context, configuration);
ConfigureAutoMapper();
ConfigureVirtualFileSystem(hostingEnvironment);
ConfigureSwaggerServices(context.Services);
ConfigureMultiTenancy();
ConfigureDataProtection(context, configuration, hostingEnvironment);
}
private void ConfigureMenu(IConfiguration configuration)
private void ConfigureMenu(IConfiguration configuration)
{
Configure<AbpNavigationOptions>(options =>
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameWebHostMenuContributor(configuration));
});
}
options.MenuContributors.Add(new MyProjectNameWebHostMenuContributor(configuration));
});
}
private void ConfigureCache(IConfiguration configuration)
private void ConfigureCache(IConfiguration configuration)
{
Configure<AbpDistributedCacheOptions>(options =>
{
Configure<AbpDistributedCacheOptions>(options =>
{
options.KeyPrefix = "MyProjectName:";
});
}
options.KeyPrefix = "MyProjectName:";
});
}
private void ConfigureUrls(IConfiguration configuration)
private void ConfigureUrls(IConfiguration configuration)
{
Configure<AppUrlOptions>(options =>
{
Configure<AppUrlOptions>(options =>
{
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
});
}
options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"];
});
}
private void ConfigureMultiTenancy()
private void ConfigureMultiTenancy()
{
Configure<AbpMultiTenancyOptions>(options =>
{
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
}
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
}
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(365);
})
.AddAbpOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration)
{
context.Services.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
})
.AddCookie("Cookies", options =>
{
options.ExpireTimeSpan = TimeSpan.FromDays(365);
})
.AddAbpOpenIdConnect("oidc", options =>
{
options.Authority = configuration["AuthServer:Authority"];
options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
options.ResponseType = OpenIdConnectResponseType.CodeIdToken;
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.ClientId = configuration["AuthServer:ClientId"];
options.ClientSecret = configuration["AuthServer:ClientSecret"];
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.SaveTokens = true;
options.GetClaimsFromUserInfoEndpoint = true;
options.Scope.Add("role");
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("MyProjectName");
});
}
options.Scope.Add("role");
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("MyProjectName");
});
}
private void ConfigureAutoMapper()
private void ConfigureAutoMapper()
{
Configure<AbpAutoMapperOptions>(options =>
{
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameWebHostModule>();
});
}
options.AddMaps<MyProjectNameWebHostModule>();
});
}
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment)
{
if (hostingEnvironment.IsDevelopment())
{
if (hostingEnvironment.IsDevelopment())
Configure<AbpVirtualFileSystemOptions>(options =>
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
//<TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<AbpUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBootstrapModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiThemeSharedModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpAspNetCoreMvcUiBasicThemeModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}basic-theme{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpPermissionManagementWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}permission-management{0}src{0}Volo.Abp.PermissionManagement.Web", Path.DirectorySeparatorChar)));
options.FileSets.ReplaceEmbeddedByPhysical<AbpIdentityWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar)));
//</TEMPLATE-REMOVE>
options.FileSets.ReplaceEmbeddedByPhysical<MyProjectNameDomainSharedModule>(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<MyProjectNameWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", 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<MyProjectNameWebModule>(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}MyCompanyName.MyProjectName.Web", Path.DirectorySeparatorChar)));
});
}
}
private void ConfigureSwaggerServices(IServiceCollection services)
private void ConfigureSwaggerServices(IServiceCollection services)
{
services.AddAbpSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}
);
}
private void ConfigureDataProtection(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
{
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{
services.AddAbpSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
}
);
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
}
private void ConfigureDataProtection(
ServiceConfigurationContext context,
IConfiguration configuration,
IWebHostEnvironment hostingEnvironment)
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName");
if (!hostingEnvironment.IsDevelopment())
{
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys");
}
app.UseDeveloperExceptionPage();
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
else
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseErrorPage();
app.UseHsts();
}
app.UseErrorPage();
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
}
}

21
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs

@ -1,18 +1,17 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
namespace MyCompanyName.MyProjectName.Pages
namespace MyCompanyName.MyProjectName.Pages;
public class IndexModel : MyProjectNamePageModel
{
public class IndexModel : MyProjectNamePageModel
public void OnGet()
{
public void OnGet()
{
}
public async Task OnPostLoginAsync()
{
await HttpContext.ChallengeAsync("oidc");
}
}
}
public async Task OnPostLoginAsync()
{
await HttpContext.ChallengeAsync("oidc");
}
}

13
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace MyCompanyName.MyProjectName.Pages
namespace MyCompanyName.MyProjectName.Pages;
public abstract class MyProjectNamePageModel : AbpPageModel
{
public abstract class MyProjectNamePageModel : AbpPageModel
protected MyProjectNamePageModel()
{
protected MyProjectNamePageModel()
{
LocalizationResourceType = typeof(MyProjectNameResource);
}
LocalizationResourceType = typeof(MyProjectNameResource);
}
}
}

63
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Program.cs

@ -6,51 +6,50 @@ using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Program
{
public class Program
public static int Main(string[] args)
{
public static int Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
Log.Logger = new LoggerConfiguration()
#if DEBUG
.MinimumLevel.Debug()
#else
.MinimumLevel.Information()
#endif
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}

19
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Startup.cs

@ -2,18 +2,17 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Startup
{
public class Startup
public void ConfigureServices(IServiceCollection services)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameWebHostModule>();
}
services.AddApplication<MyProjectNameWebHostModule>();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}

33
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContext.cs

@ -7,27 +7,26 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TenantManagement.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class UnifiedDbContext : AbpDbContext<UnifiedDbContext>
{
public class UnifiedDbContext : AbpDbContext<UnifiedDbContext>
public UnifiedDbContext(DbContextOptions<UnifiedDbContext> options)
: base(options)
{
public UnifiedDbContext(DbContextOptions<UnifiedDbContext> options)
: base(options)
{
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureTenantManagement();
modelBuilder.ConfigureMyProjectName();
}
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureIdentity();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureTenantManagement();
modelBuilder.ConfigureMyProjectName();
}
}

31
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs

@ -3,27 +3,26 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public class UnifiedDbContextFactory : IDesignTimeDbContextFactory<UnifiedDbContext>
{
public class UnifiedDbContextFactory : IDesignTimeDbContextFactory<UnifiedDbContext>
public UnifiedDbContext CreateDbContext(string[] args)
{
public UnifiedDbContext CreateDbContext(string[] args)
{
var configuration = BuildConfiguration();
var configuration = BuildConfiguration();
var builder = new DbContextOptionsBuilder<UnifiedDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
var builder = new DbContextOptionsBuilder<UnifiedDbContext>()
.UseSqlServer(configuration.GetConnectionString("Default"));
return new UnifiedDbContext(builder.Options);
}
return new UnifiedDbContext(builder.Options);
}
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
private static IConfigurationRoot BuildConfiguration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false);
return builder.Build();
}
return builder.Build();
}
}

1391
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Migrations/20211105130018_Initial.cs

File diff suppressed because it is too large

247
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs

@ -41,152 +41,151 @@ using Volo.Abp.TenantManagement.Web;
using Volo.Abp.Threading;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameWebModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameHttpApiModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpAccountWebModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpIdentityWebModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpFeatureManagementWebModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpFeatureManagementHttpApiModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebUnifiedModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameWebModule),
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameHttpApiModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpAccountWebModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAccountHttpApiModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementApplicationModule),
typeof(AbpPermissionManagementHttpApiModule),
typeof(AbpIdentityWebModule),
typeof(AbpIdentityApplicationModule),
typeof(AbpIdentityHttpApiModule),
typeof(AbpIdentityEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainIdentityModule),
typeof(AbpFeatureManagementWebModule),
typeof(AbpFeatureManagementApplicationModule),
typeof(AbpFeatureManagementHttpApiModule),
typeof(AbpFeatureManagementEntityFrameworkCoreModule),
typeof(AbpTenantManagementWebModule),
typeof(AbpTenantManagementApplicationModule),
typeof(AbpTenantManagementHttpApiModule),
typeof(AbpTenantManagementEntityFrameworkCoreModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),
typeof(AbpAspNetCoreSerilogModule),
typeof(AbpSwashbuckleModule)
)]
public class MyProjectNameWebUnifiedModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
Configure<AbpDbContextOptions>(options =>
{
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
options.UseSqlServer();
});
Configure<AbpDbContextOptions>(options =>
if (hostingEnvironment.IsDevelopment())
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.UseSqlServer();
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)));
});
}
if (hostingEnvironment.IsDevelopment())
context.Services.AddAbpSwaggerGen(
options =>
{
Configure<AbpVirtualFileSystemOptions>(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.AddAbpSwaggerGen(
options =>
{
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" });
options.DocInclusionPredicate((docName, description) => true);
options.CustomSchemaIds(type => type.FullName);
});
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
Configure<AbpLocalizationOptions>(options =>
{
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
options.Languages.Add(new LanguageInfo("en", "en", "English"));
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi", "in"));
options.Languages.Add(new LanguageInfo("is", "is", "Icelandic", "is"));
options.Languages.Add(new LanguageInfo("it", "it", "Italiano", "it"));
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português (Brasil)"));
options.Languages.Add(new LanguageInfo("ro-RO", "ro-RO", "Română"));
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
});
Configure<AbpMultiTenancyOptions>(options =>
{
options.IsEnabled = MultiTenancyConsts.IsEnabled;
});
#if DEBUG
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
#endif
}
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseErrorPage();
app.UseHsts();
}
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseErrorPage();
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
if (MultiTenancyConsts.IsEnabled)
{
app.UseMultiTenancy();
}
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseAbpRequestLocalization();
app.UseAuthorization();
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
});
app.UseSwagger();
app.UseAbpSwaggerUI(options =>
{
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Support APP API");
});
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
app.UseAuditing();
app.UseAbpSerilogEnrichers();
app.UseConfiguredEndpoints();
using (var scope = context.ServiceProvider.CreateScope())
using (var scope = context.ServiceProvider.CreateScope())
{
AsyncHelper.RunSync(async () =>
{
AsyncHelper.RunSync(async () =>
{
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
});
}
await scope.ServiceProvider
.GetRequiredService<IDataSeeder>()
.SeedAsync();
});
}
}
}

11
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Pages/Index.cshtml.cs

@ -1,11 +1,10 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace MyCompanyName.MyProjectName.Pages
namespace MyCompanyName.MyProjectName.Pages;
public class IndexModel : PageModel
{
public class IndexModel : PageModel
public void OnGet()
{
public void OnGet()
{
}
}
}
}

67
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Program.cs

@ -6,47 +6,46 @@ using Microsoft.Extensions.Hosting;
using Serilog;
using Serilog.Events;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Program
{
public class Program
public static int Main(string[] args)
{
public static int Main(string[] args)
{
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.Enrich.FromLogContext()
.WriteTo.Async(c => c.File("Logs/logs.txt"))
#if DEBUG
.WriteTo.Async(c => c.Console())
#endif
.CreateLogger();
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
try
{
Log.Information("Starting web host.");
CreateHostBuilder(args).Build().Run();
return 0;
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly!");
return 1;
}
finally
{
Log.CloseAndFlush();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}
internal static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
})
.UseAutofac()
.UseSerilog();
}

19
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/Startup.cs

@ -3,18 +3,17 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class Startup
{
public class Startup
public void ConfigureServices(IServiceCollection services)
{
public void ConfigureServices(IServiceCollection services)
{
services.AddApplication<MyProjectNameWebUnifiedModule>();
}
services.AddApplication<MyProjectNameWebUnifiedModule>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{
app.InitializeApplication();
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs

@ -2,15 +2,14 @@
using Volo.Abp.Modularity;
using Volo.Abp.Authorization;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameDomainSharedModule),
typeof(AbpDddApplicationContractsModule),
typeof(AbpAuthorizationModule)
)]
public class MyProjectNameApplicationContractsModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameDomainSharedModule),
typeof(AbpDddApplicationContractsModule),
typeof(AbpAuthorizationModule)
)]
public class MyProjectNameApplicationContractsModule : AbpModule
{
}
}

11
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameRemoteServiceConsts.cs

@ -1,9 +1,8 @@
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class MyProjectNameRemoteServiceConsts
{
public class MyProjectNameRemoteServiceConsts
{
public const string RemoteServiceName = "MyProjectName";
public const string RemoteServiceName = "MyProjectName";
public const string ModuleName = "myProjectName";
}
public const string ModuleName = "myProjectName";
}

21
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs

@ -2,18 +2,17 @@
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;
namespace MyCompanyName.MyProjectName.Permissions
namespace MyCompanyName.MyProjectName.Permissions;
public class MyProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider
{
public class MyProjectNamePermissionDefinitionProvider : PermissionDefinitionProvider
public override void Define(IPermissionDefinitionContext context)
{
public override void Define(IPermissionDefinitionContext context)
{
var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName, L("Permission:MyProjectName"));
}
var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName, L("Permission:MyProjectName"));
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<MyProjectNameResource>(name);
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<MyProjectNameResource>(name);
}
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs

@ -1,14 +1,13 @@
using Volo.Abp.Reflection;
namespace MyCompanyName.MyProjectName.Permissions
namespace MyCompanyName.MyProjectName.Permissions;
public class MyProjectNamePermissions
{
public class MyProjectNamePermissions
{
public const string GroupName = "MyProjectName";
public const string GroupName = "MyProjectName";
public static string[] GetAll()
{
return ReflectionHelper.GetPublicConstantsRecursively(typeof(MyProjectNamePermissions));
}
public static string[] GetAll()
{
return ReflectionHelper.GetPublicConstantsRecursively(typeof(MyProjectNamePermissions));
}
}
}

11
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/ISampleAppService.cs

@ -1,12 +1,11 @@
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
namespace MyCompanyName.MyProjectName.Samples
namespace MyCompanyName.MyProjectName.Samples;
public interface ISampleAppService : IApplicationService
{
public interface ISampleAppService : IApplicationService
{
Task<SampleDto> GetAsync();
Task<SampleDto> GetAsync();
Task<SampleDto> GetAuthorizedAsync();
}
Task<SampleDto> GetAuthorizedAsync();
}

11
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Samples/SampleDto.cs

@ -1,7 +1,6 @@
namespace MyCompanyName.MyProjectName.Samples
namespace MyCompanyName.MyProjectName.Samples;
public class SampleDto
{
public class SampleDto
{
public int Value { get; set; }
}
}
public int Value { get; set; }
}

13
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs

@ -1,14 +1,13 @@
using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.Application.Services;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public abstract class MyProjectNameAppService : ApplicationService
{
public abstract class MyProjectNameAppService : ApplicationService
protected MyProjectNameAppService()
{
protected MyProjectNameAppService()
{
LocalizationResource = typeof(MyProjectNameResource);
ObjectMapperContext = typeof(MyProjectNameApplicationModule);
}
LocalizationResource = typeof(MyProjectNameResource);
ObjectMapperContext = typeof(MyProjectNameApplicationModule);
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs

@ -1,14 +1,13 @@
using AutoMapper;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public class MyProjectNameApplicationAutoMapperProfile : Profile
{
public class MyProjectNameApplicationAutoMapperProfile : Profile
public MyProjectNameApplicationAutoMapperProfile()
{
public MyProjectNameApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

29
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs

@ -3,23 +3,22 @@ using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
)]
public class MyProjectNameApplicationModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
)]
public class MyProjectNameApplicationModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
context.Services.AddAutoMapperObjectMapper<MyProjectNameApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
context.Services.AddAutoMapperObjectMapper<MyProjectNameApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameApplicationModule>(validate: true);
});
}
options.AddMaps<MyProjectNameApplicationModule>(validate: true);
});
}
}

43
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/Samples/SampleAppService.cs

@ -1,29 +1,28 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
namespace MyCompanyName.MyProjectName.Samples
namespace MyCompanyName.MyProjectName.Samples;
public class SampleAppService : MyProjectNameAppService, ISampleAppService
{
public class SampleAppService : MyProjectNameAppService, ISampleAppService
public Task<SampleDto> GetAsync()
{
public Task<SampleDto> GetAsync()
{
return Task.FromResult(
new SampleDto
{
Value = 42
}
);
}
return Task.FromResult(
new SampleDto
{
Value = 42
}
);
}
[Authorize]
public Task<SampleDto> GetAuthorizedAsync()
{
return Task.FromResult(
new SampleDto
{
Value = 42
}
);
}
[Authorize]
public Task<SampleDto> GetAuthorizedAsync()
{
return Task.FromResult(
new SampleDto
{
Value = 42
}
);
}
}
}

19
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorServerModule.cs

@ -1,14 +1,13 @@
using Volo.Abp.AspNetCore.Components.Server.Theming;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.Blazor.Server
namespace MyCompanyName.MyProjectName.Blazor.Server;
[DependsOn(
typeof(AbpAspNetCoreComponentsServerThemingModule),
typeof(MyProjectNameBlazorModule)
)]
public class MyProjectNameBlazorServerModule : AbpModule
{
[DependsOn(
typeof(AbpAspNetCoreComponentsServerThemingModule),
typeof(MyProjectNameBlazorModule)
)]
public class MyProjectNameBlazorServerModule : AbpModule
{
}
}
}

21
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.WebAssembly/MyProjectNameBlazorWebAssemblyModule.cs

@ -1,15 +1,14 @@
using Volo.Abp.AspNetCore.Components.WebAssembly.Theming;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.Blazor.WebAssembly
namespace MyCompanyName.MyProjectName.Blazor.WebAssembly;
[DependsOn(
typeof(MyProjectNameBlazorModule),
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule)
)]
public class MyProjectNameBlazorWebAssemblyModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameBlazorModule),
typeof(MyProjectNameHttpApiClientModule),
typeof(AbpAspNetCoreComponentsWebAssemblyThemingModule)
)]
public class MyProjectNameBlazorWebAssemblyModule : AbpModule
{
}
}
}

29
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs

@ -1,24 +1,23 @@
using System.Threading.Tasks;
using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Blazor.Menus
namespace MyCompanyName.MyProjectName.Blazor.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{
public class MyProjectNameMenuContributor : IMenuContributor
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
if (context.Menu.Name == StandardMenus.Main)
{
if (context.Menu.Name == StandardMenus.Main)
{
await ConfigureMainMenuAsync(context);
}
await ConfigureMainMenuAsync(context);
}
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
//Add main menu items.
context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "/MyProjectName", icon: "fa fa-globe"));
return Task.CompletedTask;
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
//Add main menu items.
context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "/MyProjectName", icon: "fa fa-globe"));
return Task.CompletedTask;
}
}
}

15
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Blazor.Menus
namespace MyCompanyName.MyProjectName.Blazor.Menus;
public class MyProjectNameMenus
{
public class MyProjectNameMenus
{
public const string Prefix = "MyProjectName";
public const string Prefix = "MyProjectName";
//Add your menu items here...
//public const string Home = Prefix + ".MyNewMenuItem";
//Add your menu items here...
//public const string Home = Prefix + ".MyNewMenuItem";
}
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs

@ -1,14 +1,13 @@
using AutoMapper;
namespace MyCompanyName.MyProjectName.Blazor
namespace MyCompanyName.MyProjectName.Blazor;
public class MyProjectNameBlazorAutoMapperProfile : Profile
{
public class MyProjectNameBlazorAutoMapperProfile : Profile
public MyProjectNameBlazorAutoMapperProfile()
{
public MyProjectNameBlazorAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

47
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs

@ -6,33 +6,32 @@ using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Blazor
namespace MyCompanyName.MyProjectName.Blazor;
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreComponentsWebThemingModule),
typeof(AbpAutoMapperModule)
)]
public class MyProjectNameBlazorModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreComponentsWebThemingModule),
typeof(AbpAutoMapperModule)
)]
public class MyProjectNameBlazorModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<MyProjectNameBlazorModule>();
context.Services.AddAutoMapperObjectMapper<MyProjectNameBlazorModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<MyProjectNameBlazorAutoMapperProfile>(validate: true);
});
Configure<AbpAutoMapperOptions>(options =>
{
options.AddProfile<MyProjectNameBlazorAutoMapperProfile>(validate: true);
});
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
Configure<AbpRouterOptions>(options =>
{
options.AdditionalAssemblies.Add(typeof(MyProjectNameBlazorModule).Assembly);
});
}
Configure<AbpRouterOptions>(options =>
{
options.AdditionalAssemblies.Add(typeof(MyProjectNameBlazorModule).Assembly);
});
}
}
}

11
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs

@ -1,10 +1,9 @@
using Volo.Abp.Localization;
namespace MyCompanyName.MyProjectName.Localization
namespace MyCompanyName.MyProjectName.Localization;
[LocalizationResourceName("MyProjectName")]
public class MyProjectNameResource
{
[LocalizationResourceName("MyProjectName")]
public class MyProjectNameResource
{
}
}

43
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs

@ -6,32 +6,31 @@ using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(AbpValidationModule)
)]
public class MyProjectNameDomainSharedModule : AbpModule
{
[DependsOn(
typeof(AbpValidationModule)
)]
public class MyProjectNameDomainSharedModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
Configure<AbpVirtualFileSystemOptions>(options =>
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameDomainSharedModule>();
});
options.FileSets.AddEmbedded<MyProjectNameDomainSharedModule>();
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Add<MyProjectNameResource>("en")
.AddBaseTypes(typeof(AbpValidationResource))
.AddVirtualJson("/Localization/MyProjectName");
});
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Add<MyProjectNameResource>("en")
.AddBaseTypes(typeof(AbpValidationResource))
.AddVirtualJson("/Localization/MyProjectName");
});
Configure<AbpExceptionLocalizationOptions>(options =>
{
options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource));
});
}
Configure<AbpExceptionLocalizationOptions>(options =>
{
options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource));
});
}
}

9
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameErrorCodes.cs

@ -1,7 +1,6 @@
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public static class MyProjectNameErrorCodes
{
public static class MyProjectNameErrorCodes
{
//Add your business exception error codes here...
}
//Add your business exception error codes here...
}

13
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDbProperties.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public static class MyProjectNameDbProperties
{
public static class MyProjectNameDbProperties
{
public static string DbTablePrefix { get; set; } = "MyProjectName";
public static string DbTablePrefix { get; set; } = "MyProjectName";
public static string DbSchema { get; set; } = null;
public static string DbSchema { get; set; } = null;
public const string ConnectionStringName = "MyProjectName";
}
public const string ConnectionStringName = "MyProjectName";
}

15
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs

@ -1,14 +1,13 @@
using Volo.Abp.Domain;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(AbpDddDomainModule),
typeof(MyProjectNameDomainSharedModule)
)]
public class MyProjectNameDomainModule : AbpModule
{
[DependsOn(
typeof(AbpDddDomainModule),
typeof(MyProjectNameDomainSharedModule)
)]
public class MyProjectNameDomainModule : AbpModule
{
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs

@ -1,14 +1,13 @@
using Volo.Abp.Settings;
namespace MyCompanyName.MyProjectName.Settings
namespace MyCompanyName.MyProjectName.Settings;
public class MyProjectNameSettingDefinitionProvider : SettingDefinitionProvider
{
public class MyProjectNameSettingDefinitionProvider : SettingDefinitionProvider
public override void Define(ISettingDefinitionContext context)
{
public override void Define(ISettingDefinitionContext context)
{
/* Define module settings here.
* Use names from MyProjectNameSettings class.
*/
}
/* Define module settings here.
* Use names from MyProjectNameSettings class.
*/
}
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Settings
namespace MyCompanyName.MyProjectName.Settings;
public static class MyProjectNameSettings
{
public static class MyProjectNameSettings
{
public const string GroupName = "MyProjectName";
public const string GroupName = "MyProjectName";
/* Add constants for setting names. Example:
* public const string MySettingName = GroupName + ".MySettingName";
*/
}
}
/* Add constants for setting names. Example:
* public const string MySettingName = GroupName + ".MySettingName";
*/
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/IMyProjectNameDbContext.cs

@ -1,13 +1,12 @@
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public interface IMyProjectNameDbContext : IEfCoreDbContext
{
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public interface IMyProjectNameDbContext : IEfCoreDbContext
{
/* Add DbSet for each Aggregate Root here. Example:
* DbSet<Question> Questions { get; }
*/
}
}
/* Add DbSet for each Aggregate Root here. Example:
* DbSet<Question> Questions { get; }
*/
}

33
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs

@ -2,26 +2,25 @@
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext>, IMyProjectNameDbContext
{
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public class MyProjectNameDbContext : AbpDbContext<MyProjectNameDbContext>, IMyProjectNameDbContext
{
/* Add DbSet for each Aggregate Root here. Example:
* public DbSet<Question> Questions { get; set; }
*/
/* Add DbSet for each Aggregate Root here. Example:
* public DbSet<Question> Questions { get; set; }
*/
public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options)
: base(options)
{
public MyProjectNameDbContext(DbContextOptions<MyProjectNameDbContext> options)
: base(options)
{
}
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ConfigureMyProjectName();
}
builder.ConfigureMyProjectName();
}
}
}

41
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextModelCreatingExtensions.cs

@ -1,34 +1,33 @@
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
public static class MyProjectNameDbContextModelCreatingExtensions
{
public static class MyProjectNameDbContextModelCreatingExtensions
public static void ConfigureMyProjectName(
this ModelBuilder builder)
{
public static void ConfigureMyProjectName(
this ModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
Check.NotNull(builder, nameof(builder));
/* Configure all entities here. Example:
/* Configure all entities here. Example:
builder.Entity<Question>(b =>
{
//Configure table & schema name
b.ToTable(MyProjectNameDbProperties.DbTablePrefix + "Questions", MyProjectNameDbProperties.DbSchema);
builder.Entity<Question>(b =>
{
//Configure table & schema name
b.ToTable(MyProjectNameDbProperties.DbTablePrefix + "Questions", MyProjectNameDbProperties.DbSchema);
b.ConfigureByConvention();
b.ConfigureByConvention();
//Properties
b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);
//Properties
b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength);
//Relations
b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);
//Relations
b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId);
//Indexes
b.HasIndex(q => q.CreationTime);
});
*/
}
//Indexes
b.HasIndex(q => q.CreationTime);
});
*/
}
}

23
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs

@ -2,22 +2,21 @@
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpEntityFrameworkCoreModule)
)]
public class MyProjectNameEntityFrameworkCoreModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpEntityFrameworkCoreModule)
)]
public class MyProjectNameEntityFrameworkCoreModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
context.Services.AddAbpDbContext<MyProjectNameDbContext>(options =>
{
context.Services.AddAbpDbContext<MyProjectNameDbContext>(options =>
{
/* Add custom repositories here. Example:
* options.AddRepository<Question, EfCoreQuestionRepository>();
*/
});
}
});
}
}
}

31
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs

@ -3,25 +3,24 @@ using Volo.Abp.Http.Client;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpHttpClientModule))]
public class MyProjectNameHttpApiClientModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpHttpClientModule))]
public class MyProjectNameHttpApiClientModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClientProxies(
typeof(MyProjectNameApplicationContractsModule).Assembly,
MyProjectNameRemoteServiceConsts.RemoteServiceName
);
context.Services.AddHttpClientProxies(
typeof(MyProjectNameApplicationContractsModule).Assembly,
MyProjectNameRemoteServiceConsts.RemoteServiceName
);
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameHttpApiClientModule>();
});
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameHttpApiClientModule>();
});
}
}
}

11
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameController.cs

@ -1,13 +1,12 @@
using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Mvc;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
public abstract class MyProjectNameController : AbpControllerBase
{
public abstract class MyProjectNameController : AbpControllerBase
protected MyProjectNameController()
{
protected MyProjectNameController()
{
LocalizationResource = typeof(MyProjectNameResource);
}
LocalizationResource = typeof(MyProjectNameResource);
}
}

37
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs

@ -5,29 +5,28 @@ using Volo.Abp.Localization;
using Volo.Abp.Modularity;
using Microsoft.Extensions.DependencyInjection;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreMvcModule))]
public class MyProjectNameHttpApiModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreMvcModule))]
public class MyProjectNameHttpApiModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameHttpApiModule).Assembly);
});
}
mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameHttpApiModule).Assembly);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLocalizationOptions>(options =>
{
Configure<AbpLocalizationOptions>(options =>
{
options.Resources
.Get<MyProjectNameResource>()
.AddBaseTypes(typeof(AbpUiResource));
});
}
options.Resources
.Get<MyProjectNameResource>()
.AddBaseTypes(typeof(AbpUiResource));
});
}
}

45
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Samples/SampleController.cs

@ -3,32 +3,31 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
namespace MyCompanyName.MyProjectName.Samples
namespace MyCompanyName.MyProjectName.Samples;
[Area(MyProjectNameRemoteServiceConsts.ModuleName)]
[RemoteService(Name = MyProjectNameRemoteServiceConsts.RemoteServiceName)]
[Route("api/MyProjectName/sample")]
public class SampleController : MyProjectNameController, ISampleAppService
{
[Area(MyProjectNameRemoteServiceConsts.ModuleName)]
[RemoteService(Name = MyProjectNameRemoteServiceConsts.RemoteServiceName)]
[Route("api/MyProjectName/sample")]
public class SampleController : MyProjectNameController, ISampleAppService
{
private readonly ISampleAppService _sampleAppService;
private readonly ISampleAppService _sampleAppService;
public SampleController(ISampleAppService sampleAppService)
{
_sampleAppService = sampleAppService;
}
public SampleController(ISampleAppService sampleAppService)
{
_sampleAppService = sampleAppService;
}
[HttpGet]
public async Task<SampleDto> GetAsync()
{
return await _sampleAppService.GetAsync();
}
[HttpGet]
public async Task<SampleDto> GetAsync()
{
return await _sampleAppService.GetAsync();
}
[HttpGet]
[Route("authorized")]
[Authorize]
public async Task<SampleDto> GetAuthorizedAsync()
{
return await _sampleAppService.GetAsync();
}
[HttpGet]
[Route("authorized")]
[Authorize]
public async Task<SampleDto> GetAuthorizedAsync()
{
return await _sampleAppService.GetAsync();
}
}

23
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerModule.cs

@ -2,20 +2,19 @@
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace MyCompany.MyProjectName
namespace MyCompany.MyProjectName;
[DependsOn(
typeof(AbpStudioModuleInstallerModule),
typeof(AbpVirtualFileSystemModule)
)]
public class MyProjectNameInstallerModule : AbpModule
{
[DependsOn(
typeof(AbpStudioModuleInstallerModule),
typeof(AbpVirtualFileSystemModule)
)]
public class MyProjectNameInstallerModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
Configure<AbpVirtualFileSystemOptions>(options =>
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameInstallerModule>();
});
}
options.FileSets.AddEmbedded<MyProjectNameInstallerModule>();
});
}
}

15
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Installer/MyProjectNameInstallerPipelineBuilder.cs

@ -3,15 +3,14 @@ using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Studio.ModuleInstalling;
namespace MyCompany.MyProjectName
namespace MyCompany.MyProjectName;
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
[ExposeServices(typeof(IModuleInstallingPipelineBuilder))]
public class MyProjectNameInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency
{
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)]
[ExposeServices(typeof(IModuleInstallingPipelineBuilder))]
public class MyProjectNameInstallerPipelineBuilder : ModuleInstallingPipelineBuilderBase, IModuleInstallingPipelineBuilder, ITransientDependency
public async Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
{
public async Task<ModuleInstallingPipeline> BuildAsync(ModuleInstallingContext context)
{
return GetBasePipeline(context);
}
return GetBasePipeline(context);
}
}

15
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/IMyProjectNameMongoDbContext.cs

@ -1,13 +1,12 @@
using Volo.Abp.Data;
using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB
namespace MyCompanyName.MyProjectName.MongoDB;
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public interface IMyProjectNameMongoDbContext : IAbpMongoDbContext
{
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public interface IMyProjectNameMongoDbContext : IAbpMongoDbContext
{
/* Define mongo collections here. Example:
* IMongoCollection<Question> Questions { get; }
*/
}
/* Define mongo collections here. Example:
* IMongoCollection<Question> Questions { get; }
*/
}

25
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContext.cs

@ -1,20 +1,19 @@
using Volo.Abp.Data;
using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB
namespace MyCompanyName.MyProjectName.MongoDB;
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public class MyProjectNameMongoDbContext : AbpMongoDbContext, IMyProjectNameMongoDbContext
{
[ConnectionStringName(MyProjectNameDbProperties.ConnectionStringName)]
public class MyProjectNameMongoDbContext : AbpMongoDbContext, IMyProjectNameMongoDbContext
{
/* Add mongo collections here. Example:
* public IMongoCollection<Question> Questions => Collection<Question>();
*/
/* Add mongo collections here. Example:
* public IMongoCollection<Question> Questions => Collection<Question>();
*/
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{
base.CreateModel(modelBuilder);
modelBuilder.ConfigureMyProjectName();
}
modelBuilder.ConfigureMyProjectName();
}
}
}

13
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbContextExtensions.cs

@ -1,14 +1,13 @@
using Volo.Abp;
using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB
namespace MyCompanyName.MyProjectName.MongoDB;
public static class MyProjectNameMongoDbContextExtensions
{
public static class MyProjectNameMongoDbContextExtensions
public static void ConfigureMyProjectName(
this IMongoModelBuilder builder)
{
public static void ConfigureMyProjectName(
this IMongoModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
}
Check.NotNull(builder, nameof(builder));
}
}

21
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDB/MyProjectNameMongoDbModule.cs

@ -2,22 +2,21 @@
using Volo.Abp.Modularity;
using Volo.Abp.MongoDB;
namespace MyCompanyName.MyProjectName.MongoDB
namespace MyCompanyName.MyProjectName.MongoDB;
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpMongoDbModule)
)]
public class MyProjectNameMongoDbModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameDomainModule),
typeof(AbpMongoDbModule)
)]
public class MyProjectNameMongoDbModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
context.Services.AddMongoDbContext<MyProjectNameMongoDbContext>(options =>
{
context.Services.AddMongoDbContext<MyProjectNameMongoDbContext>(options =>
{
/* Add custom repositories here. Example:
* options.AddRepository<Question, MongoQuestionRepository>();
*/
});
}
});
}
}

27
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs

@ -1,24 +1,23 @@
using System.Threading.Tasks;
using Volo.Abp.UI.Navigation;
namespace MyCompanyName.MyProjectName.Web.Menus
namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameMenuContributor : IMenuContributor
{
public class MyProjectNameMenuContributor : IMenuContributor
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
{
public async Task ConfigureMenuAsync(MenuConfigurationContext context)
if (context.Menu.Name == StandardMenus.Main)
{
if (context.Menu.Name == StandardMenus.Main)
{
await ConfigureMainMenuAsync(context);
}
await ConfigureMainMenuAsync(context);
}
}
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
//Add main menu items.
context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "~/MyProjectName", icon: "fa fa-globe"));
private Task ConfigureMainMenuAsync(MenuConfigurationContext context)
{
//Add main menu items.
context.Menu.AddItem(new ApplicationMenuItem(MyProjectNameMenus.Prefix, displayName: "MyProjectName", "~/MyProjectName", icon: "fa fa-globe"));
return Task.CompletedTask;
}
return Task.CompletedTask;
}
}
}

15
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs

@ -1,11 +1,10 @@
namespace MyCompanyName.MyProjectName.Web.Menus
namespace MyCompanyName.MyProjectName.Web.Menus;
public class MyProjectNameMenus
{
public class MyProjectNameMenus
{
public const string Prefix = "MyProjectName";
public const string Prefix = "MyProjectName";
//Add your menu items here...
//public const string Home = Prefix + ".MyNewMenuItem";
//Add your menu items here...
//public const string Home = Prefix + ".MyNewMenuItem";
}
}
}

17
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs

@ -1,14 +1,13 @@
using AutoMapper;
namespace MyCompanyName.MyProjectName.Web
namespace MyCompanyName.MyProjectName.Web;
public class MyProjectNameWebAutoMapperProfile : Profile
{
public class MyProjectNameWebAutoMapperProfile : Profile
public MyProjectNameWebAutoMapperProfile()
{
public MyProjectNameWebAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
}
}
}

67
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs

@ -10,50 +10,49 @@ using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
using MyCompanyName.MyProjectName.Permissions;
namespace MyCompanyName.MyProjectName.Web
namespace MyCompanyName.MyProjectName.Web;
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
)]
public class MyProjectNameWebModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameApplicationContractsModule),
typeof(AbpAspNetCoreMvcUiThemeSharedModule),
typeof(AbpAutoMapperModule)
)]
public class MyProjectNameWebModule : AbpModule
public override void PreConfigureServices(ServiceConfigurationContext context)
{
public override void PreConfigureServices(ServiceConfigurationContext context)
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
context.Services.PreConfigure<AbpMvcDataAnnotationsLocalizationOptions>(options =>
{
options.AddAssemblyResource(typeof(MyProjectNameResource), typeof(MyProjectNameWebModule).Assembly);
});
options.AddAssemblyResource(typeof(MyProjectNameResource), typeof(MyProjectNameWebModule).Assembly);
});
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameWebModule).Assembly);
});
}
PreConfigure<IMvcBuilder>(mvcBuilder =>
{
mvcBuilder.AddApplicationPartIfNotExists(typeof(MyProjectNameWebModule).Assembly);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpNavigationOptions>(options =>
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
options.MenuContributors.Add(new MyProjectNameMenuContributor());
});
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameWebModule>();
});
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyProjectNameWebModule>();
});
context.Services.AddAutoMapperObjectMapper<MyProjectNameWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameWebModule>(validate: true);
});
context.Services.AddAutoMapperObjectMapper<MyProjectNameWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameWebModule>(validate: true);
});
Configure<RazorPagesOptions>(options =>
{
Configure<RazorPagesOptions>(options =>
{
//Configure authorization.
});
}
}
}

11
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs

@ -1,9 +1,8 @@
namespace MyCompanyName.MyProjectName.Web.Pages.MyProjectName
namespace MyCompanyName.MyProjectName.Web.Pages.MyProjectName;
public class IndexModel : MyProjectNamePageModel
{
public class IndexModel : MyProjectNamePageModel
public void OnGet()
{
public void OnGet()
{
}
}
}
}

19
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs

@ -1,16 +1,15 @@
using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
namespace MyCompanyName.MyProjectName.Web.Pages
namespace MyCompanyName.MyProjectName.Web.Pages;
/* Inherit your PageModel classes from this class.
*/
public abstract class MyProjectNamePageModel : AbpPageModel
{
/* Inherit your PageModel classes from this class.
*/
public abstract class MyProjectNamePageModel : AbpPageModel
protected MyProjectNamePageModel()
{
protected MyProjectNamePageModel()
{
LocalizationResourceType = typeof(MyProjectNameResource);
ObjectMapperContext = typeof(MyProjectNameWebModule);
}
LocalizationResourceType = typeof(MyProjectNameResource);
ObjectMapperContext = typeof(MyProjectNameWebModule);
}
}
}

15
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
/* Inherit from this class for your application layer tests.
* See SampleAppService_Tests for example.
*/
public abstract class MyProjectNameApplicationTestBase : MyProjectNameTestBase<MyProjectNameApplicationTestModule>
{
/* Inherit from this class for your application layer tests.
* See SampleAppService_Tests for example.
*/
public abstract class MyProjectNameApplicationTestBase : MyProjectNameTestBase<MyProjectNameApplicationTestModule>
{
}
}
}

15
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs

@ -1,13 +1,12 @@
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
[DependsOn(
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameDomainTestModule)
)]
public class MyProjectNameApplicationTestModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameApplicationModule),
typeof(MyProjectNameDomainTestModule)
)]
public class MyProjectNameApplicationTestModule : AbpModule
{
}
}

39
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppService_Tests.cs

@ -2,29 +2,28 @@
using Shouldly;
using Xunit;
namespace MyCompanyName.MyProjectName.Samples
namespace MyCompanyName.MyProjectName.Samples;
public class SampleAppService_Tests : MyProjectNameApplicationTestBase
{
public class SampleAppService_Tests : MyProjectNameApplicationTestBase
{
private readonly ISampleAppService _sampleAppService;
private readonly ISampleAppService _sampleAppService;
public SampleAppService_Tests()
{
_sampleAppService = GetRequiredService<ISampleAppService>();
}
public SampleAppService_Tests()
{
_sampleAppService = GetRequiredService<ISampleAppService>();
}
[Fact]
public async Task GetAsync()
{
var result = await _sampleAppService.GetAsync();
result.Value.ShouldBe(42);
}
[Fact]
public async Task GetAsync()
{
var result = await _sampleAppService.GetAsync();
result.Value.ShouldBe(42);
}
[Fact]
public async Task GetAuthorizedAsync()
{
var result = await _sampleAppService.GetAuthorizedAsync();
result.Value.ShouldBe(42);
}
[Fact]
public async Task GetAuthorizedAsync()
{
var result = await _sampleAppService.GetAuthorizedAsync();
result.Value.ShouldBe(42);
}
}

15
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
/* Inherit from this class for your domain layer tests.
* See SampleManager_Tests for example.
*/
public abstract class MyProjectNameDomainTestBase : MyProjectNameTestBase<MyProjectNameDomainTestModule>
{
/* Inherit from this class for your domain layer tests.
* See SampleManager_Tests for example.
*/
public abstract class MyProjectNameDomainTestBase : MyProjectNameTestBase<MyProjectNameDomainTestModule>
{
}
}
}

23
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs

@ -1,17 +1,16 @@
using MyCompanyName.MyProjectName.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName
namespace MyCompanyName.MyProjectName;
/* Domain tests are configured to use the EF Core provider.
* You can switch to MongoDB, however your domain tests should be
* database independent anyway.
*/
[DependsOn(
typeof(MyProjectNameEntityFrameworkCoreTestModule)
)]
public class MyProjectNameDomainTestModule : AbpModule
{
/* Domain tests are configured to use the EF Core provider.
* You can switch to MongoDB, however your domain tests should be
* database independent anyway.
*/
[DependsOn(
typeof(MyProjectNameEntityFrameworkCoreTestModule)
)]
public class MyProjectNameDomainTestModule : AbpModule
{
}
}

23
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleManager_Tests.cs

@ -1,21 +1,20 @@
using System.Threading.Tasks;
using Xunit;
namespace MyCompanyName.MyProjectName.Samples
namespace MyCompanyName.MyProjectName.Samples;
public class SampleManager_Tests : MyProjectNameDomainTestBase
{
public class SampleManager_Tests : MyProjectNameDomainTestBase
{
//private readonly SampleManager _sampleManager;
//private readonly SampleManager _sampleManager;
public SampleManager_Tests()
{
//_sampleManager = GetRequiredService<SampleManager>();
}
public SampleManager_Tests()
{
//_sampleManager = GetRequiredService<SampleManager>();
}
[Fact]
public async Task Method1Async()
{
[Fact]
public async Task Method1Async()
{
}
}
}

15
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs

@ -1,10 +1,9 @@
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
/* This class can be used as a base class for EF Core integration tests,
* while SampleRepository_Tests uses a different approach.
*/
public abstract class MyProjectNameEntityFrameworkCoreTestBase : MyProjectNameTestBase<MyProjectNameEntityFrameworkCoreTestModule>
{
/* This class can be used as a base class for EF Core integration tests,
* while SampleRepository_Tests uses a different approach.
*/
public abstract class MyProjectNameEntityFrameworkCoreTestBase : MyProjectNameTestBase<MyProjectNameEntityFrameworkCoreTestModule>
{
}
}
}

53
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs

@ -6,38 +6,37 @@ using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Sqlite;
using Volo.Abp.Modularity;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore
namespace MyCompanyName.MyProjectName.EntityFrameworkCore;
[DependsOn(
typeof(MyProjectNameTestBaseModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule
{
[DependsOn(
typeof(MyProjectNameTestBaseModule),
typeof(MyProjectNameEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreSqliteModule)
)]
public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var sqliteConnection = CreateDatabaseAndGetConnection();
var sqliteConnection = CreateDatabaseAndGetConnection();
Configure<AbpDbContextOptions>(options =>
Configure<AbpDbContextOptions>(options =>
{
options.Configure(abpDbContextConfigurationContext =>
{
options.Configure(abpDbContextConfigurationContext =>
{
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection);
});
abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection);
});
}
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
});
}
private static SqliteConnection CreateDatabaseAndGetConnection()
{
var connection = new SqliteConnection("Data Source=:memory:");
connection.Open();
new MyProjectNameDbContext(
new DbContextOptionsBuilder<MyProjectNameDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();
new MyProjectNameDbContext(
new DbContextOptionsBuilder<MyProjectNameDbContext>().UseSqlite(connection).Options
).GetService<IRelationalDatabaseCreator>().CreateTables();
return connection;
}
return connection;
}
}

15
templates/module/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs

@ -1,12 +1,11 @@
using MyCompanyName.MyProjectName.Samples;
namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples
namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples;
public class SampleRepository_Tests : SampleRepository_Tests<MyProjectNameEntityFrameworkCoreTestModule>
{
public class SampleRepository_Tests : SampleRepository_Tests<MyProjectNameEntityFrameworkCoreTestModule>
{
/* Don't write custom repository tests here, instead write to
* the base class.
* One exception can be some specific tests related to EF core.
*/
}
/* Don't write custom repository tests here, instead write to
* the base class.
* One exception can be some specific tests related to EF core.
*/
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save