Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into feat/table

pull/2605/head
mehmet-erim 7 years ago
parent
commit
95e5018a15
  1. 26
      docs/en/Connection-Strings.md
  2. 18
      docs/en/Dependency-Injection.md
  3. 90
      docs/en/Entity-Framework-Core-Other-DBMS.md
  4. 10
      docs/en/Entity-Framework-Core-PostgreSQL.md
  5. 2
      docs/en/Entity-Framework-Core.md
  6. 12
      docs/en/Modules/Docs.md
  7. 116
      docs/en/Options.md
  8. 3
      docs/en/Virtual-File-System.md
  9. 8
      docs/en/docs-nav.json
  10. 3
      docs/zh-Hans/Virtual-File-System.md
  11. 21
      framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs
  12. 53
      framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacServiceProvider.cs
  13. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/DeveloperApiKeyResult.cs
  14. 5
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveFolderStep.cs
  15. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Module/ModuleTemplateBase.cs
  16. 10
      framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithExternalServiceProvider.cs
  17. 144
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
  18. 12
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/AbpEntityTypeBuilderExtensions.cs
  19. 18
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueComparers/AbpDictionaryValueComparer.cs
  20. 15
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueConverters/AbpJsonValueConverter.cs
  21. 6
      framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs
  22. 1
      framework/src/Volo.Abp.Http.Client/Volo.Abp.Http.Client.csproj
  23. 4
      framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs
  24. 32
      framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs
  25. 15
      framework/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs
  26. 2
      framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PersonDto.cs
  27. 4
      modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/Settings/AccountSettingDefinitionProvider.cs
  28. 5
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml
  29. 3
      modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs
  30. 4
      modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs
  31. 4
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs
  32. 4
      modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json
  33. 15
      modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs
  34. 12
      npm/ng-packs/packages/account/src/lib/components/auth-wrapper/auth-wrapper.component.html
  35. 6
      npm/ng-packs/packages/account/src/lib/components/auth-wrapper/auth-wrapper.component.ts
  36. 9
      templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs
  37. 1
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj
  38. 2
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyProjectNameIdentityServerModule.cs
  39. 9
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/Controllers/AccountController.cs
  40. 60
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostMenuContributor.cs
  41. 12
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Host/MyProjectNameWebHostModule.cs
  42. 1
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj
  43. 2
      templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyProjectNameWebUnifiedModule.cs
  44. 1
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameAppService.cs
  45. 4
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Application/MyProjectNameApplicationModule.cs
  46. 2
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectName/en.json
  47. 6
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectName/tr.json
  48. 1
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/MyProjectNameWebModule.cs
  49. 9
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectName/Index.cshtml.cs
  50. 1
      templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Web/Pages/MyProjectNamePageModel.cs

26
docs/en/Connection-Strings.md

@ -35,6 +35,21 @@ This configuration defines three different connection strings:
[Pre-built application modules](Modules/Index.md) define constants for the connection string names. For example, the IdentityServer module defines a ` ConnectionStringName ` constant in the ` AbpIdentityServerDbProperties ` class (located in the ` Volo.Abp.IdentityServer ` namespace). Other modules similarly define constants, so you can investigate the connection string name.
### AbpDbConnectionOptions
ABP actually uses the `AbpDbConnectionOptions` to get the connection strings. If you set the connection strings as explained above, `AbpDbConnectionOptions` is automatically filled. However, you can set or override the connection strings using [the options pattern](Options.md). You can configure the `AbpDbConnectionOptions` in the `ConfigureServices` method of your [module](Module-Development-Basics.md) as shown below:
````csharp
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpDbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = "...";
options.ConnectionStrings["AbpPermissionManagement"] = "...";
});
}
````
## Set the Connection String Name
A module typically has a unique connection string name associated to its `DbContext` class using the `ConnectionStringName` attribute. Example:
@ -61,4 +76,13 @@ Once you want to separate a module's database, you typically will need to create
## Multi-Tenancy
See [the multi-tenancy document](Multi-Tenancy.md) to learn how to use separate databases for tenants.
See [the multi-tenancy document](Multi-Tenancy.md) to learn how to use separate databases for tenants.
## Replace the Connection String Resolver
ABP defines the `IConnectionStringResolver` and uses it whenever it needs a connection string. It has two pre-built implementations:
* `DefaultConnectionStringResolver` uses the `AbpDbConnectionOptions` to select the connection string based on the rules defined in the "Configure the Connection Strings" section above.
* `MultiTenantConnectionStringResolver` used for multi-tenant applications and tries to get the configured connection string for the current tenant if available. It uses the `ITenantStore` to find the connection strings. It inherits from the `DefaultConnectionStringResolver` and fallbacks to the base logic if no connection string specified for the current tenant.
If you need a custom logic to determine the connection string, implement the `IConnectionStringResolver` interface (optionally derive from the existing implementations) and replace the existing implementation using the [dependency injection](Dependency-Injection.md) system.

18
docs/en/Dependency-Injection.md

@ -166,6 +166,24 @@ public class BlogModule : AbpModule
}
````
### Replace a Service
If you need to replace an existing service (defined by the ABP framework or another module dependency), you have two options;
1. Use the `Dependency` attribute of the ABP framework as explained above.
2. Use the `IServiceCollection.Replace` method of the Microsoft Dependency Injection library. Example:
````csharp
public class MyModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
//Replacing the IConnectionStringResolver service
context.Services.Replace(ServiceDescriptor.Transient<IConnectionStringResolver, MyConnectionStringResolver>());
}
}
````
## Injecting Dependencies
There are three common ways of using a service that has already been registered.

90
docs/en/Entity-Framework-Core-Other-DBMS.md

@ -0,0 +1,90 @@
# Switch to another DBMS for Entity Framework Core
**[The application startup template](Startup-Templates/Application.md)** comes with SQL Server provider pre-configured for the Entity Framework Core. Entity Framework Core supports [many other DBMSs](https://docs.microsoft.com/en-us/ef/core/providers/) and you can use any of them with your ABP based applications.
ABP framework provides integration packages for some common DBMSs to make the configuration a bit easier (see the [entity framework core document](Entity-Framework-Core.md) for a list of available integration packages). However, you can configure your DBMS provider without these integration packages.
While using the integration package is always recommended (it also makes standard for the depended version across different modules), you can do it manually if there is no integration package for your DBMS provider.
This document explains how to switch to MySQL without using [the MySQL integration package](Entity-Framework-Core-MySQL.md).
## Replace the SQL Server Dependency
* Remove the [Volo.Abp.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.SqlServer) NuGet package dependency from the `.EntityFrameworkCore` project.
* Add the [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/) NuGet package dependency to your `.EntityFrameworkCore` project.
## Remove the Module Dependency
Remove the `AbpEntityFrameworkCoreSqlServerModule` from the dependency list of your ***YourProjectName*EntityFrameworkCoreModule** class.
## Change the UseSqlServer() Calls
Find the following code part inside the *YourProjectName*EntityFrameworkCoreModule class:
````csharp
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
````
Replace it with the following code part:
````csharp
Configure<AbpDbContextOptions>(options =>
{
options.Configure(ctx =>
{
if (ctx.ExistingConnection != null)
{
ctx.DbContextOptions.UseMySql(ctx.ExistingConnection);
}
else
{
ctx.DbContextOptions.UseMySql(ctx.ConnectionString);
}
});
});
````
* `UseMySql` calls in this code is defined by the Pomelo.EntityFrameworkCore.MySql package and you can use its additional options if you need.
* This code first checks if there is an existing (active) connection to the same database in the current request and reuses it if possible. This allows to share a single transaction among different DbContext types. ABP handles the rest of the things.
* It uses `ctx.ConnectionString` and passes to the `UseMySql` if there is no active connection (which will cause to create a new database connection). Using the `ctx.ConnectionString` is important here. Don't pass a static connection string (or a connection string from a configuration). Because ABP [dynamically determines the correct connection string](Connection-Strings.md) in a multi-database or [multi-tenant](Multi-Tenancy.md) environment.
## Change the Connection Strings
MySQL connection strings are different than SQL Server connection strings. So, check all `appsettings.json` files in your solution and replace the connection strings inside them. See the [connectionstrings.com]( https://www.connectionstrings.com/mysql/ ) for details of MySQL connection string options.
You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure.
## Change the Migrations DbContext
MySQL DBMS has some slight differences than the SQL Server. Some module database mapping configuration (especially the field lengths) causes problems with MySQL. For example, some of the the [IdentityServer module](Modules/IdentityServer.md) tables has such problems and it provides an option to configure the fields based on your DBMS.
The startup template contains a *YourProjectName*MigrationsDbContext which is responsible to maintain and migrate the database schema. This DbContext basically calls extension methods of the depended modules to configure their database tables.
Open the *YourProjectName*MigrationsDbContext and change the `builder.ConfigureIdentityServer();` line as shown below:
````csharp
builder.ConfigureIdentityServer(options =>
{
options.DatabaseProvider = EfCoreDatabaseProvider.MySql;
});
````
Then `ConfigureIdentityServer()` method will set the field lengths to not exceed the MySQL limits. Refer to related module documentation if you have any problem while creating or executing the database migrations.
## Re-Generate the Migrations
The startup template uses [Entity Framework Core's Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/). EF Core Migrations depend on the selected DBMS provider. So, changing the DBMS provider will cause the migration fails.
* Delete the Migrations folder under the `.EntityFrameworkCore.DbMigrations` project and re-build the solution.
* Run `Add-Migration "Initial"` on the Package Manager Console (select the `.DbMigrator` (or `.Web`) project as the startup project in the Solution Explorer and select the `.EntityFrameworkCore.DbMigrations` project as the default project in the Package Manager Console).
This will create a database migration with all database objects (tables) configured.
Run the `.DbMigrator` project to create the database and seed the initial data.
## Run the Application
It is ready. Just run the application and enjoy coding.

10
docs/en/Entity-Framework-Core-PostgreSQL.md

@ -12,12 +12,12 @@ Find ***YourProjectName*EntityFrameworkCoreModule** class inside the `.EntityFra
## UsePostgreSql()
Find `UseSqlServer()` calls in your solution, replace with `UsePostgreSql()`. Check the following files:
Find `UseSqlServer()` call in *YourProjectName*EntityFrameworkCoreModule.cs inside the `.EntityFrameworkCore` project and replace with `UsePostgreSql()`.
* *YourProjectName*EntityFrameworkCoreModule.cs inside the `.EntityFrameworkCore` project.
* *YourProjectName*MigrationsDbContextFactory.cs inside the `.EntityFrameworkCore.DbMigrations` project.
> Depending on your solution structure, you may find more code files need to be changed.
Find `UseSqlServer()` call in *YourProjectName*MigrationsDbContextFactory.cs inside the `.EntityFrameworkCore.DbMigrations` project and replace with `UseNpgsql()`.
> Depending on your solution structure, you may find more `UseSqlServer()` calls that needs to be changed.
## Change the Connection Strings
@ -38,4 +38,4 @@ Run the `.DbMigrator` project to create the database and seed the initial data.
## Run the Application
It is ready. Just run the application and enjoy coding.
It is ready. Just run the application and enjoy coding.

2
docs/en/Entity-Framework-Core.md

@ -38,6 +38,8 @@ ABP framework provides integration packages for some common DBMSs to make the co
* [MySQL](Entity-Framework-Core-MySQL.md)
* [PostgreSQL](Entity-Framework-Core-PostgreSQL.md)
* [SQLite](Entity-Framework-Core-SQLite.md)
* [Others](Entity-Framework-Core-Other-DBMS.md)
## Creating DbContext

12
docs/en/Modules/Docs.md

@ -316,7 +316,7 @@ You can use [ABP Framework](https://github.com/abpframework/abp/) GitHub documen
- ExtraProperties:
```json
{"GitHubRootUrl":"https://github.com/abpframework/abp/tree/{version}/docs/en/","GitHubAccessToken":"***"}
{"GitHubRootUrl":"https://github.com/abpframework/abp/tree/{version}/docs","GitHubAccessToken":"***"}
```
Note that `GitHubAccessToken` is masked with `***`. It's a private token that you must get it from GitHub. See https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/
@ -328,7 +328,7 @@ You can use [ABP Framework](https://github.com/abpframework/abp/) GitHub documen
For `SQL` databases, you can use the below `T-SQL` command to insert the specified sample into your `DocsProjects` table:
```mssql
INSERT [dbo].[DocsProjects] ([Id], [Name], [ShortName], [Format], [DefaultDocumentName], [NavigationDocumentName], [MinimumVersion], [DocumentStoreType], [ExtraProperties], [MainWebsiteUrl], [LatestVersionBranchName]) VALUES (N'12f21123-e08e-4f15-bedb-ae0b2d939658', N'ABP framework (GitHub)', N'abp', N'md', N'Index', N'docs-nav.json', NULL, N'GitHub', N'{"GitHubRootUrl":"https://github.com/abpframework/abp/tree/{version}/docs/en/","GitHubAccessToken":"***"}', N'/', N'master')
INSERT [dbo].[DocsProjects] ([Id], [Name], [ShortName], [Format], [DefaultDocumentName], [NavigationDocumentName], [MinimumVersion], [DocumentStoreType], [ExtraProperties], [MainWebsiteUrl], [LatestVersionBranchName]) VALUES (N'12f21123-e08e-4f15-bedb-ae0b2d939658', N'ABP framework (GitHub)', N'abp', N'md', N'Index', N'docs-nav.json', NULL, N'GitHub', N'{"GitHubRootUrl":"https://github.com/abpframework/abp/tree/{version}/docs","GitHubAccessToken":"***"}', N'/', N'master')
```
Be aware that `GitHubAccessToken` is masked. It's a private token and you must get your own token and replace the `***` string.
@ -354,10 +354,10 @@ You can use [ABP Framework](https://github.com/abpframework/abp/) GitHub documen
- ExtraProperties:
```json
{"Path":"C:\\Github\\abp\\docs\\en"}
{"Path":"C:\\Github\\abp\\docs"}
```
Note that `Path` must be replaced with your local docs directory. You can fetch the ABP Framework's documents from https://github.com/abpframework/abp/tree/master/docs/en and copy to the directory `C:\\Github\\abp\\docs\\en` to get it work.
Note that `Path` must be replaced with your local docs directory. You can fetch the ABP Framework's documents from https://github.com/abpframework/abp/tree/master/docs and copy to the directory `C:\\Github\\abp\\docs` to get it work.
- MainWebsiteUrl: `/`
@ -366,11 +366,9 @@ You can use [ABP Framework](https://github.com/abpframework/abp/) GitHub documen
For `SQL` databases, you can use the below `T-SQL` command to insert the specified sample into your `DocsProjects` table:
```mssql
INSERT [dbo].[DocsProjects] ([Id], [Name], [ShortName], [Format], [DefaultDocumentName], [NavigationDocumentName], [MinimumVersion], [DocumentStoreType], [ExtraProperties], [MainWebsiteUrl], [LatestVersionBranchName]) VALUES (N'12f21123-e08e-4f15-bedb-ae0b2d939659', N'ABP framework (FileSystem)', N'abp', N'md', N'Index', N'docs-nav.json', NULL, N'FileSystem', N'{"Path":"C:\\Github\\abp\\docs\\en"}', N'/', NULL)
INSERT [dbo].[DocsProjects] ([Id], [Name], [ShortName], [Format], [DefaultDocumentName], [NavigationDocumentName], [MinimumVersion], [DocumentStoreType], [ExtraProperties], [MainWebsiteUrl], [LatestVersionBranchName]) VALUES (N'12f21123-e08e-4f15-bedb-ae0b2d939659', N'ABP framework (FileSystem)', N'abp', N'md', N'Index', N'docs-nav.json', NULL, N'FileSystem', N'{"Path":"C:\\Github\\abp\\docs"}', N'/', NULL)
```
Add one of the sample projects above and run the application. In the menu you will see `Documents` link, click the menu link to open the documents page.
So far, we have created a new application from abp.io website and made it up and ready for Docs module.

116
docs/en/Options.md

@ -1,4 +1,118 @@
# Options
TODO!
Microsoft has introduced [the options pattern](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options) that is used to configure a group of settings used by the framework services. This pattern is implemented by the [Microsoft.Extensions.Options](https://www.nuget.org/packages/Microsoft.Extensions.Options) NuGet package, so it is usable by any type of applications in addition to ASP.NET Core based applications.
ABP framework follows this option pattern and defines options classes to configure the framework and the modules (they are explained in the documents of the related feature).
Since [the Microsoft documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options) explains the pattern in detail, no reason to repeat all. However, ABP adds a few more features and they will be explained here.
## Configure Options
You typically configure options in the `ConfigureServices` of the `Startup` class. However, since ABP framework provides a modular infrastructure, you configure options in the `ConfigureServices` of your [module](Module-Development-Basics.md). Example:
````csharp
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.Configure<AbpAuditingOptions>(options =>
{
options.IsEnabled = false;
});
}
````
* `AbpAuditingOptions` is a simple class defines some properties like `IsEnabled` used here.
* `AbpModule` base class defines `Configure` method to make the code simpler. So, instead of `context.Services.Configure<...>`, you can directly use the `Configure<...>` shortcut method.
If you are developing a reusable module, you may need to define an options class to allow developers to configure your module. In this case, define a plain options class as shown below:
````csharp
public class MyOptions
{
public int Value1 { get; set; }
public bool Value2 { get; set; }
}
````
Then developers can configure your options just like the `AbpAuditingOptions` example above:
````csharp
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<MyOptions>(options =>
{
options.Value1 = 42;
options.Value2 = true;
});
}
````
* In this example, used the shortcut `Configure<...>` method.
### Get the Option Value
Whenever you need to get the value of an option, [inject](Dependency-Injection.md) the `IOptions<TOption>` service into your class and use its `.Value` property. Example:
````csharp
public class MyService : ITransientDependency
{
private readonly MyOptions _options;
public MyService(IOptions<MyOptions> options)
{
_options = options.Value; //Notice the options.Value usage!
}
public void DoIt()
{
var v1 = _options.Value1;
var v2 = _options.Value2;
}
}
````
Read [the Microsoft documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options) for all details of the options pattern.
## Pre Configure
One restriction of the options pattern is that you can only resolve (inject) the `IOptions<MyOptions>` and get the option values when the dependency injection configuration completes (that means the `ConfigureServices` methods of all modules complete).
If you are developing a module, you may need to allow developers to set some options and use these options in the dependency injection registration phase. You may need to configure other services or change the dependency injection registration code based on these option values.
For such cases, ABP introduces the `PreConfigure<TOptions>` and the `ExecutePreConfiguredActions<TOptions>` extension methods for the `IServiceCollection`. The pattern works as explained below.
1. Define a plan option class in your module. Example:
````csharp
public class MyPreOptions
{
public bool MyValue { get; set; }
}
````
Then any [module class](Module-Development-Basics.md) depends on your module can use the `PreConfigure<TOptions>` method in its `PreConfigureServices` method. Example:
````csharp
public override void PreConfigureServices(ServiceConfigurationContext context)
{
PreConfigure<MyPreOptions>(options =>
{
options.MyValue = true;
});
}
````
> Multiple modules can pre-configure the options and override the option values based on their dependency order.
Finally, your module can execute the `ExecutePreConfiguredActions` method in its `ConfigureServices` method to get the configured option values. Example:
````csharp
public override void ConfigureServices(ServiceConfigurationContext context)
{
var options = context.Services.ExecutePreConfiguredActions<MyPreOptions>();
if (options.MyValue)
{
//...
}
}
````

3
docs/en/Virtual-File-System.md

@ -38,7 +38,8 @@ If you want to add multiple files, this can be tedious. Alternatively, you can d
````C#
<ItemGroup>
<None Remove="MyResources\**\*.*" />
<EmbeddedResource Include="MyResources\**\*.*" />
<Content Remove="MyResources\**\*.*" />
</ItemGroup>
````

8
docs/en/docs-nav.json

@ -60,6 +60,10 @@
"text": "Configuration",
"path": "Configuration.md"
},
{
"text": "Options",
"path": "Options.md"
},
{
"text": "Dependency Injection",
"path": "Dependency-Injection.md",
@ -281,6 +285,10 @@
{
"text": "Switch to SQLite",
"path": "Entity-Framework-Core-SQLite.md"
},
{
"text": "Switch to another DBMS",
"path": "Entity-Framework-Core-Other-DBMS.md"
}
]
},

3
docs/zh-Hans/Virtual-File-System.md

@ -39,7 +39,8 @@ namespace MyCompany.MyProject
````C#
<ItemGroup>
<None Remove="MyResources\**\*.*" />
<EmbeddedResource Include="MyResources\**\*.*" />
<Content Remove="MyResources\**\*.*" />
</ItemGroup>
````

21
framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/AbpApplicationBuilderExtensions.cs

@ -2,6 +2,7 @@
using JetBrains.Annotations;
using Microsoft.AspNetCore.RequestLocalization;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
using Volo.Abp.AspNetCore.Auditing;
using Volo.Abp.AspNetCore.ExceptionHandling;
@ -20,7 +21,20 @@ namespace Microsoft.AspNetCore.Builder
Check.NotNull(app, nameof(app));
app.ApplicationServices.GetRequiredService<ObjectAccessor<IApplicationBuilder>>().Value = app;
app.ApplicationServices.GetRequiredService<IAbpApplicationWithExternalServiceProvider>().Initialize(app.ApplicationServices);
var application = app.ApplicationServices.GetRequiredService<IAbpApplicationWithExternalServiceProvider>();
var applicationLifetime = app.ApplicationServices.GetRequiredService<IHostApplicationLifetime>();
applicationLifetime.ApplicationStopping.Register(() =>
{
application.Shutdown();
});
applicationLifetime.ApplicationStopped.Register(() =>
{
application.Dispose();
});
application.Initialize(app.ApplicationServices);
}
public static IApplicationBuilder UseAuditing(this IApplicationBuilder app)
@ -42,7 +56,8 @@ namespace Microsoft.AspNetCore.Builder
.UseMiddleware<AbpCorrelationIdMiddleware>();
}
public static IApplicationBuilder UseAbpRequestLocalization(this IApplicationBuilder app, Action<RequestLocalizationOptions> optionsAction = null)
public static IApplicationBuilder UseAbpRequestLocalization(this IApplicationBuilder app,
Action<RequestLocalizationOptions> optionsAction = null)
{
app.ApplicationServices
.GetRequiredService<IAbpRequestLocalizationOptionsProvider>()
@ -62,4 +77,4 @@ namespace Microsoft.AspNetCore.Builder
return app.UseMiddleware<AbpExceptionHandlingMiddleware>();
}
}
}
}

53
framework/src/Volo.Abp.Autofac/Autofac/Extensions/DependencyInjection/AutofacServiceProvider.cs

@ -1,6 +1,6 @@
// This software is part of the Autofac IoC container
// Copyright © 2015 Autofac Contributors
// http://autofac.org
// https://autofac.org
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
@ -33,19 +33,21 @@ namespace Autofac.Extensions.DependencyInjection
/// </summary>
/// <seealso cref="System.IServiceProvider" />
/// <seealso cref="Microsoft.Extensions.DependencyInjection.ISupportRequiredService" />
public class AutofacServiceProvider : IServiceProvider, ISupportRequiredService
public class AutofacServiceProvider : IServiceProvider, ISupportRequiredService, IDisposable
{
private readonly IComponentContext _componentContext;
private readonly ILifetimeScope _lifetimeScope;
private bool _disposed = false;
/// <summary>
/// Initializes a new instance of the <see cref="AutofacServiceProvider"/> class.
/// </summary>
/// <param name="componentContext">
/// The component context from which services should be resolved.
/// <param name="lifetimeScope">
/// The lifetime scope from which services will be resolved.
/// </param>
public AutofacServiceProvider(IComponentContext componentContext)
public AutofacServiceProvider(ILifetimeScope lifetimeScope)
{
this._componentContext = componentContext;
this._lifetimeScope = lifetimeScope;
}
/// <summary>
@ -66,7 +68,7 @@ namespace Autofac.Extensions.DependencyInjection
/// </exception>
public object GetRequiredService(Type serviceType)
{
return this._componentContext.Resolve(serviceType);
return this._lifetimeScope.Resolve(serviceType);
}
/// <summary>
@ -81,7 +83,40 @@ namespace Autofac.Extensions.DependencyInjection
/// </returns>
public object GetService(Type serviceType)
{
return this._componentContext.ResolveOptional(serviceType);
return this._lifetimeScope.ResolveOptional(serviceType);
}
/// <summary>
/// Gets the underlying instance of <see cref="ILifetimeScope" />.
/// </summary>
public ILifetimeScope LifetimeScope => _lifetimeScope;
/// <summary>
/// Releases unmanaged and - optionally - managed resources.
/// </summary>
/// <param name="disposing">
/// <see langword="true" /> to release both managed and unmanaged resources;
/// <see langword="false" /> to release only unmanaged resources.
/// </param>
protected virtual void Dispose(bool disposing)
{
if (!this._disposed)
{
this._disposed = true;
if (disposing)
{
this._lifetimeScope.Dispose();
}
}
}
/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
}
}

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/DeveloperApiKeyResult.cs

@ -7,7 +7,7 @@ namespace Volo.Abp.Cli.Licensing
public bool HasActiveLicense { get; set; }
public string OrganizationName { get; set; }
public string ApiKey { get; set; }
public DateTime LicenseEndTime { get; set; }
public DateTime? LicenseEndTime { get; set; }
public string LicenseCode { get; set; }
}
}

5
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveFolderStep.cs

@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
{
@ -14,7 +15,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
public override void Execute(ProjectBuildContext context)
{
//Remove the folder content
var folderPathWithSlash = _folderPath + "/";
var folderPathWithSlash = _folderPath.EnsureEndsWith('/');
context.Files.RemoveAll(file => file.Name.StartsWith(folderPathWithSlash));
//Remove the folder

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Module/ModuleTemplateBase.cs

@ -43,6 +43,8 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.Module
"MyCompanyName.MyProjectName.Web.Unified",
projectFolderPath: "/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified"
));
steps.Add(new RemoveFolderStep("/angular"));
}
private void RandomizeSslPorts(ProjectBuildContext context, List<ProjectBuildPipelineStep> steps)

10
framework/src/Volo.Abp.Core/Volo/Abp/AbpApplicationWithExternalServiceProvider.cs

@ -26,5 +26,15 @@ namespace Volo.Abp
InitializeModules();
}
public override void Dispose()
{
base.Dispose();
if (ServiceProvider is IDisposable disposableServiceProvider)
{
disposableServiceProvider.Dispose();
}
}
}
}

144
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs

@ -11,13 +11,13 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.EntityFrameworkCore.EntityHistory;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.EntityFrameworkCore.ValueConverters;
using Volo.Abp.Guids;
using Volo.Abp.MultiTenancy;
@ -323,147 +323,9 @@ namespace Volo.Abp.EntityFrameworkCore
return;
}
ConfigureConcurrencyStampProperty<TEntity>(modelBuilder, mutableEntityType);
ConfigureExtraProperties<TEntity>(modelBuilder, mutableEntityType);
ConfigureAuditProperties<TEntity>(modelBuilder, mutableEntityType);
ConfigureTenantIdProperty<TEntity>(modelBuilder, mutableEntityType);
ConfigureGlobalFilters<TEntity>(modelBuilder, mutableEntityType);
}
protected virtual void ConfigureConcurrencyStampProperty<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType)
where TEntity : class
{
if (!typeof(IHasConcurrencyStamp).IsAssignableFrom(typeof(TEntity)))
{
return;
}
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IHasConcurrencyStamp) x).ConcurrencyStamp)
.IsConcurrencyToken()
.HasColumnName(nameof(IHasConcurrencyStamp.ConcurrencyStamp));
});
}
protected virtual void ConfigureExtraProperties<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType)
where TEntity : class
{
if (!typeof(IHasExtraProperties).IsAssignableFrom(typeof(TEntity)))
{
return;
}
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IHasExtraProperties) x).ExtraProperties)
.HasConversion(
d => JsonConvert.SerializeObject(d, Formatting.None),
s => JsonConvert.DeserializeObject<Dictionary<string, object>>(s)
)
.HasColumnName(nameof(IHasExtraProperties.ExtraProperties));
});
}
protected virtual void ConfigureAuditProperties<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType)
where TEntity : class
{
if (typeof(TEntity).IsAssignableTo<IHasCreationTime>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IHasCreationTime)x).CreationTime)
.IsRequired()
.HasColumnName(nameof(IHasCreationTime.CreationTime));
});
}
modelBuilder.Entity<TEntity>().ConfigureByConvention();
if (typeof(TEntity).IsAssignableTo<IMayHaveCreator>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IMayHaveCreator)x).CreatorId)
.IsRequired(false)
.HasColumnName(nameof(IMayHaveCreator.CreatorId));
});
}
if (typeof(TEntity).IsAssignableTo<IMustHaveCreator>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IMustHaveCreator)x).CreatorId)
.IsRequired()
.HasColumnName(nameof(IMustHaveCreator.CreatorId));
});
}
if (typeof(TEntity).IsAssignableTo<IHasModificationTime>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IHasModificationTime)x).LastModificationTime)
.IsRequired(false)
.HasColumnName(nameof(IHasModificationTime.LastModificationTime));
});
}
if (typeof(TEntity).IsAssignableTo<IModificationAuditedObject>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IModificationAuditedObject)x).LastModifierId)
.IsRequired(false)
.HasColumnName(nameof(IModificationAuditedObject.LastModifierId));
});
}
if (typeof(TEntity).IsAssignableTo<ISoftDelete>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((ISoftDelete) x).IsDeleted)
.IsRequired()
.HasDefaultValue(false)
.HasColumnName(nameof(ISoftDelete.IsDeleted));
});
}
if (typeof(TEntity).IsAssignableTo<IHasDeletionTime>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IHasDeletionTime)x).DeletionTime)
.IsRequired(false)
.HasColumnName(nameof(IHasDeletionTime.DeletionTime));
});
}
if (typeof(TEntity).IsAssignableTo<IDeletionAuditedObject>())
{
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IDeletionAuditedObject)x).DeleterId)
.IsRequired(false)
.HasColumnName(nameof(IDeletionAuditedObject.DeleterId));
});
}
}
protected virtual void ConfigureTenantIdProperty<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType)
where TEntity : class
{
if (!typeof(TEntity).IsAssignableTo<IMultiTenant>())
{
return;
}
modelBuilder.Entity<TEntity>(b =>
{
b.Property(x => ((IMultiTenant)x).TenantId)
.IsRequired(false)
.HasColumnName(nameof(IMultiTenant.TenantId));
});
ConfigureGlobalFilters<TEntity>(modelBuilder, mutableEntityType);
}
protected virtual void ConfigureGlobalFilters<TEntity>(ModelBuilder modelBuilder, IMutableEntityType mutableEntityType)

12
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/Modeling/AbpEntityTypeBuilderExtensions.cs

@ -2,11 +2,11 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Newtonsoft.Json;
using Volo.Abp.Auditing;
using Volo.Abp.Data;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Auditing;
using Volo.Abp.EntityFrameworkCore.ValueComparers;
using Volo.Abp.EntityFrameworkCore.ValueConverters;
using Volo.Abp.MultiTenancy;
namespace Volo.Abp.EntityFrameworkCore.Modeling
@ -57,11 +57,9 @@ namespace Volo.Abp.EntityFrameworkCore.Modeling
if (b.Metadata.ClrType.IsAssignableTo<IHasExtraProperties>())
{
b.Property<Dictionary<string, object>>(nameof(IHasExtraProperties.ExtraProperties))
.HasConversion(
d => JsonConvert.SerializeObject(d, Formatting.None),
s => JsonConvert.DeserializeObject<Dictionary<string, object>>(s)
)
.HasColumnName(nameof(IHasExtraProperties.ExtraProperties));
.HasColumnName(nameof(IHasExtraProperties.ExtraProperties))
.HasConversion(new AbpJsonValueConverter<Dictionary<string, object>>())
.Metadata.SetValueComparer(new AbpDictionaryValueComparer());
}
}

18
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueComparers/AbpDictionaryValueComparer.cs

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace Volo.Abp.EntityFrameworkCore.ValueComparers
{
public class AbpDictionaryValueComparer : ValueComparer<Dictionary<string, object>>
{
public AbpDictionaryValueComparer()
: base(
(d1, d2) => d1.SequenceEqual(d2),
d => d.Aggregate(0, (k, v) => HashCode.Combine(k, v.GetHashCode())),
d => d.ToDictionary(k => k.Key, v => v.Value))
{
}
}
}

15
framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/ValueConverters/AbpJsonValueConverter.cs

@ -0,0 +1,15 @@
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Newtonsoft.Json;
namespace Volo.Abp.EntityFrameworkCore.ValueConverters
{
public class AbpJsonValueConverter<TPropertyType> : ValueConverter<TPropertyType, string>
{
public AbpJsonValueConverter()
: base(
d => JsonConvert.SerializeObject(d, Formatting.None),
s => JsonConvert.DeserializeObject<TPropertyType>(s))
{
}
}
}

6
framework/src/Volo.Abp.Http.Client/Microsoft/Extensions/DependencyInjection/ServiceCollectionDynamicHttpClientProxyExtensions.cs

@ -8,6 +8,7 @@ using Volo.Abp;
using Volo.Abp.Castle.DynamicProxy;
using Volo.Abp.Http.Client;
using Volo.Abp.Http.Client.DynamicProxying;
using Volo.Abp.Validation;
namespace Microsoft.Extensions.DependencyInjection
{
@ -154,6 +155,9 @@ namespace Microsoft.Extensions.DependencyInjection
services.AddTransient(interceptorType);
var interceptorAdapterType = typeof(AbpAsyncDeterminationInterceptor<>).MakeGenericType(interceptorType);
var validationInterceptorAdapterType =
typeof(AbpAsyncDeterminationInterceptor<>).MakeGenericType(typeof(ValidationInterceptor));
if (asDefaultService)
{
@ -162,6 +166,7 @@ namespace Microsoft.Extensions.DependencyInjection
serviceProvider => ProxyGeneratorInstance
.CreateInterfaceProxyWithoutTarget(
type,
(IInterceptor)serviceProvider.GetRequiredService(validationInterceptorAdapterType),
(IInterceptor)serviceProvider.GetRequiredService(interceptorAdapterType)
)
);
@ -174,6 +179,7 @@ namespace Microsoft.Extensions.DependencyInjection
var service = ProxyGeneratorInstance
.CreateInterfaceProxyWithoutTarget(
type,
(IInterceptor)serviceProvider.GetRequiredService(validationInterceptorAdapterType),
(IInterceptor)serviceProvider.GetRequiredService(interceptorAdapterType)
);

1
framework/src/Volo.Abp.Http.Client/Volo.Abp.Http.Client.csproj

@ -24,6 +24,7 @@
<ProjectReference Include="..\Volo.Abp.Http\Volo.Abp.Http.csproj" />
<ProjectReference Include="..\Volo.Abp.MultiTenancy\Volo.Abp.MultiTenancy.csproj" />
<ProjectReference Include="..\Volo.Abp.Threading\Volo.Abp.Threading.csproj" />
<ProjectReference Include="..\Volo.Abp.Validation\Volo.Abp.Validation.csproj" />
</ItemGroup>
</Project>

4
framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/AbpHttpClientModule.cs

@ -3,6 +3,7 @@ using Volo.Abp.Castle;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
using Volo.Abp.Validation;
namespace Volo.Abp.Http.Client
{
@ -10,7 +11,8 @@ namespace Volo.Abp.Http.Client
typeof(AbpHttpModule),
typeof(AbpCastleCoreModule),
typeof(AbpThreadingModule),
typeof(AbpMultiTenancyModule)
typeof(AbpMultiTenancyModule),
typeof(AbpValidationModule)
)]
public class AbpHttpClientModule : AbpModule
{

32
framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs

@ -2,6 +2,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute.Extensions;
using Shouldly;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Repositories;
@ -9,6 +10,7 @@ using Volo.Abp.Http.Client;
using Volo.Abp.TestApp.Application;
using Volo.Abp.TestApp.Application.Dto;
using Volo.Abp.TestApp.Domain;
using Volo.Abp.Validation;
using Xunit;
namespace Volo.Abp.Http.DynamicProxying
@ -38,7 +40,8 @@ namespace Volo.Abp.Http.DynamicProxying
[Fact]
public async Task GetList()
{
var people = await _peopleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false);
var people = await _peopleAppService.GetListAsync(new PagedAndSortedResultRequestDto())
.ConfigureAwait(false);
people.TotalCount.ShouldBeGreaterThan(0);
people.Items.Count.ShouldBe((int) people.TotalCount);
}
@ -59,11 +62,11 @@ namespace Volo.Abp.Http.DynamicProxying
{
var uniquePersonName = Guid.NewGuid().ToString();
var person = await _peopleAppService.CreateAsync(new PersonDto
{
Name = uniquePersonName,
Age = 42
}
var person = await _peopleAppService.CreateAsync(new PersonDto
{
Name = uniquePersonName,
Age = 42
}
).ConfigureAwait(false);
person.ShouldNotBeNull();
@ -74,7 +77,20 @@ namespace Volo.Abp.Http.DynamicProxying
personInDb.ShouldNotBeNull();
personInDb.Id.ShouldBe(person.Id);
}
[Fact]
public async Task Create_Validate_Exception()
{
await Assert.ThrowsAsync<AbpValidationException>(async () =>
{
var person = await _peopleAppService.CreateAsync(new PersonDto
{
Age = 42
}
).ConfigureAwait(false);
}).ConfigureAwait(false);
}
[Fact]
public async Task Update()
{
@ -135,4 +151,4 @@ namespace Volo.Abp.Http.DynamicProxying
result.Inner1.Inner2.Value3.ShouldBe("value three");
}
}
}
}

15
framework/test/Volo.Abp.TestApp.Tests/Volo/Abp/TestApp/Application/PersonAppService_Tests.cs

@ -19,7 +19,7 @@ namespace Volo.Abp.TestApp.Application
public PersonAppService_Tests()
{
_peopleAppService = ServiceProvider.GetRequiredService<IPeopleAppService>();
_peopleAppService = ServiceProvider.GetRequiredService<IPeopleAppService>();
}
protected override void AfterAddApplication(IServiceCollection services)
@ -31,14 +31,17 @@ namespace Volo.Abp.TestApp.Application
[Fact]
public async Task GetList()
{
var people = await _peopleAppService.GetListAsync(new PagedAndSortedResultRequestDto()).ConfigureAwait(false);
var people = await _peopleAppService.GetListAsync(new PagedAndSortedResultRequestDto())
.ConfigureAwait(false);
people.Items.Count.ShouldBeGreaterThan(0);
}
[Fact]
public async Task Create()
{
var personDto = await _peopleAppService.CreateAsync(new PersonDto()).ConfigureAwait(false);
var uniquePersonName = Guid.NewGuid().ToString();
var personDto = await _peopleAppService.CreateAsync(new PersonDto {Name = uniquePersonName})
.ConfigureAwait(false);
var repository = ServiceProvider.GetService<IRepository<Person, Guid>>();
var person = await repository.FindAsync(personDto.Id).ConfigureAwait(false);
@ -52,7 +55,9 @@ namespace Volo.Abp.TestApp.Application
{
_fakeCurrentTenant.Id.Returns(TestDataBuilder.TenantId1);
var personDto = await _peopleAppService.CreateAsync(new PersonDto()).ConfigureAwait(false);
var uniquePersonName = Guid.NewGuid().ToString();
var personDto = await _peopleAppService.CreateAsync(new PersonDto {Name = uniquePersonName})
.ConfigureAwait(false);
var repository = ServiceProvider.GetService<IRepository<Person, Guid>>();
var person = await repository.FindAsync(personDto.Id).ConfigureAwait(false);
@ -63,4 +68,4 @@ namespace Volo.Abp.TestApp.Application
person.TenantId.ShouldBe(TestDataBuilder.TenantId1);
}
}
}
}

2
framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/Dto/PersonDto.cs

@ -1,4 +1,5 @@
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
using Volo.Abp.MultiTenancy;
@ -6,6 +7,7 @@ namespace Volo.Abp.TestApp.Application.Dto
{
public class PersonDto : EntityDto<Guid>, IMultiTenant
{
[Required]
public string Name { get; set; }
public int Age { get; set; }

4
modules/account/src/Volo.Abp.Account.Application/Volo/Abp/Account/Settings/AccountSettingDefinitionProvider.cs

@ -13,7 +13,7 @@ namespace Volo.Abp.Account.Settings
AccountSettingNames.IsSelfRegistrationEnabled,
"true",
L("DisplayName:Abp.Account.IsSelfRegistrationEnabled"),
L("Description:Abp.Account.IsSelfRegistrationEnabled"))
L("Description:Abp.Account.IsSelfRegistrationEnabled"), isVisibleToClients : true)
);
context.Add(
@ -21,7 +21,7 @@ namespace Volo.Abp.Account.Settings
AccountSettingNames.EnableLocalLogin,
"true",
L("DisplayName:Abp.Account.EnableLocalLogin"),
L("Description:Abp.Account.EnableLocalLogin"))
L("Description:Abp.Account.EnableLocalLogin"), isVisibleToClients : true)
);
}

5
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml

@ -1,5 +1,6 @@
@page
@using Volo.Abp.Account.Settings
@using Volo.Abp.Settings
@model Volo.Abp.Account.Web.Pages.Account.LoginModel
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
@inject Volo.Abp.Settings.ISettingProvider SettingProvider
@ -7,8 +8,8 @@
{
<div class="card mt-3 shadow-sm rounded">
<div class="card-body p-5">
<h4>@L["Login"]</h4>
@if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase))
<h4>@L["Login"]</h4>
@if (await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled))
{
<strong>
@L["AreYouANewUser"]

3
modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml.cs

@ -45,7 +45,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
protected virtual async Task CheckSelfRegistrationAsync()
{
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false))
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false) ||
!await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false))
{
throw new UserFriendlyException(L["SelfRegistrationDisabledMessage"]);
}

4
modules/docs/src/Volo.Docs.Web/Markdown/MarkdownDocumentToHtmlConverter.cs

@ -24,7 +24,7 @@ namespace Volo.Docs.Markdown
}
private const string MdLinkFormat = "[{0}]({1}{2}/{3}/{4}{5}/{6})";
private const string MarkdownLinkRegExp = @"\[(.*?)\]\((.*?\.md)\)";
private const string MarkdownLinkRegExp = @"\[(.*?)\]\((.*?)\)";
private const string AnchorLinkRegExp = @"<a[^>]+href=\""(.*?)\""[^>]*>(.*)?</a>";
public virtual string Convert(ProjectDto project, DocumentWithDetailsDto document, string version,
@ -56,7 +56,7 @@ namespace Volo.Docs.Markdown
var normalized = Regex.Replace(content, MarkdownLinkRegExp, delegate (Match match)
{
var link = match.Groups[2].Value;
if (UrlHelper.IsExternalLink(link))
if (UrlHelper.IsExternalLink(link) || !link.EndsWith(".md"))
{
return match.Value;
}

4
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -439,7 +439,7 @@ namespace Volo.Docs.Pages.Documents.Project
var value = keyValue.Split("=")[1];
UserPreferences.Add(key, value);
UserPreferences.Add(key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == key)
UserPreferences.Add(key + "_Value", DocumentPreferences?.Parameters?.FirstOrDefault(p => p.Name == key)
?.Values.FirstOrDefault(v => v.Key == value).Value);
}
}
@ -456,7 +456,7 @@ namespace Volo.Docs.Pages.Documents.Project
UserPreferences.Add(key, value);
UserPreferences.Add(key + "_Value",
DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == key)?.Values
DocumentPreferences?.Parameters?.FirstOrDefault(p => p.Name == key)?.Values
.FirstOrDefault(v => v.Key == value).Value);
}

4
modules/identity/src/Volo.Abp.Identity.Domain.Shared/Volo/Abp/Identity/Localization/en.json

@ -7,7 +7,7 @@
"UserName": "User name",
"EmailAddress": "Email address",
"PhoneNumber": "Phone number",
"UserInformations": "User informations",
"UserInformations": "User information",
"DisplayName:IsDefault": "Default",
"DisplayName:IsStatic": "Static",
"DisplayName:IsPublic": "Public",
@ -99,4 +99,4 @@
"Description:Abp.Identity.User.IsUserNameUpdateEnabled": "Whether the username can be updated by the user.",
"Description:Abp.Identity.User.IsEmailUpdateEnabled": "Whether the email can be updated by the user."
}
}
}

15
modules/identityserver/src/Volo.Abp.IdentityServer.EntityFrameworkCore/Volo/Abp/IdentityServer/EntityFrameworkCore/IdentityServerDbContextModelCreatingExtensions.cs

@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.Modeling;
using Volo.Abp.EntityFrameworkCore.ValueComparers;
using Volo.Abp.EntityFrameworkCore.ValueConverters;
using Volo.Abp.IdentityServer.ApiResources;
using Volo.Abp.IdentityServer.Clients;
using Volo.Abp.IdentityServer.Devices;
@ -203,10 +204,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
identityResource.Property(x => x.DisplayName).HasMaxLength(IdentityResourceConsts.DisplayNameMaxLength);
identityResource.Property(x => x.Description).HasMaxLength(IdentityResourceConsts.DescriptionMaxLength);
identityResource.Property(x => x.Properties)
.HasConversion(
d => JsonConvert.SerializeObject(d, Formatting.None),
s => JsonConvert.DeserializeObject<Dictionary<string, string>>(s)
);
.HasConversion(new AbpJsonValueConverter<Dictionary<string, object>>())
.Metadata.SetValueComparer(new AbpDictionaryValueComparer());
identityResource.HasMany(x => x.UserClaims).WithOne().HasForeignKey(x => x.IdentityResourceId).IsRequired();
});
@ -230,10 +229,8 @@ namespace Volo.Abp.IdentityServer.EntityFrameworkCore
apiResource.Property(x => x.DisplayName).HasMaxLength(ApiResourceConsts.DisplayNameMaxLength);
apiResource.Property(x => x.Description).HasMaxLength(ApiResourceConsts.DescriptionMaxLength);
apiResource.Property(x => x.Properties)
.HasConversion(
d => JsonConvert.SerializeObject(d, Formatting.None),
s => JsonConvert.DeserializeObject<Dictionary<string, string>>(s)
);
.HasConversion(new AbpJsonValueConverter<Dictionary<string, object>>())
.Metadata.SetValueComparer(new AbpDictionaryValueComparer());
apiResource.HasMany(x => x.Secrets).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();
apiResource.HasMany(x => x.Scopes).WithOne().HasForeignKey(x => x.ApiResourceId).IsRequired();

12
npm/ng-packs/packages/account/src/lib/components/auth-wrapper/auth-wrapper.component.html

@ -5,7 +5,10 @@
></abp-tenant-box>
<div class="abp-account-container">
<div class="card mt-3 shadow-sm rounded">
<div
*ngIf="(enableLocalLogin$ | async) !== 'False'; else disableLocalLoginTemplate"
class="card mt-3 shadow-sm rounded"
>
<div class="card-body p-5">
<ng-content *ngTemplateOutlet="mainContentRef"></ng-content>
</div>
@ -14,3 +17,10 @@
</div>
</div>
</div>
<ng-template #disableLocalLoginTemplate>
<div class="alert alert-warning">
<strong>{{ 'AbpAccount::InvalidLoginRequest' | abpLocalization }}</strong>
{{ 'AbpAccount::ThereAreNoLoginSchemesConfiguredForThisClient' | abpLocalization }}
</div>
</ng-template>

6
npm/ng-packs/packages/account/src/lib/components/auth-wrapper/auth-wrapper.component.ts

@ -1,5 +1,8 @@
import { Component, Input, TemplateRef } from '@angular/core';
import { Account } from '../../models/account';
import { Select } from '@ngxs/store';
import { ConfigState } from '@abp/ng.core';
import { Observable } from 'rxjs';
@Component({
selector: 'abp-auth-wrapper',
@ -8,6 +11,9 @@ import { Account } from '../../models/account';
})
export class AuthWrapperComponent
implements Account.AuthWrapperComponentInputs, Account.AuthWrapperComponentOutputs {
@Select(ConfigState.getSetting('Abp.Account.EnableLocalLogin'))
enableLocalLogin$: Observable<'True' | 'False'>;
@Input()
readonly mainContentRef: TemplateRef<any>;

9
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/Menus/MyProjectNameMenuContributor.cs

@ -8,6 +8,7 @@ using MyCompanyName.MyProjectName.MultiTenancy;
using Volo.Abp.Account.Localization;
using Volo.Abp.TenantManagement.Web.Navigation;
using Volo.Abp.UI.Navigation;
using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName.Web.Menus
{
@ -51,11 +52,15 @@ namespace MyCompanyName.MyProjectName.Web.Menus
{
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
var accountStringLocalizer = context.ServiceProvider.GetRequiredService<IStringLocalizer<AccountResource>>();
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
var identityServerUrl = _configuration["AuthServer:Authority"] ?? "";
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage", icon: "fa fa-cog", order: 1000, null, "_blank"));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
if (currentUser.IsAuthenticated)
{
context.Menu.AddItem(new ApplicationMenuItem("Account.Manage", accountStringLocalizer["ManageYourProfile"], $"{identityServerUrl.EnsureEndsWith('/')}Account/Manage", icon: "fa fa-cog", order: 1000, null, "_blank"));
context.Menu.AddItem(new ApplicationMenuItem("Account.Logout", l["Logout"], url: "/Account/Logout", icon: "fa fa-power-off", order: int.MaxValue - 1000));
}
return Task.CompletedTask;
}

1
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.IdentityServer/MyCompanyName.MyProjectName.IdentityServer.csproj

@ -22,6 +22,7 @@
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" />
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web.IdentityServer\Volo.Abp.Account.Web.IdentityServer.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore\Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\audit-logging\src\Volo.Abp.AuditLogging.EntityFrameworkCore\Volo.Abp.AuditLogging.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\identityserver\src\Volo.Abp.IdentityServer.EntityFrameworkCore\Volo.Abp.IdentityServer.EntityFrameworkCore.csproj" />

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

@ -11,6 +11,7 @@ using StackExchange.Redis;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Authentication.JwtBearer;
using Volo.Abp.AspNetCore.Mvc;
@ -44,6 +45,7 @@ namespace MyCompanyName.MyProjectName
{
[DependsOn(
typeof(AbpAccountWebIdentityServerModule),
typeof(AbpAccountApplicationModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule),
typeof(AbpAspNetCoreMvcModule),
typeof(AbpAspNetCoreMvcUiBasicThemeModule),

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

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

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

@ -0,0 +1,60 @@
using System;
using System.Threading.Tasks;
using Localization.Resources.AbpUi;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Localization;
using MyCompanyName.MyProjectName.Localization;
using Volo.Abp.UI.Navigation;
using Volo.Abp.Users;
namespace MyCompanyName.MyProjectName
{
public class MyProjectNameWebHostMenuContributor : IMenuContributor
{
private readonly IConfiguration _configuration;
public MyProjectNameWebHostMenuContributor(IConfiguration configuration)
{
_configuration = configuration;
}
public Task ConfigureMenuAsync(MenuConfigurationContext context)
{
if (context.Menu.Name == StandardMenus.User)
{
AddLogoutItemToMenu(context);
}
return Task.CompletedTask;
}
private void AddLogoutItemToMenu(MenuConfigurationContext context)
{
var currentUser = context.ServiceProvider.GetRequiredService<ICurrentUser>();
var l = context.ServiceProvider.GetRequiredService<IStringLocalizer<MyProjectNameResource>>();
if (currentUser.IsAuthenticated)
{
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Manage",
l["ManageYourProfile"],
$"{_configuration["AuthServer:Authority"].EnsureEndsWith('/')}Account/Manage",
icon: "fa fa-cog",
order: int.MaxValue - 1001,
null,
"_blank")
);
context.Menu.Items.Add(new ApplicationMenuItem(
"Account.Logout",
l["Logout"],
"/Account/Logout",
"fas fa-power-off",
order: int.MaxValue - 1000
));
}
}
}
}

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

@ -37,6 +37,7 @@ using Volo.Abp.TenantManagement;
using Volo.Abp.TenantManagement.Web;
using Volo.Abp.UI.Navigation.Urls;
using Volo.Abp.UI;
using Volo.Abp.UI.Navigation;
using Volo.Abp.VirtualFileSystem;
namespace MyCompanyName.MyProjectName
@ -76,6 +77,7 @@ namespace MyCompanyName.MyProjectName
var hostingEnvironment = context.Services.GetHostingEnvironment();
var configuration = context.Services.GetConfiguration();
ConfigureMenu(configuration);
ConfigureCache(configuration);
ConfigureUrls(configuration);
ConfigureAuthentication(context, configuration);
@ -85,7 +87,15 @@ namespace MyCompanyName.MyProjectName
ConfigureMultiTenancy();
ConfigureRedis(context, configuration, hostingEnvironment);
}
private void ConfigureMenu(IConfiguration configuration)
{
Configure<AbpNavigationOptions>(options =>
{
options.MenuContributors.Add(new MyProjectNameWebHostMenuContributor(configuration));
});
}
private void ConfigureCache(IConfiguration configuration)
{
Configure<AbpDistributedCacheOptions>(options =>

1
templates/module/aspnet-core/host/MyCompanyName.MyProjectName.Web.Unified/MyCompanyName.MyProjectName.Web.Unified.csproj

@ -19,6 +19,7 @@
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.EntityFrameworkCore.SqlServer\Volo.Abp.EntityFrameworkCore.SqlServer.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\audit-logging\src\Volo.Abp.AuditLogging.EntityFrameworkCore\Volo.Abp.AuditLogging.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Web\Volo.Abp.Account.Web.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\account\src\Volo.Abp.Account.Application\Volo.Abp.Account.Application.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\setting-management\src\Volo.Abp.SettingManagement.EntityFrameworkCore\Volo.Abp.SettingManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.Application\Volo.Abp.PermissionManagement.Application.csproj" />
<ProjectReference Include="..\..\..\..\..\modules\permission-management\src\Volo.Abp.PermissionManagement.EntityFrameworkCore\Volo.Abp.PermissionManagement.EntityFrameworkCore.csproj" />

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

@ -8,6 +8,7 @@ using MyCompanyName.MyProjectName.Web;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Swagger;
using Volo.Abp;
using Volo.Abp.Account;
using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
@ -42,6 +43,7 @@ namespace MyCompanyName.MyProjectName
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
typeof(AbpAutofacModule),
typeof(AbpAccountWebModule),
typeof(AbpAccountApplicationModule),
typeof(AbpEntityFrameworkCoreSqlServerModule),
typeof(AbpSettingManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementEntityFrameworkCoreModule),

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

@ -8,6 +8,7 @@ namespace MyCompanyName.MyProjectName
protected MyProjectNameAppService()
{
LocalizationResource = typeof(MyProjectNameResource);
ObjectMapperContext = typeof(MyProjectNameApplicationModule);
}
}
}

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

@ -1,4 +1,5 @@
using Volo.Abp.AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
using Volo.Abp.Application;
@ -14,6 +15,7 @@ namespace MyCompanyName.MyProjectName
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAutoMapperObjectMapper<MyProjectNameApplicationModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameApplicationModule>(validate: true);

2
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectName/en.json

@ -1,6 +1,6 @@
{
"culture": "en",
"texts": {
"ManageYourProfile": "Manage your profile"
}
}

6
templates/module/aspnet-core/src/MyCompanyName.MyProjectName.Domain.Shared/Localization/MyProjectName/tr.json

@ -0,0 +1,6 @@
{
"culture": "tr",
"texts": {
"ManageYourProfile": "Profil yönetimi"
}
}

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

@ -42,6 +42,7 @@ namespace MyCompanyName.MyProjectName.Web
options.FileSets.AddEmbedded<MyProjectNameWebModule>("MyCompanyName.MyProjectName.Web");
});
context.Services.AddAutoMapperObjectMapper<MyProjectNameWebModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyProjectNameWebModule>(validate: true);

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

@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace MyCompanyName.MyProjectName.Web.Pages.MyProjectName
{
public class IndexModel : PageModel
public class IndexModel : MyProjectNamePageModel
{
public void OnGet()
{

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

@ -10,6 +10,7 @@ namespace MyCompanyName.MyProjectName.Web.Pages
protected MyProjectNamePageModel()
{
LocalizationResourceType = typeof(MyProjectNameResource);
ObjectMapperContext = typeof(MyProjectNameWebModule);
}
}
}
Loading…
Cancel
Save