diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs index 647a60bba4..a3d78164fa 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameApplicationContractsModule.cs @@ -7,23 +7,22 @@ using Volo.Abp.PermissionManagement; using Volo.Abp.SettingManagement; using Volo.Abp.TenantManagement; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameDomainSharedModule), + typeof(AbpAccountApplicationContractsModule), + typeof(AbpFeatureManagementApplicationContractsModule), + typeof(AbpIdentityApplicationContractsModule), + typeof(AbpPermissionManagementApplicationContractsModule), + typeof(AbpSettingManagementApplicationContractsModule), + typeof(AbpTenantManagementApplicationContractsModule), + typeof(AbpObjectExtendingModule) +)] +public class MyProjectNameApplicationContractsModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainSharedModule), - typeof(AbpAccountApplicationContractsModule), - typeof(AbpFeatureManagementApplicationContractsModule), - typeof(AbpIdentityApplicationContractsModule), - typeof(AbpPermissionManagementApplicationContractsModule), - typeof(AbpSettingManagementApplicationContractsModule), - typeof(AbpTenantManagementApplicationContractsModule), - typeof(AbpObjectExtendingModule) - )] - public class MyProjectNameApplicationContractsModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - MyProjectNameDtoExtensions.Configure(); - } + MyProjectNameDtoExtensions.Configure(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameDtoExtensions.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameDtoExtensions.cs index 35af461b46..5c72f28399 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameDtoExtensions.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/MyProjectNameDtoExtensions.cs @@ -2,16 +2,16 @@ using Volo.Abp.ObjectExtending; using Volo.Abp.Threading; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameDtoExtensions { - public static class MyProjectNameDtoExtensions - { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); - public static void Configure() + public static void Configure() + { + OneTimeRunner.Run(() => { - OneTimeRunner.Run(() => - { /* You can add extension properties to DTOs * defined in the depended modules. * @@ -23,7 +23,6 @@ namespace MyCompanyName.MyProjectName * See the documentation for more: * https://docs.abp.io/en/abp/latest/Object-Extensions */ - }); - } + }); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs index 569fa7b6a7..f3bee53236 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissionDefinitionProvider.cs @@ -2,20 +2,19 @@ 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); - //Define your own permissions here. Example: - //myGroup.AddPermission(MyProjectNamePermissions.MyPermission1, L("Permission:MyPermission1")); - } + var myGroup = context.AddGroup(MyProjectNamePermissions.GroupName); + //Define your own permissions here. Example: + //myGroup.AddPermission(MyProjectNamePermissions.MyPermission1, L("Permission:MyPermission1")); + } - private static LocalizableString L(string name) - { - return LocalizableString.Create(name); - } + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs index 155117c7d3..764822a9b2 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application.Contracts/Permissions/MyProjectNamePermissions.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.Permissions +namespace MyCompanyName.MyProjectName.Permissions; + +public static class MyProjectNamePermissions { - public static class MyProjectNamePermissions - { - public const string GroupName = "MyProjectName"; + public const string GroupName = "MyProjectName"; - //Add your own permission names. Example: - //public const string MyPermission1 = GroupName + ".MyPermission1"; - } -} \ No newline at end of file + //Add your own permission names. Example: + //public const string MyPermission1 = GroupName + ".MyPermission1"; +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs index 8cf7cca603..e6c70ee280 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs @@ -4,15 +4,14 @@ using System.Text; using MyCompanyName.MyProjectName.Localization; using Volo.Abp.Application.Services; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/* Inherit your application services from this class. + */ +public abstract class MyProjectNameAppService : ApplicationService { - /* Inherit your application services from this class. - */ - public abstract class MyProjectNameAppService : ApplicationService + protected MyProjectNameAppService() { - protected MyProjectNameAppService() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs index 20f646f998..f3f7d14052 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationAutoMapperProfile.cs +++ b/templates/app/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. */ } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs index 3974ea7be3..12ba3bdc25 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs @@ -7,26 +7,25 @@ using Volo.Abp.PermissionManagement; using Volo.Abp.SettingManagement; using Volo.Abp.TenantManagement; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameDomainModule), + typeof(AbpAccountApplicationModule), + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpIdentityApplicationModule), + typeof(AbpPermissionManagementApplicationModule), + typeof(AbpTenantManagementApplicationModule), + typeof(AbpFeatureManagementApplicationModule), + typeof(AbpSettingManagementApplicationModule) + )] +public class MyProjectNameApplicationModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainModule), - typeof(AbpAccountApplicationModule), - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpIdentityApplicationModule), - typeof(AbpPermissionManagementApplicationModule), - typeof(AbpTenantManagementApplicationModule), - typeof(AbpFeatureManagementApplicationModule), - typeof(AbpSettingManagementApplicationModule) - )] - public class MyProjectNameApplicationModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.AddMaps(); + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs index 7ca2386d14..3d774fefce 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Components.Toolbar.LoginLink +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Components.Toolbar.LoginLink; + +public class LoginLinkViewComponent : AbpViewComponent { - public class LoginLinkViewComponent : AbpViewComponent + public virtual IViewComponentResult Invoke() { - public virtual IViewComponentResult Invoke() - { - return View("~/Components/Toolbar/LoginLink/Default.cshtml"); - } + return View("~/Components/Toolbar/LoginLink/Default.cshtml"); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Controllers/AccountController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Controllers/AccountController.cs index 44d63fa0f2..711f17e1e6 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Controllers/AccountController.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Controllers/AccountController.cs @@ -1,9 +1,8 @@ using Volo.Abp.AspNetCore.Mvc.Authentication; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Controllers +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Controllers; + +public class AccountController : ChallengeAccountController { - public class AccountController : ChallengeAccountController - { - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs index ef176b1a1f..2ed1a3fcb2 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenuContributor.cs @@ -12,71 +12,70 @@ using Volo.Abp.TenantManagement.Blazor.Navigation; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus; + +public class MyProjectNameMenuContributor : IMenuContributor { - public class MyProjectNameMenuContributor : IMenuContributor + private readonly IConfiguration _configuration; + + public MyProjectNameMenuContributor(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public MyProjectNameMenuContributor(IConfiguration configuration) + public async Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.Main) { - _configuration = configuration; + await ConfigureMainMenuAsync(context); } - - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + else if (context.Menu.Name == StandardMenus.User) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } - else if (context.Menu.Name == StandardMenus.User) - { - await ConfigureUserMenuAsync(context); - } + await ConfigureUserMenuAsync(context); } + } - private Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - var administration = context.Menu.GetAdministration(); - var l = context.GetLocalizer(); + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var administration = context.Menu.GetAdministration(); + var l = context.GetLocalizer(); - context.Menu.Items.Insert( - 0, - new ApplicationMenuItem( - MyProjectNameMenus.Home, - l["Menu:Home"], - "/", - icon: "fas fa-home", - order: 0 - ) - ); - - if (MultiTenancyConsts.IsEnabled) - { - administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); - } - else - { - administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); - } - - administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); - administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); + context.Menu.Items.Insert( + 0, + new ApplicationMenuItem( + MyProjectNameMenus.Home, + l["Menu:Home"], + "/", + icon: "fas fa-home", + order: 0 + ) + ); - return Task.CompletedTask; + if (MultiTenancyConsts.IsEnabled) + { + administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); } - - private Task ConfigureUserMenuAsync(MenuConfigurationContext context) + else { - var l = context.GetLocalizer(); - var accountStringLocalizer = context.GetLocalizer(); - var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; + administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); + } - context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); - context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated()); + administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); + administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); - return Task.CompletedTask; - } + return Task.CompletedTask; + } + + private Task ConfigureUserMenuAsync(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); + var accountStringLocalizer = context.GetLocalizer(); + var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; + + context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); + context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated()); + + return Task.CompletedTask; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenus.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenus.cs index 8e9ab98402..cad1dd03e1 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenus.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameMenus.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus; + +public class MyProjectNameMenus { - public class MyProjectNameMenus - { - private const string Prefix = "MyProjectName"; - public const string Home = Prefix + ".Home"; + private const string Prefix = "MyProjectName"; + public const string Home = Prefix + ".Home"; - //Add your menu items here... + //Add your menu items here... - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameToolbarContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameToolbarContributor.cs index 71cb951bc8..d14b155ea3 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameToolbarContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Menus/MyProjectNameToolbarContributor.cs @@ -4,23 +4,22 @@ using MyCompanyName.MyProjectName.Blazor.Server.Tiered.Components.Toolbar.LoginL using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.Users; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Menus; + +public class MyProjectNameToolbarContributor : IToolbarContributor { - public class MyProjectNameToolbarContributor : IToolbarContributor + public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) { - public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) + if (context.Toolbar.Name != StandardToolbars.Main) { - if (context.Toolbar.Name != StandardToolbars.Main) - { - return Task.CompletedTask; - } - - if (!context.ServiceProvider.GetRequiredService().IsAuthenticated) - { - context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent))); - } - return Task.CompletedTask; } + + if (!context.ServiceProvider.GetRequiredService().IsAuthenticated) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent))); + } + + return Task.CompletedTask; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs index 46c9506e00..cb88cf5172 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBlazorModule.cs @@ -48,286 +48,285 @@ using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered; + +[DependsOn( + typeof(MyProjectNameHttpApiClientModule), + typeof(MyProjectNameHttpApiModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpAspNetCoreMvcClientModule), + typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), + typeof(AbpHttpClientIdentityModelWebModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAutofacModule), + typeof(AbpSwashbuckleModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpAspNetCoreComponentsServerBasicThemeModule), + typeof(AbpIdentityBlazorServerModule), + typeof(AbpTenantManagementBlazorServerModule), + typeof(AbpSettingManagementBlazorServerModule) + )] +public class MyProjectNameBlazorModule : AbpModule { - [DependsOn( - typeof(MyProjectNameHttpApiClientModule), - typeof(MyProjectNameHttpApiModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpAspNetCoreMvcClientModule), - typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), - typeof(AbpHttpClientIdentityModelWebModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAutofacModule), - typeof(AbpSwashbuckleModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpAspNetCoreComponentsServerBasicThemeModule), - typeof(AbpIdentityBlazorServerModule), - typeof(AbpTenantManagementBlazorServerModule), - typeof(AbpSettingManagementBlazorServerModule) - )] - public class MyProjectNameBlazorModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(MyProjectNameResource), - typeof(MyProjectNameDomainSharedModule).Assembly, - typeof(MyProjectNameApplicationContractsModule).Assembly, - typeof(MyProjectNameBlazorModule).Assembly - ); - }); - } + options.AddAssemblyResource( + typeof(MyProjectNameResource), + typeof(MyProjectNameDomainSharedModule).Assembly, + typeof(MyProjectNameApplicationContractsModule).Assembly, + typeof(MyProjectNameBlazorModule).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(); - ConfigureUrls(configuration); - ConfigureCache(); - ConfigureBundles(); - ConfigureMultiTenancy(); - ConfigureAuthentication(context, configuration); - ConfigureAutoMapper(); - ConfigureVirtualFileSystem(hostingEnvironment); - ConfigureLocalizationServices(); - ConfigureBlazorise(context); - ConfigureRouter(context); - ConfigureMenu(configuration); - ConfigureDataProtection(context, configuration, hostingEnvironment); - ConfigureSwaggerServices(context.Services); - } + ConfigureUrls(configuration); + ConfigureCache(); + ConfigureBundles(); + ConfigureMultiTenancy(); + ConfigureAuthentication(context, configuration); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureLocalizationServices(); + ConfigureBlazorise(context); + ConfigureRouter(context); + ConfigureMenu(configuration); + ConfigureDataProtection(context, configuration, hostingEnvironment); + ConfigureSwaggerServices(context.Services); + } - private void ConfigureUrls(IConfiguration configuration) + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); + } - private void ConfigureCache() + private void ConfigureCache() + { + Configure(options => { - Configure(options => - { - options.KeyPrefix = "MyProjectName:"; - }); - } + options.KeyPrefix = "MyProjectName:"; + }); + } - private void ConfigureBundles() + private void ConfigureBundles() + { + Configure(options => { - Configure(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.Tiered.styles.css"); - } - ); - }); - } + } + ); + }); + } - private void ConfigureMultiTenancy() + private void ConfigureMultiTenancy() + { + Configure(options => { - Configure(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 ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + { + if (hostingEnvironment.IsDevelopment()) { - if (hostingEnvironment.IsDevelopment()) + Configure(options => { - Configure(options => - { // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); - options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); - }); - } - } - - private void ConfigureLocalizationServices() - { - Configure(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("hu", "hu", "Magyar")); - 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("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", "de")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); + options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); }); } + } - private void ConfigureBlazorise(ServiceConfigurationContext context) - { - context.Services - .AddBootstrap5Providers() - .AddFontAwesomeIcons(); - } - - private void ConfigureMenu(IConfiguration configuration) + private void ConfigureLocalizationServices() + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration)); - }); + 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("hu", "hu", "Magyar")); + 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("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", "de")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); + } - Configure(options => - { - options.Contributors.Add(new MyProjectNameToolbarContributor()); - }); - } + private void ConfigureBlazorise(ServiceConfigurationContext context) + { + context.Services + .AddBootstrap5Providers() + .AddFontAwesomeIcons(); + } - private void ConfigureRouter(ServiceConfigurationContext context) + private void ConfigureMenu(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; - }); - } + options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration)); + }); - private void ConfigureAutoMapper() + Configure(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.Contributors.Add(new MyProjectNameToolbarContributor()); + }); + } - private void ConfigureSwaggerServices(IServiceCollection services) + private void ConfigureRouter(ServiceConfigurationContext context) + { + Configure(options => { - services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - } - ); - } + options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; + }); + } - private void ConfigureDataProtection( - ServiceConfigurationContext context, - IConfiguration configuration, - IWebHostEnvironment hostingEnvironment) + private void ConfigureAutoMapper() + { + Configure(options => { - var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); - if (!hostingEnvironment.IsDevelopment()) + options.AddMaps(); + }); + } + + private void ConfigureSwaggerServices(IServiceCollection services) + { + services.AddAbpSwaggerGen( + options => { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); } - } + ); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + private void ConfigureDataProtection( + ServiceConfigurationContext context, + IConfiguration configuration, + IWebHostEnvironment hostingEnvironment) + { + var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); + if (!hostingEnvironment.IsDevelopment()) { - var env = context.GetEnvironment(); - var app = context.GetApplicationBuilder(); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); + } + } - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var env = context.GetEnvironment(); + var app = context.GetApplicationBuilder(); - app.UseAbpRequestLocalization(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } - if (!env.IsDevelopment()) - { - app.UseErrorPage(); - } + app.UseAbpRequestLocalization(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); + if (!env.IsDevelopment()) + { + app.UseErrorPage(); + } - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - }); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); } + + app.UseAuthorization(); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + }); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBrandingProvider.cs index 1c31172a52..d481c41c40 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Ui.Branding; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameComponentBase.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameComponentBase.cs index 654c18873c..ff7eca44e2 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameComponentBase.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/MyProjectNameComponentBase.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Components; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered; + +public abstract class MyProjectNameComponentBase : AbpComponentBase { - public abstract class MyProjectNameComponentBase : AbpComponentBase + protected MyProjectNameComponentBase() { - protected MyProjectNameComponentBase() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Pages/Index.razor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Pages/Index.razor.cs index 97cdd22b3f..ed0f7b1c64 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Pages/Index.razor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Pages/Index.razor.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Pages +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered.Pages; + +public partial class Index { - public partial class Index - { - } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Program.cs index 5ec3416569..c783074558 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Program.cs @@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered; + +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) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Startup.cs index c1624c69e8..d3aed6dfd0 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/Startup.cs @@ -2,18 +2,17 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered +namespace MyCompanyName.MyProjectName.Blazor.Server.Tiered; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenuContributor.cs index ef9f62dbed..eeabef69b1 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenuContributor.cs @@ -6,47 +6,46 @@ using Volo.Abp.SettingManagement.Blazor.Menus; using Volo.Abp.TenantManagement.Blazor.Navigation; using Volo.Abp.UI.Navigation; -namespace MyCompanyName.MyProjectName.Blazor.Server.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.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(); - var l = context.GetLocalizer(); - - context.Menu.Items.Insert( - 0, - new ApplicationMenuItem( - MyProjectNameMenus.Home, - l["Menu:Home"], - "/", - icon: "fas fa-home", - order: 0 - ) - ); - - if (MultiTenancyConsts.IsEnabled) - { - administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); - } - else - { - administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); - } + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var administration = context.Menu.GetAdministration(); + var l = context.GetLocalizer(); - administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); - administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); + context.Menu.Items.Insert( + 0, + new ApplicationMenuItem( + MyProjectNameMenus.Home, + l["Menu:Home"], + "/", + icon: "fas fa-home", + order: 0 + ) + ); - return Task.CompletedTask; + if (MultiTenancyConsts.IsEnabled) + { + administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); + } + else + { + administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); } + + administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); + administration.SetSubItemOrder(SettingManagementMenus.GroupName, 3); + + return Task.CompletedTask; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenus.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenus.cs index 660de9a3b9..3723eafb0b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenus.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Menus/MyProjectNameMenus.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.Blazor.Server.Menus +namespace MyCompanyName.MyProjectName.Blazor.Server.Menus; + +public class MyProjectNameMenus { - public class MyProjectNameMenus - { - private const string Prefix = "MyProjectName"; - public const string Home = Prefix + ".Home"; + private const string Prefix = "MyProjectName"; + public const string Home = Prefix + ".Home"; - //Add your menu items here... + //Add your menu items here... - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs index 316d29f8fa..5877ad7585 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBlazorModule.cs @@ -42,116 +42,116 @@ using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName.Blazor.Server +namespace MyCompanyName.MyProjectName.Blazor.Server; + +[DependsOn( + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(MyProjectNameHttpApiModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAutofacModule), + typeof(AbpSwashbuckleModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAspNetCoreComponentsServerBasicThemeModule), + typeof(AbpIdentityBlazorServerModule), + typeof(AbpTenantManagementBlazorServerModule), + typeof(AbpSettingManagementBlazorServerModule) + )] +public class MyProjectNameBlazorModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(MyProjectNameHttpApiModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAutofacModule), - typeof(AbpSwashbuckleModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAspNetCoreComponentsServerBasicThemeModule), - typeof(AbpIdentityBlazorServerModule), - typeof(AbpTenantManagementBlazorServerModule), - typeof(AbpSettingManagementBlazorServerModule) - )] - public class MyProjectNameBlazorModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(MyProjectNameResource), - typeof(MyProjectNameDomainModule).Assembly, - typeof(MyProjectNameDomainSharedModule).Assembly, - typeof(MyProjectNameApplicationModule).Assembly, - typeof(MyProjectNameApplicationContractsModule).Assembly, - typeof(MyProjectNameBlazorModule).Assembly - ); - }); - } + options.AddAssemblyResource( + typeof(MyProjectNameResource), + typeof(MyProjectNameDomainModule).Assembly, + typeof(MyProjectNameDomainSharedModule).Assembly, + typeof(MyProjectNameApplicationModule).Assembly, + typeof(MyProjectNameApplicationContractsModule).Assembly, + typeof(MyProjectNameBlazorModule).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(); - ConfigureUrls(configuration); - ConfigureBundles(); - ConfigureAuthentication(context, configuration); - ConfigureAutoMapper(); - ConfigureVirtualFileSystem(hostingEnvironment); - ConfigureLocalizationServices(); - ConfigureSwaggerServices(context.Services); - ConfigureAutoApiControllers(); - ConfigureBlazorise(context); - ConfigureRouter(context); - ConfigureMenu(context); - } + ConfigureUrls(configuration); + ConfigureBundles(); + ConfigureAuthentication(context, configuration); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureLocalizationServices(); + ConfigureSwaggerServices(context.Services); + ConfigureAutoApiControllers(); + ConfigureBlazorise(context); + ConfigureRouter(context); + ConfigureMenu(context); + } - private void ConfigureUrls(IConfiguration configuration) + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); + } - private void ConfigureBundles() + private void ConfigureBundles() + { + Configure(options => { - Configure(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.styles.css"); - } - ); - }); - } + } + ); + }); + } - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) - { - context.Services.AddAuthentication() - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = "MyProjectName"; - }); - } + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication() + .AddJwtBearer(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "MyProjectName"; + }); + } - private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + { + if (hostingEnvironment.IsDevelopment()) { - if (hostingEnvironment.IsDevelopment()) + Configure(options => { - Configure(options => - { // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); //options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}identity{0}src{0}Volo.Abp.Identity.Web", Path.DirectorySeparatorChar))); @@ -159,129 +159,128 @@ namespace MyCompanyName.MyProjectName.Blazor.Server //options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); - options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); - }); - } - } - - private void ConfigureLocalizationServices() - { - Configure(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("hu", "hu", "Magyar")); - 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("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", "de")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); + options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); }); } + } - 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 ConfigureBlazorise(ServiceConfigurationContext context) + private void ConfigureLocalizationServices() + { + Configure(options => { - context.Services - .AddBootstrap5Providers() - .AddFontAwesomeIcons(); - } + 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("hu", "hu", "Magyar")); + 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("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", "de")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); + } - private void ConfigureMenu(ServiceConfigurationContext context) - { - Configure(options => + private void ConfigureSwaggerServices(IServiceCollection services) + { + services.AddAbpSwaggerGen( + options => { - options.MenuContributors.Add(new MyProjectNameMenuContributor()); - }); - } + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); + } + ); + } - private void ConfigureRouter(ServiceConfigurationContext context) + private void ConfigureBlazorise(ServiceConfigurationContext context) + { + context.Services + .AddBootstrap5Providers() + .AddFontAwesomeIcons(); + } + + private void ConfigureMenu(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; - }); - } + options.MenuContributors.Add(new MyProjectNameMenuContributor()); + }); + } - private void ConfigureAutoApiControllers() + private void ConfigureRouter(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); - }); - } + options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; + }); + } - private void ConfigureAutoMapper() + private void ConfigureAutoApiControllers() + { + Configure(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); + }); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + private void ConfigureAutoMapper() + { + Configure(options => { - var env = context.GetEnvironment(); - var app = context.GetApplicationBuilder(); + options.AddMaps(); + }); + } - app.UseAbpRequestLocalization(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var env = context.GetEnvironment(); + var app = context.GetApplicationBuilder(); - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } - else - { - app.UseExceptionHandler("/Error"); - app.UseHsts(); - } + app.UseAbpRequestLocalization(); - app.UseHttpsRedirection(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); - app.UseJwtTokenMiddleware(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + app.UseExceptionHandler("/Error"); + app.UseHsts(); + } - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + app.UseHttpsRedirection(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); + app.UseJwtTokenMiddleware(); - app.UseUnitOfWork(); - app.UseIdentityServer(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - }); - app.UseConfiguredEndpoints(); + 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(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBrandingProvider.cs index 11eb31a5d5..c78d470cdc 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Ui.Branding; -namespace MyCompanyName.MyProjectName.Blazor.Server +namespace MyCompanyName.MyProjectName.Blazor.Server; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameComponentBase.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameComponentBase.cs index 098dffc782..cff6d62d5d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameComponentBase.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/MyProjectNameComponentBase.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Components; -namespace MyCompanyName.MyProjectName.Blazor.Server +namespace MyCompanyName.MyProjectName.Blazor.Server; + +public abstract class MyProjectNameComponentBase : AbpComponentBase { - public abstract class MyProjectNameComponentBase : AbpComponentBase + protected MyProjectNameComponentBase() { - protected MyProjectNameComponentBase() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/Index.razor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/Index.razor.cs index e8144b37ca..0ee22c7f5a 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/Index.razor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Pages/Index.razor.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName.Blazor.Server.Pages +namespace MyCompanyName.MyProjectName.Blazor.Server.Pages; + +public partial class Index { - public partial class Index - { - } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Program.cs index 636f823d17..d414fd7b78 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Program.cs @@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName.Blazor.Server +namespace MyCompanyName.MyProjectName.Blazor.Server; + +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) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Startup.cs index 309255b725..1aae1bb1d3 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server/Startup.cs @@ -2,18 +2,17 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -namespace MyCompanyName.MyProjectName.Blazor.Server +namespace MyCompanyName.MyProjectName.Blazor.Server; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs index 73c78a98c9..b4db763405 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenuContributor.cs @@ -8,61 +8,60 @@ using Volo.Abp.Authorization.Permissions; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; -namespace MyCompanyName.MyProjectName.Blazor.Menus +namespace MyCompanyName.MyProjectName.Blazor.Menus; + +public class MyProjectNameMenuContributor : IMenuContributor { - public class MyProjectNameMenuContributor : IMenuContributor + private readonly IConfiguration _configuration; + + public MyProjectNameMenuContributor(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public MyProjectNameMenuContributor(IConfiguration configuration) + public async Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.Main) { - _configuration = configuration; + await ConfigureMainMenuAsync(context); } - - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + else if (context.Menu.Name == StandardMenus.User) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } - else if (context.Menu.Name == StandardMenus.User) - { - await ConfigureUserMenuAsync(context); - } + await ConfigureUserMenuAsync(context); } + } - private Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - var l = context.GetLocalizer(); + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); - context.Menu.Items.Insert( - 0, - new ApplicationMenuItem( - MyProjectNameMenus.Home, - l["Menu:Home"], - "/", - icon: "fas fa-home" - ) - ); + context.Menu.Items.Insert( + 0, + new ApplicationMenuItem( + MyProjectNameMenus.Home, + l["Menu:Home"], + "/", + icon: "fas fa-home" + ) + ); - return Task.CompletedTask; - } + return Task.CompletedTask; + } - private Task ConfigureUserMenuAsync(MenuConfigurationContext context) - { - var accountStringLocalizer = context.GetLocalizer(); + private Task ConfigureUserMenuAsync(MenuConfigurationContext context) + { + var accountStringLocalizer = context.GetLocalizer(); - var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; + var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; - context.Menu.AddItem(new ApplicationMenuItem( - "Account.Manage", - accountStringLocalizer["MyAccount"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", - icon: "fa fa-cog", - order: 1000, - null).RequireAuthenticated()); + context.Menu.AddItem(new ApplicationMenuItem( + "Account.Manage", + accountStringLocalizer["MyAccount"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", + icon: "fa fa-cog", + order: 1000, + null).RequireAuthenticated()); - return Task.CompletedTask; - } + return Task.CompletedTask; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs index e65e49be30..89cf3424a9 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Menus/MyProjectNameMenus.cs +++ b/templates/app/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 - { - private const string Prefix = "MyProjectName"; - public const string Home = Prefix + ".Home"; + private const string Prefix = "MyProjectName"; + public const string Home = Prefix + ".Home"; - //Add your menu items here... + //Add your menu items here... - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs index e6c9d51544..9ca9e14d04 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +public class MyProjectNameBlazorAutoMapperProfile : Profile { - public class MyProjectNameBlazorAutoMapperProfile : Profile + public MyProjectNameBlazorAutoMapperProfile() { - public MyProjectNameBlazorAutoMapperProfile() - { - //Define your AutoMapper configuration here for the Blazor project. - } + //Define your AutoMapper configuration here for the Blazor project. } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs index 34d6d7d7b3..11e4dc97d5 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBlazorModule.cs @@ -18,87 +18,86 @@ using Volo.Abp.Identity.Blazor.WebAssembly; using Volo.Abp.SettingManagement.Blazor.WebAssembly; using Volo.Abp.TenantManagement.Blazor.WebAssembly; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +[DependsOn( + typeof(AbpAutofacWebAssemblyModule), + typeof(MyProjectNameHttpApiClientModule), + typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule), + typeof(AbpIdentityBlazorWebAssemblyModule), + typeof(AbpTenantManagementBlazorWebAssemblyModule), + typeof(AbpSettingManagementBlazorWebAssemblyModule) +)] +public class MyProjectNameBlazorModule : AbpModule { - [DependsOn( - typeof(AbpAutofacWebAssemblyModule), - typeof(MyProjectNameHttpApiClientModule), - typeof(AbpAspNetCoreComponentsWebAssemblyBasicThemeModule), - typeof(AbpIdentityBlazorWebAssemblyModule), - typeof(AbpTenantManagementBlazorWebAssemblyModule), - typeof(AbpSettingManagementBlazorWebAssemblyModule) - )] - public class MyProjectNameBlazorModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var environment = context.Services.GetSingletonInstance(); - var builder = context.Services.GetSingletonInstance(); + var environment = context.Services.GetSingletonInstance(); + var builder = context.Services.GetSingletonInstance(); - 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(options => { - Configure(options => - { - options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; - }); - } + options.AppAssembly = typeof(MyProjectNameBlazorModule).Assembly; + }); + } - private void ConfigureMenu(ServiceConfigurationContext context) + private void ConfigureMenu(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor(context.Services.GetConfiguration())); - }); - } + options.MenuContributors.Add(new MyProjectNameMenuContributor(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.UserOptions.RoleClaim = JwtClaimTypes.Role; - options.ProviderOptions.DefaultScopes.Add("MyProjectName"); - options.ProviderOptions.DefaultScopes.Add("role"); - options.ProviderOptions.DefaultScopes.Add("email"); - options.ProviderOptions.DefaultScopes.Add("phone"); - }); - } + builder.Configuration.Bind("AuthServer", options.ProviderOptions); + options.UserOptions.RoleClaim = JwtClaimTypes.Role; + options.ProviderOptions.DefaultScopes.Add("MyProjectName"); + options.ProviderOptions.DefaultScopes.Add("role"); + options.ProviderOptions.DefaultScopes.Add("email"); + options.ProviderOptions.DefaultScopes.Add("phone"); + }); + } - private static void ConfigureUI(WebAssemblyHostBuilder builder) - { - builder.RootComponents.Add("#ApplicationContainer"); - } + private static void ConfigureUI(WebAssemblyHostBuilder builder) + { + builder.RootComponents.Add("#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(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.AddMaps(); + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBrandingProvider.cs index 711f36ad33..cb2a796562 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Ui.Branding; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBundleContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBundleContributor.cs index 43c0a96ed4..e1db0aa325 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBundleContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameBundleContributor.cs @@ -1,20 +1,19 @@ using Volo.Abp.Bundling; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +/* Add your global styles/scripts here. + * See https://docs.abp.io/en/abp/latest/UI/Blazor/Global-Scripts-Styles to learn how to use it + */ +public class MyProjectNameBundleContributor : IBundleContributor { - /* Add your global styles/scripts here. - * See https://docs.abp.io/en/abp/latest/UI/Blazor/Global-Scripts-Styles to learn how to use it - */ - public class MyProjectNameBundleContributor : 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); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameComponentBase.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameComponentBase.cs index b6c05db0ab..918030409d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameComponentBase.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/MyProjectNameComponentBase.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Components; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +public abstract class MyProjectNameComponentBase : AbpComponentBase { - public abstract class MyProjectNameComponentBase : AbpComponentBase + protected MyProjectNameComponentBase() { - protected MyProjectNameComponentBase() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs index 3e1570ecc8..6cdb6de417 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Pages/Index.razor.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName.Blazor.Pages +namespace MyCompanyName.MyProjectName.Blazor.Pages; + +public partial class Index { - public partial class Index - { - } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs index 31f1c228ad..1ded753836 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor/Program.cs @@ -1,24 +1,23 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -namespace MyCompanyName.MyProjectName.Blazor +namespace MyCompanyName.MyProjectName.Blazor; + +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(options => - { - options.UseAutofac(); - }); + var application = builder.AddApplication(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(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs index 08a58a9899..ca084c1833 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/DbMigratorHostedService.cs @@ -7,41 +7,40 @@ using MyCompanyName.MyProjectName.Data; using Serilog; using Volo.Abp; -namespace MyCompanyName.MyProjectName.DbMigrator +namespace MyCompanyName.MyProjectName.DbMigrator; + +public class DbMigratorHostedService : IHostedService { - public class DbMigratorHostedService : IHostedService + private readonly IHostApplicationLifetime _hostApplicationLifetime; + private readonly IConfiguration _configuration; + + public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime, IConfiguration configuration) { - private readonly IHostApplicationLifetime _hostApplicationLifetime; - private readonly IConfiguration _configuration; + _hostApplicationLifetime = hostApplicationLifetime; + _configuration = configuration; + } - public DbMigratorHostedService(IHostApplicationLifetime hostApplicationLifetime, IConfiguration configuration) + public async Task StartAsync(CancellationToken cancellationToken) + { + using (var application = AbpApplicationFactory.Create(options => { - _hostApplicationLifetime = hostApplicationLifetime; - _configuration = configuration; - } - - public async Task StartAsync(CancellationToken cancellationToken) + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + options.Services.AddLogging(c => c.AddSerilog()); + })) { - using (var application = AbpApplicationFactory.Create(options => - { - options.Services.ReplaceConfiguration(_configuration); - options.UseAutofac(); - options.Services.AddLogging(c => c.AddSerilog()); - })) - { - application.Initialize(); - - await application - .ServiceProvider - .GetRequiredService() - .MigrateAsync(); - - application.Shutdown(); - - _hostApplicationLifetime.StopApplication(); - } - } + application.Initialize(); + + await application + .ServiceProvider + .GetRequiredService() + .MigrateAsync(); + + application.Shutdown(); - public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; + _hostApplicationLifetime.StopApplication(); + } } + + public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs index 44e0157e68..51bc87cd52 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/MyProjectNameDbMigratorModule.cs @@ -3,18 +3,17 @@ using Volo.Abp.Autofac; using Volo.Abp.BackgroundJobs; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.DbMigrator +namespace MyCompanyName.MyProjectName.DbMigrator; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(MyProjectNameApplicationContractsModule) + )] +public class MyProjectNameDbMigratorModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(MyProjectNameApplicationContractsModule) - )] - public class MyProjectNameDbMigratorModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - Configure(options => options.IsJobExecutionEnabled = false); - } + Configure(options => options.IsJobExecutionEnabled = false); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/Program.cs index e6f095308c..9025e56c37 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/Program.cs @@ -7,36 +7,35 @@ using Microsoft.Extensions.Logging; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName.DbMigrator +namespace MyCompanyName.MyProjectName.DbMigrator; + +class Program { - class Program + static async Task Main(string[] args) { - static async Task Main(string[] args) - { - Log.Logger = new LoggerConfiguration() - .MinimumLevel.Information() - .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) - .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) + Log.Logger = new LoggerConfiguration() + .MinimumLevel.Information() + .MinimumLevel.Override("Microsoft", LogEventLevel.Warning) + .MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) #if DEBUG .MinimumLevel.Override("MyCompanyName.MyProjectName", LogEventLevel.Debug) #else .MinimumLevel.Override("MyCompanyName.MyProjectName", LogEventLevel.Information) #endif .Enrich.FromLogContext() - .WriteTo.Async(c => c.File("Logs/logs.txt")) - .WriteTo.Async(c => c.Console()) - .CreateLogger(); - - await CreateHostBuilder(args).RunConsoleAsync(); - } + .WriteTo.Async(c => c.File("Logs/logs.txt")) + .WriteTo.Async(c => c.Console()) + .CreateLogger(); - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureLogging((context, logging) => logging.ClearProviders()) - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }); + await CreateHostBuilder(args).RunConsoleAsync(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureLogging((context, logging) => logging.ClearProviders()) + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs index 6ca0ab55f0..7c4deb35ab 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectNameResource.cs +++ b/templates/app/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 - { - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs index fef853b693..c5aad5562d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MultiTenancy/MultiTenancyConsts.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.MultiTenancy +namespace MyCompanyName.MyProjectName.MultiTenancy; + +public static class MultiTenancyConsts { - public static class MultiTenancyConsts - { - /* Enable/disable multi-tenancy easily in a single point. - * If you will never need to multi-tenancy, you can remove - * related modules and code parts, including this file. - */ - public const bool IsEnabled = true; - } + /* Enable/disable multi-tenancy easily in a single point. + * If you will never need to multi-tenancy, you can remove + * related modules and code parts, including this file. + */ + public const bool IsEnabled = true; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainErrorCodes.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainErrorCodes.cs index d2bd62ad79..792f64c652 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainErrorCodes.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainErrorCodes.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameDomainErrorCodes { - public static class MyProjectNameDomainErrorCodes - { - /* You can add your business exception error codes here, as constants */ - } + /* You can add your business exception error codes here, as constants */ } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs index b59dab0922..9d3f467583 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameDomainSharedModule.cs @@ -13,47 +13,46 @@ using Volo.Abp.TenantManagement; using Volo.Abp.Validation.Localization; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAuditLoggingDomainSharedModule), + typeof(AbpBackgroundJobsDomainSharedModule), + typeof(AbpFeatureManagementDomainSharedModule), + typeof(AbpIdentityDomainSharedModule), + typeof(AbpIdentityServerDomainSharedModule), + typeof(AbpPermissionManagementDomainSharedModule), + typeof(AbpSettingManagementDomainSharedModule), + typeof(AbpTenantManagementDomainSharedModule) + )] +public class MyProjectNameDomainSharedModule : AbpModule { - [DependsOn( - typeof(AbpAuditLoggingDomainSharedModule), - typeof(AbpBackgroundJobsDomainSharedModule), - typeof(AbpFeatureManagementDomainSharedModule), - typeof(AbpIdentityDomainSharedModule), - typeof(AbpIdentityServerDomainSharedModule), - typeof(AbpPermissionManagementDomainSharedModule), - typeof(AbpSettingManagementDomainSharedModule), - typeof(AbpTenantManagementDomainSharedModule) - )] - public class MyProjectNameDomainSharedModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - MyProjectNameGlobalFeatureConfigurator.Configure(); - MyProjectNameModuleExtensionConfigurator.Configure(); - } + MyProjectNameGlobalFeatureConfigurator.Configure(); + MyProjectNameModuleExtensionConfigurator.Configure(); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.FileSets.AddEmbedded(); - }); + options.FileSets.AddEmbedded(); + }); - Configure(options => - { - options.Resources - .Add("en") - .AddBaseTypes(typeof(AbpValidationResource)) - .AddVirtualJson("/Localization/MyProjectName"); + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/MyProjectName"); - options.DefaultResourceType = typeof(MyProjectNameResource); - }); + options.DefaultResourceType = typeof(MyProjectNameResource); + }); - Configure(options => - { - options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource)); - }); - } + Configure(options => + { + options.MapCodeNamespace("MyProjectName", typeof(MyProjectNameResource)); + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameGlobalFeatureConfigurator.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameGlobalFeatureConfigurator.cs index f316b58687..53fd51494e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameGlobalFeatureConfigurator.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameGlobalFeatureConfigurator.cs @@ -1,15 +1,15 @@ using Volo.Abp.Threading; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameGlobalFeatureConfigurator { - public static class MyProjectNameGlobalFeatureConfigurator - { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); - public static void Configure() + public static void Configure() + { + OneTimeRunner.Run(() => { - OneTimeRunner.Run(() => - { /* You can configure (enable/disable) global features of the used modules here. * * YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT! @@ -17,7 +17,6 @@ namespace MyCompanyName.MyProjectName * Please refer to the documentation to lear more about the Global Features System: * https://docs.abp.io/en/abp/latest/Global-Features */ - }); - } + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameModuleExtensionConfigurator.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameModuleExtensionConfigurator.cs index 53a4ab0879..2a6eddf60f 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameModuleExtensionConfigurator.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/MyProjectNameModuleExtensionConfigurator.cs @@ -3,70 +3,69 @@ using Volo.Abp.Identity; using Volo.Abp.ObjectExtending; using Volo.Abp.Threading; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameModuleExtensionConfigurator { - public static class MyProjectNameModuleExtensionConfigurator - { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); - public static void Configure() + public static void Configure() + { + OneTimeRunner.Run(() => { - OneTimeRunner.Run(() => - { - ConfigureExistingProperties(); - ConfigureExtraProperties(); - }); - } + ConfigureExistingProperties(); + ConfigureExtraProperties(); + }); + } - private static void ConfigureExistingProperties() - { - /* You can change max lengths for properties of the - * entities defined in the modules used by your application. - * - * Example: Change user and role name max lengths + private static void ConfigureExistingProperties() + { + /* You can change max lengths for properties of the + * entities defined in the modules used by your application. + * + * Example: Change user and role name max lengths - IdentityUserConsts.MaxNameLength = 99; - IdentityRoleConsts.MaxNameLength = 99; + IdentityUserConsts.MaxNameLength = 99; + IdentityRoleConsts.MaxNameLength = 99; - * Notice: It is not suggested to change property lengths - * unless you really need it. Go with the standard values wherever possible. - * - * If you are using EF Core, you will need to run the add-migration command after your changes. - */ - } + * Notice: It is not suggested to change property lengths + * unless you really need it. Go with the standard values wherever possible. + * + * If you are using EF Core, you will need to run the add-migration command after your changes. + */ + } - private static void ConfigureExtraProperties() - { - /* You can configure extra properties for the - * entities defined in the modules used by your application. - * - * This class can be used to define these extra properties - * with a high level, easy to use API. - * - * Example: Add a new property to the user entity of the identity module + private static void ConfigureExtraProperties() + { + /* You can configure extra properties for the + * entities defined in the modules used by your application. + * + * This class can be used to define these extra properties + * with a high level, easy to use API. + * + * Example: Add a new property to the user entity of the identity module - ObjectExtensionManager.Instance.Modules() - .ConfigureIdentity(identity => + ObjectExtensionManager.Instance.Modules() + .ConfigureIdentity(identity => + { + identity.ConfigureUser(user => { - identity.ConfigureUser(user => - { - user.AddOrUpdateProperty( //property type: string - "SocialSecurityNumber", //property name - property => - { - //validation rules - property.Attributes.Add(new RequiredAttribute()); - property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); + user.AddOrUpdateProperty( //property type: string + "SocialSecurityNumber", //property name + property => + { + //validation rules + property.Attributes.Add(new RequiredAttribute()); + property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4}); - //...other configurations for this property - } - ); - }); + //...other configurations for this property + } + ); }); + }); - * See the documentation for more: - * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions - */ - } + * See the documentation for more: + * https://docs.abp.io/en/abp/latest/Module-Entity-Extensions + */ } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/IMyProjectNameDbSchemaMigrator.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/IMyProjectNameDbSchemaMigrator.cs index 34c4cf76aa..f4076b2d4d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/IMyProjectNameDbSchemaMigrator.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/IMyProjectNameDbSchemaMigrator.cs @@ -1,9 +1,8 @@ using System.Threading.Tasks; -namespace MyCompanyName.MyProjectName.Data +namespace MyCompanyName.MyProjectName.Data; + +public interface IMyProjectNameDbSchemaMigrator { - public interface IMyProjectNameDbSchemaMigrator - { - Task MigrateAsync(); - } + Task MigrateAsync(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs index d9e2a7f406..dd0e61135d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs @@ -13,212 +13,211 @@ using Volo.Abp.Identity; using Volo.Abp.MultiTenancy; using Volo.Abp.TenantManagement; -namespace MyCompanyName.MyProjectName.Data +namespace MyCompanyName.MyProjectName.Data; + +public class MyProjectNameDbMigrationService : ITransientDependency { - public class MyProjectNameDbMigrationService : ITransientDependency + public ILogger Logger { get; set; } + + private readonly IDataSeeder _dataSeeder; + private readonly IEnumerable _dbSchemaMigrators; + private readonly ITenantRepository _tenantRepository; + private readonly ICurrentTenant _currentTenant; + + public MyProjectNameDbMigrationService( + IDataSeeder dataSeeder, + IEnumerable dbSchemaMigrators, + ITenantRepository tenantRepository, + ICurrentTenant currentTenant) { - public ILogger Logger { get; set; } - - private readonly IDataSeeder _dataSeeder; - private readonly IEnumerable _dbSchemaMigrators; - private readonly ITenantRepository _tenantRepository; - private readonly ICurrentTenant _currentTenant; - - public MyProjectNameDbMigrationService( - IDataSeeder dataSeeder, - IEnumerable dbSchemaMigrators, - ITenantRepository tenantRepository, - ICurrentTenant currentTenant) - { - _dataSeeder = dataSeeder; - _dbSchemaMigrators = dbSchemaMigrators; - _tenantRepository = tenantRepository; - _currentTenant = currentTenant; + _dataSeeder = dataSeeder; + _dbSchemaMigrators = dbSchemaMigrators; + _tenantRepository = tenantRepository; + _currentTenant = currentTenant; - Logger = NullLogger.Instance; - } + Logger = NullLogger.Instance; + } - public async Task MigrateAsync() - { - // - var initialMigrationAdded = AddInitialMigrationIfNotExist(); + public async Task MigrateAsync() + { + // + var initialMigrationAdded = AddInitialMigrationIfNotExist(); - if (initialMigrationAdded) - { - return; - } - // + if (initialMigrationAdded) + { + return; + } + // - Logger.LogInformation("Started database migrations..."); + Logger.LogInformation("Started database migrations..."); - await MigrateDatabaseSchemaAsync(); - await SeedDataAsync(); + await MigrateDatabaseSchemaAsync(); + await SeedDataAsync(); - Logger.LogInformation($"Successfully completed host database migrations."); + Logger.LogInformation($"Successfully completed host database migrations."); - var tenants = await _tenantRepository.GetListAsync(includeDetails: true); + var tenants = await _tenantRepository.GetListAsync(includeDetails: true); - var migratedDatabaseSchemas = new HashSet(); - foreach (var tenant in tenants) + var migratedDatabaseSchemas = new HashSet(); + foreach (var tenant in tenants) + { + using (_currentTenant.Change(tenant.Id)) { - using (_currentTenant.Change(tenant.Id)) + if (tenant.ConnectionStrings.Any()) { - if (tenant.ConnectionStrings.Any()) - { - var tenantConnectionStrings = tenant.ConnectionStrings - .Select(x => x.Value) - .ToList(); + var tenantConnectionStrings = tenant.ConnectionStrings + .Select(x => x.Value) + .ToList(); - if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) - { - await MigrateDatabaseSchemaAsync(tenant); + if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) + { + await MigrateDatabaseSchemaAsync(tenant); - migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); - } + migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); } - - await SeedDataAsync(tenant); } - Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); + await SeedDataAsync(tenant); } - Logger.LogInformation("Successfully completed all database migrations."); - Logger.LogInformation("You can safely end this process..."); + Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); } - private async Task MigrateDatabaseSchemaAsync(Tenant tenant = null) - { - Logger.LogInformation( - $"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); + Logger.LogInformation("Successfully completed all database migrations."); + Logger.LogInformation("You can safely end this process..."); + } - foreach (var migrator in _dbSchemaMigrators) - { - await migrator.MigrateAsync(); - } - } + private async Task MigrateDatabaseSchemaAsync(Tenant tenant = null) + { + Logger.LogInformation( + $"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); - private async Task SeedDataAsync(Tenant tenant = null) + foreach (var migrator in _dbSchemaMigrators) { - Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); - - await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id) - .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue) - .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue) - ); + await migrator.MigrateAsync(); } + } - // - private bool AddInitialMigrationIfNotExist() + private async Task SeedDataAsync(Tenant tenant = null) + { + Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); + + await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id) + .WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue) + .WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue) + ); + } + + // + private bool AddInitialMigrationIfNotExist() + { + try { - try - { - if (!DbMigrationsProjectExists()) - { - return false; - } - } - catch (Exception) + if (!DbMigrationsProjectExists()) { return false; } + } + catch (Exception) + { + return false; + } - try + try + { + if (!MigrationsFolderExists()) { - if (!MigrationsFolderExists()) - { - AddInitialMigration(); - return true; - } - else - { - return false; - } + AddInitialMigration(); + return true; } - catch (Exception e) + else { - Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); return false; } } - - private bool DbMigrationsProjectExists() + catch (Exception e) { - var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); - - return dbMigrationsProjectFolder != null; + Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); + return false; } + } - private bool MigrationsFolderExists() - { - var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); + private bool DbMigrationsProjectExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); - return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); - } + return dbMigrationsProjectFolder != null; + } - private void AddInitialMigration() - { - Logger.LogInformation("Creating initial migration..."); + private bool MigrationsFolderExists() + { + var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); - string argumentPrefix; - string fileName; + return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); + } - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) - { - argumentPrefix = "-c"; - fileName = "/bin/bash"; - } - else - { - argumentPrefix = "/C"; - fileName = "cmd.exe"; - } + private void AddInitialMigration() + { + Logger.LogInformation("Creating initial migration..."); - var procStartInfo = new ProcessStartInfo(fileName, - $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\"" - ); + string argumentPrefix; + string fileName; - try - { - Process.Start(procStartInfo); - } - catch (Exception) - { - throw new Exception("Couldn't run ABP CLI..."); - } + if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + argumentPrefix = "-c"; + fileName = "/bin/bash"; } - - private string GetEntityFrameworkCoreProjectFolderPath() + else { - var slnDirectoryPath = GetSolutionDirectoryPath(); + argumentPrefix = "/C"; + fileName = "cmd.exe"; + } - if (slnDirectoryPath == null) - { - throw new Exception("Solution folder not found!"); - } + var procStartInfo = new ProcessStartInfo(fileName, + $"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\"" + ); - var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src"); + try + { + Process.Start(procStartInfo); + } + catch (Exception) + { + throw new Exception("Couldn't run ABP CLI..."); + } + } + + private string GetEntityFrameworkCoreProjectFolderPath() + { + var slnDirectoryPath = GetSolutionDirectoryPath(); - return Directory.GetDirectories(srcDirectoryPath) - .FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore")); + if (slnDirectoryPath == null) + { + throw new Exception("Solution folder not found!"); } - private string GetSolutionDirectoryPath() + var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src"); + + return Directory.GetDirectories(srcDirectoryPath) + .FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore")); + } + + private string GetSolutionDirectoryPath() + { + var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + + while (Directory.GetParent(currentDirectory.FullName) != null) { - var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + currentDirectory = Directory.GetParent(currentDirectory.FullName); - while (Directory.GetParent(currentDirectory.FullName) != null) + if (Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) { - currentDirectory = Directory.GetParent(currentDirectory.FullName); - - if (Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) - { - return currentDirectory.FullName; - } + return currentDirectory.FullName; } - - return null; } - // + + return null; } + // } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/NullMyProjectNameDbSchemaMigrator.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/NullMyProjectNameDbSchemaMigrator.cs index 417be59326..f6c542435b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/NullMyProjectNameDbSchemaMigrator.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/NullMyProjectNameDbSchemaMigrator.cs @@ -1,16 +1,15 @@ using System.Threading.Tasks; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName.Data +namespace MyCompanyName.MyProjectName.Data; + +/* This is used if database provider does't define + * IMyProjectNameDbSchemaMigrator implementation. + */ +public class NullMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator, ITransientDependency { - /* This is used if database provider does't define - * IMyProjectNameDbSchemaMigrator implementation. - */ - public class NullMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator, ITransientDependency + public Task MigrateAsync() { - public Task MigrateAsync() - { - return Task.CompletedTask; - } + return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs index 72323efe49..da0b56a6d0 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/IdentityServer/IdentityServerDataSeedContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/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 CreateApiResourceAsync(string name, IEnumerable claims) + private async Task CreateApiResourceAsync(string name, IEnumerable 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 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 apiScope; + return await _apiResourceRepository.UpdateAsync(apiResource); + } + + private async Task 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,215 +140,214 @@ 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('/'); - - 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('/'); + + 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("/") } + ); + } - //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("/") } - ); - } - - // + // - // 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("/") } - ); - } - - // - - // - - //Blazor Server Tiered Client - var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"]; - if (!blazorServerTieredClientId.IsNullOrWhiteSpace()) - { - var blazorServerTieredClientRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/'); - - /* MyProjectName_BlazorServerTiered client is only needed if you created a tiered blazor server - * solution. Otherwise, you can delete this client. */ - - await CreateClientAsync( - name: blazorServerTieredClientId, - scopes: commonScopes, - grantTypes: new[] { "hybrid" }, - secret: (configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*").Sha256(), - redirectUri: $"{blazorServerTieredClientRootUrl}signin-oidc", - postLogoutRedirectUri: $"{blazorServerTieredClientRootUrl}signout-callback-oidc", - frontChannelLogoutUri: $"{blazorServerTieredClientRootUrl}Account/FrontChannelLogout", - corsOrigins: new[] { blazorServerTieredClientRootUrl.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("/") } + ); + } - // - - // 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("/") } - ); - } + // + + // 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("/") } + ); + } + + // + + // + + //Blazor Server Tiered Client + var blazorServerTieredClientId = configurationSection["MyProjectName_BlazorServerTiered:ClientId"]; + if (!blazorServerTieredClientId.IsNullOrWhiteSpace()) + { + var blazorServerTieredClientRootUrl = configurationSection["MyProjectName_BlazorServerTiered:RootUrl"].EnsureEndsWith('/'); + + /* MyProjectName_BlazorServerTiered client is only needed if you created a tiered blazor server + * solution. Otherwise, you can delete this client. */ + + await CreateClientAsync( + name: blazorServerTieredClientId, + scopes: commonScopes, + grantTypes: new[] { "hybrid" }, + secret: (configurationSection["MyProjectName_BlazorServerTiered:ClientSecret"] ?? "1q2w3e*").Sha256(), + redirectUri: $"{blazorServerTieredClientRootUrl}signin-oidc", + postLogoutRedirectUri: $"{blazorServerTieredClientRootUrl}signout-callback-oidc", + frontChannelLogoutUri: $"{blazorServerTieredClientRootUrl}Account/FrontChannelLogout", + corsOrigins: new[] { blazorServerTieredClientRootUrl.RemovePostFix("/") } + ); } - private async Task CreateClientAsync( - string name, - IEnumerable scopes, - IEnumerable grantTypes, - string secret = null, - string redirectUri = null, - string postLogoutRedirectUri = null, - string frontChannelLogoutUri = null, - bool requireClientSecret = true, - bool requirePkce = false, - IEnumerable permissions = null, - IEnumerable corsOrigins = null) + // + + // Swagger Client + var swaggerClientId = configurationSection["MyProjectName_Swagger:ClientId"]; + if (!swaggerClientId.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 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 CreateClientAsync( + string name, + IEnumerable scopes, + IEnumerable grantTypes, + string secret = null, + string redirectUri = null, + string postLogoutRedirectUri = null, + string frontChannelLogoutUri = null, + bool requireClientSecret = true, + bool requirePkce = false, + IEnumerable permissions = null, + IEnumerable 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); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs index d939cfca9f..1de402e611 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameConsts.cs @@ -1,9 +1,8 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameConsts { - public static class MyProjectNameConsts - { - public const string DbTablePrefix = "App"; + public const string DbTablePrefix = "App"; - public const string DbSchema = null; - } + public const string DbSchema = null; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs index 91b05c877d..2737edd6c2 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/MyProjectNameDomainModule.cs @@ -14,33 +14,32 @@ using Volo.Abp.PermissionManagement.IdentityServer; using Volo.Abp.SettingManagement; using Volo.Abp.TenantManagement; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameDomainSharedModule), + typeof(AbpAuditLoggingDomainModule), + typeof(AbpBackgroundJobsDomainModule), + typeof(AbpFeatureManagementDomainModule), + typeof(AbpIdentityDomainModule), + typeof(AbpPermissionManagementDomainIdentityModule), + typeof(AbpIdentityServerDomainModule), + typeof(AbpPermissionManagementDomainIdentityServerModule), + typeof(AbpSettingManagementDomainModule), + typeof(AbpTenantManagementDomainModule), + typeof(AbpEmailingModule) +)] +public class MyProjectNameDomainModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainSharedModule), - typeof(AbpAuditLoggingDomainModule), - typeof(AbpBackgroundJobsDomainModule), - typeof(AbpFeatureManagementDomainModule), - typeof(AbpIdentityDomainModule), - typeof(AbpPermissionManagementDomainIdentityModule), - typeof(AbpIdentityServerDomainModule), - typeof(AbpPermissionManagementDomainIdentityServerModule), - typeof(AbpSettingManagementDomainModule), - typeof(AbpTenantManagementDomainModule), - typeof(AbpEmailingModule) - )] - public class MyProjectNameDomainModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - Configure(options => - { - options.IsEnabled = MultiTenancyConsts.IsEnabled; - }); + options.IsEnabled = MultiTenancyConsts.IsEnabled; + }); #if DEBUG - context.Services.Replace(ServiceDescriptor.Singleton()); + context.Services.Replace(ServiceDescriptor.Singleton()); #endif - } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs index f5e6df1818..2ca3620a21 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettingDefinitionProvider.cs @@ -1,13 +1,12 @@ 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 your own settings here. Example: - //context.Add(new SettingDefinition(MyProjectNameSettings.MySetting1)); - } + //Define your own settings here. Example: + //context.Add(new SettingDefinition(MyProjectNameSettings.MySetting1)); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs index 73268a3460..533dda5124 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Settings/MyProjectNameSettings.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.Settings +namespace MyCompanyName.MyProjectName.Settings; + +public static class MyProjectNameSettings { - public static class MyProjectNameSettings - { - private const string Prefix = "MyProjectName"; + private const string Prefix = "MyProjectName"; - //Add your own setting names here. Example: - //public const string MySetting1 = Prefix + ".MySetting1"; - } -} \ No newline at end of file + //Add your own setting names here. Example: + //public const string MySetting1 = Prefix + ".MySetting1"; +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreMyProjectNameDbSchemaMigrator.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreMyProjectNameDbSchemaMigrator.cs index 45fb944a73..10b3d75c3d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreMyProjectNameDbSchemaMigrator.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/EntityFrameworkCoreMyProjectNameDbSchemaMigrator.cs @@ -5,31 +5,30 @@ using Microsoft.Extensions.DependencyInjection; using MyCompanyName.MyProjectName.Data; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class EntityFrameworkCoreMyProjectNameDbSchemaMigrator + : IMyProjectNameDbSchemaMigrator, ITransientDependency { - public class EntityFrameworkCoreMyProjectNameDbSchemaMigrator - : IMyProjectNameDbSchemaMigrator, ITransientDependency - { - private readonly IServiceProvider _serviceProvider; + private readonly IServiceProvider _serviceProvider; - public EntityFrameworkCoreMyProjectNameDbSchemaMigrator( - IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } + public EntityFrameworkCoreMyProjectNameDbSchemaMigrator( + IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } - public async Task MigrateAsync() - { - /* We intentionally resolving the MyProjectNameDbContext - * from IServiceProvider (instead of directly injecting it) - * to properly get the connection string of the current tenant in the - * current scope. - */ + public async Task MigrateAsync() + { + /* We intentionally resolving the MyProjectNameDbContext + * from IServiceProvider (instead of directly injecting it) + * to properly get the connection string of the current tenant in the + * current scope. + */ - await _serviceProvider - .GetRequiredService() - .Database - .MigrateAsync(); - } + await _serviceProvider + .GetRequiredService() + .Database + .MigrateAsync(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs index 9fdb0220e5..ed168aa016 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContext.cs @@ -13,74 +13,73 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[ReplaceDbContext(typeof(IIdentityDbContext))] +[ReplaceDbContext(typeof(ITenantManagementDbContext))] +[ConnectionStringName("Default")] +public class MyProjectNameDbContext : + AbpDbContext, + IIdentityDbContext, + ITenantManagementDbContext { - [ReplaceDbContext(typeof(IIdentityDbContext))] - [ReplaceDbContext(typeof(ITenantManagementDbContext))] - [ConnectionStringName("Default")] - public class MyProjectNameDbContext : - AbpDbContext, - IIdentityDbContext, - ITenantManagementDbContext - { - /* Add DbSet properties for your Aggregate Roots / Entities here. */ - - #region Entities from the modules - - /* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext - * and replaced them for this DbContext. This allows you to perform JOIN - * queries for the entities of these modules over the repositories easily. You - * typically don't need that for other modules. But, if you need, you can - * implement the DbContext interface of the needed module and use ReplaceDbContext - * attribute just like IIdentityDbContext and ITenantManagementDbContext. - * - * More info: Replacing a DbContext of a module ensures that the related module - * uses this DbContext on runtime. Otherwise, it will use its own DbContext class. - */ - - //Identity - public DbSet Users { get; set; } - public DbSet Roles { get; set; } - public DbSet ClaimTypes { get; set; } - public DbSet OrganizationUnits { get; set; } - public DbSet SecurityLogs { get; set; } - public DbSet LinkUsers { get; set; } - - // Tenant Management - public DbSet Tenants { get; set; } - public DbSet TenantConnectionStrings { get; set; } + /* Add DbSet properties for your Aggregate Roots / Entities here. */ + + #region Entities from the modules + + /* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext + * and replaced them for this DbContext. This allows you to perform JOIN + * queries for the entities of these modules over the repositories easily. You + * typically don't need that for other modules. But, if you need, you can + * implement the DbContext interface of the needed module and use ReplaceDbContext + * attribute just like IIdentityDbContext and ITenantManagementDbContext. + * + * More info: Replacing a DbContext of a module ensures that the related module + * uses this DbContext on runtime. Otherwise, it will use its own DbContext class. + */ + + //Identity + public DbSet Users { get; set; } + public DbSet Roles { get; set; } + public DbSet ClaimTypes { get; set; } + public DbSet OrganizationUnits { get; set; } + public DbSet SecurityLogs { get; set; } + public DbSet LinkUsers { get; set; } - #endregion - - public MyProjectNameDbContext(DbContextOptions options) - : base(options) - { + // Tenant Management + public DbSet Tenants { get; set; } + public DbSet TenantConnectionStrings { get; set; } - } + #endregion - protected override void OnModelCreating(ModelBuilder builder) - { - base.OnModelCreating(builder); + public MyProjectNameDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); - /* Include modules to your migration db context */ + /* Include modules to your migration db context */ - builder.ConfigurePermissionManagement(); - builder.ConfigureSettingManagement(); - builder.ConfigureBackgroundJobs(); - builder.ConfigureAuditLogging(); - builder.ConfigureIdentity(); - builder.ConfigureIdentityServer(); - builder.ConfigureFeatureManagement(); - builder.ConfigureTenantManagement(); + builder.ConfigurePermissionManagement(); + builder.ConfigureSettingManagement(); + builder.ConfigureBackgroundJobs(); + builder.ConfigureAuditLogging(); + builder.ConfigureIdentity(); + builder.ConfigureIdentityServer(); + builder.ConfigureFeatureManagement(); + builder.ConfigureTenantManagement(); - /* Configure your own tables/entities inside here */ + /* Configure your own tables/entities inside here */ - //builder.Entity(b => - //{ - // b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema); - // b.ConfigureByConvention(); //auto configure for the base class props - // //... - //}); - } + //builder.Entity(b => + //{ + // b.ToTable(MyProjectNameConsts.DbTablePrefix + "YourEntities", MyProjectNameConsts.DbSchema); + // b.ConfigureByConvention(); //auto configure for the base class props + // //... + //}); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs index 139a723f34..01fdb39a61 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameDbContextFactory.cs @@ -3,31 +3,30 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Design; using Microsoft.Extensions.Configuration; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +/* This class is needed for EF Core console commands + * (like Add-Migration and Update-Database commands) */ +public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory { - /* This class is needed for EF Core console commands - * (like Add-Migration and Update-Database commands) */ - public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory + public MyProjectNameDbContext CreateDbContext(string[] args) { - public MyProjectNameDbContext CreateDbContext(string[] args) - { - MyProjectNameEfCoreEntityExtensionMappings.Configure(); + MyProjectNameEfCoreEntityExtensionMappings.Configure(); - var configuration = BuildConfiguration(); + var configuration = BuildConfiguration(); - var builder = new DbContextOptionsBuilder() - .UseSqlServer(configuration.GetConnectionString("Default")); + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); - return new MyProjectNameDbContext(builder.Options); - } + return new MyProjectNameDbContext(builder.Options); + } - private static IConfigurationRoot BuildConfiguration() - { - var builder = new ConfigurationBuilder() - .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../MyCompanyName.MyProjectName.DbMigrator/")) - .AddJsonFile("appsettings.json", optional: false); + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../MyCompanyName.MyProjectName.DbMigrator/")) + .AddJsonFile("appsettings.json", optional: false); - return builder.Build(); - } + return builder.Build(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEfCoreEntityExtensionMappings.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEfCoreEntityExtensionMappings.cs index eb0983c595..ed4b9bf497 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEfCoreEntityExtensionMappings.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEfCoreEntityExtensionMappings.cs @@ -3,19 +3,19 @@ using Volo.Abp.Identity; using Volo.Abp.ObjectExtending; using Volo.Abp.Threading; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public static class MyProjectNameEfCoreEntityExtensionMappings { - public static class MyProjectNameEfCoreEntityExtensionMappings + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + + public static void Configure() { - private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + MyProjectNameGlobalFeatureConfigurator.Configure(); + MyProjectNameModuleExtensionConfigurator.Configure(); - public static void Configure() + OneTimeRunner.Run(() => { - MyProjectNameGlobalFeatureConfigurator.Configure(); - MyProjectNameModuleExtensionConfigurator.Configure(); - - OneTimeRunner.Run(() => - { /* You can configure extra properties for the * entities defined in the modules used by your application. * @@ -39,7 +39,6 @@ namespace MyCompanyName.MyProjectName.EntityFrameworkCore * See the documentation for more: * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities */ - }); - } + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs index 0b4258dd18..9cecbb904d 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreModule.cs @@ -11,42 +11,41 @@ using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.TenantManagement.EntityFrameworkCore; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[DependsOn( + typeof(MyProjectNameDomainModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityServerEntityFrameworkCoreModule), + typeof(AbpPermissionManagementEntityFrameworkCoreModule), + typeof(AbpSettingManagementEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqlServerModule), + typeof(AbpBackgroundJobsEntityFrameworkCoreModule), + typeof(AbpAuditLoggingEntityFrameworkCoreModule), + typeof(AbpTenantManagementEntityFrameworkCoreModule), + typeof(AbpFeatureManagementEntityFrameworkCoreModule) + )] +public class MyProjectNameEntityFrameworkCoreModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainModule), - typeof(AbpIdentityEntityFrameworkCoreModule), - typeof(AbpIdentityServerEntityFrameworkCoreModule), - typeof(AbpPermissionManagementEntityFrameworkCoreModule), - typeof(AbpSettingManagementEntityFrameworkCoreModule), - typeof(AbpEntityFrameworkCoreSqlServerModule), - typeof(AbpBackgroundJobsEntityFrameworkCoreModule), - typeof(AbpAuditLoggingEntityFrameworkCoreModule), - typeof(AbpTenantManagementEntityFrameworkCoreModule), - typeof(AbpFeatureManagementEntityFrameworkCoreModule) - )] - public class MyProjectNameEntityFrameworkCoreModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) - { - MyProjectNameEfCoreEntityExtensionMappings.Configure(); - } + MyProjectNameEfCoreEntityExtensionMappings.Configure(); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => { - context.Services.AddAbpDbContext(options => - { /* Remove "includeAllEntities: true" to create * default repositories only for aggregate roots */ - options.AddDefaultRepositories(includeAllEntities: true); - }); + options.AddDefaultRepositories(includeAllEntities: true); + }); - Configure(options => - { + Configure(options => + { /* The main point to change your DBMS. * See also MyProjectNameMigrationsDbContextFactory for EF Core tooling. */ - options.UseSqlServer(); - }); - } + options.UseSqlServer(); + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20211105125915_Initial.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20211105125915_Initial.cs index e55b554b12..24e64888b2 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20211105125915_Initial.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.EntityFrameworkCore/Migrations/20211105125915_Initial.cs @@ -3,1368 +3,1321 @@ using Microsoft.EntityFrameworkCore.Migrations; #nullable disable -namespace MyCompanyName.MyProjectName.Migrations +namespace MyCompanyName.MyProjectName.Migrations; + +public partial class Initial : Migration { - public partial class Initial : Migration + protected override void Up(MigrationBuilder migrationBuilder) { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "AbpAuditLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - TenantName = table.Column(type: "nvarchar(max)", nullable: true), - ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), - ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - Exceptions = table.Column(type: "nvarchar(max)", nullable: true), - Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - HttpStatusCode = table.Column(type: "int", nullable: true), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpBackgroundJobs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - JobName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - JobArgs = table.Column(type: "nvarchar(max)", maxLength: 1048576, nullable: false), - TryCount = table.Column(type: "smallint", nullable: false, defaultValue: (short)0), - CreationTime = table.Column(type: "datetime2", nullable: false), - NextTryTime = table.Column(type: "datetime2", nullable: false), - LastTryTime = table.Column(type: "datetime2", nullable: true), - IsAbandoned = table.Column(type: "bit", nullable: false, defaultValue: false), - Priority = table.Column(type: "tinyint", nullable: false, defaultValue: (byte)15), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpBackgroundJobs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpClaimTypes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Required = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - ValueType = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpFeatureValues", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpLinkUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), - SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), - TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), - TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnits", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ParentId = table.Column(type: "uniqueidentifier", nullable: true), - Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), - DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); - table.ForeignKey( - name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", - column: x => x.ParentId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id"); - }); - - migrationBuilder.CreateTable( - name: "AbpPermissionGrants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpRoles", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsDefault = table.Column(type: "bit", nullable: false), - IsStatic = table.Column(type: "bit", nullable: false), - IsPublic = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoles", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSecurityLogs", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), - UserId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpSettings", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), - ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpSettings", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpTenants", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenants", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "AbpUsers", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), - Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), - PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), - PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), - IsActive = table.Column(type: "bit", nullable: false), - TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), - LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), - AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUsers", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResources", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Enabled = table.Column(type: "bit", nullable: false), - AllowedAccessTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Enabled = table.Column(type: "bit", nullable: false), - Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Required = table.Column(type: "bit", nullable: false), - Emphasize = table.Column(type: "bit", nullable: false), - ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClients", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - ClientName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - ClientUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - LogoUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - Enabled = table.Column(type: "bit", nullable: false), - ProtocolType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - RequireClientSecret = table.Column(type: "bit", nullable: false), - RequireConsent = table.Column(type: "bit", nullable: false), - AllowRememberConsent = table.Column(type: "bit", nullable: false), - AlwaysIncludeUserClaimsInIdToken = table.Column(type: "bit", nullable: false), - RequirePkce = table.Column(type: "bit", nullable: false), - AllowPlainTextPkce = table.Column(type: "bit", nullable: false), - RequireRequestObject = table.Column(type: "bit", nullable: false), - AllowAccessTokensViaBrowser = table.Column(type: "bit", nullable: false), - FrontChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - FrontChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), - BackChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - BackChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), - AllowOfflineAccess = table.Column(type: "bit", nullable: false), - IdentityTokenLifetime = table.Column(type: "int", nullable: false), - AllowedIdentityTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - AccessTokenLifetime = table.Column(type: "int", nullable: false), - AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), - ConsentLifetime = table.Column(type: "int", nullable: true), - AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), - SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), - RefreshTokenUsage = table.Column(type: "int", nullable: false), - UpdateAccessTokenClaimsOnRefresh = table.Column(type: "bit", nullable: false), - RefreshTokenExpiration = table.Column(type: "int", nullable: false), - AccessTokenType = table.Column(type: "int", nullable: false), - EnableLocalLogin = table.Column(type: "bit", nullable: false), - IncludeJwtId = table.Column(type: "bit", nullable: false), - AlwaysSendClientClaims = table.Column(type: "bit", nullable: false), - ClientClaimsPrefix = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - PairWiseSubjectSalt = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - UserSsoLifetime = table.Column(type: "int", nullable: true), - UserCodeType = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - DeviceCodeLifetime = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClients", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerDeviceFlowCodes", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - DeviceCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - UserCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Expiration = table.Column(type: "datetime2", nullable: false), - Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResources", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Enabled = table.Column(type: "bit", nullable: false), - Required = table.Column(type: "bit", nullable: false), - Emphasize = table.Column(type: "bit", nullable: false), - ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true), - LastModificationTime = table.Column(type: "datetime2", nullable: true), - LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), - IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), - DeleterId = table.Column(type: "uniqueidentifier", nullable: true), - DeletionTime = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerPersistedGrants", - columns: table => new - { - Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), - SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), - ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - Expiration = table.Column(type: "datetime2", nullable: true), - ConsumedTime = table.Column(type: "datetime2", nullable: true), - Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), - Id = table.Column(type: "uniqueidentifier", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), - ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); - }); - - migrationBuilder.CreateTable( - name: "AbpAuditLogActions", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), - MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), - Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - ExecutionTime = table.Column(type: "datetime2", nullable: false), - ExecutionDuration = table.Column(type: "int", nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); - table.ForeignKey( - name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ChangeTime = table.Column(type: "datetime2", nullable: false), - ChangeType = table.Column(type: "tinyint", nullable: false), - EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", - column: x => x.AuditLogId, - principalTable: "AbpAuditLogs", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpOrganizationUnitRoles", - columns: table => new - { - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpRoleClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpRoleClaims_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpTenantConnectionStrings", - columns: table => new - { - TenantId = table.Column(type: "uniqueidentifier", nullable: false), - Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Value = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); - table.ForeignKey( - name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", - column: x => x.TenantId, - principalTable: "AbpTenants", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserClaims", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - UserId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), - ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserClaims", x => x.Id); - table.ForeignKey( - name: "FK_AbpUserClaims_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserLogins", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), - ProviderDisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); - table.ForeignKey( - name: "FK_AbpUserLogins_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserOrganizationUnits", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - CreationTime = table.Column(type: "datetime2", nullable: false), - CreatorId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", - column: x => x.OrganizationUnitId, - principalTable: "AbpOrganizationUnits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserRoles", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - RoleId = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpRoles_RoleId", - column: x => x.RoleId, - principalTable: "AbpRoles", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_AbpUserRoles_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpUserTokens", - columns: table => new - { - UserId = table.Column(type: "uniqueidentifier", nullable: false), - LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), - Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - Value = table.Column(type: "nvarchar(max)", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); - table.ForeignKey( - name: "FK_AbpUserTokens_AbpUsers_UserId", - column: x => x.UserId, - principalTable: "AbpUsers", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceClaims", - columns: table => new - { - Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceProperties", - columns: table => new - { - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceScopes", - columns: table => new - { - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiResourceSecrets", - columns: table => new - { - Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), - ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), - Expiration = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId", - column: x => x.ApiResourceId, - principalTable: "IdentityServerApiResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopeClaims", - columns: table => new - { - Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId", - column: x => x.ApiScopeId, - principalTable: "IdentityServerApiScopes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerApiScopeProperties", - columns: table => new - { - ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId", - column: x => x.ApiScopeId, - principalTable: "IdentityServerApiScopes", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientClaims", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientCorsOrigins", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Origin = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); - table.ForeignKey( - name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientGrantTypes", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - GrantType = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); - table.ForeignKey( - name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientIdPRestrictions", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Provider = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); - table.ForeignKey( - name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientPostLogoutRedirectUris", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - PostLogoutRedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); - table.ForeignKey( - name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientProperties", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientRedirectUris", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - RedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); - table.ForeignKey( - name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientScopes", - columns: table => new - { - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); - table.ForeignKey( - name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerClientSecrets", - columns: table => new - { - Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), - ClientId = table.Column(type: "uniqueidentifier", nullable: false), - Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), - Expiration = table.Column(type: "datetime2", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", - column: x => x.ClientId, - principalTable: "IdentityServerClients", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResourceClaims", - columns: table => new - { - Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), - IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type }); - table.ForeignKey( - name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId", - column: x => x.IdentityResourceId, - principalTable: "IdentityServerIdentityResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "IdentityServerIdentityResourceProperties", - columns: table => new - { - IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false), - Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), - Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value }); - table.ForeignKey( - name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId", - column: x => x.IdentityResourceId, - principalTable: "IdentityServerIdentityResources", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "AbpEntityPropertyChanges", - columns: table => new - { - Id = table.Column(type: "uniqueidentifier", nullable: false), - TenantId = table.Column(type: "uniqueidentifier", nullable: true), - EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), - NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), - PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), - PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); - table.ForeignKey( - name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", - column: x => x.EntityChangeId, - principalTable: "AbpEntityChanges", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_AuditLogId", - table: "AbpAuditLogActions", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", - table: "AbpAuditLogActions", - columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", - table: "AbpAuditLogs", - columns: new[] { "TenantId", "UserId", "ExecutionTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime", - table: "AbpBackgroundJobs", - columns: new[] { "IsAbandoned", "NextTryTime" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_AuditLogId", - table: "AbpEntityChanges", - column: "AuditLogId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", - table: "AbpEntityChanges", - columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpEntityPropertyChanges_EntityChangeId", - table: "AbpEntityPropertyChanges", - column: "EntityChangeId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", - table: "AbpFeatureValues", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", - table: "AbpLinkUsers", - columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, - unique: true, - filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", - table: "AbpOrganizationUnitRoles", - columns: new[] { "RoleId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_Code", - table: "AbpOrganizationUnits", - column: "Code"); - - migrationBuilder.CreateIndex( - name: "IX_AbpOrganizationUnits_ParentId", - table: "AbpOrganizationUnits", - column: "ParentId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", - table: "AbpPermissionGrants", - columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[TenantId] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoleClaims_RoleId", - table: "AbpRoleClaims", - column: "RoleId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpRoles_NormalizedName", - table: "AbpRoles", - column: "NormalizedName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Action", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Action" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_ApplicationName", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "ApplicationName" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_Identity", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "Identity" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSecurityLogs_TenantId_UserId", - table: "AbpSecurityLogs", - columns: new[] { "TenantId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpSettings_Name_ProviderName_ProviderKey", - table: "AbpSettings", - columns: new[] { "Name", "ProviderName", "ProviderKey" }, - unique: true, - filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); - - migrationBuilder.CreateIndex( - name: "IX_AbpTenants_Name", - table: "AbpTenants", - column: "Name"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserClaims_UserId", - table: "AbpUserClaims", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserLogins_LoginProvider_ProviderKey", - table: "AbpUserLogins", - columns: new[] { "LoginProvider", "ProviderKey" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", - table: "AbpUserOrganizationUnits", - columns: new[] { "UserId", "OrganizationUnitId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUserRoles_RoleId_UserId", - table: "AbpUserRoles", - columns: new[] { "RoleId", "UserId" }); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_Email", - table: "AbpUsers", - column: "Email"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedEmail", - table: "AbpUsers", - column: "NormalizedEmail"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_NormalizedUserName", - table: "AbpUsers", - column: "NormalizedUserName"); - - migrationBuilder.CreateIndex( - name: "IX_AbpUsers_UserName", - table: "AbpUsers", - column: "UserName"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerClients_ClientId", - table: "IdentityServerClients", - column: "ClientId"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", - table: "IdentityServerDeviceFlowCodes", - column: "DeviceCode", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_Expiration", - table: "IdentityServerDeviceFlowCodes", - column: "Expiration"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerDeviceFlowCodes_UserCode", - table: "IdentityServerDeviceFlowCodes", - column: "UserCode"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_Expiration", - table: "IdentityServerPersistedGrants", - column: "Expiration"); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", - table: "IdentityServerPersistedGrants", - columns: new[] { "SubjectId", "ClientId", "Type" }); - - migrationBuilder.CreateIndex( - name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type", - table: "IdentityServerPersistedGrants", - columns: new[] { "SubjectId", "SessionId", "Type" }); - } + migrationBuilder.CreateTable( + name: "AbpAuditLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + TenantName = table.Column(type: "nvarchar(max)", nullable: true), + ImpersonatorUserId = table.Column(type: "uniqueidentifier", nullable: true), + ImpersonatorTenantId = table.Column(type: "uniqueidentifier", nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + HttpMethod = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + Url = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + Exceptions = table.Column(type: "nvarchar(max)", nullable: true), + Comments = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + HttpStatusCode = table.Column(type: "int", nullable: true), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpBackgroundJobs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + JobName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + JobArgs = table.Column(type: "nvarchar(max)", maxLength: 1048576, nullable: false), + TryCount = table.Column(type: "smallint", nullable: false, defaultValue: (short)0), + CreationTime = table.Column(type: "datetime2", nullable: false), + NextTryTime = table.Column(type: "datetime2", nullable: false), + LastTryTime = table.Column(type: "datetime2", nullable: true), + IsAbandoned = table.Column(type: "bit", nullable: false, defaultValue: false), + Priority = table.Column(type: "tinyint", nullable: false, defaultValue: (byte)15), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpBackgroundJobs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpClaimTypes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Required = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + Regex = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + RegexDescription = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Description = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + ValueType = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpFeatureValues", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpLinkUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + SourceUserId = table.Column(type: "uniqueidentifier", nullable: false), + SourceTenantId = table.Column(type: "uniqueidentifier", nullable: true), + TargetUserId = table.Column(type: "uniqueidentifier", nullable: false), + TargetTenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnits", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ParentId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(95)", maxLength: 95, nullable: false), + DisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); + table.ForeignKey( + name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", + column: x => x.ParentId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "AbpPermissionGrants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpRoles", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsDefault = table.Column(type: "bit", nullable: false), + IsStatic = table.Column(type: "bit", nullable: false), + IsPublic = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoles", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSecurityLogs", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ApplicationName = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Identity = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + Action = table.Column(type: "nvarchar(96)", maxLength: 96, nullable: true), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + TenantName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + CorrelationId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ClientIpAddress = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + BrowserInfo = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpSettings", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(2048)", maxLength: 2048, nullable: false), + ProviderName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + ProviderKey = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpSettings", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpTenants", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenants", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "AbpUsers", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Surname = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: true), + Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + EmailConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + PasswordHash = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + SecurityStamp = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + IsExternal = table.Column(type: "bit", nullable: false, defaultValue: false), + PhoneNumber = table.Column(type: "nvarchar(16)", maxLength: 16, nullable: true), + PhoneNumberConfirmed = table.Column(type: "bit", nullable: false, defaultValue: false), + IsActive = table.Column(type: "bit", nullable: false), + TwoFactorEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + LockoutEnd = table.Column(type: "datetimeoffset", nullable: true), + LockoutEnabled = table.Column(type: "bit", nullable: false, defaultValue: false), + AccessFailedCount = table.Column(type: "int", nullable: false, defaultValue: 0), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUsers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResources", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + AllowedAccessTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Enabled = table.Column(type: "bit", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Required = table.Column(type: "bit", nullable: false), + Emphasize = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClients", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ClientName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + ClientUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + LogoUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + ProtocolType = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + RequireClientSecret = table.Column(type: "bit", nullable: false), + RequireConsent = table.Column(type: "bit", nullable: false), + AllowRememberConsent = table.Column(type: "bit", nullable: false), + AlwaysIncludeUserClaimsInIdToken = table.Column(type: "bit", nullable: false), + RequirePkce = table.Column(type: "bit", nullable: false), + AllowPlainTextPkce = table.Column(type: "bit", nullable: false), + RequireRequestObject = table.Column(type: "bit", nullable: false), + AllowAccessTokensViaBrowser = table.Column(type: "bit", nullable: false), + FrontChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + FrontChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + BackChannelLogoutUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + BackChannelLogoutSessionRequired = table.Column(type: "bit", nullable: false), + AllowOfflineAccess = table.Column(type: "bit", nullable: false), + IdentityTokenLifetime = table.Column(type: "int", nullable: false), + AllowedIdentityTokenSigningAlgorithms = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + AccessTokenLifetime = table.Column(type: "int", nullable: false), + AuthorizationCodeLifetime = table.Column(type: "int", nullable: false), + ConsentLifetime = table.Column(type: "int", nullable: true), + AbsoluteRefreshTokenLifetime = table.Column(type: "int", nullable: false), + SlidingRefreshTokenLifetime = table.Column(type: "int", nullable: false), + RefreshTokenUsage = table.Column(type: "int", nullable: false), + UpdateAccessTokenClaimsOnRefresh = table.Column(type: "bit", nullable: false), + RefreshTokenExpiration = table.Column(type: "int", nullable: false), + AccessTokenType = table.Column(type: "int", nullable: false), + EnableLocalLogin = table.Column(type: "bit", nullable: false), + IncludeJwtId = table.Column(type: "bit", nullable: false), + AlwaysSendClientClaims = table.Column(type: "bit", nullable: false), + ClientClaimsPrefix = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + PairWiseSubjectSalt = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + UserSsoLifetime = table.Column(type: "int", nullable: true), + UserCodeType = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + DeviceCodeLifetime = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerDeviceFlowCodes", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + DeviceCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + UserCode = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: false), + Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerDeviceFlowCodes", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResources", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + DisplayName = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Enabled = table.Column(type: "bit", nullable: false), + Required = table.Column(type: "bit", nullable: false), + Emphasize = table.Column(type: "bit", nullable: false), + ShowInDiscoveryDocument = table.Column(type: "bit", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResources", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerPersistedGrants", + columns: table => new { + Key = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Type = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + SubjectId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + SessionId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: true), + ClientId = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + Description = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + Expiration = table.Column(type: "datetime2", nullable: true), + ConsumedTime = table.Column(type: "datetime2", nullable: true), + Data = table.Column(type: "nvarchar(max)", maxLength: 50000, nullable: false), + Id = table.Column(type: "uniqueidentifier", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true), + ConcurrencyStamp = table.Column(type: "nvarchar(40)", maxLength: 40, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerPersistedGrants", x => x.Key); + }); + + migrationBuilder.CreateTable( + name: "AbpAuditLogActions", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + ServiceName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true), + MethodName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true), + Parameters = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + ExecutionTime = table.Column(type: "datetime2", nullable: false), + ExecutionDuration = table.Column(type: "int", nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpAuditLogActions", x => x.Id); + table.ForeignKey( + name: "FK_AbpAuditLogActions_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + AuditLogId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ChangeTime = table.Column(type: "datetime2", nullable: false), + ChangeType = table.Column(type: "tinyint", nullable: false), + EntityTenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityId = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + EntityTypeFullName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + ExtraProperties = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityChanges_AbpAuditLogs_AuditLogId", + column: x => x.AuditLogId, + principalTable: "AbpAuditLogs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpOrganizationUnitRoles", + columns: table => new { + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpRoleClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpRoleClaims_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpTenantConnectionStrings", + columns: table => new { + TenantId = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Value = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); + table.ForeignKey( + name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", + column: x => x.TenantId, + principalTable: "AbpTenants", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserClaims", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ClaimType = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: false), + ClaimValue = table.Column(type: "nvarchar(1024)", maxLength: 1024, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserClaims", x => x.Id); + table.ForeignKey( + name: "FK_AbpUserClaims_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserLogins", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + ProviderKey = table.Column(type: "nvarchar(196)", maxLength: 196, nullable: false), + ProviderDisplayName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); + table.ForeignKey( + name: "FK_AbpUserLogins_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserOrganizationUnits", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + OrganizationUnitId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUnitId", + column: x => x.OrganizationUnitId, + principalTable: "AbpOrganizationUnits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserRoles", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + RoleId = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpRoles_RoleId", + column: x => x.RoleId, + principalTable: "AbpRoles", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_AbpUserRoles_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpUserTokens", + columns: table => new { + UserId = table.Column(type: "uniqueidentifier", nullable: false), + LoginProvider = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Value = table.Column(type: "nvarchar(max)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); + table.ForeignKey( + name: "FK_AbpUserTokens_AbpUsers_UserId", + column: x => x.UserId, + principalTable: "AbpUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceClaims", + columns: table => new { + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceClaims", x => new { x.ApiResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceClaims_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceProperties", + columns: table => new { + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceProperties", x => new { x.ApiResourceId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceProperties_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceScopes", + columns: table => new { + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceScopes", x => new { x.ApiResourceId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceScopes_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiResourceSecrets", + columns: table => new { + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), + ApiResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiResourceSecrets", x => new { x.ApiResourceId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiResourceSecrets_IdentityServerApiResources_ApiResourceId", + column: x => x.ApiResourceId, + principalTable: "IdentityServerApiResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeClaims", + columns: table => new { + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeClaims", x => new { x.ApiScopeId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeClaims_IdentityServerApiScopes_ApiScopeId", + column: x => x.ApiScopeId, + principalTable: "IdentityServerApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerApiScopeProperties", + columns: table => new { + ApiScopeId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerApiScopeProperties", x => new { x.ApiScopeId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerApiScopeProperties_IdentityServerApiScopes_ApiScopeId", + column: x => x.ApiScopeId, + principalTable: "IdentityServerApiScopes", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientClaims", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientClaims", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientClaims_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientCorsOrigins", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Origin = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientCorsOrigins", x => new { x.ClientId, x.Origin }); + table.ForeignKey( + name: "FK_IdentityServerClientCorsOrigins_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientGrantTypes", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + GrantType = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientGrantTypes", x => new { x.ClientId, x.GrantType }); + table.ForeignKey( + name: "FK_IdentityServerClientGrantTypes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientIdPRestrictions", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Provider = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientIdPRestrictions", x => new { x.ClientId, x.Provider }); + table.ForeignKey( + name: "FK_IdentityServerClientIdPRestrictions_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientPostLogoutRedirectUris", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + PostLogoutRedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientPostLogoutRedirectUris", x => new { x.ClientId, x.PostLogoutRedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientPostLogoutRedirectUris_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientProperties", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientProperties", x => new { x.ClientId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientProperties_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientRedirectUris", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + RedirectUri = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientRedirectUris", x => new { x.ClientId, x.RedirectUri }); + table.ForeignKey( + name: "FK_IdentityServerClientRedirectUris_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientScopes", + columns: table => new { + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Scope = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientScopes", x => new { x.ClientId, x.Scope }); + table.ForeignKey( + name: "FK_IdentityServerClientScopes_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerClientSecrets", + columns: table => new { + Type = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(4000)", maxLength: 4000, nullable: false), + ClientId = table.Column(type: "uniqueidentifier", nullable: false), + Description = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: true), + Expiration = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerClientSecrets", x => new { x.ClientId, x.Type, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerClientSecrets_IdentityServerClients_ClientId", + column: x => x.ClientId, + principalTable: "IdentityServerClients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResourceClaims", + columns: table => new { + Type = table.Column(type: "nvarchar(200)", maxLength: 200, nullable: false), + IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResourceClaims", x => new { x.IdentityResourceId, x.Type }); + table.ForeignKey( + name: "FK_IdentityServerIdentityResourceClaims_IdentityServerIdentityResources_IdentityResourceId", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "IdentityServerIdentityResourceProperties", + columns: table => new { + IdentityResourceId = table.Column(type: "uniqueidentifier", nullable: false), + Key = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: false), + Value = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_IdentityServerIdentityResourceProperties", x => new { x.IdentityResourceId, x.Key, x.Value }); + table.ForeignKey( + name: "FK_IdentityServerIdentityResourceProperties_IdentityServerIdentityResources_IdentityResourceId", + column: x => x.IdentityResourceId, + principalTable: "IdentityServerIdentityResources", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "AbpEntityPropertyChanges", + columns: table => new { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + EntityChangeId = table.Column(type: "uniqueidentifier", nullable: false), + NewValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + OriginalValue = table.Column(type: "nvarchar(512)", maxLength: 512, nullable: true), + PropertyName = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + PropertyTypeFullName = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_AbpEntityPropertyChanges", x => x.Id); + table.ForeignKey( + name: "FK_AbpEntityPropertyChanges_AbpEntityChanges_EntityChangeId", + column: x => x.EntityChangeId, + principalTable: "AbpEntityChanges", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_AuditLogId", + table: "AbpAuditLogActions", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogActions_TenantId_ServiceName_MethodName_ExecutionTime", + table: "AbpAuditLogActions", + columns: new[] { "TenantId", "ServiceName", "MethodName", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpAuditLogs_TenantId_UserId_ExecutionTime", + table: "AbpAuditLogs", + columns: new[] { "TenantId", "UserId", "ExecutionTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpBackgroundJobs_IsAbandoned_NextTryTime", + table: "AbpBackgroundJobs", + columns: new[] { "IsAbandoned", "NextTryTime" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_AuditLogId", + table: "AbpEntityChanges", + column: "AuditLogId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityChanges_TenantId_EntityTypeFullName_EntityId", + table: "AbpEntityChanges", + columns: new[] { "TenantId", "EntityTypeFullName", "EntityId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpEntityPropertyChanges_EntityChangeId", + table: "AbpEntityPropertyChanges", + column: "EntityChangeId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", + table: "AbpFeatureValues", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_TargetTenantId", + table: "AbpLinkUsers", + columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, + unique: true, + filter: "[SourceTenantId] IS NOT NULL AND [TargetTenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", + table: "AbpOrganizationUnitRoles", + columns: new[] { "RoleId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_Code", + table: "AbpOrganizationUnits", + column: "Code"); + + migrationBuilder.CreateIndex( + name: "IX_AbpOrganizationUnits_ParentId", + table: "AbpOrganizationUnits", + column: "ParentId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", + table: "AbpPermissionGrants", + columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[TenantId] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoleClaims_RoleId", + table: "AbpRoleClaims", + column: "RoleId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpRoles_NormalizedName", + table: "AbpRoles", + column: "NormalizedName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Action", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Action" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_ApplicationName", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "ApplicationName" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_Identity", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "Identity" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSecurityLogs_TenantId_UserId", + table: "AbpSecurityLogs", + columns: new[] { "TenantId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpSettings_Name_ProviderName_ProviderKey", + table: "AbpSettings", + columns: new[] { "Name", "ProviderName", "ProviderKey" }, + unique: true, + filter: "[ProviderName] IS NOT NULL AND [ProviderKey] IS NOT NULL"); + + migrationBuilder.CreateIndex( + name: "IX_AbpTenants_Name", + table: "AbpTenants", + column: "Name"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserClaims_UserId", + table: "AbpUserClaims", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserLogins_LoginProvider_ProviderKey", + table: "AbpUserLogins", + columns: new[] { "LoginProvider", "ProviderKey" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", + table: "AbpUserOrganizationUnits", + columns: new[] { "UserId", "OrganizationUnitId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUserRoles_RoleId_UserId", + table: "AbpUserRoles", + columns: new[] { "RoleId", "UserId" }); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_Email", + table: "AbpUsers", + column: "Email"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedEmail", + table: "AbpUsers", + column: "NormalizedEmail"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_NormalizedUserName", + table: "AbpUsers", + column: "NormalizedUserName"); + + migrationBuilder.CreateIndex( + name: "IX_AbpUsers_UserName", + table: "AbpUsers", + column: "UserName"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerClients_ClientId", + table: "IdentityServerClients", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_DeviceCode", + table: "IdentityServerDeviceFlowCodes", + column: "DeviceCode", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_Expiration", + table: "IdentityServerDeviceFlowCodes", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerDeviceFlowCodes_UserCode", + table: "IdentityServerDeviceFlowCodes", + column: "UserCode"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_Expiration", + table: "IdentityServerPersistedGrants", + column: "Expiration"); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_ClientId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "ClientId", "Type" }); + + migrationBuilder.CreateIndex( + name: "IX_IdentityServerPersistedGrants_SubjectId_SessionId_Type", + table: "IdentityServerPersistedGrants", + columns: new[] { "SubjectId", "SessionId", "Type" }); + } - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "AbpAuditLogActions"); + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "AbpAuditLogActions"); - migrationBuilder.DropTable( - name: "AbpBackgroundJobs"); + migrationBuilder.DropTable( + name: "AbpBackgroundJobs"); - migrationBuilder.DropTable( - name: "AbpClaimTypes"); + migrationBuilder.DropTable( + name: "AbpClaimTypes"); - migrationBuilder.DropTable( - name: "AbpEntityPropertyChanges"); + migrationBuilder.DropTable( + name: "AbpEntityPropertyChanges"); - migrationBuilder.DropTable( - name: "AbpFeatureValues"); + migrationBuilder.DropTable( + name: "AbpFeatureValues"); - migrationBuilder.DropTable( - name: "AbpLinkUsers"); + migrationBuilder.DropTable( + name: "AbpLinkUsers"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnitRoles"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnitRoles"); - migrationBuilder.DropTable( - name: "AbpPermissionGrants"); + migrationBuilder.DropTable( + name: "AbpPermissionGrants"); - migrationBuilder.DropTable( - name: "AbpRoleClaims"); + migrationBuilder.DropTable( + name: "AbpRoleClaims"); - migrationBuilder.DropTable( - name: "AbpSecurityLogs"); + migrationBuilder.DropTable( + name: "AbpSecurityLogs"); - migrationBuilder.DropTable( - name: "AbpSettings"); + migrationBuilder.DropTable( + name: "AbpSettings"); - migrationBuilder.DropTable( - name: "AbpTenantConnectionStrings"); + migrationBuilder.DropTable( + name: "AbpTenantConnectionStrings"); - migrationBuilder.DropTable( - name: "AbpUserClaims"); + migrationBuilder.DropTable( + name: "AbpUserClaims"); - migrationBuilder.DropTable( - name: "AbpUserLogins"); + migrationBuilder.DropTable( + name: "AbpUserLogins"); - migrationBuilder.DropTable( - name: "AbpUserOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpUserOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpUserRoles"); + migrationBuilder.DropTable( + name: "AbpUserRoles"); - migrationBuilder.DropTable( - name: "AbpUserTokens"); + migrationBuilder.DropTable( + name: "AbpUserTokens"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceClaims"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceClaims"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceProperties"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceProperties"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceScopes"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceScopes"); - migrationBuilder.DropTable( - name: "IdentityServerApiResourceSecrets"); + migrationBuilder.DropTable( + name: "IdentityServerApiResourceSecrets"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopeClaims"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopeClaims"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopeProperties"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopeProperties"); - migrationBuilder.DropTable( - name: "IdentityServerClientClaims"); + migrationBuilder.DropTable( + name: "IdentityServerClientClaims"); - migrationBuilder.DropTable( - name: "IdentityServerClientCorsOrigins"); + migrationBuilder.DropTable( + name: "IdentityServerClientCorsOrigins"); - migrationBuilder.DropTable( - name: "IdentityServerClientGrantTypes"); + migrationBuilder.DropTable( + name: "IdentityServerClientGrantTypes"); - migrationBuilder.DropTable( - name: "IdentityServerClientIdPRestrictions"); + migrationBuilder.DropTable( + name: "IdentityServerClientIdPRestrictions"); - migrationBuilder.DropTable( - name: "IdentityServerClientPostLogoutRedirectUris"); + migrationBuilder.DropTable( + name: "IdentityServerClientPostLogoutRedirectUris"); - migrationBuilder.DropTable( - name: "IdentityServerClientProperties"); + migrationBuilder.DropTable( + name: "IdentityServerClientProperties"); - migrationBuilder.DropTable( - name: "IdentityServerClientRedirectUris"); + migrationBuilder.DropTable( + name: "IdentityServerClientRedirectUris"); - migrationBuilder.DropTable( - name: "IdentityServerClientScopes"); + migrationBuilder.DropTable( + name: "IdentityServerClientScopes"); - migrationBuilder.DropTable( - name: "IdentityServerClientSecrets"); + migrationBuilder.DropTable( + name: "IdentityServerClientSecrets"); - migrationBuilder.DropTable( - name: "IdentityServerDeviceFlowCodes"); + migrationBuilder.DropTable( + name: "IdentityServerDeviceFlowCodes"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResourceClaims"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResourceClaims"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResourceProperties"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResourceProperties"); - migrationBuilder.DropTable( - name: "IdentityServerPersistedGrants"); + migrationBuilder.DropTable( + name: "IdentityServerPersistedGrants"); - migrationBuilder.DropTable( - name: "AbpEntityChanges"); + migrationBuilder.DropTable( + name: "AbpEntityChanges"); - migrationBuilder.DropTable( - name: "AbpTenants"); + migrationBuilder.DropTable( + name: "AbpTenants"); - migrationBuilder.DropTable( - name: "AbpOrganizationUnits"); + migrationBuilder.DropTable( + name: "AbpOrganizationUnits"); - migrationBuilder.DropTable( - name: "AbpRoles"); + migrationBuilder.DropTable( + name: "AbpRoles"); - migrationBuilder.DropTable( - name: "AbpUsers"); + migrationBuilder.DropTable( + name: "AbpUsers"); - migrationBuilder.DropTable( - name: "IdentityServerApiResources"); + migrationBuilder.DropTable( + name: "IdentityServerApiResources"); - migrationBuilder.DropTable( - name: "IdentityServerApiScopes"); + migrationBuilder.DropTable( + name: "IdentityServerApiScopes"); - migrationBuilder.DropTable( - name: "IdentityServerClients"); + migrationBuilder.DropTable( + name: "IdentityServerClients"); - migrationBuilder.DropTable( - name: "IdentityServerIdentityResources"); + migrationBuilder.DropTable( + name: "IdentityServerIdentityResources"); - migrationBuilder.DropTable( - name: "AbpAuditLogs"); - } + migrationBuilder.DropTable( + name: "AbpAuditLogs"); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs index e54e6cf8c7..07f7c9e4cb 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Client/MyProjectNameHttpApiClientModule.cs @@ -8,32 +8,31 @@ using Volo.Abp.TenantManagement; using Volo.Abp.SettingManagement; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpAccountHttpApiClientModule), + typeof(AbpIdentityHttpApiClientModule), + typeof(AbpPermissionManagementHttpApiClientModule), + typeof(AbpTenantManagementHttpApiClientModule), + typeof(AbpFeatureManagementHttpApiClientModule), + typeof(AbpSettingManagementHttpApiClientModule) +)] +public class MyProjectNameHttpApiClientModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpAccountHttpApiClientModule), - typeof(AbpIdentityHttpApiClientModule), - typeof(AbpPermissionManagementHttpApiClientModule), - typeof(AbpTenantManagementHttpApiClientModule), - typeof(AbpFeatureManagementHttpApiClientModule), - typeof(AbpSettingManagementHttpApiClientModule) - )] - public class MyProjectNameHttpApiClientModule : AbpModule + public const string RemoteServiceName = "Default"; + + public override void ConfigureServices(ServiceConfigurationContext context) { - public const string RemoteServiceName = "Default"; + context.Services.AddHttpClientProxies( + typeof(MyProjectNameApplicationContractsModule).Assembly, + RemoteServiceName + ); - public override void ConfigureServices(ServiceConfigurationContext context) + Configure(options => { - context.Services.AddHttpClientProxies( - typeof(MyProjectNameApplicationContractsModule).Assembly, - RemoteServiceName - ); - - Configure(options => - { - options.FileSets.AddEmbedded(); - }); - } + options.FileSets.AddEmbedded(); + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs index cebd5b80ee..02a2380214 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Controllers/HomeController.cs +++ b/templates/app/aspnet-core/src/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"); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs index 9be9cb21f5..db8ba2982e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/MyProjectNameHttpApiHostModule.cs @@ -27,199 +27,198 @@ using Volo.Abp.Modularity; using Volo.Abp.Swashbuckle; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameHttpApiModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpAspNetCoreMvcUiMultiTenancyModule), + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) +)] +public class MyProjectNameHttpApiHostModule : AbpModule { - [DependsOn( - typeof(MyProjectNameHttpApiModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpAspNetCoreMvcUiMultiTenancyModule), - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameHttpApiHostModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var configuration = context.Services.GetConfiguration(); - var hostingEnvironment = context.Services.GetHostingEnvironment(); - - ConfigureConventionalControllers(); - ConfigureAuthentication(context, configuration); - ConfigureLocalization(); - ConfigureCache(configuration); - ConfigureVirtualFileSystem(context); - ConfigureDataProtection(context, configuration, hostingEnvironment); - ConfigureCors(context, configuration); - ConfigureSwaggerServices(context, configuration); - } - - private void ConfigureCache(IConfiguration configuration) - { - Configure(options => { options.KeyPrefix = "MyProjectName:"; }); - } + var configuration = context.Services.GetConfiguration(); + var hostingEnvironment = context.Services.GetHostingEnvironment(); + + ConfigureConventionalControllers(); + ConfigureAuthentication(context, configuration); + ConfigureLocalization(); + ConfigureCache(configuration); + ConfigureVirtualFileSystem(context); + ConfigureDataProtection(context, configuration, hostingEnvironment); + ConfigureCors(context, configuration); + ConfigureSwaggerServices(context, configuration); + } - private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); + private void ConfigureCache(IConfiguration configuration) + { + Configure(options => { options.KeyPrefix = "MyProjectName:"; }); + } - if (hostingEnvironment.IsDevelopment()) - { - Configure(options => - { - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); - }); - } - } + private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); - private void ConfigureConventionalControllers() + if (hostingEnvironment.IsDevelopment()) { - Configure(options => + Configure(options => { - options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); }); } + } - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + private void ConfigureConventionalControllers() + { + Configure(options => { - context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = "MyProjectName"; - }); - } + options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); + }); + } - private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) - { - context.Services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], - new Dictionary - { - {"MyProjectName", "MyProjectName API"} - }, - options => - { - options.SwaggerDoc("v1", new OpenApiInfo {Title = "MyProjectName API", Version = "v1"}); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - } + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) + .AddJwtBearer(options => + { + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "MyProjectName"; + }); + } - private void ConfigureLocalization() - { - Configure(options => + private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAbpSwaggerGenWithOAuth( + configuration["AuthServer:Authority"], + new Dictionary { - 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("ro-RO", "ro-RO", "Română")); - options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); - options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); - 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", "de")); - options.Languages.Add(new LanguageInfo("es", "es", "Español", "es")); + {"MyProjectName", "MyProjectName API"} + }, + 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) + private void ConfigureLocalization() + { + Configure(options => { - var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); - if (!hostingEnvironment.IsDevelopment()) - { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); - } - } + 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("ro-RO", "ro-RO", "Română")); + options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar")); + options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português")); + 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", "de")); + options.Languages.Add(new LanguageInfo("es", "es", "Español", "es")); + }); + } - private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) + private void ConfigureDataProtection( + ServiceConfigurationContext context, + IConfiguration configuration, + IWebHostEnvironment hostingEnvironment) + { + var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); + if (!hostingEnvironment.IsDevelopment()) { - 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 redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); } + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddCors(options => { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) + options.AddDefaultPolicy(builder => { - app.UseDeveloperExceptionPage(); - } + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + } - app.UseAbpRequestLocalization(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(); - app.UseAuthentication(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } - app.UseAuthorization(); + app.UseAbpRequestLocalization(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(); + app.UseAuthentication(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - var configuration = context.GetConfiguration(); - options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); - options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); - options.OAuthScopes("MyProjectName"); - }); + app.UseAuthorization(); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseUnitOfWork(); - app.UseConfiguredEndpoints(); - } + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + + var configuration = context.GetConfiguration(); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + options.OAuthScopes("MyProjectName"); + }); + + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseUnitOfWork(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs index e16edddb92..fbbae26ddd 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Program.cs @@ -5,52 +5,51 @@ 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) - .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 MyCompanyName.MyProjectName.HttpApi.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 MyCompanyName.MyProjectName.HttpApi.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(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs index 644425b274..05e84529fc 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/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(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs index cebd5b80ee..02a2380214 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Controllers/HomeController.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/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"); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs index 5680cd733d..fb6e75d065 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.DependencyInjection; using Volo.Abp.Ui.Branding; -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"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs index 7e20326cea..586507bbc4 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/MyProjectNameHttpApiHostModule.cs @@ -29,219 +29,218 @@ using Volo.Abp.Swashbuckle; using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameHttpApiModule), + typeof(AbpAutofacModule), + typeof(AbpAspNetCoreMultiTenancyModule), + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) +)] +public class MyProjectNameHttpApiHostModule : AbpModule { - [DependsOn( - typeof(MyProjectNameHttpApiModule), - typeof(AbpAutofacModule), - typeof(AbpAspNetCoreMultiTenancyModule), - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameHttpApiHostModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + var configuration = context.Services.GetConfiguration(); + var hostingEnvironment = context.Services.GetHostingEnvironment(); + + ConfigureBundles(); + ConfigureUrls(configuration); + ConfigureConventionalControllers(); + ConfigureAuthentication(context, configuration); + ConfigureLocalization(); + ConfigureVirtualFileSystem(context); + ConfigureCors(context, configuration); + ConfigureSwaggerServices(context, configuration); + } + + private void ConfigureBundles() + { + Configure(options => { - var configuration = context.Services.GetConfiguration(); - var hostingEnvironment = context.Services.GetHostingEnvironment(); - - ConfigureBundles(); - ConfigureUrls(configuration); - ConfigureConventionalControllers(); - ConfigureAuthentication(context, configuration); - ConfigureLocalization(); - ConfigureVirtualFileSystem(context); - ConfigureCors(context, configuration); - ConfigureSwaggerServices(context, configuration); - } + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => { bundle.AddFiles("/global-styles.css"); } + ); + }); + } - private void ConfigureBundles() + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.StyleBundles.Configure( - BasicThemeBundles.Styles.Global, - bundle => { bundle.AddFiles("/global-styles.css"); } - ); - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); + + options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; + options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; + }); + } - private void ConfigureUrls(IConfiguration configuration) + private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + + if (hostingEnvironment.IsDevelopment()) { - Configure(options => + Configure(options => { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); - - options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; - options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); + options.FileSets.ReplaceEmbeddedByPhysical( + Path.Combine(hostingEnvironment.ContentRootPath, + $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); }); } + } - private void ConfigureVirtualFileSystem(ServiceConfigurationContext context) + private void ConfigureConventionalControllers() + { + Configure(options => { - var hostingEnvironment = context.Services.GetHostingEnvironment(); + options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); + }); + } - if (hostingEnvironment.IsDevelopment()) + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication() + .AddJwtBearer(options => { - Configure(options => + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "MyProjectName"; + options.BackchannelHttpHandler = new HttpClientHandler { - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); - options.FileSets.ReplaceEmbeddedByPhysical( - Path.Combine(hostingEnvironment.ContentRootPath, - $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); - }); - } - } + ServerCertificateCustomValidationCallback = + HttpClientHandler.DangerousAcceptAnyServerCertificateValidator + }; + }); + } - private void ConfigureConventionalControllers() - { - Configure(options => + private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAbpSwaggerGenWithOAuth( + configuration["AuthServer:Authority"], + new Dictionary { - options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); + {"MyProjectName", "MyProjectName API"} + }, + options => + { + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); }); - } - - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) - { - context.Services.AddAuthentication() - .AddJwtBearer(options => - { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = "MyProjectName"; - options.BackchannelHttpHandler = new HttpClientHandler - { - ServerCertificateCustomValidationCallback = - HttpClientHandler.DangerousAcceptAnyServerCertificateValidator - }; - }); - } + } - private static void ConfigureSwaggerServices(ServiceConfigurationContext context, IConfiguration configuration) + private void ConfigureLocalization() + { + Configure(options => { - context.Services.AddAbpSwaggerGenWithOAuth( - configuration["AuthServer:Authority"], - new Dictionary - { - {"MyProjectName", "MyProjectName API"} - }, - options => - { - options.SwaggerDoc("v1", new OpenApiInfo {Title = "MyProjectName API", Version = "v1"}); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - }); - } + 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", "de")); + options.Languages.Add(new LanguageInfo("es", "es", "Español", "es")); + }); + } - private void ConfigureLocalization() + private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddCors(options => { - Configure(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", "de")); - options.Languages.Add(new LanguageInfo("es", "es", "Español", "es")); + options.AddDefaultPolicy(builder => + { + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); }); - } + }); + } - private void ConfigureCors(ServiceConfigurationContext context, IConfiguration configuration) - { - 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(); - }); - }); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - public override void OnApplicationInitialization(ApplicationInitializationContext context) + if (env.IsDevelopment()) { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); - - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } + app.UseDeveloperExceptionPage(); + } - app.UseAbpRequestLocalization(); + app.UseAbpRequestLocalization(); - if (!env.IsDevelopment()) - { - app.UseErrorPage(); - } + if (!env.IsDevelopment()) + { + app.UseErrorPage(); + } - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(); - app.UseAuthentication(); - app.UseJwtTokenMiddleware(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(); + app.UseAuthentication(); + app.UseJwtTokenMiddleware(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); + } - app.UseUnitOfWork(); - app.UseIdentityServer(); - app.UseAuthorization(); + app.UseUnitOfWork(); + app.UseIdentityServer(); + app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(c => - { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + app.UseSwagger(); + app.UseAbpSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - var configuration = context.ServiceProvider.GetRequiredService(); - c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); - c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); - c.OAuthScopes("MyProjectName"); - }); + var configuration = context.ServiceProvider.GetRequiredService(); + c.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + c.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + c.OAuthScopes("MyProjectName"); + }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); - } + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Program.cs index e16edddb92..fbbae26ddd 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Program.cs @@ -5,52 +5,51 @@ 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) - .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 MyCompanyName.MyProjectName.HttpApi.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 MyCompanyName.MyProjectName.HttpApi.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(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Startup.cs index 644425b274..05e84529fc 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.HostWithIds/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(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Controllers/MyProjectNameController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Controllers/MyProjectNameController.cs index 346f27f7a3..cb193a25e6 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Controllers/MyProjectNameController.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Controllers/MyProjectNameController.cs @@ -1,15 +1,14 @@ using MyCompanyName.MyProjectName.Localization; using Volo.Abp.AspNetCore.Mvc; -namespace MyCompanyName.MyProjectName.Controllers +namespace MyCompanyName.MyProjectName.Controllers; + +/* Inherit your controllers from this class. + */ +public abstract class MyProjectNameController : AbpControllerBase { - /* Inherit your controllers from this class. - */ - public abstract class MyProjectNameController : AbpControllerBase + protected MyProjectNameController() { - protected MyProjectNameController() - { - LocalizationResource = typeof(MyProjectNameResource); - } + LocalizationResource = typeof(MyProjectNameResource); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs index ccec2232ed..8700b992ef 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/Models/Test/TestModel.cs @@ -1,11 +1,10 @@ using System; -namespace MyCompanyName.MyProjectName.Models.Test +namespace MyCompanyName.MyProjectName.Models.Test; + +public class TestModel { - public class TestModel - { - public string Name { get; set; } + public string Name { get; set; } - public DateTime BirthDate { get; set; } - } -} \ No newline at end of file + public DateTime BirthDate { get; set; } +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs index 7d83d21361..6b6c039701 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi/MyProjectNameHttpApiModule.cs @@ -9,34 +9,33 @@ using Volo.Abp.PermissionManagement.HttpApi; using Volo.Abp.SettingManagement; using Volo.Abp.TenantManagement; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameApplicationContractsModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpPermissionManagementHttpApiModule), + typeof(AbpTenantManagementHttpApiModule), + typeof(AbpFeatureManagementHttpApiModule), + typeof(AbpSettingManagementHttpApiModule) + )] +public class MyProjectNameHttpApiModule : AbpModule { - [DependsOn( - typeof(MyProjectNameApplicationContractsModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpIdentityHttpApiModule), - typeof(AbpPermissionManagementHttpApiModule), - typeof(AbpTenantManagementHttpApiModule), - typeof(AbpFeatureManagementHttpApiModule), - typeof(AbpSettingManagementHttpApiModule) - )] - public class MyProjectNameHttpApiModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - ConfigureLocalization(); - } + ConfigureLocalization(); + } - private void ConfigureLocalization() + private void ConfigureLocalization() + { + Configure(options => { - Configure(options => - { - options.Resources - .Get() - .AddBaseTypes( - typeof(AbpUiResource) - ); - }); - } + options.Resources + .Get() + .AddBaseTypes( + typeof(AbpUiResource) + ); + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs index 3f6994c9e4..340ce5fb7b 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/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"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs index e6146b9aba..fcaa4f5ab5 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs @@ -32,169 +32,168 @@ using Volo.Abp.UI.Navigation.Urls; using Volo.Abp.UI; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAccountApplicationModule), + typeof(AbpAccountHttpApiModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(AbpAspNetCoreSerilogModule) + )] +public class MyProjectNameIdentityServerModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAccountApplicationModule), - typeof(AbpAccountHttpApiModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpAspNetCoreSerilogModule) - )] - 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(options => - { - options.Resources - .Get() - .AddBaseTypes( - typeof(AbpUiResource) - ); - - 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", "de")); - options.Languages.Add(new LanguageInfo("es", "es", "Español", "es")); - }); + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); - Configure(options => - { - options.StyleBundles.Configure( - BasicThemeBundles.Styles.Global, - bundle => - { - bundle.AddFiles("/global-styles.css"); - } + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes( + typeof(AbpUiResource) ); - }); - Configure(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", "de")); + options.Languages.Add(new LanguageInfo("es", "es", "Español", "es")); + }); + + Configure(options => + { + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); + }); + + Configure(options => + { //options.IsEnabledForGetRequests = true; options.ApplicationName = "AuthServer"; - }); + }); - if (hostingEnvironment.IsDevelopment()) + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - Configure(options => - { // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web.IdentityServer", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web.IdentityServer", Path.DirectorySeparatorChar))); // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); - }); - } + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); + }); + } - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); + Configure(options => + { + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + options.RedirectAllowedUrls.AddRange(configuration["App:RedirectAllowedUrls"].Split(',')); - options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; - options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; - }); + options.Applications["Angular"].RootUrl = configuration["App:ClientUrl"]; + options.Applications["Angular"].Urls[AccountUrlNames.PasswordReset] = "account/reset-password"; + }); - Configure(options => - { - options.IsJobExecutionEnabled = false; - }); + Configure(options => + { + options.IsJobExecutionEnabled = false; + }); - Configure(options => - { - options.KeyPrefix = "MyProjectName:"; - }); + Configure(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"); - } + 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(); }); - } + }); + } - 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(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } - app.UseAbpRequestLocalization(); + app.UseAbpRequestLocalization(); - if (!env.IsDevelopment()) - { - app.UseErrorPage(); - } + if (!env.IsDevelopment()) + { + app.UseErrorPage(); + } - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseCors(); - app.UseAuthentication(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseCors(); + app.UseAuthentication(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } - - app.UseUnitOfWork(); - app.UseIdentityServer(); - app.UseAuthorization(); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); } + + app.UseUnitOfWork(); + app.UseIdentityServer(); + app.UseAuthorization(); + app.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs index cfd795c936..e8230ee00c 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/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() - { - } } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs index 8a57ded111..c1592d400c 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Program.cs @@ -5,52 +5,51 @@ 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) - .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 MyCompanyName.MyProjectName.IdentityServer."); - CreateHostBuilder(args).Build().Run(); - return 0; - } - catch (Exception ex) - { - Log.Fatal(ex, "MyCompanyName.MyProjectName.IdentityServer terminated unexpectedly!"); - return 1; - } - finally - { - Log.CloseAndFlush(); - } + try + { + Log.Information("Starting MyCompanyName.MyProjectName.IdentityServer."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "MyCompanyName.MyProjectName.IdentityServer terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Startup.cs index 7fd62325bd..50f174aa59 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.IdentityServer/Startup.cs @@ -1,18 +1,17 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs index 2a00826ba7..5a32a7ad2e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MongoDbMyProjectNameDbSchemaMigrator.cs @@ -7,38 +7,37 @@ using Volo.Abp.Data; using Volo.Abp.DependencyInjection; using Volo.Abp.MongoDB; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +public class MongoDbMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator, ITransientDependency { - public class MongoDbMyProjectNameDbSchemaMigrator : IMyProjectNameDbSchemaMigrator , ITransientDependency + private readonly IServiceProvider _serviceProvider; + + public MongoDbMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider) { - private readonly IServiceProvider _serviceProvider; + _serviceProvider = serviceProvider; + } - public MongoDbMyProjectNameDbSchemaMigrator(IServiceProvider serviceProvider) - { - _serviceProvider = serviceProvider; - } + public async Task MigrateAsync() + { + var dbContexts = _serviceProvider.GetServices(); + var connectionStringResolver = _serviceProvider.GetRequiredService(); - public async Task MigrateAsync() + foreach (var dbContext in dbContexts) { - var dbContexts = _serviceProvider.GetServices(); - var connectionStringResolver = _serviceProvider.GetRequiredService(); + var connectionString = + await connectionStringResolver.ResolveAsync( + ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType())); + var mongoUrl = new MongoUrl(connectionString); + var databaseName = mongoUrl.DatabaseName; + var client = new MongoClient(mongoUrl); - foreach (var dbContext in dbContexts) + if (databaseName.IsNullOrWhiteSpace()) { - var connectionString = - await connectionStringResolver.ResolveAsync( - ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType())); - var mongoUrl = new MongoUrl(connectionString); - var databaseName = mongoUrl.DatabaseName; - var client = new MongoClient(mongoUrl); - - if (databaseName.IsNullOrWhiteSpace()) - { - databaseName = ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType()); - } - - (dbContext as AbpMongoDbContext)?.InitializeCollections(client.GetDatabase(databaseName)); + databaseName = ConnectionStringNameAttribute.GetConnStringName(dbContext.GetType()); } + + (dbContext as AbpMongoDbContext)?.InitializeCollections(client.GetDatabase(databaseName)); } } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs index c034bf5768..4033323cd8 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbContext.cs @@ -1,23 +1,22 @@ using Volo.Abp.Data; using Volo.Abp.MongoDB; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[ConnectionStringName("Default")] +public class MyProjectNameMongoDbContext : AbpMongoDbContext { - [ConnectionStringName("Default")] - public class MyProjectNameMongoDbContext : AbpMongoDbContext - { - /* Add mongo collections here. Example: - * public IMongoCollection Questions => Collection(); - */ + /* Add mongo collections here. Example: + * public IMongoCollection Questions => Collection(); + */ - protected override void CreateModel(IMongoModelBuilder modelBuilder) - { - base.CreateModel(modelBuilder); + protected override void CreateModel(IMongoModelBuilder modelBuilder) + { + base.CreateModel(modelBuilder); - //builder.Entity(b => - //{ - // //... - //}); - } + //builder.Entity(b => + //{ + // //... + //}); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs index cff61b4ed0..fa2327adb4 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.MongoDB/MongoDb/MyProjectNameMongoDbModule.cs @@ -10,32 +10,31 @@ using Volo.Abp.SettingManagement.MongoDB; using Volo.Abp.TenantManagement.MongoDB; using Volo.Abp.Uow; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[DependsOn( + typeof(MyProjectNameDomainModule), + typeof(AbpPermissionManagementMongoDbModule), + typeof(AbpSettingManagementMongoDbModule), + typeof(AbpIdentityMongoDbModule), + typeof(AbpIdentityServerMongoDbModule), + typeof(AbpBackgroundJobsMongoDbModule), + typeof(AbpAuditLoggingMongoDbModule), + typeof(AbpTenantManagementMongoDbModule), + typeof(AbpFeatureManagementMongoDbModule) + )] +public class MyProjectNameMongoDbModule : AbpModule { - [DependsOn( - typeof(MyProjectNameDomainModule), - typeof(AbpPermissionManagementMongoDbModule), - typeof(AbpSettingManagementMongoDbModule), - typeof(AbpIdentityMongoDbModule), - typeof(AbpIdentityServerMongoDbModule), - typeof(AbpBackgroundJobsMongoDbModule), - typeof(AbpAuditLoggingMongoDbModule), - typeof(AbpTenantManagementMongoDbModule), - typeof(AbpFeatureManagementMongoDbModule) - )] - public class MyProjectNameMongoDbModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) + context.Services.AddMongoDbContext(options => { - context.Services.AddMongoDbContext(options => - { - options.AddDefaultRepositories(); - }); + options.AddDefaultRepositories(); + }); - Configure(options => - { - options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; - }); - } + Configure(options => + { + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; + }); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs index b93104a565..000d8ccdf2 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Components/Toolbar/LoginLink/LoginLinkViewComponent.cs @@ -1,13 +1,12 @@ using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc; -namespace MyCompanyName.MyProjectName.Web.Components.Toolbar.LoginLink +namespace MyCompanyName.MyProjectName.Web.Components.Toolbar.LoginLink; + +public class LoginLinkViewComponent : AbpViewComponent { - public class LoginLinkViewComponent : AbpViewComponent + public virtual IViewComponentResult Invoke() { - public virtual IViewComponentResult Invoke() - { - return View("~/Components/Toolbar/LoginLink/Default.cshtml"); - } + return View("~/Components/Toolbar/LoginLink/Default.cshtml"); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs index 29fa140e4d..feac147496 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs @@ -1,9 +1,8 @@ using Volo.Abp.AspNetCore.Mvc.Authentication; -namespace MyCompanyName.MyProjectName.Web.Controllers +namespace MyCompanyName.MyProjectName.Web.Controllers; + +public class AccountController : ChallengeAccountController { - public class AccountController : ChallengeAccountController - { - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs index 47298887a4..fd918a71db 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs @@ -12,71 +12,70 @@ using Volo.Abp.TenantManagement.Web.Navigation; using Volo.Abp.UI.Navigation; using Volo.Abp.Users; -namespace MyCompanyName.MyProjectName.Web.Menus +namespace MyCompanyName.MyProjectName.Web.Menus; + +public class MyProjectNameMenuContributor : IMenuContributor { - public class MyProjectNameMenuContributor : IMenuContributor + private readonly IConfiguration _configuration; + + public MyProjectNameMenuContributor(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public MyProjectNameMenuContributor(IConfiguration configuration) + public async Task ConfigureMenuAsync(MenuConfigurationContext context) + { + if (context.Menu.Name == StandardMenus.Main) { - _configuration = configuration; + await ConfigureMainMenuAsync(context); } - - public async Task ConfigureMenuAsync(MenuConfigurationContext context) + else if (context.Menu.Name == StandardMenus.User) { - if (context.Menu.Name == StandardMenus.Main) - { - await ConfigureMainMenuAsync(context); - } - else if (context.Menu.Name == StandardMenus.User) - { - await ConfigureUserMenuAsync(context); - } + await ConfigureUserMenuAsync(context); } + } - private Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - var administration = context.Menu.GetAdministration(); - var l = context.GetLocalizer(); + private Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var administration = context.Menu.GetAdministration(); + var l = context.GetLocalizer(); - context.Menu.Items.Insert( - 0, - new ApplicationMenuItem( - MyProjectNameMenus.Home, - l["Menu:Home"], - "~/", - icon: "fas fa-home", - order: 0 - ) - ); - - if (MultiTenancyConsts.IsEnabled) - { - administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); - } - else - { - administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); - } - - administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); - administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3); + context.Menu.Items.Insert( + 0, + new ApplicationMenuItem( + MyProjectNameMenus.Home, + l["Menu:Home"], + "~/", + icon: "fas fa-home", + order: 0 + ) + ); - return Task.CompletedTask; + if (MultiTenancyConsts.IsEnabled) + { + administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); } - - private Task ConfigureUserMenuAsync(MenuConfigurationContext context) + else { - var l = context.GetLocalizer(); - var accountStringLocalizer = context.GetLocalizer(); - var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; + administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); + } - context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"], - $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); - context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated()); + administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); + administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3); - return Task.CompletedTask; - } + return Task.CompletedTask; + } + + private Task ConfigureUserMenuAsync(MenuConfigurationContext context) + { + var l = context.GetLocalizer(); + var accountStringLocalizer = context.GetLocalizer(); + var identityServerUrl = _configuration["AuthServer:Authority"] ?? ""; + + context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["MyAccount"], + $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage?returnUrl={_configuration["App:SelfUrl"]}", icon: "fa fa-cog", order: 1000, null, "_blank").RequireAuthenticated()); + context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "~/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000).RequireAuthenticated()); + + return Task.CompletedTask; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenus.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenus.cs index d4563554b4..1c71ea1cf3 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenus.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenus.cs @@ -1,11 +1,10 @@ -namespace MyCompanyName.MyProjectName.Web.Menus +namespace MyCompanyName.MyProjectName.Web.Menus; + +public class MyProjectNameMenus { - public class MyProjectNameMenus - { - private const string Prefix = "MyProjectName"; - public const string Home = Prefix + ".Home"; + private const string Prefix = "MyProjectName"; + public const string Home = Prefix + ".Home"; - //Add your menu items here... + //Add your menu items here... - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameToolbarContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameToolbarContributor.cs index 6769279081..0b4be1a3f7 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameToolbarContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameToolbarContributor.cs @@ -4,23 +4,22 @@ using MyCompanyName.MyProjectName.Web.Components.Toolbar.LoginLink; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.Users; -namespace MyCompanyName.MyProjectName.Web.Menus +namespace MyCompanyName.MyProjectName.Web.Menus; + +public class MyProjectNameToolbarContributor : IToolbarContributor { - public class MyProjectNameToolbarContributor : IToolbarContributor + public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) { - public virtual Task ConfigureToolbarAsync(IToolbarConfigurationContext context) + if (context.Toolbar.Name != StandardToolbars.Main) { - if (context.Toolbar.Name != StandardToolbars.Main) - { - return Task.CompletedTask; - } - - if (!context.ServiceProvider.GetRequiredService().IsAuthenticated) - { - context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent))); - } - return Task.CompletedTask; } + + if (!context.ServiceProvider.GetRequiredService().IsAuthenticated) + { + context.Toolbar.Items.Add(new ToolbarItem(typeof(LoginLinkViewComponent))); + } + + return Task.CompletedTask; } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs index f330fbf665..5263e0a4f5 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs index e728b8a6e7..eea8d4cb05 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +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. } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs index 206e47abd9..1eb7288f93 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebModule.cs @@ -42,226 +42,225 @@ using Volo.Abp.UI; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +[DependsOn( + typeof(MyProjectNameHttpApiClientModule), + typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), + typeof(AbpAspNetCoreMvcClientModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAutofacModule), + typeof(AbpCachingStackExchangeRedisModule), + typeof(AbpSettingManagementWebModule), + typeof(AbpHttpClientWebModule), + typeof(AbpHttpClientIdentityModelWebModule), + typeof(AbpIdentityWebModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) + )] +public class MyProjectNameWebModule : AbpModule { - [DependsOn( - typeof(MyProjectNameHttpApiClientModule), - typeof(AbpAspNetCoreAuthenticationOpenIdConnectModule), - typeof(AbpAspNetCoreMvcClientModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAutofacModule), - typeof(AbpCachingStackExchangeRedisModule), - typeof(AbpSettingManagementWebModule), - typeof(AbpHttpClientWebModule), - typeof(AbpHttpClientIdentityModelWebModule), - typeof(AbpIdentityWebModule), - typeof(AbpTenantManagementWebModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameWebModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(MyProjectNameResource), - typeof(MyProjectNameDomainSharedModule).Assembly, - typeof(MyProjectNameApplicationContractsModule).Assembly, - typeof(MyProjectNameWebModule).Assembly - ); - }); - } + options.AddAssemblyResource( + typeof(MyProjectNameResource), + typeof(MyProjectNameDomainSharedModule).Assembly, + typeof(MyProjectNameApplicationContractsModule).Assembly, + typeof(MyProjectNameWebModule).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(); - ConfigureBundles(); - ConfigureCache(); - ConfigureDataProtection(context, configuration, hostingEnvironment); - ConfigureUrls(configuration); - ConfigureAuthentication(context, configuration); - ConfigureAutoMapper(); - ConfigureVirtualFileSystem(hostingEnvironment); - ConfigureNavigationServices(configuration); - ConfigureMultiTenancy(); - ConfigureSwaggerServices(context.Services); - } + ConfigureBundles(); + ConfigureCache(); + ConfigureDataProtection(context, configuration, hostingEnvironment); + ConfigureUrls(configuration); + ConfigureAuthentication(context, configuration); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureNavigationServices(configuration); + ConfigureMultiTenancy(); + ConfigureSwaggerServices(context.Services); + } - private void ConfigureBundles() + private void ConfigureBundles() + { + Configure(options => { - Configure(options => - { - options.StyleBundles.Configure( - BasicThemeBundles.Styles.Global, - bundle => - { - bundle.AddFiles("/global-styles.css"); - } - ); - }); - } + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => + { + bundle.AddFiles("/global-styles.css"); + } + ); + }); + } - private void ConfigureCache() + private void ConfigureCache() + { + Configure(options => { - Configure(options => - { - options.KeyPrefix = "MyProjectName:"; - }); - } + options.KeyPrefix = "MyProjectName:"; + }); + } - private void ConfigureUrls(IConfiguration configuration) + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); + } - private void ConfigureMultiTenancy() + private void ConfigureMultiTenancy() + { + Configure(options => { - Configure(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(options => { - Configure(options => - { - options.AddMaps(); - }); - } + options.AddMaps(); + }); + } - private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + { + if (hostingEnvironment.IsDevelopment()) { - if (hostingEnvironment.IsDevelopment()) + Configure(options => { - Configure(options => - { // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(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(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(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(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(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); - options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); - }); - } - } - - private void ConfigureNavigationServices(IConfiguration configuration) - { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration)); - }); - - Configure(options => - { - options.Contributors.Add(new MyProjectNameToolbarContributor()); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); + options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); }); } + } - private void ConfigureSwaggerServices(IServiceCollection services) + private void ConfigureNavigationServices(IConfiguration configuration) + { + Configure(options => { - services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - } - ); - } + options.MenuContributors.Add(new MyProjectNameMenuContributor(configuration)); + }); - private void ConfigureDataProtection( - ServiceConfigurationContext context, - IConfiguration configuration, - IWebHostEnvironment hostingEnvironment) + Configure(options => { - var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); - if (!hostingEnvironment.IsDevelopment()) + options.Contributors.Add(new MyProjectNameToolbarContributor()); + }); + } + + private void ConfigureSwaggerServices(IServiceCollection services) + { + services.AddAbpSwaggerGen( + options => { - var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); - dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); } - } + ); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + private void ConfigureDataProtection( + ServiceConfigurationContext context, + IConfiguration configuration, + IWebHostEnvironment hostingEnvironment) + { + var dataProtectionBuilder = context.Services.AddDataProtection().SetApplicationName("MyProjectName"); + if (!hostingEnvironment.IsDevelopment()) { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); + var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]); + dataProtectionBuilder.PersistKeysToStackExchangeRedis(redis, "MyProjectName-Protection-Keys"); + } + } - if (env.IsDevelopment()) - { - app.UseDeveloperExceptionPage(); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - app.UseAbpRequestLocalization(); + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } - if (!env.IsDevelopment()) - { - app.UseErrorPage(); - } + app.UseAbpRequestLocalization(); - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); + if (!env.IsDevelopment()) + { + app.UseErrorPage(); + } - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - }); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + if (MultiTenancyConsts.IsEnabled) + { + app.UseMultiTenancy(); } + + app.UseAuthorization(); + app.UseSwagger(); + app.UseAbpSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); + }); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs index 53735ec253..b60c7db877 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/Index.cshtml.cs @@ -1,18 +1,17 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; -namespace MyCompanyName.MyProjectName.Web.Pages +namespace MyCompanyName.MyProjectName.Web.Pages; + +public class IndexModel : MyProjectNamePageModel { - public class IndexModel : MyProjectNamePageModel + public void OnGet() { - public void OnGet() - { - - } - public async Task OnPostLoginAsync() - { - await HttpContext.ChallengeAsync("oidc"); - } } -} \ No newline at end of file + + public async Task OnPostLoginAsync() + { + await HttpContext.ChallengeAsync("oidc"); + } +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs index 7ea1f42a6f..076d99e317 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Pages/MyProjectNamePageModel.cs +++ b/templates/app/aspnet-core/src/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.Web.Pages +namespace MyCompanyName.MyProjectName.Web.Pages; + +public abstract class MyProjectNamePageModel : AbpPageModel { - public abstract class MyProjectNamePageModel : AbpPageModel + protected MyProjectNamePageModel() { - protected MyProjectNamePageModel() - { - LocalizationResourceType = typeof(MyProjectNameResource); - } + LocalizationResourceType = typeof(MyProjectNameResource); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Program.cs index e6d0635c7c..fa6764a4fd 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Program.cs @@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +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(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Startup.cs index 9428c74114..8175f31cb7 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Startup.cs @@ -2,18 +2,17 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs index 07433df4c4..7a85f3ab7e 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenuContributor.cs @@ -6,45 +6,44 @@ using Volo.Abp.SettingManagement.Web.Navigation; using Volo.Abp.TenantManagement.Web.Navigation; 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 async Task ConfigureMainMenuAsync(MenuConfigurationContext context) - { - var administration = context.Menu.GetAdministration(); - var l = context.GetLocalizer(); + private async Task ConfigureMainMenuAsync(MenuConfigurationContext context) + { + var administration = context.Menu.GetAdministration(); + var l = context.GetLocalizer(); - context.Menu.Items.Insert( - 0, - new ApplicationMenuItem( - MyProjectNameMenus.Home, - l["Menu:Home"], - "~/", - icon: "fas fa-home", - order: 0 - ) - ); - - if (MultiTenancyConsts.IsEnabled) - { - administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); - } - else - { - administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); - } + context.Menu.Items.Insert( + 0, + new ApplicationMenuItem( + MyProjectNameMenus.Home, + l["Menu:Home"], + "~/", + icon: "fas fa-home", + order: 0 + ) + ); - administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); - administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3); + if (MultiTenancyConsts.IsEnabled) + { + administration.SetSubItemOrder(TenantManagementMenuNames.GroupName, 1); + } + else + { + administration.TryRemoveMenuItem(TenantManagementMenuNames.GroupName); } + + administration.SetSubItemOrder(IdentityMenuNames.GroupName, 2); + administration.SetSubItemOrder(SettingManagementMenuNames.GroupName, 3); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs index d4563554b4..1c71ea1cf3 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Menus/MyProjectNameMenus.cs +++ b/templates/app/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 - { - private const string Prefix = "MyProjectName"; - public const string Home = Prefix + ".Home"; + private const string Prefix = "MyProjectName"; + public const string Home = Prefix + ".Home"; - //Add your menu items here... + //Add your menu items here... - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs index f330fbf665..5263e0a4f5 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameBrandingProvider.cs @@ -1,11 +1,10 @@ using Volo.Abp.Ui.Branding; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +[Dependency(ReplaceServices = true)] +public class MyProjectNameBrandingProvider : DefaultBrandingProvider { - [Dependency(ReplaceServices = true)] - public class MyProjectNameBrandingProvider : DefaultBrandingProvider - { - public override string AppName => "MyProjectName"; - } + public override string AppName => "MyProjectName"; } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs index e728b8a6e7..eea8d4cb05 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebAutoMapperProfile.cs @@ -1,12 +1,11 @@ using AutoMapper; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +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. } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs index ad4567babd..b6daf2a4a8 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs @@ -38,217 +38,216 @@ using Volo.Abp.UI; using Volo.Abp.UI.Navigation; using Volo.Abp.VirtualFileSystem; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +[DependsOn( + typeof(MyProjectNameHttpApiModule), + typeof(MyProjectNameApplicationModule), + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(AbpAutofacModule), + typeof(AbpIdentityWebModule), + typeof(AbpSettingManagementWebModule), + typeof(AbpAccountWebIdentityServerModule), + typeof(AbpAspNetCoreMvcUiBasicThemeModule), + typeof(AbpAspNetCoreAuthenticationJwtBearerModule), + typeof(AbpTenantManagementWebModule), + typeof(AbpAspNetCoreSerilogModule), + typeof(AbpSwashbuckleModule) + )] +public class MyProjectNameWebModule : AbpModule { - [DependsOn( - typeof(MyProjectNameHttpApiModule), - typeof(MyProjectNameApplicationModule), - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(AbpAutofacModule), - typeof(AbpIdentityWebModule), - typeof(AbpSettingManagementWebModule), - typeof(AbpAccountWebIdentityServerModule), - typeof(AbpAspNetCoreMvcUiBasicThemeModule), - typeof(AbpAspNetCoreAuthenticationJwtBearerModule), - typeof(AbpTenantManagementWebModule), - typeof(AbpAspNetCoreSerilogModule), - typeof(AbpSwashbuckleModule) - )] - public class MyProjectNameWebModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(options => { - context.Services.PreConfigure(options => - { - options.AddAssemblyResource( - typeof(MyProjectNameResource), - typeof(MyProjectNameDomainModule).Assembly, - typeof(MyProjectNameDomainSharedModule).Assembly, - typeof(MyProjectNameApplicationModule).Assembly, - typeof(MyProjectNameApplicationContractsModule).Assembly, - typeof(MyProjectNameWebModule).Assembly - ); - }); - } - - public override void ConfigureServices(ServiceConfigurationContext context) - { - var hostingEnvironment = context.Services.GetHostingEnvironment(); - var configuration = context.Services.GetConfiguration(); - - ConfigureUrls(configuration); - ConfigureBundles(); - ConfigureAuthentication(context, configuration); - ConfigureAutoMapper(); - ConfigureVirtualFileSystem(hostingEnvironment); - ConfigureLocalizationServices(); - ConfigureNavigationServices(); - ConfigureAutoApiControllers(); - ConfigureSwaggerServices(context.Services); - } + options.AddAssemblyResource( + typeof(MyProjectNameResource), + typeof(MyProjectNameDomainModule).Assembly, + typeof(MyProjectNameDomainSharedModule).Assembly, + typeof(MyProjectNameApplicationModule).Assembly, + typeof(MyProjectNameApplicationContractsModule).Assembly, + typeof(MyProjectNameWebModule).Assembly + ); + }); + } - private void ConfigureUrls(IConfiguration configuration) - { - Configure(options => - { - options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; - }); - } + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + ConfigureUrls(configuration); + ConfigureBundles(); + ConfigureAuthentication(context, configuration); + ConfigureAutoMapper(); + ConfigureVirtualFileSystem(hostingEnvironment); + ConfigureLocalizationServices(); + ConfigureNavigationServices(); + ConfigureAutoApiControllers(); + ConfigureSwaggerServices(context.Services); + } - private void ConfigureBundles() + private void ConfigureUrls(IConfiguration configuration) + { + Configure(options => { - Configure(options => - { - options.StyleBundles.Configure( - BasicThemeBundles.Styles.Global, - bundle => - { - bundle.AddFiles("/global-styles.css"); - } - ); - }); - } + options.Applications["MVC"].RootUrl = configuration["App:SelfUrl"]; + }); + } - private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + private void ConfigureBundles() + { + Configure(options => { - context.Services.AddAuthentication() - .AddJwtBearer(options => + options.StyleBundles.Configure( + BasicThemeBundles.Styles.Global, + bundle => { - options.Authority = configuration["AuthServer:Authority"]; - options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); - options.Audience = "MyProjectName"; - }); - } + bundle.AddFiles("/global-styles.css"); + } + ); + }); + } - private void ConfigureAutoMapper() - { - Configure(options => + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + context.Services.AddAuthentication() + .AddJwtBearer(options => { - options.AddMaps(); + options.Authority = configuration["AuthServer:Authority"]; + options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]); + options.Audience = "MyProjectName"; }); - } + } - private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + private void ConfigureAutoMapper() + { + Configure(options => { - if (hostingEnvironment.IsDevelopment()) + options.AddMaps(); + }); + } + + private void ConfigureVirtualFileSystem(IWebHostEnvironment hostingEnvironment) + { + if (hostingEnvironment.IsDevelopment()) + { + Configure(options => { - Configure(options => - { // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.UI", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar))); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(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(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(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(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}framework{0}src{0}Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}feature-management{0}src{0}Volo.Abp.FeatureManagement.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(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(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}account{0}src{0}Volo.Abp.Account.Web", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}..{0}modules{0}tenant-management{0}src{0}Volo.Abp.TenantManagement.Web", Path.DirectorySeparatorChar))); // options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain.Shared")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); - options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); - options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); - }); - } - } - - private void ConfigureLocalizationServices() - { - Configure(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("hu", "hu", "Magyar")); - 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("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", "de")); - options.Languages.Add(new LanguageInfo("es", "es", "Español")); - }); - } - - private void ConfigureNavigationServices() - { - Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor()); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Domain")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application.Contracts")); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, $"..{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Application")); + options.FileSets.ReplaceEmbeddedByPhysical(hostingEnvironment.ContentRootPath); }); } + } - private void ConfigureAutoApiControllers() + private void ConfigureLocalizationServices() + { + Configure(options => { - Configure(options => - { - options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); - }); - } + 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("hu", "hu", "Magyar")); + 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("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", "de")); + options.Languages.Add(new LanguageInfo("es", "es", "Español")); + }); + } - private void ConfigureSwaggerServices(IServiceCollection services) + private void ConfigureNavigationServices() + { + Configure(options => { - services.AddAbpSwaggerGen( - options => - { - options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); - options.DocInclusionPredicate((docName, description) => true); - options.CustomSchemaIds(type => type.FullName); - } - ); - } + options.MenuContributors.Add(new MyProjectNameMenuContributor()); + }); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) + private void ConfigureAutoApiControllers() + { + Configure(options => { - var app = context.GetApplicationBuilder(); - var env = context.GetEnvironment(); + options.ConventionalControllers.Create(typeof(MyProjectNameApplicationModule).Assembly); + }); + } - if (env.IsDevelopment()) + private void ConfigureSwaggerServices(IServiceCollection services) + { + services.AddAbpSwaggerGen( + options => { - app.UseDeveloperExceptionPage(); + options.SwaggerDoc("v1", new OpenApiInfo { Title = "MyProjectName API", Version = "v1" }); + options.DocInclusionPredicate((docName, description) => true); + options.CustomSchemaIds(type => type.FullName); } + ); + } - app.UseAbpRequestLocalization(); + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); - if (!env.IsDevelopment()) - { - app.UseErrorPage(); - } + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } - app.UseCorrelationId(); - app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthentication(); - app.UseJwtTokenMiddleware(); + app.UseAbpRequestLocalization(); - if (MultiTenancyConsts.IsEnabled) - { - app.UseMultiTenancy(); - } + if (!env.IsDevelopment()) + { + app.UseErrorPage(); + } - app.UseUnitOfWork(); - app.UseIdentityServer(); - app.UseAuthorization(); - app.UseSwagger(); - app.UseAbpSwaggerUI(options => - { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "MyProjectName API"); - }); - app.UseAuditing(); - app.UseAbpSerilogEnrichers(); - app.UseConfiguredEndpoints(); + app.UseCorrelationId(); + app.UseStaticFiles(); + app.UseRouting(); + app.UseAuthentication(); + app.UseJwtTokenMiddleware(); + + 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.UseAuditing(); + app.UseAbpSerilogEnrichers(); + app.UseConfiguredEndpoints(); } } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs index 6a89e42f63..bad09e4c1c 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/Index.cshtml.cs @@ -1,10 +1,9 @@ -namespace MyCompanyName.MyProjectName.Web.Pages +namespace MyCompanyName.MyProjectName.Web.Pages; + +public class IndexModel : MyProjectNamePageModel { - public class IndexModel : MyProjectNamePageModel + public void OnGet() { - public void OnGet() - { - - } + } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs index d0b9c04a45..f294a28605 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs @@ -1,15 +1,14 @@ 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); - } + LocalizationResourceType = typeof(MyProjectNameResource); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs index e6d0635c7c..fa6764a4fd 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Program.cs @@ -5,52 +5,51 @@ using Microsoft.Extensions.Hosting; using Serilog; using Serilog.Events; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +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(); } - - internal static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup(); - }) - .UseAutofac() - .UseSerilog(); } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); } diff --git a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Startup.cs b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Startup.cs index 5bacb0f77e..4500cd8c22 100644 --- a/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Startup.cs +++ b/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web/Startup.cs @@ -1,18 +1,17 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; -namespace MyCompanyName.MyProjectName.Web +namespace MyCompanyName.MyProjectName.Web; + +public class Startup { - public class Startup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app) + { + app.InitializeApplication(); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs index ea5a2de740..89f3adcb06 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationCollection.cs @@ -1,11 +1,10 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; using Xunit; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] +public class MyProjectNameApplicationCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase { - [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] - public class MyProjectNameApplicationCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs index 8b6ef3f422..26a144d3a8 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestBase.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public abstract class MyProjectNameApplicationTestBase : MyProjectNameTestBase { - public abstract class MyProjectNameApplicationTestBase : MyProjectNameTestBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs index 10fb6b3348..95ba50122b 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/MyProjectNameApplicationTestModule.cs +++ b/templates/app/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 - { - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs index 836ee8f170..1fa30d115a 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Application.Tests/Samples/SampleAppServiceTests.cs @@ -3,32 +3,31 @@ using System.Threading.Tasks; using Volo.Abp.Identity; using Xunit; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +/* This is just an example test class. + * Normally, you don't test code of the modules you are using + * (like IIdentityUserAppService here). + * Only test your own application services. + */ +[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] +public class SampleAppServiceTests : MyProjectNameApplicationTestBase { - /* This is just an example test class. - * Normally, you don't test code of the modules you are using - * (like IIdentityUserAppService here). - * Only test your own application services. - */ - [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] - public class SampleAppServiceTests : MyProjectNameApplicationTestBase - { - private readonly IIdentityUserAppService _userAppService; + private readonly IIdentityUserAppService _userAppService; - public SampleAppServiceTests() - { - _userAppService = GetRequiredService(); - } + public SampleAppServiceTests() + { + _userAppService = GetRequiredService(); + } - [Fact] - public async Task Initial_Data_Should_Contain_Admin_User() - { - //Act - var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); + [Fact] + public async Task Initial_Data_Should_Contain_Admin_User() + { + //Act + var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); - //Assert - result.TotalCount.ShouldBeGreaterThan(0); - result.Items.ShouldContain(u => u.UserName == "admin"); - } + //Assert + result.TotalCount.ShouldBeGreaterThan(0); + result.Items.ShouldContain(u => u.UserName == "admin"); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs index 81a68dd7f8..b09e099e9a 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainCollection.cs @@ -1,11 +1,10 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; using Xunit; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] +public class MyProjectNameDomainCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase { - [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] - public class MyProjectNameDomainCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs index a7d2dd7a1d..87a426d039 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestBase.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public abstract class MyProjectNameDomainTestBase : MyProjectNameTestBase { - public abstract class MyProjectNameDomainTestBase : MyProjectNameTestBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs index 9dca6ff611..340c63cc8b 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/MyProjectNameDomainTestModule.cs @@ -1,13 +1,12 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(MyProjectNameEntityFrameworkCoreTestModule) + )] +public class MyProjectNameDomainTestModule : AbpModule { - [DependsOn( - typeof(MyProjectNameEntityFrameworkCoreTestModule) - )] - public class MyProjectNameDomainTestModule : AbpModule - { - } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs index e39a6148a6..1578cd4feb 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Domain.Tests/Samples/SampleDomainTests.cs @@ -3,44 +3,43 @@ using Shouldly; using Volo.Abp.Identity; using Xunit; -namespace MyCompanyName.MyProjectName.Samples +namespace MyCompanyName.MyProjectName.Samples; + +/* This is just an example test class. + * Normally, you don't test code of the modules you are using + * (like IdentityUserManager here). + * Only test your own domain services. + */ +[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] +public class SampleDomainTests : MyProjectNameDomainTestBase { - /* This is just an example test class. - * Normally, you don't test code of the modules you are using - * (like IdentityUserManager here). - * Only test your own domain services. - */ - [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] - public class SampleDomainTests : MyProjectNameDomainTestBase + private readonly IIdentityUserRepository _identityUserRepository; + private readonly IdentityUserManager _identityUserManager; + + public SampleDomainTests() { - private readonly IIdentityUserRepository _identityUserRepository; - private readonly IdentityUserManager _identityUserManager; + _identityUserRepository = GetRequiredService(); + _identityUserManager = GetRequiredService(); + } - public SampleDomainTests() - { - _identityUserRepository = GetRequiredService(); - _identityUserManager = GetRequiredService(); - } + [Fact] + public async Task Should_Set_Email_Of_A_User() + { + IdentityUser adminUser; - [Fact] - public async Task Should_Set_Email_Of_A_User() + /* Need to manually start Unit Of Work because + * FirstOrDefaultAsync should be executed while db connection / context is available. + */ + await WithUnitOfWorkAsync(async () => { - IdentityUser adminUser; - - /* Need to manually start Unit Of Work because - * FirstOrDefaultAsync should be executed while db connection / context is available. - */ - await WithUnitOfWorkAsync(async () => - { - adminUser = await _identityUserRepository - .FindByNormalizedUserNameAsync("ADMIN"); + adminUser = await _identityUserRepository + .FindByNormalizedUserNameAsync("ADMIN"); - await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io"); - await _identityUserRepository.UpdateAsync(adminUser); - }); + await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io"); + await _identityUserRepository.UpdateAsync(adminUser); + }); - adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN"); - adminUser.Email.ShouldBe("newemail@abp.io"); - } + adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN"); + adminUser.Email.ShouldBe("newemail@abp.io"); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs index 858709c1c9..7f6bb7d86e 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollection.cs @@ -1,10 +1,9 @@ using Xunit; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] +public class MyProjectNameEntityFrameworkCoreCollection : ICollectionFixture { - [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] - public class MyProjectNameEntityFrameworkCoreCollection : ICollectionFixture - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs index bba037d413..03da4873e6 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreCollectionFixtureBase.cs @@ -1,10 +1,9 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; using Xunit; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class MyProjectNameEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture { - public class MyProjectNameEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs index 120c141972..33d1723c99 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreFixture.cs @@ -1,12 +1,11 @@ using System; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public class MyProjectNameEntityFrameworkCoreFixture : IDisposable { - public class MyProjectNameEntityFrameworkCoreFixture : IDisposable + public void Dispose() { - public void Dispose() - { - } } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs index 7e26566457..58752e20d9 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestBase.cs @@ -1,9 +1,8 @@ using Volo.Abp; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +public abstract class MyProjectNameEntityFrameworkCoreTestBase : MyProjectNameTestBase { - public abstract class MyProjectNameEntityFrameworkCoreTestBase : MyProjectNameTestBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs index 147d01a098..d68373b4fb 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/MyProjectNameEntityFrameworkCoreTestModule.cs @@ -8,55 +8,54 @@ using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore.Sqlite; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore +namespace MyCompanyName.MyProjectName.EntityFrameworkCore; + +[DependsOn( + typeof(MyProjectNameEntityFrameworkCoreModule), + typeof(MyProjectNameTestBaseModule), + typeof(AbpEntityFrameworkCoreSqliteModule) + )] +public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule { - [DependsOn( - typeof(MyProjectNameEntityFrameworkCoreModule), - typeof(MyProjectNameTestBaseModule), - typeof(AbpEntityFrameworkCoreSqliteModule) - )] - public class MyProjectNameEntityFrameworkCoreTestModule : AbpModule + private SqliteConnection _sqliteConnection; + + public override void ConfigureServices(ServiceConfigurationContext context) { - private SqliteConnection _sqliteConnection; + ConfigureInMemorySqlite(context.Services); + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - ConfigureInMemorySqlite(context.Services); - } + private void ConfigureInMemorySqlite(IServiceCollection services) + { + _sqliteConnection = CreateDatabaseAndGetConnection(); - private void ConfigureInMemorySqlite(IServiceCollection services) + services.Configure(options => { - _sqliteConnection = CreateDatabaseAndGetConnection(); - - services.Configure(options => + options.Configure(context => { - options.Configure(context => - { - context.DbContextOptions.UseSqlite(_sqliteConnection); - }); + context.DbContextOptions.UseSqlite(_sqliteConnection); }); - } - - public override void OnApplicationShutdown(ApplicationShutdownContext context) - { - _sqliteConnection.Dispose(); - } + }); + } - private static SqliteConnection CreateDatabaseAndGetConnection() - { - var connection = new SqliteConnection("Data Source=:memory:"); - connection.Open(); + public override void OnApplicationShutdown(ApplicationShutdownContext context) + { + _sqliteConnection.Dispose(); + } - var options = new DbContextOptionsBuilder() - .UseSqlite(connection) - .Options; + private static SqliteConnection CreateDatabaseAndGetConnection() + { + var connection = new SqliteConnection("Data Source=:memory:"); + connection.Open(); - using (var context = new MyProjectNameDbContext(options)) - { - context.GetService().CreateTables(); - } + var options = new DbContextOptionsBuilder() + .UseSqlite(connection) + .Options; - return connection; + using (var context = new MyProjectNameDbContext(options)) + { + context.GetService().CreateTables(); } + + return connection; } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs index fb69be6a1e..6f68d622d4 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepositoryTests.cs @@ -7,39 +7,38 @@ using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Xunit; -namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples +namespace MyCompanyName.MyProjectName.EntityFrameworkCore.Samples; + +/* This is just an example test class. + * Normally, you don't test ABP framework code + * (like default AppUser repository IRepository here). + * Only test your custom repository methods. + */ +[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] +public class SampleRepositoryTests : MyProjectNameEntityFrameworkCoreTestBase { - /* This is just an example test class. - * Normally, you don't test ABP framework code - * (like default AppUser repository IRepository here). - * Only test your custom repository methods. - */ - [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] - public class SampleRepositoryTests : MyProjectNameEntityFrameworkCoreTestBase - { - private readonly IRepository _appUserRepository; + private readonly IRepository _appUserRepository; - public SampleRepositoryTests() - { - _appUserRepository = GetRequiredService>(); - } + public SampleRepositoryTests() + { + _appUserRepository = GetRequiredService>(); + } - [Fact] - public async Task Should_Query_AppUser() + [Fact] + public async Task Should_Query_AppUser() + { + /* Need to manually start Unit Of Work because + * FirstOrDefaultAsync should be executed while db connection / context is available. + */ + await WithUnitOfWorkAsync(async () => { - /* Need to manually start Unit Of Work because - * FirstOrDefaultAsync should be executed while db connection / context is available. - */ - await WithUnitOfWorkAsync(async () => - { //Act var adminUser = await (await _appUserRepository.GetQueryableAsync()) - .Where(u => u.UserName == "admin") - .FirstOrDefaultAsync(); + .Where(u => u.UserName == "admin") + .FirstOrDefaultAsync(); //Assert adminUser.ShouldNotBeNull(); - }); - } + }); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs index 59c2582c3d..a35d6d8098 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -3,24 +3,23 @@ using System.Threading.Tasks; using Volo.Abp.Account; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp +namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp; + +public class ClientDemoService : ITransientDependency { - public class ClientDemoService : ITransientDependency - { - private readonly IProfileAppService _profileAppService; + private readonly IProfileAppService _profileAppService; - public ClientDemoService(IProfileAppService profileAppService) - { - _profileAppService = profileAppService; - } + public ClientDemoService(IProfileAppService profileAppService) + { + _profileAppService = profileAppService; + } - public async Task RunAsync() - { - var output = await _profileAppService.GetAsync(); - Console.WriteLine($"UserName : {output.UserName}"); - Console.WriteLine($"Email : {output.Email}"); - Console.WriteLine($"Name : {output.Name}"); - Console.WriteLine($"Surname : {output.Surname}"); - } + public async Task RunAsync() + { + var output = await _profileAppService.GetAsync(); + Console.WriteLine($"UserName : {output.UserName}"); + Console.WriteLine($"Email : {output.Email}"); + Console.WriteLine($"Name : {output.Name}"); + Console.WriteLine($"Surname : {output.Surname}"); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs index 422f86abb1..53eab979d4 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs @@ -5,34 +5,33 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Volo.Abp; -namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp +namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp; + +public class ConsoleTestAppHostedService : IHostedService { - public class ConsoleTestAppHostedService : IHostedService + private readonly IConfiguration _configuration; + + public ConsoleTestAppHostedService(IConfiguration configuration) { - private readonly IConfiguration _configuration; + _configuration = configuration; + } - public ConsoleTestAppHostedService(IConfiguration configuration) + public async Task StartAsync(CancellationToken cancellationToken) + { + using (var application = AbpApplicationFactory.Create(options => { - _configuration = configuration; - } - - public async Task StartAsync(CancellationToken cancellationToken) + options.Services.ReplaceConfiguration(_configuration); + options.UseAutofac(); + })) { - using (var application = AbpApplicationFactory.Create(options => - { - options.Services.ReplaceConfiguration(_configuration); - options.UseAutofac(); - })) - { - application.Initialize(); + application.Initialize(); - var demo = application.ServiceProvider.GetRequiredService(); - await demo.RunAsync(); + var demo = application.ServiceProvider.GetRequiredService(); + await demo.RunAsync(); - application.Shutdown(); - } + application.Shutdown(); } - - public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } + + public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs index 0370c686d3..84f58f0759 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/MyProjectNameConsoleApiClientModule.cs @@ -6,26 +6,25 @@ using Volo.Abp.Http.Client; using Volo.Abp.Http.Client.IdentityModel; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp +namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(MyProjectNameHttpApiClientModule), + typeof(AbpHttpClientIdentityModelModule) + )] +public class MyProjectNameConsoleApiClientModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(MyProjectNameHttpApiClientModule), - typeof(AbpHttpClientIdentityModelModule) - )] - public class MyProjectNameConsoleApiClientModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(options => { - PreConfigure(options => + options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => { - options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) => - { - clientBuilder.AddTransientHttpErrorPolicy( - policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) - ); - }); + clientBuilder.AddTransientHttpErrorPolicy( + policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i))) + ); }); - } + }); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs index 2055438bc5..e49e1beec8 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp/Program.cs @@ -3,21 +3,20 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; -namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp +namespace MyCompanyName.MyProjectName.HttpApi.Client.ConsoleTestApp; + +class Program { - class Program + static async Task Main(string[] args) { - static async Task Main(string[] args) - { - await CreateHostBuilder(args).RunConsoleAsync(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .AddAppSettingsSecretsJson() - .ConfigureServices((hostContext, services) => - { - services.AddHostedService(); - }); + await CreateHostBuilder(args).RunConsoleAsync(); } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureServices((hostContext, services) => + { + services.AddHostedService(); + }); } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs index 52160c0e3c..ab0d818132 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoCollection.cs @@ -1,10 +1,9 @@ using Xunit; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] +public class MyProjectNameMongoCollection : MyProjectNameMongoDbCollectionFixtureBase { - [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] - public class MyProjectNameMongoCollection : MyProjectNameMongoDbCollectionFixtureBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs index 05c514a677..34a62f7009 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbCollectionFixtureBase.cs @@ -1,10 +1,9 @@ using MyCompanyName.MyProjectName.MongoDB; using Xunit; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +public class MyProjectNameMongoDbCollectionFixtureBase : ICollectionFixture { - public class MyProjectNameMongoDbCollectionFixtureBase : ICollectionFixture - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs index 3ce3120ddd..bd3278ed14 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbFixture.cs @@ -1,22 +1,21 @@ using System; using Mongo2Go; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +public class MyProjectNameMongoDbFixture : IDisposable { - public class MyProjectNameMongoDbFixture : IDisposable - { - private static readonly MongoDbRunner MongoDbRunner; - public static readonly string ConnectionString; + private static readonly MongoDbRunner MongoDbRunner; + public static readonly string ConnectionString; - static MyProjectNameMongoDbFixture() - { - MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); - ConnectionString = MongoDbRunner.ConnectionString; - } + static MyProjectNameMongoDbFixture() + { + MongoDbRunner = MongoDbRunner.Start(singleNodeReplSet: true, singleNodeReplSetWaitTimeout: 20); + ConnectionString = MongoDbRunner.ConnectionString; + } - public void Dispose() - { - MongoDbRunner?.Dispose(); - } + public void Dispose() + { + MongoDbRunner?.Dispose(); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestBase.cs index c7fc5f9eea..8a23184eec 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestBase.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +public abstract class MyProjectNameMongoDbTestBase : MyProjectNameTestBase { - public abstract class MyProjectNameMongoDbTestBase : MyProjectNameTestBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs index f2a0a5d2fe..bc60373794 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/MyProjectNameMongoDbTestModule.cs @@ -2,25 +2,24 @@ using Volo.Abp.Data; using Volo.Abp.Modularity; -namespace MyCompanyName.MyProjectName.MongoDB +namespace MyCompanyName.MyProjectName.MongoDB; + +[DependsOn( + typeof(MyProjectNameTestBaseModule), + typeof(MyProjectNameMongoDbModule) + )] +public class MyProjectNameMongoDbTestModule : AbpModule { - [DependsOn( - typeof(MyProjectNameTestBaseModule), - typeof(MyProjectNameMongoDbModule) - )] - public class MyProjectNameMongoDbTestModule : AbpModule + public override void ConfigureServices(ServiceConfigurationContext context) { - public override void ConfigureServices(ServiceConfigurationContext context) - { - var stringArray = MyProjectNameMongoDbFixture.ConnectionString.Split('?'); - var connectionString = stringArray[0].EnsureEndsWith('/') + - "Db_" + - Guid.NewGuid().ToString("N") + "/?" + stringArray[1]; + var stringArray = MyProjectNameMongoDbFixture.ConnectionString.Split('?'); + var connectionString = stringArray[0].EnsureEndsWith('/') + + "Db_" + + Guid.NewGuid().ToString("N") + "/?" + stringArray[1]; - Configure(options => - { - options.ConnectionStrings.Default = connectionString; - }); - } + Configure(options => + { + options.ConnectionStrings.Default = connectionString; + }); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs index 7d3f8ebc47..9f51c616ec 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.MongoDB.Tests/MongoDb/Samples/SampleRepositoryTests.cs @@ -6,38 +6,37 @@ using Volo.Abp.Domain.Repositories; using Volo.Abp.Identity; using Xunit; -namespace MyCompanyName.MyProjectName.MongoDB.Samples +namespace MyCompanyName.MyProjectName.MongoDB.Samples; + +/* This is just an example test class. + * Normally, you don't test ABP framework code + * (like default AppUser repository IRepository here). + * Only test your custom repository methods. + */ +[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] +public class SampleRepositoryTests : MyProjectNameMongoDbTestBase { - /* This is just an example test class. - * Normally, you don't test ABP framework code - * (like default AppUser repository IRepository here). - * Only test your custom repository methods. - */ - [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] - public class SampleRepositoryTests : MyProjectNameMongoDbTestBase - { - private readonly IRepository _appUserRepository; + private readonly IRepository _appUserRepository; - public SampleRepositoryTests() - { - _appUserRepository = GetRequiredService>(); - } + public SampleRepositoryTests() + { + _appUserRepository = GetRequiredService>(); + } - [Fact] - public async Task Should_Query_AppUser() + [Fact] + public async Task Should_Query_AppUser() + { + /* Need to manually start Unit Of Work because + * FirstOrDefaultAsync should be executed while db connection / context is available. + */ + await WithUnitOfWorkAsync(async () => { - /* Need to manually start Unit Of Work because - * FirstOrDefaultAsync should be executed while db connection / context is available. - */ - await WithUnitOfWorkAsync(async () => - { //Act var adminUser = await (await _appUserRepository.GetMongoQueryableAsync()) - .FirstOrDefaultAsync(u => u.UserName == "admin"); + .FirstOrDefaultAsync(u => u.UserName == "admin"); //Assert adminUser.ShouldNotBeNull(); - }); - } + }); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs index 34bb6c01c2..5289a4bee2 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBase.cs @@ -6,55 +6,54 @@ using Volo.Abp.Modularity; using Volo.Abp.Uow; using Volo.Abp.Testing; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/* All test classes are derived from this class, directly or indirectly. + */ +public abstract class MyProjectNameTestBase : AbpIntegratedTest + where TStartupModule : IAbpModule { - /* All test classes are derived from this class, directly or indirectly. - */ - public abstract class MyProjectNameTestBase : AbpIntegratedTest - where TStartupModule : IAbpModule + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) { - protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) - { - options.UseAutofac(); - } + options.UseAutofac(); + } - protected virtual Task WithUnitOfWorkAsync(Func func) - { - return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); - } + protected virtual Task WithUnitOfWorkAsync(Func func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } - protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + { + using (var scope = ServiceProvider.CreateScope()) { - using (var scope = ServiceProvider.CreateScope()) - { - var uowManager = scope.ServiceProvider.GetRequiredService(); + var uowManager = scope.ServiceProvider.GetRequiredService(); - using (var uow = uowManager.Begin(options)) - { - await action(); + using (var uow = uowManager.Begin(options)) + { + await action(); - await uow.CompleteAsync(); - } + await uow.CompleteAsync(); } } + } - protected virtual Task WithUnitOfWorkAsync(Func> func) - { - return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); - } + protected virtual Task WithUnitOfWorkAsync(Func> func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } - protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + { + using (var scope = ServiceProvider.CreateScope()) { - using (var scope = ServiceProvider.CreateScope()) + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) { - var uowManager = scope.ServiceProvider.GetRequiredService(); - - using (var uow = uowManager.Begin(options)) - { - var result = await func(); - await uow.CompleteAsync(); - return result; - } + var result = await func(); + await uow.CompleteAsync(); + return result; } } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs index 1dfc546ad6..fdd6bad274 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestBaseModule.cs @@ -8,55 +8,54 @@ using Volo.Abp.IdentityServer; using Volo.Abp.Modularity; using Volo.Abp.Threading; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(MyProjectNameDomainModule) + )] +public class MyProjectNameTestBaseModule : AbpModule { - [DependsOn( - typeof(AbpAutofacModule), - typeof(AbpTestBaseModule), - typeof(AbpAuthorizationModule), - typeof(MyProjectNameDomainModule) - )] - public class MyProjectNameTestBaseModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + PreConfigure(options => { - PreConfigure(options => - { - options.AddDeveloperSigningCredential = false; - }); + options.AddDeveloperSigningCredential = false; + }); - PreConfigure(identityServerBuilder => - { - identityServerBuilder.AddDeveloperSigningCredential(false, System.Guid.NewGuid().ToString()); - }); - } + PreConfigure(identityServerBuilder => + { + identityServerBuilder.AddDeveloperSigningCredential(false, System.Guid.NewGuid().ToString()); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => { - Configure(options => - { - options.IsJobExecutionEnabled = false; - }); + options.IsJobExecutionEnabled = false; + }); - context.Services.AddAlwaysAllowAuthorization(); - } + context.Services.AddAlwaysAllowAuthorization(); + } - public override void OnApplicationInitialization(ApplicationInitializationContext context) - { - SeedTestData(context); - } + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } - private static void SeedTestData(ApplicationInitializationContext context) + private static void SeedTestData(ApplicationInitializationContext context) + { + AsyncHelper.RunSync(async () => { - AsyncHelper.RunSync(async () => + using (var scope = context.ServiceProvider.CreateScope()) { - using (var scope = context.ServiceProvider.CreateScope()) - { - await scope.ServiceProvider - .GetRequiredService() - .SeedAsync(); - } - }); - } + await scope.ServiceProvider + .GetRequiredService() + .SeedAsync(); + } + }); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs index 342185c841..39dfc008c4 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestConsts.cs @@ -1,7 +1,6 @@ -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public static class MyProjectNameTestConsts { - public static class MyProjectNameTestConsts - { - public const string CollectionDefinitionName = "MyProjectName collection"; - } + public const string CollectionDefinitionName = "MyProjectName collection"; } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestDataSeedContributor.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestDataSeedContributor.cs index 64f90c71a8..a5b30ea176 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestDataSeedContributor.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/MyProjectNameTestDataSeedContributor.cs @@ -2,15 +2,14 @@ using Volo.Abp.Data; using Volo.Abp.DependencyInjection; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameTestDataSeedContributor : IDataSeedContributor, ITransientDependency { - public class MyProjectNameTestDataSeedContributor : IDataSeedContributor, ITransientDependency + public Task SeedAsync(DataSeedContext context) { - public Task SeedAsync(DataSeedContext context) - { - /* Seed additional test data... */ + /* Seed additional test data... */ - return Task.CompletedTask; - } + return Task.CompletedTask; } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs index 5e6b064875..717ba2c324 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -3,41 +3,40 @@ using System.Security.Claims; using Volo.Abp.DependencyInjection; using Volo.Abp.Security.Claims; -namespace MyCompanyName.MyProjectName.Security +namespace MyCompanyName.MyProjectName.Security; + +[Dependency(ReplaceServices = true)] +public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor { - [Dependency(ReplaceServices = true)] - public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor + protected override ClaimsPrincipal GetClaimsPrincipal() { - protected override ClaimsPrincipal GetClaimsPrincipal() - { - return GetPrincipal(); - } + return GetPrincipal(); + } - private ClaimsPrincipal _principal; + private ClaimsPrincipal _principal; - private ClaimsPrincipal GetPrincipal() + private ClaimsPrincipal GetPrincipal() + { + if (_principal == null) { - if (_principal == null) + lock (this) { - lock (this) + if (_principal == null) { - if (_principal == null) - { - _principal = new ClaimsPrincipal( - new ClaimsIdentity( - new List - { + _principal = new ClaimsPrincipal( + new ClaimsIdentity( + new List + { new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), new Claim(AbpClaimTypes.UserName,"admin"), new Claim(AbpClaimTypes.Email,"admin@abp.io") - } - ) - ); - } + } + ) + ); } } - - return _principal; } + + return _principal; } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs index 453be8f7fc..36ff0836c2 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebCollection.cs @@ -1,11 +1,10 @@ using MyCompanyName.MyProjectName.EntityFrameworkCore; using Xunit; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] +public class MyProjectNameWebCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase { - [CollectionDefinition(MyProjectNameTestConsts.CollectionDefinitionName)] - public class MyProjectNameWebCollection : MyProjectNameEntityFrameworkCoreCollectionFixtureBase - { - } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestBase.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestBase.cs index 7c3f6330c8..ae94b2fe6d 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestBase.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestBase.cs @@ -6,34 +6,33 @@ using Microsoft.Extensions.Hosting; using Shouldly; using Volo.Abp.AspNetCore.TestBase; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public abstract class MyProjectNameWebTestBase : AbpAspNetCoreIntegratedTestBase { - public abstract class MyProjectNameWebTestBase : AbpAspNetCoreIntegratedTestBase + protected override IHostBuilder CreateHostBuilder() { - protected override IHostBuilder CreateHostBuilder() - { - return base - .CreateHostBuilder() - .UseContentRoot(WebContentDirectoryFinder.CalculateContentRootFolder()); - } + return base + .CreateHostBuilder() + .UseContentRoot(WebContentDirectoryFinder.CalculateContentRootFolder()); + } - protected virtual async Task GetResponseAsObjectAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK) - { - var strResponse = await GetResponseAsStringAsync(url, expectedStatusCode); - return JsonSerializer.Deserialize(strResponse, new JsonSerializerOptions(JsonSerializerDefaults.Web)); - } + protected virtual async Task GetResponseAsObjectAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK) + { + var strResponse = await GetResponseAsStringAsync(url, expectedStatusCode); + return JsonSerializer.Deserialize(strResponse, new JsonSerializerOptions(JsonSerializerDefaults.Web)); + } - protected virtual async Task GetResponseAsStringAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK) - { - var response = await GetResponseAsync(url, expectedStatusCode); - return await response.Content.ReadAsStringAsync(); - } + protected virtual async Task GetResponseAsStringAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK) + { + var response = await GetResponseAsync(url, expectedStatusCode); + return await response.Content.ReadAsStringAsync(); + } - protected virtual async Task GetResponseAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK) - { - var response = await Client.GetAsync(url); - response.StatusCode.ShouldBe(expectedStatusCode); - return response; - } + protected virtual async Task GetResponseAsync(string url, HttpStatusCode expectedStatusCode = HttpStatusCode.OK) + { + var response = await Client.GetAsync(url); + response.StatusCode.ShouldBe(expectedStatusCode); + return response; } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs index 8f7b9e2daa..ef8c3a4deb 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestModule.cs @@ -14,56 +14,55 @@ using Volo.Abp.Modularity; using Volo.Abp.UI.Navigation; using Volo.Abp.Validation.Localization; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +[DependsOn( + typeof(AbpAspNetCoreTestBaseModule), + typeof(MyProjectNameWebModule), + typeof(MyProjectNameApplicationTestModule) +)] +public class MyProjectNameWebTestModule : AbpModule { - [DependsOn( - typeof(AbpAspNetCoreTestBaseModule), - typeof(MyProjectNameWebModule), - typeof(MyProjectNameApplicationTestModule) - )] - public class MyProjectNameWebTestModule : AbpModule + public override void PreConfigureServices(ServiceConfigurationContext context) { - public override void PreConfigureServices(ServiceConfigurationContext context) + context.Services.PreConfigure(builder => { - context.Services.PreConfigure(builder => - { - builder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(MyProjectNameWebModule).Assembly)); - }); - } + builder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(MyProjectNameWebModule).Assembly)); + }); + } - public override void ConfigureServices(ServiceConfigurationContext context) - { - ConfigureLocalizationServices(context.Services); - ConfigureNavigationServices(context.Services); - } + public override void ConfigureServices(ServiceConfigurationContext context) + { + ConfigureLocalizationServices(context.Services); + ConfigureNavigationServices(context.Services); + } - private static void ConfigureLocalizationServices(IServiceCollection services) + private static void ConfigureLocalizationServices(IServiceCollection services) + { + var cultures = new List { new CultureInfo("en"), new CultureInfo("tr") }; + services.Configure(options => { - var cultures = new List { new CultureInfo("en"), new CultureInfo("tr") }; - services.Configure(options => - { - options.DefaultRequestCulture = new RequestCulture("en"); - options.SupportedCultures = cultures; - options.SupportedUICultures = cultures; - }); + options.DefaultRequestCulture = new RequestCulture("en"); + options.SupportedCultures = cultures; + options.SupportedUICultures = cultures; + }); - services.Configure(options => - { - options.Resources - .Get() - .AddBaseTypes( - typeof(AbpValidationResource), - typeof(AbpUiResource) - ); - }); - } + services.Configure(options => + { + options.Resources + .Get() + .AddBaseTypes( + typeof(AbpValidationResource), + typeof(AbpUiResource) + ); + }); + } - private static void ConfigureNavigationServices(IServiceCollection services) + private static void ConfigureNavigationServices(IServiceCollection services) + { + services.Configure(options => { - services.Configure(options => - { - options.MenuContributors.Add(new MyProjectNameMenuContributor()); - }); - } + options.MenuContributors.Add(new MyProjectNameMenuContributor()); + }); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestStartup.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestStartup.cs index eefa272f9e..1851f73c9f 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestStartup.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/MyProjectNameWebTestStartup.cs @@ -4,18 +4,17 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Volo.Abp; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +public class MyProjectNameWebTestStartup { - public class MyProjectNameWebTestStartup + public void ConfigureServices(IServiceCollection services) { - public void ConfigureServices(IServiceCollection services) - { - services.AddApplication(); - } + services.AddApplication(); + } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) - { - app.InitializeApplication(); - } + public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); } -} \ No newline at end of file +} diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs index 6d59438b47..9958e8a71a 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/Pages/Index_Tests.cs @@ -2,16 +2,15 @@ using Shouldly; using Xunit; -namespace MyCompanyName.MyProjectName.Pages +namespace MyCompanyName.MyProjectName.Pages; + +[Collection(MyProjectNameTestConsts.CollectionDefinitionName)] +public class Index_Tests : MyProjectNameWebTestBase { - [Collection(MyProjectNameTestConsts.CollectionDefinitionName)] - public class Index_Tests : MyProjectNameWebTestBase + [Fact] + public async Task Welcome_Page() { - [Fact] - public async Task Welcome_Page() - { - var response = await GetResponseAsStringAsync("/"); - response.ShouldNotBeNull(); - } + var response = await GetResponseAsStringAsync("/"); + response.ShouldNotBeNull(); } } diff --git a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/WebContentDirectoryFinder.cs b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/WebContentDirectoryFinder.cs index d3796af4d4..4c8c4bfd0c 100644 --- a/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/WebContentDirectoryFinder.cs +++ b/templates/app/aspnet-core/test/MyCompanyName.MyProjectName.Web.Tests/WebContentDirectoryFinder.cs @@ -2,59 +2,58 @@ using System.IO; using System.Linq; -namespace MyCompanyName.MyProjectName +namespace MyCompanyName.MyProjectName; + +/// +/// This class is used to find root path of the web project. Used for; +/// 1. unit tests (to find views). +/// 2. entity framework core command line commands (to find the conn string). +/// +public static class WebContentDirectoryFinder { - /// - /// This class is used to find root path of the web project. Used for; - /// 1. unit tests (to find views). - /// 2. entity framework core command line commands (to find the conn string). - /// - public static class WebContentDirectoryFinder + public static string CalculateContentRootFolder() { - public static string CalculateContentRootFolder() + var domainAssemblyDirectoryPath = + Path.GetDirectoryName(typeof(MyProjectNameDomainModule).Assembly.Location); + if (domainAssemblyDirectoryPath == null) { - var domainAssemblyDirectoryPath = - Path.GetDirectoryName(typeof(MyProjectNameDomainModule).Assembly.Location); - if (domainAssemblyDirectoryPath == null) - { - throw new Exception( - $"Could not find location of {typeof(MyProjectNameDomainModule).Assembly.FullName} assembly!"); - } - - var directoryInfo = new DirectoryInfo(domainAssemblyDirectoryPath); - - if (Environment.GetEnvironmentVariable("NCrunch") == "1") - { - while (!DirectoryContains(directoryInfo.FullName, "MyCompanyName.MyProjectName.Web.csproj", SearchOption.AllDirectories)) - { - directoryInfo = directoryInfo.Parent ?? throw new Exception("Could not find content root folder!"); - } - - var webProject = Directory.GetFiles(directoryInfo.FullName, string.Empty, SearchOption.AllDirectories) - .First(filePath => string.Equals(Path.GetFileName(filePath), "MyCompanyName.MyProjectName.Web.csproj")); + throw new Exception( + $"Could not find location of {typeof(MyProjectNameDomainModule).Assembly.FullName} assembly!"); + } - return Path.GetDirectoryName(webProject); - } + var directoryInfo = new DirectoryInfo(domainAssemblyDirectoryPath); - while (!DirectoryContains(directoryInfo.FullName, "MyCompanyName.MyProjectName.sln")) + if (Environment.GetEnvironmentVariable("NCrunch") == "1") + { + while (!DirectoryContains(directoryInfo.FullName, "MyCompanyName.MyProjectName.Web.csproj", SearchOption.AllDirectories)) { directoryInfo = directoryInfo.Parent ?? throw new Exception("Could not find content root folder!"); } - var webFolder = Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Web"); - if (Directory.Exists(webFolder)) - { - return webFolder; - } + var webProject = Directory.GetFiles(directoryInfo.FullName, string.Empty, SearchOption.AllDirectories) + .First(filePath => string.Equals(Path.GetFileName(filePath), "MyCompanyName.MyProjectName.Web.csproj")); - throw new Exception("Could not find root folder of the web project!"); + return Path.GetDirectoryName(webProject); + } + + while (!DirectoryContains(directoryInfo.FullName, "MyCompanyName.MyProjectName.sln")) + { + directoryInfo = directoryInfo.Parent ?? throw new Exception("Could not find content root folder!"); } - private static bool DirectoryContains(string directory, string fileName, - SearchOption searchOption = SearchOption.TopDirectoryOnly) + var webFolder = Path.Combine(directoryInfo.FullName, $"src{Path.DirectorySeparatorChar}MyCompanyName.MyProjectName.Web"); + if (Directory.Exists(webFolder)) { - return Directory.GetFiles(directory, string.Empty, searchOption) - .Any(filePath => string.Equals(Path.GetFileName(filePath), fileName)); + return webFolder; } + + throw new Exception("Could not find root folder of the web project!"); + } + + private static bool DirectoryContains(string directory, string fileName, + SearchOption searchOption = SearchOption.TopDirectoryOnly) + { + return Directory.GetFiles(directory, string.Empty, searchOption) + .Any(filePath => string.Equals(Path.GetFileName(filePath), fileName)); } }