Browse Source

Merge remote-tracking branch 'abpframework/dev' into Translate

pull/2548/head
liangshiwei 7 years ago
parent
commit
409675431d
  1. 2
      abp_io/AbpIoLocalization/AbpIoLocalization/AbpIoLocalization.csproj
  2. 5
      abp_io/AbpIoLocalization/AbpIoLocalization/AbpIoLocalizationModule.cs
  3. 0
      docs/cs/Entity-Framework-Core-PostgreSQL.md
  4. 2
      docs/cs/docs-nav.json
  5. 2
      docs/en/Best-Practices/Index.md
  6. 67
      docs/en/Connection-Strings.md
  7. 12
      docs/en/Data-Access.md
  8. 58
      docs/en/Entity-Framework-Core-MySQL.md
  9. 41
      docs/en/Entity-Framework-Core-PostgreSQL.md
  10. 41
      docs/en/Entity-Framework-Core-SQLite.md
  11. 44
      docs/en/Entity-Framework-Core.md
  12. 73
      docs/en/EntityFrameworkCore-PostgreSQL-Integration.md
  13. 4
      docs/en/Modules/Docs.md
  14. 3
      docs/en/Modules/IdentityServer.md
  15. 2
      docs/en/Modules/Index.md
  16. 45
      docs/en/docs-nav.json
  17. 2
      docs/pt-BR/docs-nav.json
  18. 0
      docs/zh-Hans/Entity-Framework-Core-PostgreSQL.md
  19. 2
      docs/zh-Hans/docs-nav.json
  20. 4
      framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Microsoft/AspNetCore/Builder/JwtTokenMiddleware.cs
  21. 8
      framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs
  22. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/CachedApplicationConfigurationClient.cs
  23. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs
  24. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs
  25. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs
  26. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteSettingProvider.cs
  27. 12
      framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteTenantStore.cs
  28. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelperService.cs
  29. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelperService.cs
  30. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs
  31. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelperService.cs
  32. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs
  33. 12
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs
  34. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperExtensions.cs
  35. 20
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs
  36. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs
  37. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs
  38. 18
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs
  39. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabDropdownTagHelperService.cs
  40. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabLinkTagHelperService.cs
  41. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs
  42. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabsTagHelperService.cs
  43. 12
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
  44. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelperService.cs
  45. 6
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleTagHelperService.cs
  46. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs
  47. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs
  48. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs
  49. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs
  50. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantController.cs
  51. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs
  52. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/MainNavbarMenuViewComponent.cs
  53. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/LanguageSwitchViewComponent.cs
  54. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/MainNavbarToolsViewComponent.cs
  55. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/UserMenuViewComponent.cs
  56. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs
  57. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs
  58. 10
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/AbpViewComponentHelper.cs
  59. 6
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetManager.cs
  60. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
  61. 15
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  62. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs
  63. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
  64. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs
  65. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs
  66. 6
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeatureActionFilter.cs
  67. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs
  68. 31
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Response/AbpNoContentActionFilter.cs
  69. 14
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs
  70. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs
  71. 4
      framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationMiddleware.cs
  72. 6
      framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs
  73. 6
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs
  74. 6
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingMiddleware.cs
  75. 2
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs
  76. 4
      framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Uow/AbpUnitOfWorkMiddleware.cs
  77. 4
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs
  78. 4
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs
  79. 38
      framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs
  80. 2
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs
  81. 6
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptor.cs
  82. 4
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/MethodInvocationAuthorizationService.cs
  83. 2
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/PermissionRequirementHandler.cs
  84. 2
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs
  85. 4
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs
  86. 2
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RolePermissionValueProvider.cs
  87. 2
      framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/UserPermissionValueProvider.cs
  88. 5
      framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/BackgroundJobExecuter.cs
  89. 6
      framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/IBackgroundJobExecuter.cs
  90. 3
      framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/HangfireJobExecutionAdapter.cs
  91. 13
      framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueue.cs
  92. 8
      framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs
  93. 4
      framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/RabbitMqBackgroundJobManager.cs
  94. 93
      framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs
  95. 4
      framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/DefaultBackgroundJobManager.cs
  96. 55
      framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AsyncPeriodicBackgroundWorkerBase.cs
  97. 14
      framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerContext.cs
  98. 4
      framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerManager.cs
  99. 26
      framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/PeriodicBackgroundWorkerBase.cs
  100. 18
      framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs

2
abp_io/AbpIoLocalization/AbpIoLocalization/AbpIoLocalization.csproj

@ -5,7 +5,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\..\framework\src\Volo.Abp.Localization\Volo.Abp.Localization.csproj" /> <ProjectReference Include="..\..\..\framework\src\Volo.Abp.Validation\Volo.Abp.Validation.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

5
abp_io/AbpIoLocalization/AbpIoLocalization/AbpIoLocalizationModule.cs

@ -8,13 +8,14 @@ using AbpIoLocalization.Support.Localization;
using AbpIoLocalization.Www; using AbpIoLocalization.Www;
using Volo.Abp.Localization; using Volo.Abp.Localization;
using Volo.Abp.Localization.ExceptionHandling; using Volo.Abp.Localization.ExceptionHandling;
using Volo.Abp.Localization.Resources.AbpValidation;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Validation;
using Volo.Abp.Validation.Localization;
using Volo.Abp.VirtualFileSystem; using Volo.Abp.VirtualFileSystem;
namespace AbpIoLocalization namespace AbpIoLocalization
{ {
[DependsOn(typeof(AbpLocalizationModule))] [DependsOn(typeof(AbpValidationModule))]
public class AbpIoLocalizationModule : AbpModule public class AbpIoLocalizationModule : AbpModule
{ {
public override void ConfigureServices(ServiceConfigurationContext context) public override void ConfigureServices(ServiceConfigurationContext context)

0
docs/cs/EntityFrameworkCore-PostgreSQL-Integration.md → docs/cs/Entity-Framework-Core-PostgreSQL.md

2
docs/cs/docs-nav.json

@ -264,7 +264,7 @@
"items": [ "items": [
{ {
"text": "PostgreSQL integrace", "text": "PostgreSQL integrace",
"path": "EntityFrameworkCore-PostgreSQL-Integration.md" "path": "Entity-Framework-Core-PostgreSQL.md"
} }
] ]
}, },

2
docs/en/Best-Practices/Index.md

@ -23,5 +23,5 @@ Also, this guide is mostly usable for general **application development**.
* [Data Transfer Objects](Data-Transfer-Objects.md) * [Data Transfer Objects](Data-Transfer-Objects.md)
* Data Access * Data Access
* [Entity Framework Core Integration](Entity-Framework-Core-Integration.md) * [Entity Framework Core Integration](Entity-Framework-Core-Integration.md)
* [MongoDB Integration](MongoDB-Integration.md) * [MongoDB Integration](MongoDB-Integration.md)

67
docs/en/Connection-Strings.md

@ -1,11 +1,64 @@
# Data Access # Connection Strings
ABP framework was designed as database agnostic, it can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. ABP Framework is designed to be [modular](Module-Development-Basics.md), [microservice compatible](Microservice-Architecture.md) and [multi-tenancy](Multi-Tenancy.md) aware. Connection string management is also designed to support these scenarios;
However, currently the following providers are implements: * Allows to set separate connection strings for every module, so every module can have its own physical database. Modules even might be configured to use different DBMSs.
* Allows to set separate connection string and use a separate database per tenant (in a SaaS application).
* [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli).) It also supports hybrid scenarios;
* [MongoDB](MongoDB.md)
* [Dapper](Dapper.md)
More providers might be added in the next releases. * Allows to group modules into databases (all modules into a single shared database, 2 modules to database A, 3 modules to database B, 1 module to database C and rest of the modules to database D... etc.)
* Allows to group tenants into databases, just like the modules.
* Allows to separate databases per tenant per module (which might be harder to maintain for you because of too many databases, but the ABP framework supports it).
All the [pre-built application modules](Modules/Index.md) are designed to be compatible these scenarios.
## Configure the Connection Strings
See the following configuration:
````json
"ConnectionStrings": {
"Default": "Server=localhost;Database=MyMainDb;Trusted_Connection=True;",
"AbpIdentityServer": "Server=localhost;Database=MyIdsDb;Trusted_Connection=True;",
"AbpPermissionManagement": "Server=localhost;Database=MyPermissionDb;Trusted_Connection=True;"
}
````
> ABP uses the `IConfiguration` service to get the application configuration. While the simplest way to write configuration into the `appsettings.json` file, it is not limited to this file. You can use environment variables, user secrets, Azure Key Vault... etc. See the [configuration](Configuration.md) document for more.
This configuration defines three different connection strings:
* `MyMainDb` (the `Default` connection string) is the main connection string of the application. If you don't specify a connection string for a module, it fallbacks to the `Default` connection string. The [application startup template](Startup-Templates/Application.md) is configured to use a single connection string, so all the modules uses a single shared database.
* `MyIdsDb` is used by the [IdentityServer](Modules/IdentityServer.md) module.
* `MyPermissionDb` is used by the [Permission Management](Modules/Permission-Management.md) module.
[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.
## Set the Connection String Name
A module typically has a unique connection string name associated to its `DbContext` class using the `ConnectionStringName` attribute. Example:
````csharp
[ConnectionStringName("AbpIdentityServer")]
public class IdentityServerDbContext
: AbpDbContext<IdentityServerDbContext>, IIdentityServerDbContext
{
}
````
For [Entity Framework Core](Entity-Framework-Core.md) and [MongoDB](MongoDB.md), write this to your `DbContext` class (and the interface if it has).
> If you are developing a reusable, database provider independent module see also [the best practices guide](Best-Practices/Index.md).
## Database Migrations for the Entity Framework Core
Relational databases require to create the database and the database schema (tables, views... etc.) before using it.
The startup template (with EF Core ORM) comes with a single database and a `.EntityFrameworkCore.DbMigrations` project that contains the migration files for that database. This project mainly defines a *YourProjectName*MigrationsDbContext that calls the `Configure...()` methods of the used modules, like `builder.ConfigurePermissionManagement()`.
Once you want to separate a module's database, you typically will need to create a second migration path. The easiest way to create a copy of the `.EntityFrameworkCore.DbMigrations` project with the `DbContext` inside it, change its content to only call the `Configure...()` methods of the modules needs to be stored in the second database and re-create the initial migration. In this case, you also need to change the `.DbMigrator` application to be able to work with these second database too. In this way, you will have a separate migrations DbContext per database.
## Multi-Tenancy
See [the multi-tenancy document](Multi-Tenancy.md) to learn how to use separate databases for tenants.

12
docs/en/Data-Access.md

@ -1,11 +1,15 @@
# Data Access # Data Access
ABP framework was designed as database agnostic, it can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. ## Database Providers
However, currently the following providers are implements: ABP framework was designed as database agnostic. It can work any type of data source by the help of the [repository](Repositories.md) and [unit of work](Unit-Of-Work.md) abstractions. However, currently the following providers are implemented:
* [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/?tabs=dotnet-core-cli).) * [Entity Framework Core](Entity-Framework-Core.md) (works with [various DBMS and providers](https://docs.microsoft.com/en-us/ef/core/providers/).)
* [MongoDB](MongoDB.md) * [MongoDB](MongoDB.md)
* [Dapper](Dapper.md) * [Dapper](Dapper.md)
More providers might be added in the next releases. More providers will be added in the future.
## See Also
* [Connection Strings](Connection-Strings.md)

58
docs/en/Entity-Framework-Core-MySQL.md

@ -0,0 +1,58 @@
# Switch to EF Core MySQL Provider
This document explains how to switch to the **MySQL** database provider for **[the application startup template](Startup-Templates/Application.md)** which comes with SQL Server provider pre-configured.
## Replace the Volo.Abp.EntityFrameworkCore.SqlServer Package
`.EntityFrameworkCore` project in the solution depends on the [Volo.Abp.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.SqlServer) NuGet package. Remove this package and add the same version of the [Volo.Abp.EntityFrameworkCore.MySQL](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.MySQL) package.
## Replace the Module Dependency
Find ***YourProjectName*EntityFrameworkCoreModule** class inside the `.EntityFrameworkCore` project, remove `typeof(AbpEntityFrameworkCoreSqlServerModule)` from the `DependsOn` attribute, add `typeof(AbpEntityFrameworkCoreMySQLModule)` (also replace `using Volo.Abp.EntityFrameworkCore.SqlServer;` with `using Volo.Abp.EntityFrameworkCore.MySQL;`).
## UseMySQL()
Find `UseSqlServer()` calls in your solution, replace with `UseMySQL()`. Check the following files:
* *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.
## 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.

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

@ -0,0 +1,41 @@
# Switch to EF Core PostgreSQL Provider
This document explains how to switch to the **PostgreSQL** database provider for **[the application startup template](Startup-Templates/Application.md)** which comes with SQL Server provider pre-configured.
## Replace the Volo.Abp.EntityFrameworkCore.SqlServer Package
`.EntityFrameworkCore` project in the solution depends on the [Volo.Abp.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.SqlServer) NuGet package. Remove this package and add the same version of the [Volo.Abp.EntityFrameworkCore.PostgreSql](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.PostgreSql) package.
## Replace the Module Dependency
Find ***YourProjectName*EntityFrameworkCoreModule** class inside the `.EntityFrameworkCore` project, remove `typeof(AbpEntityFrameworkCoreSqlServerModule)` from the `DependsOn` attribute, add `typeof(AbpEntityFrameworkCorePostgreSqlModule)` (also replace `using Volo.Abp.EntityFrameworkCore.SqlServer;` with `using Volo.Abp.EntityFrameworkCore.PostgreSql;`).
## UsePostgreSql()
Find `UseSqlServer()` calls in your solution, replace with `UsePostgreSql()`. Check the following files:
* *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.
## Change the Connection Strings
PostgreSql 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/postgresql/ ) for details of PostgreSql connection string options.
You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure.
## 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.

41
docs/en/Entity-Framework-Core-SQLite.md

@ -0,0 +1,41 @@
# Switch to EF Core SQLite Provider
This document explains how to switch to the **SQLite** database provider for **[the application startup template](Startup-Templates/Application.md)** which comes with SQL Server provider pre-configured.
## Replace the Volo.Abp.EntityFrameworkCore.SqlServer Package
`.EntityFrameworkCore` project in the solution depends on the [Volo.Abp.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.SqlServer) NuGet package. Remove this package and add the same version of the [Volo.Abp.EntityFrameworkCore.Sqlite](https://www.nuget.org/packages/Volo.Abp.EntityFrameworkCore.Sqlite) package.
## Replace the Module Dependency
Find ***YourProjectName*EntityFrameworkCoreModule** class inside the `.EntityFrameworkCore` project, remove `typeof(AbpEntityFrameworkCoreSqlServerModule)` from the `DependsOn` attribute, add `typeof(AbpEntityFrameworkCoreSqliteModule)` (also replace `using Volo.Abp.EntityFrameworkCore.SqlServer;` with `using Volo.Abp.EntityFrameworkCore.Sqlite;`).
## UseSqlite()
Find `UseSqlServer()` calls in your solution, replace with `UseSqlite()`. Check the following files:
* *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.
## Change the Connection Strings
SQLite 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/sqlite/ ) for details of SQLite connection string options.
You typically will change the `appsettings.json` inside the `.DbMigrator` and `.Web` projects, but it depends on your solution structure.
## 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.

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

@ -28,6 +28,17 @@ namespace MyCompany.MyProject
> Note: Instead, you can directly download a [startup template](https://abp.io/Templates) with EF Core pre-installed. > Note: Instead, you can directly download a [startup template](https://abp.io/Templates) with EF Core pre-installed.
### Database Management System Selection
Entity Framework Core supports various database management systems ([see all](https://docs.microsoft.com/en-us/ef/core/providers/)). ABP framework and this document doesn't depend on any specific DBMS.
If you are creating a reusable library, avoid to depend on a specific DBMS package. However, in a final application you eventually will select a DBMS.
ABP framework provides integration packages for some common DBMSs to make the configuration a bit easier. [The startup templates](Startup-Templates/Index.md) come with **SQL Server (localdb) pre-configured**. See the following documents to learn how to configure for the other DBMS providers:
* [MySQL](Entity-Framework-Core-MySQL.md)
* [PostgreSQL](Entity-Framework-Core-PostgreSQL.md)
## Creating DbContext ## Creating DbContext
You can create your DbContext as you normally do. It should be derived from `AbpDbContext<T>` as shown below: You can create your DbContext as you normally do. It should be derived from `AbpDbContext<T>` as shown below:
@ -62,7 +73,7 @@ public class MyDbContext : AbpDbContext<MyDbContext>
} }
``` ```
If you don't configure, the `Default` connection string is used. If you configure a specific connection string name, but not define this connection string name in the application configuration then it fallbacks to the `Default` connection string. If you don't configure, the `Default` connection string is used. If you configure a specific connection string name, but not define this connection string name in the application configuration then it fallbacks to the `Default` connection string (see [the connection strings document](Connection-Strings.md) for more information).
## Registering DbContext To Dependency Injection ## Registering DbContext To Dependency Injection
@ -126,7 +137,8 @@ public class BookManager : DomainService
{ {
private readonly IRepository<Book, Guid> _bookRepository; private readonly IRepository<Book, Guid> _bookRepository;
public BookManager(IRepository<Book, Guid> bookRepository) //inject default repository //inject default repository to the constructor
public BookManager(IRepository<Book, Guid> bookRepository)
{ {
_bookRepository = bookRepository; _bookRepository = bookRepository;
} }
@ -142,7 +154,8 @@ public class BookManager : DomainService
Type = type Type = type
}; };
await _bookRepository.InsertAsync(book); //Use a standard repository method //Use a standard repository method
await _bookRepository.InsertAsync(book);
return book; return book;
} }
@ -153,9 +166,9 @@ This sample uses `InsertAsync` method to insert a new entity to the database.
### Add Custom Repositories ### Add Custom Repositories
Default generic repositories are powerful enough in most cases (since they implement `IQueryable`). However, you may need to create a custom repository to add your own repository methods. Default generic repositories are powerful enough in most cases (since they implement `IQueryable`). However, you may need to create a custom repository to add your own repository methods. Assume that you want to delete all books by type.
Assume that you want to delete all books by type. It's suggested to define an interface for your custom repository: It's suggested to define an interface for your custom repository:
````csharp ````csharp
public interface IBookRepository : IRepository<Book, Guid> public interface IBookRepository : IRepository<Book, Guid>
@ -187,21 +200,23 @@ public class BookRepository : EfCoreRepository<BookStoreDbContext, Book, Guid>,
Now, it's possible to [inject](Dependency-Injection.md) the `IBookRepository` and use the `DeleteBooksByType` method when needed. Now, it's possible to [inject](Dependency-Injection.md) the `IBookRepository` and use the `DeleteBooksByType` method when needed.
#### Override Default Generic Repository #### Override the Default Generic Repository
Even if you create a custom repository, you can still inject the default generic repository (`IRepository<Book, Guid>` for this example). Default repository implementation will not use the class you have created. Even if you create a custom repository, you can still inject the default generic repository (`IRepository<Book, Guid>` for this example). Default repository implementation will not use the class you have created.
If you want to replace default repository implementation with your custom repository, do it inside `AddAbpDbContext` options: If you want to replace default repository implementation with your custom repository, do it inside the `AddAbpDbContext` options:
````csharp ````csharp
context.Services.AddAbpDbContext<BookStoreDbContext>(options => context.Services.AddAbpDbContext<BookStoreDbContext>(options =>
{ {
options.AddDefaultRepositories(); options.AddDefaultRepositories();
options.AddRepository<Book, BookRepository>(); //Replaces IRepository<Book, Guid>
//Replaces IRepository<Book, Guid>
options.AddRepository<Book, BookRepository>();
}); });
```` ````
This is especially important when you want to **override a base repository method** to customize it. For instance, you may want to override `DeleteAsync` method to delete an entity in a more efficient way: This is especially important when you want to **override a base repository method** to customize it. For instance, you may want to override `DeleteAsync` method to delete a specific entity in a more efficient way:
````csharp ````csharp
public override async Task DeleteAsync( public override async Task DeleteAsync(
@ -215,7 +230,7 @@ public override async Task DeleteAsync(
### Access to the EF Core API ### Access to the EF Core API
In most cases, you want to hide EF Core APIs behind a repository (this is the main purpose of the repository). However, if you want to access the DbContext instance over the repository, you can use `GetDbContext()` or `GetDbSet()` extension methods. Example: In most cases, you want to hide EF Core APIs behind a repository (this is the main purpose of the repository pattern). However, if you want to access the `DbContext` instance over the repository, you can use `GetDbContext()` or `GetDbSet()` extension methods. Example:
````csharp ````csharp
public class BookService public class BookService
@ -243,9 +258,9 @@ public class BookService
#### Set Default Repository Classes #### Set Default Repository Classes
Default generic repositories are implemented by `EfCoreRepository` class by default. You can create your own implementation and use it for default repository implementation. Default generic repositories are implemented by `EfCoreRepository` class by default. You can create your own implementation and use it for all the default repository implementations.
First, define your repository classes like that: First, define your default repository classes like that:
```csharp ```csharp
public class MyRepositoryBase<TEntity> public class MyRepositoryBase<TEntity>
@ -271,7 +286,7 @@ public class MyRepositoryBase<TEntity, TKey>
First one is for [entities with composite keys](Entities.md), second one is for entities with single primary key. First one is for [entities with composite keys](Entities.md), second one is for entities with single primary key.
It's suggested to inherit from the `EfCoreRepository` class and override methods if needed. Otherwise, you will have to implement all standard repository methods manually. It's suggested to inherit from the `EfCoreRepository` class and override methods if needed. Otherwise, you will have to implement all the standard repository methods manually.
Now, you can use `SetDefaultRepositoryClasses` option: Now, you can use `SetDefaultRepositoryClasses` option:
@ -282,6 +297,7 @@ context.Services.AddAbpDbContext<BookStoreDbContext>(options =>
typeof(MyRepositoryBase<,>), typeof(MyRepositoryBase<,>),
typeof(MyRepositoryBase<>) typeof(MyRepositoryBase<>)
); );
//... //...
}); });
``` ```
@ -316,7 +332,7 @@ public class BookRepository : EfCoreRepository<IBookStoreDbContext, Book, Guid>,
} }
```` ````
One advantage of using interface for a DbContext is then it becomes replaceable by another implementation. One advantage of using an interface for a DbContext is then it will be replaceable by another implementation.
#### Replace Other DbContextes #### Replace Other DbContextes

73
docs/en/EntityFrameworkCore-PostgreSQL-Integration.md

@ -1,73 +0,0 @@
## Entity Framework Core PostgreSQL Integration
> See [Entity Framework Core Integration document](../Entity-Framework-Core.md) for the basics of the EF Core integration.
### EntityFrameworkCore Project Update
- In `Acme.BookStore.EntityFrameworkCore` project replace package `Volo.Abp.EntityFrameworkCore.SqlServer` with `Volo.Abp.EntityFrameworkCore.PostgreSql`
- Update to use PostgreSQL in `BookStoreEntityFrameworkCoreModule`
- Replace the `AbpEntityFrameworkCoreSqlServerModule` with the `AbpEntityFrameworkCorePostgreSqlModule`
- Replace the `options.UseSqlServer()` with the `options.UsePostgreSql()`
- In other projects update the PostgreSQL connection string in necessary `appsettings.json` files
- more info of [PostgreSQL connection strings](https://www.connectionstrings.com/postgresql/),You need to pay attention to `Npgsql` in this document
### EntityFrameworkCore.DbMigrations Project Update
- Update to use PostgreSQL in `XXXMigrationsDbContextFactory`
- Replace the `new DbContextOptionsBuilder<XXXMigrationsDbContext>().UseSqlServer()` with the `new DbContextOptionsBuilder<XXXMigrationsDbContext>().UseNpgsql()`
### Delete Existing Migrations
Delete all existing migration files (including `DbContextModelSnapshot`)
![postgresql-delete-initial-migrations](images/postgresql-delete-initial-migrations.png)
### Regenerate Initial Migration
Set the correct startup project (usually a web project)
![set-as-startup-project](../images/set-as-startup-project.png)
Open the **Package Manager Console** (Tools -> Nuget Package Manager -> Package Manager Console), select the `.EntityFrameworkCore.DbMigrations` as the **Default project** and execute the following command:
Run `Add-Migration` command.
````
PM> Add-Migration Initial
````
### Update the Database
You have two options to create the database.
#### Using the DbMigrator Application
The solution contains a console application (named `Acme.BookStore.DbMigrator` in this sample) that can create database, apply migrations and seed initial data. It is useful on development as well as on production environment.
> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one.
Right click to the `.DbMigrator` project and select **Set as StartUp Project**:
![set-as-startup-project](../images/set-as-startup-project.png)
Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below:
![set-as-startup-project](../images/db-migrator-app.png)
#### Using EF Core Update-Database Command
Ef Core has `Update-Database` command which creates database if necessary and applies pending migrations.
Set the correct startup project (usually a web project)
![set-as-startup-project](../images/set-as-startup-project.png)
Open the **Package Manager Console** (Tools -> Nuget Package Manager -> Package Manager Console), select the `.EntityFrameworkCore.DbMigrations` as the **Default project** and execute the following command:
````
PM> Update-Database
````
This will create a new database based on the configured connection string.
![postgresql-update-database](images/postgresql-update-database.png)
> Using the `.DbMigrator` tool is the suggested way, because it also seeds the initial data to be able to properly run the web application.

4
docs/en/Modules/Docs.md

@ -501,6 +501,10 @@ You can also use variables in a text, adding **_Value** postfix to its key:
This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider. This document assumes that you prefer to use **{{ UI_Value }}** as the UI framework and **{{ DB_Value }}** as the database provider.
```` ````
Also, **Document_Language_Code** and **Document_Version** keys are pre-defined if you want to get the language code or the version of the current document (This may be useful for creating links that redirects to another documentation system in another domain).
------
**IMPORTANT NOTICE**: Scriban uses "{{" and "}}" for syntax. Therefore, you must use escape blocks if you are going to use those in your document (an Angular document, for example). See [Scriban docs](<https://github.com/lunet-io/scriban/blob/master/doc/language.md#13-escape-block> ) for more information. **IMPORTANT NOTICE**: Scriban uses "{{" and "}}" for syntax. Therefore, you must use escape blocks if you are going to use those in your document (an Angular document, for example). See [Scriban docs](<https://github.com/lunet-io/scriban/blob/master/doc/language.md#13-escape-block> ) for more information.
### 8- Creating the Navigation Document ### 8- Creating the Navigation Document

3
docs/en/Modules/IdentityServer.md

@ -0,0 +1,3 @@
# IdentityServer Module
TODO

2
docs/en/Modules/Index.md

@ -17,7 +17,7 @@ There are some **free and open source** application modules developed and mainta
* **Blogging**: Used to create fancy blogs. ABP's [own blog](https://abp.io/blog/abp/) already using this module. * **Blogging**: Used to create fancy blogs. ABP's [own blog](https://abp.io/blog/abp/) already using this module.
* [**Docs**](Docs.md): Used to create technical documentation pages. ABP's [own documentation](https://docs.abp.io) already using this module. * [**Docs**](Docs.md): Used to create technical documentation pages. ABP's [own documentation](https://docs.abp.io) already using this module.
* **Identity**: Used to manage roles, users and their permissions. * **Identity**: Used to manage roles, users and their permissions.
* **Identity Server**: Integrates to IdentityServer4. * **IdentityServer**: Integrates to IdentityServer4.
* **Permission Management**: Used to persist permissions. * **Permission Management**: Used to persist permissions.
* **[Setting Management](Setting-Management.md)**: Used to persist and manage the [settings](../Settings.md). * **[Setting Management](Setting-Management.md)**: Used to persist and manage the [settings](../Settings.md).
* **Tenant Management**: Used to manage tenants for a [multi-tenant](../Multi-Tenancy.md) application. * **Tenant Management**: Used to manage tenants for a [multi-tenant](../Multi-Tenancy.md) application.

45
docs/en/docs-nav.json

@ -257,25 +257,42 @@
}, },
{ {
"text": "Data Access", "text": "Data Access",
"path": "Data-Access.md", "path": "Data-Access.md",
"items": [ "items": [
{ {
"text": "Entity Framework Core Integration", "text": "Connection Strings",
"path": "Entity-Framework-Core.md", "path": "Connection-Strings.md"
"items": [ },
{
"text": "Database Providers",
"items": [
{
"text": "Entity Framework Core",
"path": "Entity-Framework-Core.md",
"items": [
{
"text": "Switch to MySQL",
"path": "Entity-Framework-Core-MySQL.md"
},
{
"text": "Switch to PostgreSQL",
"path": "Entity-Framework-Core-PostgreSQL.md"
},
{
"text": "Switch to SQLite",
"path": "Entity-Framework-Core-SQLite.md"
}
]
},
{ {
"text": "PostgreSQL Integration", "text": "MongoDB",
"path": "EntityFrameworkCore-PostgreSQL-Integration.md" "path": "MongoDB.md"
},
{
"text": "Dapper",
"path": "Dapper.md"
} }
] ]
},
{
"text": "MongoDB Integration",
"path": "MongoDB.md"
},
{
"text": "Dapper Integration",
"path": "Dapper.md"
} }
] ]
}, },

2
docs/pt-BR/docs-nav.json

@ -249,7 +249,7 @@
"items": [ "items": [
{ {
"text": "Integração do PostgreSQL", "text": "Integração do PostgreSQL",
"path": "EntityFrameworkCore-PostgreSQL-Integration.md" "path": "Entity-Framework-Core-PostgreSQL.md"
} }
] ]
}, },

0
docs/zh-Hans/EntityFrameworkCore-PostgreSQL-Integration.md → docs/zh-Hans/Entity-Framework-Core-PostgreSQL.md

2
docs/zh-Hans/docs-nav.json

@ -254,7 +254,7 @@
"items": [ "items": [
{ {
"text": "PostgreSQL 集成", "text": "PostgreSQL 集成",
"path": "EntityFrameworkCore-PostgreSQL-Integration.md" "path": "Entity-Framework-Core-PostgreSQL.md"
} }
] ]
}, },

4
framework/src/Volo.Abp.AspNetCore.Authentication.JwtBearer/Microsoft/AspNetCore/Builder/JwtTokenMiddleware.cs

@ -11,14 +11,14 @@ namespace Microsoft.AspNetCore.Builder
{ {
if (ctx.User.Identity?.IsAuthenticated != true) if (ctx.User.Identity?.IsAuthenticated != true)
{ {
var result = await ctx.AuthenticateAsync(schema); var result = await ctx.AuthenticateAsync(schema).ConfigureAwait(false);
if (result.Succeeded && result.Principal != null) if (result.Succeeded && result.Principal != null)
{ {
ctx.User = result.Principal; ctx.User = result.Principal;
} }
} }
await next(); await next().ConfigureAwait(false);
}); });
} }
} }

8
framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs

@ -33,7 +33,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
TenantConfiguration tenant = null; TenantConfiguration tenant = null;
if (resolveResult.TenantIdOrName != null) if (resolveResult.TenantIdOrName != null)
{ {
tenant = await FindTenantAsync(resolveResult.TenantIdOrName); tenant = await FindTenantAsync(resolveResult.TenantIdOrName).ConfigureAwait(false);
if (tenant == null) if (tenant == null)
{ {
//TODO: A better exception? //TODO: A better exception?
@ -45,7 +45,7 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
using (_currentTenant.Change(tenant?.Id, tenant?.Name)) using (_currentTenant.Change(tenant?.Id, tenant?.Name))
{ {
await next(context); await next(context).ConfigureAwait(false);
} }
} }
@ -53,11 +53,11 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
{ {
if (Guid.TryParse(tenantIdOrName, out var parsedTenantId)) if (Guid.TryParse(tenantIdOrName, out var parsedTenantId))
{ {
return await _tenantStore.FindAsync(parsedTenantId); return await _tenantStore.FindAsync(parsedTenantId).ConfigureAwait(false);
} }
else else
{ {
return await _tenantStore.FindAsync(tenantIdOrName); return await _tenantStore.FindAsync(tenantIdOrName).ConfigureAwait(false);
} }
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/CachedApplicationConfigurationClient.cs

@ -43,12 +43,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
configuration = await Cache.GetOrAddAsync( configuration = await Cache.GetOrAddAsync(
cacheKey, cacheKey,
async () => await Proxy.Service.GetAsync(), async () => await Proxy.Service.GetAsync().ConfigureAwait(false),
() => new DistributedCacheEntryOptions () => new DistributedCacheEntryOptions
{ {
AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(120) //TODO: Should be configurable. Default value should be higher (5 mins would be good). AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(120) //TODO: Should be configurable. Default value should be higher (5 mins would be good).
} }
); ).ConfigureAwait(false);
if (httpContext != null) if (httpContext != null)
{ {

2
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteFeatureChecker.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public override async Task<string> GetOrNullAsync(string name) public override async Task<string> GetOrNullAsync(string name)
{ {
var configuration = await ConfigurationClient.GetAsync(); var configuration = await ConfigurationClient.GetAsync().ConfigureAwait(false);
return configuration.Features.Values.GetOrDefault(name); return configuration.Features.Values.GetOrDefault(name);
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteLanguageProvider.cs

@ -16,7 +16,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public async Task<IReadOnlyList<LanguageInfo>> GetLanguagesAsync() public async Task<IReadOnlyList<LanguageInfo>> GetLanguagesAsync()
{ {
var configuration = await ConfigurationClient.GetAsync(); var configuration = await ConfigurationClient.GetAsync().ConfigureAwait(false);
return configuration.Localization.Languages; return configuration.Localization.Languages;
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemotePermissionChecker.cs

@ -16,7 +16,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public async Task<bool> IsGrantedAsync(string name) public async Task<bool> IsGrantedAsync(string name)
{ {
var configuration = await ConfigurationClient.GetAsync(); var configuration = await ConfigurationClient.GetAsync().ConfigureAwait(false);
return configuration.Auth.GrantedPolicies.ContainsKey(name); return configuration.Auth.GrantedPolicies.ContainsKey(name);
} }
@ -24,7 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public async Task<bool> IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name) public async Task<bool> IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name)
{ {
/* This provider always works for the current principal. */ /* This provider always works for the current principal. */
return await IsGrantedAsync(name); return await IsGrantedAsync(name).ConfigureAwait(false);
} }
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteSettingProvider.cs

@ -17,13 +17,13 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
public async Task<string> GetOrNullAsync(string name) public async Task<string> GetOrNullAsync(string name)
{ {
var configuration = await ConfigurationClient.GetAsync(); var configuration = await ConfigurationClient.GetAsync().ConfigureAwait(false);
return configuration.Setting.Values.GetOrDefault(name); return configuration.Setting.Values.GetOrDefault(name);
} }
public async Task<List<SettingValue>> GetAllAsync() public async Task<List<SettingValue>> GetAllAsync()
{ {
var configuration = await ConfigurationClient.GetAsync(); var configuration = await ConfigurationClient.GetAsync().ConfigureAwait(false);
return configuration return configuration
.Setting.Values .Setting.Values
.Select(s => new SettingValue(s.Key, s.Value)) .Select(s => new SettingValue(s.Key, s.Value))

12
framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/RemoteTenantStore.cs

@ -39,13 +39,13 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = await Cache.GetOrAddAsync( tenantConfiguration = await Cache.GetOrAddAsync(
cacheKey, cacheKey,
async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name)), async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name).ConfigureAwait(false)),
() => new DistributedCacheEntryOptions () => new DistributedCacheEntryOptions
{ {
AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow =
TimeSpan.FromMinutes(5) //TODO: Should be configurable. TimeSpan.FromMinutes(5) //TODO: Should be configurable.
} }
); ).ConfigureAwait(false);
if (httpContext != null) if (httpContext != null)
{ {
@ -67,13 +67,13 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = await Cache.GetOrAddAsync( tenantConfiguration = await Cache.GetOrAddAsync(
cacheKey, cacheKey,
async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id)), async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id).ConfigureAwait(false)),
() => new DistributedCacheEntryOptions () => new DistributedCacheEntryOptions
{ {
AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow =
TimeSpan.FromMinutes(5) //TODO: Should be configurable. TimeSpan.FromMinutes(5) //TODO: Should be configurable.
} }
); ).ConfigureAwait(false);
if (httpContext != null) if (httpContext != null)
{ {
@ -95,7 +95,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = Cache.GetOrAdd( tenantConfiguration = Cache.GetOrAdd(
cacheKey, cacheKey,
() => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name))), () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name).ConfigureAwait(false))),
() => new DistributedCacheEntryOptions () => new DistributedCacheEntryOptions
{ {
AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow =
@ -123,7 +123,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
tenantConfiguration = Cache.GetOrAdd( tenantConfiguration = Cache.GetOrAdd(
cacheKey, cacheKey,
() => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id))), () => AsyncHelper.RunSync(async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id).ConfigureAwait(false))),
() => new DistributedCacheEntryOptions () => new DistributedCacheEntryOptions
{ {
AbsoluteExpirationRelativeToNow = AbsoluteExpirationRelativeToNow =

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Breadcrumb/AbpBreadcrumbTagHelperService.cs

@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Breadcrumb
{ {
var list = InitilizeFormGroupContentsContext(context, output); var list = InitilizeFormGroupContentsContext(context, output);
await output.GetChildContentAsync(); await output.GetChildContentAsync().ConfigureAwait(false);
SetInnerOlTag(context, output); SetInnerOlTag(context, output);
SetInnerList(context, output, list); SetInnerList(context, output, list);

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Carousel/AbpCarouselTagHelperService.cs

@ -19,7 +19,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Carousel
var itemList = InitilizeCarouselItemsContentsContext(context, output); var itemList = InitilizeCarouselItemsContentsContext(context, output);
await output.GetChildContentAsync(); await output.GetChildContentAsync().ConfigureAwait(false);
SetOneItemAsActive(context, output, itemList); SetOneItemAsActive(context, output, itemList);
SetItems(context, output, itemList); SetItems(context, output, itemList);

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionItemTagHelperService.cs

@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
{ {
SetRandomIdIfNotProvided(); SetRandomIdIfNotProvided();
var innerContent = (await output.GetChildContentAsync()).GetContent(); var innerContent = (await output.GetChildContentAsync().ConfigureAwait(false)).GetContent();
var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, innerContent); var html = GetAccordionHeaderItem(context, output) + GetAccordionContentItem(context, output, innerContent);

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpAccordionTagHelperService.cs

@ -20,7 +20,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
var items = InitilizeFormGroupContentsContext(context, output); var items = InitilizeFormGroupContentsContext(context, output);
await output.GetChildContentAsync(); await output.GetChildContentAsync().ConfigureAwait(false);
var content = GetContent(items); var content = GetContent(items);

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Collapse/AbpCollapseBodyTagHelperService.cs

@ -22,7 +22,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Collapse
output.Attributes.AddClass("multi-collapse"); output.Attributes.AddClass("multi-collapse");
} }
var innerContent = (await output.GetChildContentAsync()).GetContent(); var innerContent = (await output.GetChildContentAsync().ConfigureAwait(false)).GetContent();
output.Content.SetHtmlContent(innerContent); output.Content.SetHtmlContent(innerContent);
} }

12
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Dropdown/AbpDropdownButtonTagHelperService.cs

@ -26,9 +26,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{ {
var content = await output.GetChildContentAsync(); var content = await output.GetChildContentAsync().ConfigureAwait(false);
var buttonsAsHtml = await GetButtonsAsHtmlAsync(context, output, content); var buttonsAsHtml = await GetButtonsAsHtmlAsync(context, output, content).ConfigureAwait(false);
output.PreElement.SetHtmlContent(buttonsAsHtml); output.PreElement.SetHtmlContent(buttonsAsHtml);
@ -43,13 +43,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown
{ {
var buttonBuilder = new StringBuilder(""); var buttonBuilder = new StringBuilder("");
var mainButton = await GetMainButtonAsync(context, output, content); var mainButton = await GetMainButtonAsync(context, output, content).ConfigureAwait(false);
buttonBuilder.AppendLine(mainButton); buttonBuilder.AppendLine(mainButton);
if (TagHelper.DropdownStyle == DropdownStyle.Split) if (TagHelper.DropdownStyle == DropdownStyle.Split)
{ {
var splitButton = await GetSplitButtonAsync(context, output); var splitButton = await GetSplitButtonAsync(context, output).ConfigureAwait(false);
buttonBuilder.AppendLine(splitButton); buttonBuilder.AppendLine(splitButton);
} }
@ -68,7 +68,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown
abpButtonTagHelper.ButtonType = TagHelper.ButtonType; abpButtonTagHelper.ButtonType = TagHelper.ButtonType;
var attributes = GetAttributesForMainButton(context, output); var attributes = GetAttributesForMainButton(context, output);
var buttonTag = await abpButtonTagHelper.ProcessAndGetOutputAsync(attributes, context, "button", TagMode.StartTagAndEndTag); var buttonTag = await abpButtonTagHelper.ProcessAndGetOutputAsync(attributes, context, "button", TagMode.StartTagAndEndTag).ConfigureAwait(false);
buttonTag.PreContent.SetHtmlContent(content.GetContent()); buttonTag.PreContent.SetHtmlContent(content.GetContent());
@ -89,7 +89,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Dropdown
abpButtonTagHelper.ButtonType = TagHelper.ButtonType; abpButtonTagHelper.ButtonType = TagHelper.ButtonType;
var attributes = GetAttributesForSplitButton(context, output); var attributes = GetAttributesForSplitButton(context, output);
return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag); return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual TagHelperAttributeList GetAttributesForMainButton(TagHelperContext context, TagHelperOutput output) protected virtual TagHelperAttributeList GetAttributesForMainButton(TagHelperContext context, TagHelperOutput output)

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Extensions/TagHelperExtensions.cs

@ -19,14 +19,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Extensions
tagHelper.Init(context); tagHelper.Init(context);
await tagHelper.ProcessAsync(innerContext, innerOutput); await tagHelper.ProcessAsync(innerContext, innerOutput).ConfigureAwait(false);
return innerOutput; return innerOutput;
} }
public static async Task<string> RenderAsync(this TagHelper tagHelper, TagHelperAttributeList attributeList, TagHelperContext context, HtmlEncoder htmlEncoder, string tagName = "div", TagMode tagMode = TagMode.SelfClosing) public static async Task<string> RenderAsync(this TagHelper tagHelper, TagHelperAttributeList attributeList, TagHelperContext context, HtmlEncoder htmlEncoder, string tagName = "div", TagMode tagMode = TagMode.SelfClosing)
{ {
var innerOutput = await tagHelper.ProcessAndGetOutputAsync(attributeList, context, tagName, tagMode); var innerOutput = await tagHelper.ProcessAndGetOutputAsync(attributeList, context, tagName, tagMode).ConfigureAwait(false);
return innerOutput.Render(htmlEncoder); return innerOutput.Render(htmlEncoder);
} }

20
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpDynamicformTagHelperService.cs

@ -37,11 +37,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
NormalizeTagMode(context, output); NormalizeTagMode(context, output);
var childContent = (await output.GetChildContentAsync()).GetContent(); var childContent = (await output.GetChildContentAsync().ConfigureAwait(false)).GetContent();
await ConvertToMvcForm(context, output); await ConvertToMvcForm(context, output).ConfigureAwait(false);
await ProcessFieldsAsync(context, output); await ProcessFieldsAsync(context, output).ConfigureAwait(false);
SetContent(context, output, list, childContent); SetContent(context, output, list, childContent);
@ -67,9 +67,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
ViewContext = TagHelper.ViewContext ViewContext = TagHelper.ViewContext
}; };
var formTagOutput = await formTagHelper.ProcessAndGetOutputAsync(output.Attributes, context, "form", TagMode.StartTagAndEndTag); var formTagOutput = await formTagHelper.ProcessAndGetOutputAsync(output.Attributes, context, "form", TagMode.StartTagAndEndTag).ConfigureAwait(false);
await formTagOutput.GetChildContentAsync(); await formTagOutput.GetChildContentAsync().ConfigureAwait(false);
output.PostContent.SetHtmlContent(output.PostContent.GetContent() + formTagOutput.PostContent.GetContent()); output.PostContent.SetHtmlContent(output.PostContent.GetContent() + formTagOutput.PostContent.GetContent());
output.PreContent.SetHtmlContent(output.PreContent.GetContent() + formTagOutput.PreContent.GetContent()); output.PreContent.SetHtmlContent(output.PreContent.GetContent() + formTagOutput.PreContent.GetContent());
@ -134,11 +134,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{ {
if (IsSelectGroup(context, model)) if (IsSelectGroup(context, model))
{ {
await ProcessSelectGroupAsync(context, output, model); await ProcessSelectGroupAsync(context, output, model).ConfigureAwait(false);
} }
else else
{ {
await ProcessInputGroupAsync(context, output, model); await ProcessInputGroupAsync(context, output, model).ConfigureAwait(false);
} }
} }
} }
@ -147,7 +147,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{ {
var abpSelectTagHelper = GetSelectGroupTagHelper(context, output, model); var abpSelectTagHelper = GetSelectGroupTagHelper(context, output, model);
await abpSelectTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag); await abpSelectTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual AbpTagHelper GetSelectGroupTagHelper(TagHelperContext context, TagHelperOutput output, ModelExpression model) protected virtual AbpTagHelper GetSelectGroupTagHelper(TagHelperContext context, TagHelperOutput output, ModelExpression model)
@ -185,7 +185,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
abpButtonTagHelper.Text = "Submit"; abpButtonTagHelper.Text = "Submit";
abpButtonTagHelper.ButtonType = AbpButtonType.Primary; abpButtonTagHelper.ButtonType = AbpButtonType.Primary;
return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag); return await abpButtonTagHelper.RenderAsync(attributes, context, _htmlEncoder, "button", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual async Task ProcessInputGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model) protected virtual async Task ProcessInputGroupAsync(TagHelperContext context, TagHelperOutput output, ModelExpression model)
@ -195,7 +195,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
abpInputTagHelper.ViewContext = TagHelper.ViewContext; abpInputTagHelper.ViewContext = TagHelper.ViewContext;
abpInputTagHelper.DisplayRequiredSymbol = TagHelper.RequiredSymbols ?? true; abpInputTagHelper.DisplayRequiredSymbol = TagHelper.RequiredSymbols ?? true;
await abpInputTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag); await abpInputTagHelper.RenderAsync(new TagHelperAttributeList(), context, _htmlEncoder, "div", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual List<ModelExpression> GetModels(TagHelperContext context, TagHelperOutput output) protected virtual List<ModelExpression> GetModels(TagHelperContext context, TagHelperOutput output)

16
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpInputTagHelperService.cs

@ -27,7 +27,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{ {
var (innerHtml, isCheckBox) = await GetFormInputGroupAsHtmlAsync(context, output); var (innerHtml, isCheckBox) = await GetFormInputGroupAsHtmlAsync(context, output).ConfigureAwait(false);
var order = TagHelper.AspFor.ModelExplorer.GetDisplayOrder(); var order = TagHelper.AspFor.ModelExplorer.GetDisplayOrder();
@ -57,12 +57,12 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual async Task<(string, bool)> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output) protected virtual async Task<(string, bool)> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output)
{ {
var (inputTag, isCheckBox) = await GetInputTagHelperOutputAsync(context, output); var (inputTag, isCheckBox) = await GetInputTagHelperOutputAsync(context, output).ConfigureAwait(false);
var inputHtml = inputTag.Render(_encoder); var inputHtml = inputTag.Render(_encoder);
var label = await GetLabelAsHtmlAsync(context, output, inputTag, isCheckBox); var label = await GetLabelAsHtmlAsync(context, output, inputTag, isCheckBox).ConfigureAwait(false);
var info = GetInfoAsHtml(context, output, inputTag, isCheckBox); var info = GetInfoAsHtml(context, output, inputTag, isCheckBox);
var validation = isCheckBox ? "" : await GetValidationAsHtmlAsync(context, output, inputTag); var validation = isCheckBox ? "" : await GetValidationAsHtmlAsync(context, output, inputTag).ConfigureAwait(false);
return (GetContent(context, output, label, inputHtml, validation, info, isCheckBox), isCheckBox); return (GetContent(context, output, label, inputHtml, validation, info, isCheckBox), isCheckBox);
} }
@ -82,7 +82,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var attributeList = new TagHelperAttributeList { { "class", "text-danger" } }; var attributeList = new TagHelperAttributeList { { "class", "text-danger" } };
return await validationMessageTagHelper.RenderAsync(attributeList, context, _encoder, "span", TagMode.StartTagAndEndTag); return await validationMessageTagHelper.RenderAsync(attributeList, context, _encoder, "span", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual string GetContent(TagHelperContext context, TagHelperOutput output, string label, string inputHtml, string validation, string infoHtml, bool isCheckbox) protected virtual string GetContent(TagHelperContext context, TagHelperOutput output, string label, string inputHtml, string validation, string infoHtml, bool isCheckbox)
@ -125,7 +125,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
{ {
var tagHelper = GetInputTagHelper(context, output); var tagHelper = GetInputTagHelper(context, output);
var inputTagHelperOutput = await tagHelper.ProcessAndGetOutputAsync(GetInputAttributes(context, output), context, "input"); var inputTagHelperOutput = await tagHelper.ProcessAndGetOutputAsync(GetInputAttributes(context, output), context, "input").ConfigureAwait(false);
ConvertToTextAreaIfTextArea(inputTagHelperOutput); ConvertToTextAreaIfTextArea(inputTagHelperOutput);
AddDisabledAttribute(inputTagHelperOutput); AddDisabledAttribute(inputTagHelperOutput);
@ -227,7 +227,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
if (string.IsNullOrEmpty(TagHelper.Label)) if (string.IsNullOrEmpty(TagHelper.Label))
{ {
return await GetLabelAsHtmlUsingTagHelperAsync(context, output, isCheckbox) + GetRequiredSymbol(context, output); return await GetLabelAsHtmlUsingTagHelperAsync(context, output, isCheckbox).ConfigureAwait(false) + GetRequiredSymbol(context, output);
} }
var checkboxClass = isCheckbox ? "class=\"custom-control-label\" " : ""; var checkboxClass = isCheckbox ? "class=\"custom-control-label\" " : "";
@ -301,7 +301,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
attributeList.AddClass("custom-control-label"); attributeList.AddClass("custom-control-label");
} }
return await labelTagHelper.RenderAsync(attributeList, context, _encoder, "label", TagMode.StartTagAndEndTag); return await labelTagHelper.RenderAsync(attributeList, context, _encoder, "label", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual void ConvertToTextAreaIfTextArea(TagHelperOutput tagHelperOutput) protected virtual void ConvertToTextAreaIfTextArea(TagHelperOutput tagHelperOutput)

16
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Form/AbpSelectTagHelperService.cs

@ -30,7 +30,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{ {
var innerHtml = await GetFormInputGroupAsHtmlAsync(context, output); var innerHtml = await GetFormInputGroupAsHtmlAsync(context, output).ConfigureAwait(false);
var order = TagHelper.AspFor.ModelExplorer.GetDisplayOrder(); var order = TagHelper.AspFor.ModelExplorer.GetDisplayOrder();
@ -52,10 +52,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
protected virtual async Task<string> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output) protected virtual async Task<string> GetFormInputGroupAsHtmlAsync(TagHelperContext context, TagHelperOutput output)
{ {
var selectTag = await GetSelectTagAsync(context, output); var selectTag = await GetSelectTagAsync(context, output).ConfigureAwait(false);
var selectAsHtml = selectTag.Render(_encoder); var selectAsHtml = selectTag.Render(_encoder);
var label = await GetLabelAsHtmlAsync(context, output, selectTag); var label = await GetLabelAsHtmlAsync(context, output, selectTag).ConfigureAwait(false);
var validation = await GetValidationAsHtmlAsync(context, output, selectTag); var validation = await GetValidationAsHtmlAsync(context, output, selectTag).ConfigureAwait(false);
var infoText = GetInfoAsHtml(context, output, selectTag); var infoText = GetInfoAsHtml(context, output, selectTag);
return label + Environment.NewLine + selectAsHtml + Environment.NewLine + infoText + Environment.NewLine + validation; return label + Environment.NewLine + selectAsHtml + Environment.NewLine + infoText + Environment.NewLine + validation;
@ -75,7 +75,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
ViewContext = TagHelper.ViewContext ViewContext = TagHelper.ViewContext
}; };
var selectTagHelperOutput = await selectTagHelper.ProcessAndGetOutputAsync(GetInputAttributes(context, output), context, "select", TagMode.StartTagAndEndTag); var selectTagHelperOutput = await selectTagHelper.ProcessAndGetOutputAsync(GetInputAttributes(context, output), context, "select", TagMode.StartTagAndEndTag).ConfigureAwait(false);
selectTagHelperOutput.Attributes.AddClass("form-control"); selectTagHelperOutput.Attributes.AddClass("form-control");
selectTagHelperOutput.Attributes.AddClass(GetSize(context, output)); selectTagHelperOutput.Attributes.AddClass(GetSize(context, output));
@ -123,7 +123,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
return "<label " + GetIdAttributeAsString(selectTag) + ">" + TagHelper.Label + "</label>" + GetRequiredSymbol(context, output); return "<label " + GetIdAttributeAsString(selectTag) + ">" + TagHelper.Label + "</label>" + GetRequiredSymbol(context, output);
} }
return await GetLabelAsHtmlUsingTagHelperAsync(context, output) + GetRequiredSymbol(context, output); return await GetLabelAsHtmlUsingTagHelperAsync(context, output).ConfigureAwait(false) + GetRequiredSymbol(context, output);
} }
protected virtual string GetRequiredSymbol(TagHelperContext context, TagHelperOutput output) protected virtual string GetRequiredSymbol(TagHelperContext context, TagHelperOutput output)
@ -242,7 +242,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
ViewContext = TagHelper.ViewContext ViewContext = TagHelper.ViewContext
}; };
return await labelTagHelper.RenderAsync(new TagHelperAttributeList(), context, _encoder, "label", TagMode.StartTagAndEndTag); return await labelTagHelper.RenderAsync(new TagHelperAttributeList(), context, _encoder, "label", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual async Task<string> GetValidationAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag) protected virtual async Task<string> GetValidationAsHtmlAsync(TagHelperContext context, TagHelperOutput output, TagHelperOutput inputTag)
@ -255,7 +255,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Form
var attributeList = new TagHelperAttributeList { { "class", "text-danger" } }; var attributeList = new TagHelperAttributeList { { "class", "text-danger" } };
return await validationMessageTagHelper.RenderAsync(attributeList, context, _encoder, "span", TagMode.StartTagAndEndTag); return await validationMessageTagHelper.RenderAsync(attributeList, context, _encoder, "span", TagMode.StartTagAndEndTag).ConfigureAwait(false);
} }
protected virtual string GetSize(TagHelperContext context, TagHelperOutput output) protected virtual string GetSize(TagHelperContext context, TagHelperOutput output)

18
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Pagination/AbpPaginationTagHelperService.cs

@ -31,7 +31,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
} }
ProcessMainTag(context, output); ProcessMainTag(context, output);
await SetContentAsHtmlAsync(context, output); await SetContentAsHtmlAsync(context, output).ConfigureAwait(false);
} }
protected virtual async Task SetContentAsHtmlAsync(TagHelperContext context, TagHelperOutput output) protected virtual async Task SetContentAsHtmlAsync(TagHelperContext context, TagHelperOutput output)
@ -39,9 +39,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
var html = new StringBuilder(""); var html = new StringBuilder("");
html.AppendLine(GetOpeningTags(context, output)); html.AppendLine(GetOpeningTags(context, output));
html.AppendLine(await GetPreviousButtonAsync(context, output)); html.AppendLine(await GetPreviousButtonAsync(context, output).ConfigureAwait(false));
html.AppendLine(await GetPagesAsync(context, output)); html.AppendLine(await GetPagesAsync(context, output).ConfigureAwait(false));
html.AppendLine(await GetNextButton(context, output)); html.AppendLine(await GetNextButton(context, output).ConfigureAwait(false));
html.AppendLine(GetClosingTags(context, output)); html.AppendLine(GetClosingTags(context, output));
output.Content.SetHtmlContent(html.ToString()); output.Content.SetHtmlContent(html.ToString());
@ -61,7 +61,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
foreach (var page in TagHelper.Model.Pages) foreach (var page in TagHelper.Model.Pages)
{ {
pagesHtml.AppendLine(await GetPageAsync(context, output, page)); pagesHtml.AppendLine(await GetPageAsync(context, output, page).ConfigureAwait(false));
} }
return pagesHtml.ToString(); return pagesHtml.ToString();
@ -86,7 +86,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
} }
else else
{ {
pageHtml.AppendLine(await RenderAnchorTagHelperLinkHtmlAsync(context, output, page.Index.ToString(), page.Index.ToString())); pageHtml.AppendLine(await RenderAnchorTagHelperLinkHtmlAsync(context, output, page.Index.ToString(), page.Index.ToString()).ConfigureAwait(false));
} }
pageHtml.AppendLine("</li>"); pageHtml.AppendLine("</li>");
@ -102,7 +102,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
: (TagHelper.Model.CurrentPage - 1).ToString(); : (TagHelper.Model.CurrentPage - 1).ToString();
return return
"<li class=\"page-item " + (TagHelper.Model.CurrentPage == 1 ? "disabled" : "") + "\">\r\n" + "<li class=\"page-item " + (TagHelper.Model.CurrentPage == 1 ? "disabled" : "") + "\">\r\n" +
(await RenderAnchorTagHelperLinkHtmlAsync(context, output, currentPage, localizationKey)) + " </li>"; (await RenderAnchorTagHelperLinkHtmlAsync(context, output, currentPage, localizationKey).ConfigureAwait(false)) + " </li>";
} }
protected virtual async Task<string> GetNextButton(TagHelperContext context, TagHelperOutput output) protected virtual async Task<string> GetNextButton(TagHelperContext context, TagHelperOutput output)
@ -111,7 +111,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
var currentPage = (TagHelper.Model.CurrentPage + 1).ToString(); var currentPage = (TagHelper.Model.CurrentPage + 1).ToString();
return return
"<li class=\"page-item " + (TagHelper.Model.CurrentPage >= TagHelper.Model.TotalPageCount ? "disabled" : "") + "\">\r\n" + "<li class=\"page-item " + (TagHelper.Model.CurrentPage >= TagHelper.Model.TotalPageCount ? "disabled" : "") + "\">\r\n" +
(await RenderAnchorTagHelperLinkHtmlAsync(context, output, currentPage, localizationKey)) + (await RenderAnchorTagHelperLinkHtmlAsync(context, output, currentPage, localizationKey).ConfigureAwait(false)) +
" </li>"; " </li>";
} }
@ -121,7 +121,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Pagination
var anchorTagHelper = GetAnchorTagHelper(currentPage, out var attributeList); var anchorTagHelper = GetAnchorTagHelper(currentPage, out var attributeList);
var tagHelperOutput = await anchorTagHelper.ProcessAndGetOutputAsync(attributeList, context, "a", TagMode.StartTagAndEndTag); var tagHelperOutput = await anchorTagHelper.ProcessAndGetOutputAsync(attributeList, context, "a", TagMode.StartTagAndEndTag).ConfigureAwait(false);
tagHelperOutput.Content.SetHtmlContent(localizer[localizationKey]); tagHelperOutput.Content.SetHtmlContent(localizer[localizationKey]);

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabDropdownTagHelperService.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
throw new Exception("Name of tab dropdown tag can not bu null or empty."); throw new Exception("Name of tab dropdown tag can not bu null or empty.");
} }
await output.GetChildContentAsync(); await output.GetChildContentAsync().ConfigureAwait(false);
var tabHeader = GetTabHeaderItem(context, output); var tabHeader = GetTabHeaderItem(context, output);
var tabHeaderItems = context.GetValue<List<TabItem>>(TabItems); var tabHeaderItems = context.GetValue<List<TabItem>>(TabItems);

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabLinkTagHelperService.cs

@ -7,7 +7,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
{ {
public class AbpTabLinkTagHelperService : AbpTagHelperService<AbpTabLinkTagHelper> public class AbpTabLinkTagHelperService : AbpTagHelperService<AbpTabLinkTagHelper>
{ {
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{ {
SetPlaceholderForNameIfNotProvided(); SetPlaceholderForNameIfNotProvided();
@ -18,6 +18,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
tabHeaderItems.Add(new TabItem(tabHeader, "", false, TagHelper.Name, TagHelper.ParentDropdownName, false)); tabHeaderItems.Add(new TabItem(tabHeader, "", false, TagHelper.Name, TagHelper.ParentDropdownName, false));
output.SuppressOutput(); output.SuppressOutput();
return Task.CompletedTask;
} }
protected virtual string GetTabHeaderItem(TagHelperContext context, TagHelperOutput output) protected virtual string GetTabHeaderItem(TagHelperContext context, TagHelperOutput output)

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabTagHelperService.cs

@ -12,7 +12,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
{ {
SetPlaceholderForNameIfNotProvided(); SetPlaceholderForNameIfNotProvided();
var innerContent = await output.GetChildContentAsync(); var innerContent = await output.GetChildContentAsync().ConfigureAwait(false);
var tabHeader = GetTabHeaderItem(context, output); var tabHeader = GetTabHeaderItem(context, output);
var tabContent = GetTabContentItem(context, output, innerContent.GetContent()); var tabContent = GetTabContentItem(context, output, innerContent.GetContent());

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap/TagHelpers/Tab/AbpTabsTagHelperService.cs

@ -17,7 +17,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Tab
var items = InitilizeFormGroupContentsContext(context, output); var items = InitilizeFormGroupContentsContext(context, output);
await output.GetChildContentAsync(); await output.GetChildContentAsync().ConfigureAwait(false);
var headers = GetHeaders(context, output, items); var headers = GetHeaders(context, output, items);
var contents = GetConents(context, output, items); var contents = GetConents(context, output, items);

12
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs

@ -61,12 +61,12 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
public virtual async Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName) public virtual async Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName)
{ {
return await GetBundleFilesAsync(Options.StyleBundles, bundleName, StyleBundler); return await GetBundleFilesAsync(Options.StyleBundles, bundleName, StyleBundler).ConfigureAwait(false);
} }
public virtual async Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName) public virtual async Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName)
{ {
return await GetBundleFilesAsync(Options.ScriptBundles, bundleName, ScriptBundler); return await GetBundleFilesAsync(Options.ScriptBundles, bundleName, ScriptBundler).ConfigureAwait(false);
} }
protected virtual async Task<IReadOnlyList<string>> GetBundleFilesAsync(BundleConfigurationCollection bundles, string bundleName, IBundler bundler) protected virtual async Task<IReadOnlyList<string>> GetBundleFilesAsync(BundleConfigurationCollection bundles, string bundleName, IBundler bundler)
@ -185,17 +185,17 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
foreach (var contributor in contributors) foreach (var contributor in contributors)
{ {
await contributor.PreConfigureBundleAsync(context); await contributor.PreConfigureBundleAsync(context).ConfigureAwait(false);
} }
foreach (var contributor in contributors) foreach (var contributor in contributors)
{ {
await contributor.ConfigureBundleAsync(context); await contributor.ConfigureBundleAsync(context).ConfigureAwait(false);
} }
foreach (var contributor in contributors) foreach (var contributor in contributors)
{ {
await contributor.PostConfigureBundleAsync(context); await contributor.PostConfigureBundleAsync(context).ConfigureAwait(false);
} }
return context.Files; return context.Files;
@ -207,7 +207,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
foreach (var contributor in contributors) foreach (var contributor in contributors)
{ {
await contributor.ConfigureDynamicResourcesAsync(context); await contributor.ConfigureDynamicResourcesAsync(context).ConfigureAwait(false);
} }
return context.Files; return context.Files;

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleItemTagHelperService.cs

@ -33,7 +33,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
TagHelper.CreateBundleTagHelperItem() TagHelper.CreateBundleTagHelperItem()
}, },
TagHelper.GetNameOrNull() TagHelper.GetNameOrNull()
); ).ConfigureAwait(false);
} }
} }
} }

6
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpBundleTagHelperService.cs

@ -20,16 +20,16 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
await ResourceService.ProcessAsync( await ResourceService.ProcessAsync(
context, context,
output, output,
await GetBundleItems(context, output), await GetBundleItems(context, output).ConfigureAwait(false),
TagHelper.GetNameOrNull() TagHelper.GetNameOrNull()
); ).ConfigureAwait(false);
} }
protected virtual async Task<List<BundleTagHelperItem>> GetBundleItems(TagHelperContext context, TagHelperOutput output) protected virtual async Task<List<BundleTagHelperItem>> GetBundleItems(TagHelperContext context, TagHelperOutput output)
{ {
var bundleItems = new List<BundleTagHelperItem>(); var bundleItems = new List<BundleTagHelperItem>();
context.Items[AbpTagHelperConsts.ContextBundleItemListKey] = bundleItems; context.Items[AbpTagHelperConsts.ContextBundleItemListKey] = bundleItems;
await output.GetChildContentAsync(); //TODO: Is there a way of executing children without getting content? await output.GetChildContentAsync().ConfigureAwait(false); //TODO: Is there a way of executing children without getting content?
return bundleItems; return bundleItems;
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs

@ -56,7 +56,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
CreateBundle(bundleName, bundleItems); CreateBundle(bundleName, bundleItems);
var bundleFiles = await GetBundleFilesAsync(bundleName); var bundleFiles = await GetBundleFilesAsync(bundleName).ConfigureAwait(false);
output.Content.Clear(); output.Content.Clear();

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs

@ -36,7 +36,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
protected override async Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName) protected override async Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName)
{ {
return await BundleManager.GetScriptBundleFilesAsync(bundleName); return await BundleManager.GetScriptBundleFilesAsync(bundleName).ConfigureAwait(false);
} }
protected override void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file) protected override void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file)

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs

@ -36,7 +36,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
protected override async Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName) protected override async Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName)
{ {
return await BundleManager.GetStyleBundleFilesAsync(bundleName); return await BundleManager.GetStyleBundleFilesAsync(bundleName).ConfigureAwait(false);
} }
protected override void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file) protected override void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file)

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantAppService.cs

@ -17,7 +17,7 @@ namespace Pages.Abp.MultiTenancy
public async Task<FindTenantResultDto> FindTenantByNameAsync(string name) public async Task<FindTenantResultDto> FindTenantByNameAsync(string name)
{ {
var tenant = await TenantStore.FindAsync(name); var tenant = await TenantStore.FindAsync(name).ConfigureAwait(false);
if (tenant == null) if (tenant == null)
{ {
@ -34,7 +34,7 @@ namespace Pages.Abp.MultiTenancy
public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id) public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id)
{ {
var tenant = await TenantStore.FindAsync(id); var tenant = await TenantStore.FindAsync(id).ConfigureAwait(false);
if (tenant == null) if (tenant == null)
{ {

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/AbpTenantController.cs

@ -21,14 +21,14 @@ namespace Pages.Abp.MultiTenancy
[Route("tenants/by-name/{name}")] [Route("tenants/by-name/{name}")]
public async Task<FindTenantResultDto> FindTenantByNameAsync(string name) public async Task<FindTenantResultDto> FindTenantByNameAsync(string name)
{ {
return await _abpTenantAppService.FindTenantByNameAsync(name); return await _abpTenantAppService.FindTenantByNameAsync(name).ConfigureAwait(false);
} }
[HttpGet] [HttpGet]
[Route("tenants/by-id/{id}")] [Route("tenants/by-id/{id}")]
public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id) public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id)
{ {
return await _abpTenantAppService.FindTenantByIdAsync(id); return await _abpTenantAppService.FindTenantByIdAsync(id).ConfigureAwait(false);
} }
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy/TenantSwitchModal.cshtml.cs

@ -34,7 +34,7 @@ namespace Pages.Abp.MultiTenancy
if (CurrentTenant.IsAvailable) if (CurrentTenant.IsAvailable)
{ {
var tenant = await TenantStore.FindAsync(CurrentTenant.GetId()); var tenant = await TenantStore.FindAsync(CurrentTenant.GetId()).ConfigureAwait(false);
Input.Name = tenant?.Name; Input.Name = tenant?.Name;
} }
} }
@ -47,7 +47,7 @@ namespace Pages.Abp.MultiTenancy
} }
else else
{ {
var tenant = await TenantStore.FindAsync(Input.Name); var tenant = await TenantStore.FindAsync(Input.Name).ConfigureAwait(false);
if (tenant == null) if (tenant == null)
{ {
throw new UserFriendlyException(L["GivenTenantIsNotAvailable", Input.Name]); throw new UserFriendlyException(L["GivenTenantIsNotAvailable", Input.Name]);

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Menu/MainNavbarMenuViewComponent.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Menu
public async Task<IViewComponentResult> InvokeAsync() public async Task<IViewComponentResult> InvokeAsync()
{ {
var menu = await _menuManager.GetAsync(StandardMenus.Main); var menu = await _menuManager.GetAsync(StandardMenus.Main).ConfigureAwait(false);
return View("~/Themes/Basic/Components/Menu/Default.cshtml", menu); return View("~/Themes/Basic/Components/Menu/Default.cshtml", menu);
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/LanguageSwitchViewComponent.cs

@ -17,7 +17,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar
public async Task<IViewComponentResult> InvokeAsync() public async Task<IViewComponentResult> InvokeAsync()
{ {
var languages = await _languageProvider.GetLanguagesAsync(); var languages = await _languageProvider.GetLanguagesAsync().ConfigureAwait(false);
var currentLanguage = languages.FindByCulture( var currentLanguage = languages.FindByCulture(
CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.Name,
CultureInfo.CurrentUICulture.Name CultureInfo.CurrentUICulture.Name

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/MainNavbarToolsViewComponent.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar
public async Task<IViewComponentResult> InvokeAsync() public async Task<IViewComponentResult> InvokeAsync()
{ {
var toolbar = await _toolbarManager.GetAsync(StandardToolbars.Main); var toolbar = await _toolbarManager.GetAsync(StandardToolbars.Main).ConfigureAwait(false);
return View("~/Themes/Basic/Components/Toolbar/Default.cshtml", toolbar); return View("~/Themes/Basic/Components/Toolbar/Default.cshtml", toolbar);
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/UserMenuViewComponent.cs

@ -15,7 +15,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar
public async Task<IViewComponentResult> InvokeAsync() public async Task<IViewComponentResult> InvokeAsync()
{ {
var menu = await _menuManager.GetAsync(StandardMenus.User); var menu = await _menuManager.GetAsync(StandardMenus.User).ConfigureAwait(false);
return View("~/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml", menu); return View("~/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml", menu);
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Toolbars/BasicThemeMainTopToolbarContributor.cs

@ -25,7 +25,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Toolbars
var languageProvider = context.ServiceProvider.GetService<ILanguageProvider>(); var languageProvider = context.ServiceProvider.GetService<ILanguageProvider>();
//TODO: This duplicates GetLanguages() usage. Can we eleminate this? //TODO: This duplicates GetLanguages() usage. Can we eleminate this?
var languages = await languageProvider.GetLanguagesAsync(); var languages = await languageProvider.GetLanguagesAsync().ConfigureAwait(false);
if (languages.Count > 1) if (languages.Count > 1)
{ {
context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitchViewComponent))); context.Toolbar.Items.Add(new ToolbarItem(typeof(LanguageSwitchViewComponent)));

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Toolbars/ToolbarManager.cs

@ -33,7 +33,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars
foreach (var contributor in Options.Contributors) foreach (var contributor in Options.Contributors)
{ {
await contributor.ConfigureToolbarAsync(context); await contributor.ConfigureToolbarAsync(context).ConfigureAwait(false);
} }
} }

10
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/AbpViewComponentHelper.cs

@ -33,10 +33,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
var widget = Options.Widgets.Find(name); var widget = Options.Widgets.Find(name);
if (widget == null) if (widget == null)
{ {
return await DefaultViewComponentHelper.InvokeAsync(name, arguments); return await DefaultViewComponentHelper.InvokeAsync(name, arguments).ConfigureAwait(false);
} }
return await InvokeWidgetAsync(arguments, widget); return await InvokeWidgetAsync(arguments, widget).ConfigureAwait(false);
} }
public virtual async Task<IHtmlContent> InvokeAsync(Type componentType, object arguments) public virtual async Task<IHtmlContent> InvokeAsync(Type componentType, object arguments)
@ -44,10 +44,10 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
var widget = Options.Widgets.Find(componentType); var widget = Options.Widgets.Find(componentType);
if (widget == null) if (widget == null)
{ {
return await DefaultViewComponentHelper.InvokeAsync(componentType, arguments); return await DefaultViewComponentHelper.InvokeAsync(componentType, arguments).ConfigureAwait(false);
} }
return await InvokeWidgetAsync(arguments, widget); return await InvokeWidgetAsync(arguments, widget).ConfigureAwait(false);
} }
public virtual void Contextualize(ViewContext viewContext) public virtual void Contextualize(ViewContext viewContext)
@ -68,7 +68,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
return new HtmlContentBuilder() return new HtmlContentBuilder()
.AppendHtml($"<div {wrapperAttributesBuilder}>") .AppendHtml($"<div {wrapperAttributesBuilder}>")
.AppendHtml(await DefaultViewComponentHelper.InvokeAsync(widget.ViewComponentType, arguments)) .AppendHtml(await DefaultViewComponentHelper.InvokeAsync(widget.ViewComponentType, arguments).ConfigureAwait(false))
.AppendHtml("</div>"); .AppendHtml("</div>");
} }
} }

6
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Widgets/Volo/Abp/AspNetCore/Mvc/UI/Widgets/WidgetManager.cs

@ -27,14 +27,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
{ {
var widget = Options.Widgets.Find(widgetComponentType); var widget = Options.Widgets.Find(widgetComponentType);
return await IsGrantedAsyncInternal(widget, widgetComponentType.FullName); return await IsGrantedAsyncInternal(widget, widgetComponentType.FullName).ConfigureAwait(false);
} }
public async Task<bool> IsGrantedAsync(string name) public async Task<bool> IsGrantedAsync(string name)
{ {
var widget = Options.Widgets.Find(name); var widget = Options.Widgets.Find(name);
return await IsGrantedAsyncInternal(widget, name); return await IsGrantedAsyncInternal(widget, name).ConfigureAwait(false);
} }
private async Task<bool> IsGrantedAsyncInternal(WidgetDefinition widget, string wantedWidgetName) private async Task<bool> IsGrantedAsyncInternal(WidgetDefinition widget, string wantedWidgetName)
@ -48,7 +48,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Widgets
{ {
foreach (var requiredPolicy in widget.RequiredPolicies) foreach (var requiredPolicy in widget.RequiredPolicies)
{ {
if (!(await AuthorizationService.AuthorizeAsync(requiredPolicy)).Succeeded) if (!(await AuthorizationService.AuthorizeAsync(requiredPolicy).ConfigureAwait(false)).Succeeded)
{ {
return false; return false;
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs

@ -5,6 +5,7 @@ using Volo.Abp.AspNetCore.Mvc.Conventions;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling; using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.Features; using Volo.Abp.AspNetCore.Mvc.Features;
using Volo.Abp.AspNetCore.Mvc.ModelBinding; using Volo.Abp.AspNetCore.Mvc.ModelBinding;
using Volo.Abp.AspNetCore.Mvc.Response;
using Volo.Abp.AspNetCore.Mvc.Uow; using Volo.Abp.AspNetCore.Mvc.Uow;
using Volo.Abp.AspNetCore.Mvc.Validation; using Volo.Abp.AspNetCore.Mvc.Validation;
@ -28,6 +29,7 @@ namespace Volo.Abp.AspNetCore.Mvc
private static void AddFilters(MvcOptions options) private static void AddFilters(MvcOptions options)
{ {
options.Filters.AddService(typeof(AbpAuditActionFilter)); options.Filters.AddService(typeof(AbpAuditActionFilter));
options.Filters.AddService(typeof(AbpNoContentActionFilter));
options.Filters.AddService(typeof(AbpFeatureActionFilter)); options.Filters.AddService(typeof(AbpFeatureActionFilter));
options.Filters.AddService(typeof(AbpValidationActionFilter)); options.Filters.AddService(typeof(AbpValidationActionFilter));
options.Filters.AddService(typeof(AbpUowActionFilter)); options.Filters.AddService(typeof(AbpUowActionFilter));

15
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs

@ -56,11 +56,12 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
return new ApplicationConfigurationDto return new ApplicationConfigurationDto
{ {
Auth = await GetAuthConfigAsync(), Auth = await GetAuthConfigAsync().ConfigureAwait(false),
Features = await GetFeaturesConfigAsync(), Features = await GetFeaturesConfigAsync().ConfigureAwait(false),
Localization = await GetLocalizationConfigAsync(), Localization = await GetLocalizationConfigAsync().ConfigureAwait(false),
CurrentUser = GetCurrentUser(), CurrentUser = GetCurrentUser(),
Setting = await GetSettingConfigAsync() Setting = await GetSettingConfigAsync()
.ConfigureAwait(false)
}; };
} }
@ -81,7 +82,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
var authConfig = new ApplicationAuthConfigurationDto(); var authConfig = new ApplicationAuthConfigurationDto();
var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync(); var policyNames = await _abpAuthorizationPolicyProvider.GetPoliciesNamesAsync().ConfigureAwait(false);
Logger.LogDebug($"GetPoliciesNamesAsync returns {policyNames.Count} items."); Logger.LogDebug($"GetPoliciesNamesAsync returns {policyNames.Count} items.");
@ -91,7 +92,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
Logger.LogDebug($"_authorizationService.IsGrantedAsync? {policyName}"); Logger.LogDebug($"_authorizationService.IsGrantedAsync? {policyName}");
if (await _authorizationService.IsGrantedAsync(policyName)) if (await _authorizationService.IsGrantedAsync(policyName).ConfigureAwait(false))
{ {
authConfig.GrantedPolicies[policyName] = true; authConfig.GrantedPolicies[policyName] = true;
} }
@ -174,7 +175,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
continue; continue;
} }
result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name); result.Values[settingDefinition.Name] = await _settingProvider.GetOrNullAsync(settingDefinition.Name).ConfigureAwait(false);
} }
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetSettingConfigAsync()"); Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetSettingConfigAsync()");
@ -195,7 +196,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
continue; continue;
} }
result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name); result.Values[featureDefinition.Name] = await FeatureChecker.GetOrNullAsync(featureDefinition.Name).ConfigureAwait(false);
} }
Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetFeaturesConfigAsync()"); Logger.LogDebug("Executed AbpApplicationConfigurationAppService.GetFeaturesConfigAsync()");

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationController.cs

@ -17,7 +17,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
[HttpGet] [HttpGet]
public async Task<ApplicationConfigurationDto> GetAsync() public async Task<ApplicationConfigurationDto> GetAsync()
{ {
return await _applicationConfigurationAppService.GetAsync(); return await _applicationConfigurationAppService.GetAsync().ConfigureAwait(false);
} }
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs

@ -35,7 +35,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
[Produces(MimeTypes.Application.Javascript, MimeTypes.Text.Plain)] [Produces(MimeTypes.Application.Javascript, MimeTypes.Text.Plain)]
public async Task<ActionResult> Get() public async Task<ActionResult> Get()
{ {
var script = CreateAbpExtendScript(await _configurationAppService.GetAsync()); var script = CreateAbpExtendScript(await _configurationAppService.GetAsync().ConfigureAwait(false));
return Content( return Content(
_options.MinifyGeneratedScript == true _options.MinifyGeneratedScript == true

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Auditing/AbpAuditActionFilter.cs

@ -27,7 +27,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
{ {
if (!ShouldSaveAudit(context, out var auditLog, out var auditLogAction)) if (!ShouldSaveAudit(context, out var auditLog, out var auditLogAction))
{ {
await next(); await next().ConfigureAwait(false);
return; return;
} }
@ -37,7 +37,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Auditing
try try
{ {
var result = await next(); var result = await next().ConfigureAwait(false);
if (result.Exception != null && !result.ExceptionHandled) if (result.Exception != null && !result.ExceptionHandled)
{ {

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Authentication/ChallengeAccountController.cs

@ -40,7 +40,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Authentication
[HttpGet] [HttpGet]
public async Task<ActionResult> Logout(string returnUrl = "", string returnUrlHash = "") public async Task<ActionResult> Logout(string returnUrl = "", string returnUrlHash = "")
{ {
await HttpContext.SignOutAsync(); await HttpContext.SignOutAsync().ConfigureAwait(false);
return RedirectSafely(returnUrl, returnUrlHash); return RedirectSafely(returnUrl, returnUrlHash);
} }

6
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Features/AbpFeatureActionFilter.cs

@ -23,7 +23,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Features
{ {
if (!context.ActionDescriptor.IsControllerAction()) if (!context.ActionDescriptor.IsControllerAction())
{ {
await next(); await next().ConfigureAwait(false);
return; return;
} }
@ -33,9 +33,9 @@ namespace Volo.Abp.AspNetCore.Mvc.Features
{ {
await _methodInvocationAuthorizationService.CheckAsync( await _methodInvocationAuthorizationService.CheckAsync(
new MethodInvocationFeatureCheckerContext(methodInfo) new MethodInvocationFeatureCheckerContext(methodInfo)
); ).ConfigureAwait(false);
await next(); await next().ConfigureAwait(false);
} }
} }
} }

2
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs

@ -24,7 +24,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ModelBinding
public async Task BindModelAsync(ModelBindingContext bindingContext) public async Task BindModelAsync(ModelBindingContext bindingContext)
{ {
await _simpleTypeModelBinder.BindModelAsync(bindingContext); await _simpleTypeModelBinder.BindModelAsync(bindingContext).ConfigureAwait(false);
if (!bindingContext.Result.IsModelSet) if (!bindingContext.Result.IsModelSet)
{ {

31
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Response/AbpNoContentActionFilter.cs

@ -0,0 +1,31 @@
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.Response
{
public class AbpNoContentActionFilter : IAsyncActionFilter, ITransientDependency
{
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
if (!context.ActionDescriptor.IsControllerAction())
{
await next();
return;
}
await next();
if (context.HttpContext.Response.StatusCode == (int)HttpStatusCode.OK)
{
var returnType = context.ActionDescriptor.GetReturnType();
if (returnType == typeof(Task) || returnType == typeof(void))
{
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.NoContent;
}
}
}
}
}

14
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Uow/AbpUowActionFilter.cs

@ -25,7 +25,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
{ {
if (!context.ActionDescriptor.IsControllerAction()) if (!context.ActionDescriptor.IsControllerAction())
{ {
await next(); await next().ConfigureAwait(false);
return; return;
} }
@ -39,7 +39,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
if (unitOfWorkAttr?.IsDisabled == true) if (unitOfWorkAttr?.IsDisabled == true)
{ {
await next(); await next().ConfigureAwait(false);
return; return;
} }
@ -48,10 +48,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
//Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware //Trying to begin a reserved UOW by AbpUnitOfWorkMiddleware
if (_unitOfWorkManager.TryBeginReserved(AbpUnitOfWorkMiddleware.UnitOfWorkReservationName, options)) if (_unitOfWorkManager.TryBeginReserved(AbpUnitOfWorkMiddleware.UnitOfWorkReservationName, options))
{ {
var result = await next(); var result = await next().ConfigureAwait(false);
if (!Succeed(result)) if (!Succeed(result))
{ {
await RollbackAsync(context); await RollbackAsync(context).ConfigureAwait(false);
} }
return; return;
@ -60,10 +60,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
//Begin a new, independent unit of work //Begin a new, independent unit of work
using (var uow = _unitOfWorkManager.Begin(options)) using (var uow = _unitOfWorkManager.Begin(options))
{ {
var result = await next(); var result = await next().ConfigureAwait(false);
if (Succeed(result)) if (Succeed(result))
{ {
await uow.CompleteAsync(context.HttpContext.RequestAborted); await uow.CompleteAsync(context.HttpContext.RequestAborted).ConfigureAwait(false);
} }
} }
} }
@ -89,7 +89,7 @@ namespace Volo.Abp.AspNetCore.Mvc.Uow
var currentUow = _unitOfWorkManager.Current; var currentUow = _unitOfWorkManager.Current;
if (currentUow != null) if (currentUow != null)
{ {
await currentUow.RollbackAsync(context.HttpContext.RequestAborted); await currentUow.RollbackAsync(context.HttpContext.RequestAborted).ConfigureAwait(false);
} }
} }

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Validation/AbpValidationActionFilter.cs

@ -22,12 +22,12 @@ namespace Volo.Abp.AspNetCore.Mvc.Validation
if (!context.ActionDescriptor.IsControllerAction() || if (!context.ActionDescriptor.IsControllerAction() ||
!context.ActionDescriptor.HasObjectResult()) !context.ActionDescriptor.HasObjectResult())
{ {
await next(); await next().ConfigureAwait(false);
return; return;
} }
_validator.Validate(context.ModelState); _validator.Validate(context.ModelState);
await next(); await next().ConfigureAwait(false);
} }
} }
} }

4
framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestLocalizationMiddleware.cs

@ -27,11 +27,11 @@ namespace Microsoft.AspNetCore.RequestLocalization
next, next,
new OptionsWrapper<RequestLocalizationOptions>( new OptionsWrapper<RequestLocalizationOptions>(
await _requestLocalizationOptionsProvider.GetLocalizationOptionsAsync() await _requestLocalizationOptionsProvider.GetLocalizationOptionsAsync()
), .ConfigureAwait(false)),
_loggerFactory _loggerFactory
); );
await middleware.Invoke(context); await middleware.Invoke(context).ConfigureAwait(false);
} }
} }
} }

6
framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/DefaultAbpRequestLocalizationOptionsProvider.cs

@ -36,15 +36,15 @@ namespace Microsoft.AspNetCore.RequestLocalization
{ {
if (_requestLocalizationOptions == null) if (_requestLocalizationOptions == null)
{ {
using (await _syncSemaphore.LockAsync()) using (await _syncSemaphore.LockAsync().ConfigureAwait(false))
{ {
using (var serviceScope = _serviceProviderFactory.CreateScope()) using (var serviceScope = _serviceProviderFactory.CreateScope())
{ {
var languageProvider = serviceScope.ServiceProvider.GetRequiredService<ILanguageProvider>(); var languageProvider = serviceScope.ServiceProvider.GetRequiredService<ILanguageProvider>();
var settingProvider = serviceScope.ServiceProvider.GetRequiredService<ISettingProvider>(); var settingProvider = serviceScope.ServiceProvider.GetRequiredService<ISettingProvider>();
var languages = await languageProvider.GetLanguagesAsync(); var languages = await languageProvider.GetLanguagesAsync().ConfigureAwait(false);
var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage); var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage).ConfigureAwait(false);
var options = !languages.Any() var options = !languages.Any()
? new RequestLocalizationOptions() ? new RequestLocalizationOptions()

6
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Auditing/AbpAuditingMiddleware.cs

@ -30,7 +30,7 @@ namespace Volo.Abp.AspNetCore.Auditing
{ {
if (!ShouldWriteAuditLog(context)) if (!ShouldWriteAuditLog(context))
{ {
await next(context); await next(context).ConfigureAwait(false);
return; return;
} }
@ -38,11 +38,11 @@ namespace Volo.Abp.AspNetCore.Auditing
{ {
try try
{ {
await next(context); await next(context).ConfigureAwait(false);
} }
finally finally
{ {
await scope.SaveAsync(); await scope.SaveAsync().ConfigureAwait(false);
} }
} }
} }

6
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/ExceptionHandling/AbpExceptionHandlingMiddleware.cs

@ -29,7 +29,7 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
{ {
try try
{ {
await next(context); await next(context).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -44,7 +44,7 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
{ {
if (actionInfo.IsObjectResult) //TODO: Align with AbpExceptionFilter.ShouldHandleException! if (actionInfo.IsObjectResult) //TODO: Align with AbpExceptionFilter.ShouldHandleException!
{ {
await HandleAndWrapException(context, ex); await HandleAndWrapException(context, ex).ConfigureAwait(false);
return; return;
} }
} }
@ -72,7 +72,7 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
errorInfoConverter.Convert(exception) errorInfoConverter.Convert(exception)
) )
) )
); ).ConfigureAwait(false);
} }
private Task ClearCacheHeaders(object state) private Task ClearCacheHeaders(object state)

2
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Tracing/AbpCorrelationIdMiddleware.cs

@ -24,7 +24,7 @@ namespace Volo.Abp.AspNetCore.Tracing
try try
{ {
await next(context); await next(context).ConfigureAwait(false);
} }
finally finally
{ {

4
framework/src/Volo.Abp.AspNetCore/Volo/Abp/AspNetCore/Uow/AbpUnitOfWorkMiddleware.cs

@ -20,8 +20,8 @@ namespace Volo.Abp.AspNetCore.Uow
{ {
using (var uow = _unitOfWorkManager.Reserve(UnitOfWorkReservationName)) using (var uow = _unitOfWorkManager.Reserve(UnitOfWorkReservationName))
{ {
await next(context); await next(context).ConfigureAwait(false);
await uow.CompleteAsync(context.RequestAborted); await uow.CompleteAsync(context.RequestAborted).ConfigureAwait(false);
} }
} }
} }

4
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingInterceptor.cs

@ -22,7 +22,7 @@ namespace Volo.Abp.Auditing
{ {
if (!ShouldIntercept(invocation, out var auditLog, out var auditLogAction)) if (!ShouldIntercept(invocation, out var auditLog, out var auditLogAction))
{ {
await invocation.ProceedAsync(); await invocation.ProceedAsync().ConfigureAwait(false);
return; return;
} }
@ -30,7 +30,7 @@ namespace Volo.Abp.Auditing
try try
{ {
await invocation.ProceedAsync(); await invocation.ProceedAsync().ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

4
framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingManager.cs

@ -116,7 +116,7 @@ namespace Volo.Abp.Auditing
if (ShouldSave(saveHandle.AuditLog)) if (ShouldSave(saveHandle.AuditLog))
{ {
await _auditingStore.SaveAsync(saveHandle.AuditLog); await _auditingStore.SaveAsync(saveHandle.AuditLog).ConfigureAwait(false);
} }
} }
@ -152,7 +152,7 @@ namespace Volo.Abp.Auditing
public async Task SaveAsync() public async Task SaveAsync()
{ {
await _auditingManager.SaveAsync(this); await _auditingManager.SaveAsync(this).ConfigureAwait(false);
} }
public void Dispose() public void Dispose()

38
framework/src/Volo.Abp.Authorization/Microsoft/AspNetCore/Authorization/AbpAuthorizationServiceExtensions.cs

@ -13,7 +13,7 @@ namespace Microsoft.AspNetCore.Authorization
authorizationService, authorizationService,
null, null,
policyName policyName
); ).ConfigureAwait(false);
} }
public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement) public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement)
@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Authorization
authorizationService.AsAbpAuthorizationService().CurrentPrincipal, authorizationService.AsAbpAuthorizationService().CurrentPrincipal,
resource, resource,
requirement requirement
); ).ConfigureAwait(false);
} }
public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy) public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy)
@ -31,16 +31,16 @@ namespace Microsoft.AspNetCore.Authorization
authorizationService.AsAbpAuthorizationService().CurrentPrincipal, authorizationService.AsAbpAuthorizationService().CurrentPrincipal,
resource, resource,
policy policy
); ).ConfigureAwait(false);
} }
public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy) public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy)
{ {
return await AuthorizeAsync( return await AuthorizeAsync(
authorizationService, authorizationService,
null, null,
policy policy
); ).ConfigureAwait(false);
} }
public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements) public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements)
@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Authorization
authorizationService.AsAbpAuthorizationService().CurrentPrincipal, authorizationService.AsAbpAuthorizationService().CurrentPrincipal,
resource, resource,
requirements requirements
); ).ConfigureAwait(false);
} }
public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, string policyName) public static async Task<AuthorizationResult> AuthorizeAsync(this IAuthorizationService authorizationService, object resource, string policyName)
@ -58,42 +58,42 @@ namespace Microsoft.AspNetCore.Authorization
authorizationService.AsAbpAuthorizationService().CurrentPrincipal, authorizationService.AsAbpAuthorizationService().CurrentPrincipal,
resource, resource,
policyName policyName
); ).ConfigureAwait(false);
} }
public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, string policyName) public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, string policyName)
{ {
return (await authorizationService.AuthorizeAsync(policyName)).Succeeded; return (await authorizationService.AuthorizeAsync(policyName).ConfigureAwait(false)).Succeeded;
} }
public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement) public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement)
{ {
return (await authorizationService.AuthorizeAsync(resource, requirement)).Succeeded; return (await authorizationService.AuthorizeAsync(resource, requirement).ConfigureAwait(false)).Succeeded;
} }
public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy) public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy)
{ {
return (await authorizationService.AuthorizeAsync(resource, policy)).Succeeded; return (await authorizationService.AuthorizeAsync(resource, policy).ConfigureAwait(false)).Succeeded;
} }
public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy) public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy)
{ {
return (await authorizationService.AuthorizeAsync(policy)).Succeeded; return (await authorizationService.AuthorizeAsync(policy).ConfigureAwait(false)).Succeeded;
} }
public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements) public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements)
{ {
return (await authorizationService.AuthorizeAsync(resource, requirements)).Succeeded; return (await authorizationService.AuthorizeAsync(resource, requirements).ConfigureAwait(false)).Succeeded;
} }
public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, string policyName) public static async Task<bool> IsGrantedAsync(this IAuthorizationService authorizationService, object resource, string policyName)
{ {
return (await authorizationService.AuthorizeAsync(resource, policyName)).Succeeded; return (await authorizationService.AuthorizeAsync(resource, policyName).ConfigureAwait(false)).Succeeded;
} }
public static async Task CheckAsync(this IAuthorizationService authorizationService, string policyName) public static async Task CheckAsync(this IAuthorizationService authorizationService, string policyName)
{ {
if (!await authorizationService.IsGrantedAsync(policyName)) if (!await authorizationService.IsGrantedAsync(policyName).ConfigureAwait(false))
{ {
throw new AbpAuthorizationException("Authorization failed! Given policy has not granted: " + policyName); throw new AbpAuthorizationException("Authorization failed! Given policy has not granted: " + policyName);
} }
@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Authorization
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement) public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IAuthorizationRequirement requirement)
{ {
if (!await authorizationService.IsGrantedAsync(resource, requirement)) if (!await authorizationService.IsGrantedAsync(resource, requirement).ConfigureAwait(false))
{ {
throw new AbpAuthorizationException("Authorization failed! Given requirement has not granted for given resource: " + resource); throw new AbpAuthorizationException("Authorization failed! Given requirement has not granted for given resource: " + resource);
} }
@ -109,7 +109,7 @@ namespace Microsoft.AspNetCore.Authorization
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy) public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, AuthorizationPolicy policy)
{ {
if (!await authorizationService.IsGrantedAsync(resource, policy)) if (!await authorizationService.IsGrantedAsync(resource, policy).ConfigureAwait(false))
{ {
throw new AbpAuthorizationException("Authorization failed! Given policy has not granted for given resource: " + resource); throw new AbpAuthorizationException("Authorization failed! Given policy has not granted for given resource: " + resource);
} }
@ -117,7 +117,7 @@ namespace Microsoft.AspNetCore.Authorization
public static async Task CheckAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy) public static async Task CheckAsync(this IAuthorizationService authorizationService, AuthorizationPolicy policy)
{ {
if (!await authorizationService.IsGrantedAsync(policy)) if (!await authorizationService.IsGrantedAsync(policy).ConfigureAwait(false))
{ {
throw new AbpAuthorizationException("Authorization failed! Given policy has not granted."); throw new AbpAuthorizationException("Authorization failed! Given policy has not granted.");
} }
@ -125,7 +125,7 @@ namespace Microsoft.AspNetCore.Authorization
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements) public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, IEnumerable<IAuthorizationRequirement> requirements)
{ {
if (!await authorizationService.IsGrantedAsync(resource, requirements)) if (!await authorizationService.IsGrantedAsync(resource, requirements).ConfigureAwait(false))
{ {
throw new AbpAuthorizationException("Authorization failed! Given requirements have not granted for given resource: " + resource); throw new AbpAuthorizationException("Authorization failed! Given requirements have not granted for given resource: " + resource);
} }
@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Authorization
public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, string policyName) public static async Task CheckAsync(this IAuthorizationService authorizationService, object resource, string policyName)
{ {
if (!await authorizationService.IsGrantedAsync(resource, policyName)) if (!await authorizationService.IsGrantedAsync(resource, policyName).ConfigureAwait(false))
{ {
throw new AbpAuthorizationException("Authorization failed! Given polist has not granted for given resource: " + resource); throw new AbpAuthorizationException("Authorization failed! Given polist has not granted for given resource: " + resource);
} }

2
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AbpAuthorizationPolicyProvider.cs

@ -25,7 +25,7 @@ namespace Volo.Abp.Authorization
public override async Task<AuthorizationPolicy> GetPolicyAsync(string policyName) public override async Task<AuthorizationPolicy> GetPolicyAsync(string policyName)
{ {
var policy = await base.GetPolicyAsync(policyName); var policy = await base.GetPolicyAsync(policyName).ConfigureAwait(false);
if (policy != null) if (policy != null)
{ {
return policy; return policy;

6
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/AuthorizationInterceptor.cs

@ -15,8 +15,8 @@ namespace Volo.Abp.Authorization
public override async Task InterceptAsync(IAbpMethodInvocation invocation) public override async Task InterceptAsync(IAbpMethodInvocation invocation)
{ {
await AuthorizeAsync(invocation); await AuthorizeAsync(invocation).ConfigureAwait(false);
await invocation.ProceedAsync(); await invocation.ProceedAsync().ConfigureAwait(false);
} }
protected virtual async Task AuthorizeAsync(IAbpMethodInvocation invocation) protected virtual async Task AuthorizeAsync(IAbpMethodInvocation invocation)
@ -25,7 +25,7 @@ namespace Volo.Abp.Authorization
new MethodInvocationAuthorizationContext( new MethodInvocationAuthorizationContext(
invocation.Method invocation.Method
) )
); ).ConfigureAwait(false);
} }
} }
} }

4
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/MethodInvocationAuthorizationService.cs

@ -34,7 +34,7 @@ namespace Volo.Abp.Authorization
foreach (var authorizationAttribute in GetAuthorizationDataAttributes(context.Method)) foreach (var authorizationAttribute in GetAuthorizationDataAttributes(context.Method))
{ {
await CheckAsync(authorizationAttribute); await CheckAsync(authorizationAttribute).ConfigureAwait(false);
} }
} }
@ -74,7 +74,7 @@ namespace Volo.Abp.Authorization
} }
else else
{ {
await _authorizationService.CheckAsync(authorizationAttribute.Policy); await _authorizationService.CheckAsync(authorizationAttribute.Policy).ConfigureAwait(false);
} }
//TODO: What about roles and other props? //TODO: What about roles and other props?

2
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/PermissionRequirementHandler.cs

@ -17,7 +17,7 @@ namespace Volo.Abp.Authorization
AuthorizationHandlerContext context, AuthorizationHandlerContext context,
PermissionRequirement requirement) PermissionRequirement requirement)
{ {
if (await _permissionChecker.IsGrantedAsync(context.User, requirement.PermissionName)) if (await _permissionChecker.IsGrantedAsync(context.User, requirement.PermissionName).ConfigureAwait(false))
{ {
context.Succeed(requirement); context.Succeed(requirement);
} }

2
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/ClientPermissionValueProvider.cs

@ -25,7 +25,7 @@ namespace Volo.Abp.Authorization.Permissions
} }
return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, clientId) return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, clientId)
? PermissionGrantResult.Granted .ConfigureAwait(false) ? PermissionGrantResult.Granted
: PermissionGrantResult.Undefined; : PermissionGrantResult.Undefined;
} }
} }

4
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/PermissionChecker.cs

@ -29,7 +29,7 @@ namespace Volo.Abp.Authorization.Permissions
public virtual async Task<bool> IsGrantedAsync(string name) public virtual async Task<bool> IsGrantedAsync(string name)
{ {
return await IsGrantedAsync(PrincipalAccessor.Principal, name); return await IsGrantedAsync(PrincipalAccessor.Principal, name).ConfigureAwait(false);
} }
public virtual async Task<bool> IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name) public virtual async Task<bool> IsGrantedAsync(ClaimsPrincipal claimsPrincipal, string name)
@ -56,7 +56,7 @@ namespace Volo.Abp.Authorization.Permissions
continue; continue;
} }
var result = await provider.CheckAsync(context); var result = await provider.CheckAsync(context).ConfigureAwait(false);
if (result == PermissionGrantResult.Granted) if (result == PermissionGrantResult.Granted)
{ {

2
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/RolePermissionValueProvider.cs

@ -27,7 +27,7 @@ namespace Volo.Abp.Authorization.Permissions
foreach (var role in roles) foreach (var role in roles)
{ {
if (await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, role)) if (await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, role).ConfigureAwait(false))
{ {
return PermissionGrantResult.Granted; return PermissionGrantResult.Granted;
} }

2
framework/src/Volo.Abp.Authorization/Volo/Abp/Authorization/Permissions/UserPermissionValueProvider.cs

@ -25,7 +25,7 @@ namespace Volo.Abp.Authorization.Permissions
} }
return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, userId) return await PermissionStore.IsGrantedAsync(context.Permission.Name, Name, userId)
? PermissionGrantResult.Granted .ConfigureAwait(false) ? PermissionGrantResult.Granted
: PermissionGrantResult.Undefined; : PermissionGrantResult.Undefined;
} }
} }

5
framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/BackgroundJobExecuter.cs

@ -4,7 +4,6 @@ using Microsoft.Extensions.Options;
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundJobs namespace Volo.Abp.BackgroundJobs
{ {
@ -21,7 +20,7 @@ namespace Volo.Abp.BackgroundJobs
Logger = NullLogger<BackgroundJobExecuter>.Instance; Logger = NullLogger<BackgroundJobExecuter>.Instance;
} }
public virtual void Execute(JobExecutionContext context) public virtual async Task ExecuteAsync(JobExecutionContext context)
{ {
var job = context.ServiceProvider.GetService(context.JobType); var job = context.ServiceProvider.GetService(context.JobType);
if (job == null) if (job == null)
@ -41,7 +40,7 @@ namespace Volo.Abp.BackgroundJobs
{ {
if (jobExecuteMethod.Name == nameof(IAsyncBackgroundJob<object>.ExecuteAsync)) if (jobExecuteMethod.Name == nameof(IAsyncBackgroundJob<object>.ExecuteAsync))
{ {
AsyncHelper.RunSync(() => (Task) jobExecuteMethod.Invoke(job, new[] {context.JobArgs})); await ((Task) jobExecuteMethod.Invoke(job, new[] {context.JobArgs})).ConfigureAwait(false);
} }
else else
{ {

6
framework/src/Volo.Abp.BackgroundJobs.Abstractions/Volo/Abp/BackgroundJobs/IBackgroundJobExecuter.cs

@ -1,7 +1,9 @@
namespace Volo.Abp.BackgroundJobs using System.Threading.Tasks;
namespace Volo.Abp.BackgroundJobs
{ {
public interface IBackgroundJobExecuter public interface IBackgroundJobExecuter
{ {
void Execute(JobExecutionContext context); Task ExecuteAsync(JobExecutionContext context);
} }
} }

3
framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/HangfireJobExecutionAdapter.cs

@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundJobs.Hangfire namespace Volo.Abp.BackgroundJobs.Hangfire
{ {
@ -25,7 +26,7 @@ namespace Volo.Abp.BackgroundJobs.Hangfire
{ {
var jobType = Options.GetJob(typeof(TArgs)).JobType; var jobType = Options.GetJob(typeof(TArgs)).JobType;
var context = new JobExecutionContext(scope.ServiceProvider, jobType, args); var context = new JobExecutionContext(scope.ServiceProvider, jobType, args);
JobExecuter.Execute(context); AsyncHelper.RunSync(() => JobExecuter.ExecuteAsync(context));
} }
} }
} }

13
framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueue.cs

@ -10,6 +10,7 @@ using Nito.AsyncEx;
using RabbitMQ.Client; using RabbitMQ.Client;
using RabbitMQ.Client.Events; using RabbitMQ.Client.Events;
using Volo.Abp.RabbitMQ; using Volo.Abp.RabbitMQ;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundJobs.RabbitMQ namespace Volo.Abp.BackgroundJobs.RabbitMQ
{ {
@ -71,11 +72,11 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
{ {
CheckDisposed(); CheckDisposed();
using (await SyncObj.LockAsync()) using (await SyncObj.LockAsync().ConfigureAwait(false))
{ {
await EnsureInitializedAsync(); await EnsureInitializedAsync().ConfigureAwait(false);
await PublishAsync(args, priority, delay); await PublishAsync(args, priority, delay).ConfigureAwait(false);
return null; return null;
} }
@ -90,9 +91,9 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
return; return;
} }
using (await SyncObj.LockAsync()) using (await SyncObj.LockAsync().ConfigureAwait(false))
{ {
await EnsureInitializedAsync(); await EnsureInitializedAsync().ConfigureAwait(false);
} }
} }
@ -181,7 +182,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
try try
{ {
JobExecuter.Execute(context); AsyncHelper.RunSync(() => JobExecuter.ExecuteAsync(context));
ChannelAccessor.Channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false); ChannelAccessor.Channel.BasicAck(deliveryTag: ea.DeliveryTag, multiple: false);
} }
catch (BackgroundJobExecutionException) catch (BackgroundJobExecutionException)

8
framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/JobQueueManager.cs

@ -40,7 +40,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
foreach (var jobConfiguration in Options.GetJobs()) foreach (var jobConfiguration in Options.GetJobs())
{ {
var jobQueue = (IRunnable)ServiceProvider.GetRequiredService(typeof(IJobQueue<>).MakeGenericType(jobConfiguration.ArgsType)); var jobQueue = (IRunnable)ServiceProvider.GetRequiredService(typeof(IJobQueue<>).MakeGenericType(jobConfiguration.ArgsType));
await jobQueue.StartAsync(cancellationToken); await jobQueue.StartAsync(cancellationToken).ConfigureAwait(false);
JobQueues[jobConfiguration.JobName] = jobQueue; JobQueues[jobConfiguration.JobName] = jobQueue;
} }
} }
@ -49,7 +49,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
{ {
foreach (var jobQueue in JobQueues.Values) foreach (var jobQueue in JobQueues.Values)
{ {
await jobQueue.StopAsync(cancellationToken); await jobQueue.StopAsync(cancellationToken).ConfigureAwait(false);
} }
JobQueues.Clear(); JobQueues.Clear();
@ -64,7 +64,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
return (IJobQueue<TArgs>)jobQueue; return (IJobQueue<TArgs>)jobQueue;
} }
using (await SyncSemaphore.LockAsync()) using (await SyncSemaphore.LockAsync().ConfigureAwait(false))
{ {
if (JobQueues.TryGetValue(jobConfiguration.JobName, out jobQueue)) if (JobQueues.TryGetValue(jobConfiguration.JobName, out jobQueue))
{ {
@ -74,7 +74,7 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
jobQueue = (IJobQueue<TArgs>)ServiceProvider jobQueue = (IJobQueue<TArgs>)ServiceProvider
.GetRequiredService(typeof(IJobQueue<>).MakeGenericType(typeof(TArgs))); .GetRequiredService(typeof(IJobQueue<>).MakeGenericType(typeof(TArgs)));
await jobQueue.StartAsync(); await jobQueue.StartAsync().ConfigureAwait(false);
JobQueues.TryAdd(jobConfiguration.JobName, jobQueue); JobQueues.TryAdd(jobConfiguration.JobName, jobQueue);

4
framework/src/Volo.Abp.BackgroundJobs.RabbitMQ/Volo/Abp/BackgroundJobs/RabbitMQ/RabbitMqBackgroundJobManager.cs

@ -19,8 +19,8 @@ namespace Volo.Abp.BackgroundJobs.RabbitMQ
BackgroundJobPriority priority = BackgroundJobPriority.Normal, BackgroundJobPriority priority = BackgroundJobPriority.Normal,
TimeSpan? delay = null) TimeSpan? delay = null)
{ {
var jobQueue = await _jobQueueManager.GetAsync<TArgs>(); var jobQueue = await _jobQueueManager.GetAsync<TArgs>().ConfigureAwait(false);
return await jobQueue.EnqueueAsync(args, priority, delay); return await jobQueue.EnqueueAsync(args, priority, delay).ConfigureAwait(false);
} }
} }
} }

93
framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/BackgroundJobWorker.cs

@ -1,5 +1,6 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
@ -9,92 +10,88 @@ using Volo.Abp.Timing;
namespace Volo.Abp.BackgroundJobs namespace Volo.Abp.BackgroundJobs
{ {
public class BackgroundJobWorker : PeriodicBackgroundWorkerBase, IBackgroundJobWorker public class BackgroundJobWorker : AsyncPeriodicBackgroundWorkerBase, IBackgroundJobWorker
{ {
protected AbpBackgroundJobOptions JobOptions { get; } protected AbpBackgroundJobOptions JobOptions { get; }
protected AbpBackgroundJobWorkerOptions WorkerOptions { get; } protected AbpBackgroundJobWorkerOptions WorkerOptions { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
public BackgroundJobWorker( public BackgroundJobWorker(
AbpTimer timer, AbpTimer timer,
IOptions<AbpBackgroundJobOptions> jobOptions, IOptions<AbpBackgroundJobOptions> jobOptions,
IOptions<AbpBackgroundJobWorkerOptions> workerOptions, IOptions<AbpBackgroundJobWorkerOptions> workerOptions,
IServiceScopeFactory serviceScopeFactory) IServiceScopeFactory serviceScopeFactory)
: base(timer) : base(
timer,
serviceScopeFactory)
{ {
ServiceScopeFactory = serviceScopeFactory;
WorkerOptions = workerOptions.Value; WorkerOptions = workerOptions.Value;
JobOptions = jobOptions.Value; JobOptions = jobOptions.Value;
Timer.Period = WorkerOptions.JobPollPeriod; Timer.Period = WorkerOptions.JobPollPeriod;
} }
protected override void DoWork() protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
{ {
using (var scope = ServiceScopeFactory.CreateScope()) var store = workerContext.ServiceProvider.GetRequiredService<IBackgroundJobStore>();
{
var store = scope.ServiceProvider.GetRequiredService<IBackgroundJobStore>();
var waitingJobs = AsyncHelper.RunSync(() => store.GetWaitingJobsAsync(WorkerOptions.MaxJobFetchCount)); var waitingJobs = await store.GetWaitingJobsAsync(WorkerOptions.MaxJobFetchCount).ConfigureAwait(false);
if (!waitingJobs.Any()) if (!waitingJobs.Any())
{ {
return; return;
} }
var jobExecuter = workerContext.ServiceProvider.GetRequiredService<IBackgroundJobExecuter>();
var clock = workerContext.ServiceProvider.GetRequiredService<IClock>();
var serializer = workerContext.ServiceProvider.GetRequiredService<IBackgroundJobSerializer>();
var jobExecuter = scope.ServiceProvider.GetRequiredService<IBackgroundJobExecuter>(); foreach (var jobInfo in waitingJobs)
var clock = scope.ServiceProvider.GetRequiredService<IClock>(); {
var serializer = scope.ServiceProvider.GetRequiredService<IBackgroundJobSerializer>(); jobInfo.TryCount++;
jobInfo.LastTryTime = clock.Now;
foreach (var jobInfo in waitingJobs) try
{ {
jobInfo.TryCount++; var jobConfiguration = JobOptions.GetJob(jobInfo.JobName);
jobInfo.LastTryTime = clock.Now; var jobArgs = serializer.Deserialize(jobInfo.JobArgs, jobConfiguration.ArgsType);
var context = new JobExecutionContext(workerContext.ServiceProvider, jobConfiguration.JobType, jobArgs);
try try
{ {
var jobConfiguration = JobOptions.GetJob(jobInfo.JobName); await jobExecuter.ExecuteAsync(context).ConfigureAwait(false);
var jobArgs = serializer.Deserialize(jobInfo.JobArgs, jobConfiguration.ArgsType);
var context = new JobExecutionContext(scope.ServiceProvider, jobConfiguration.JobType, jobArgs);
try await store.DeleteAsync(jobInfo.Id).ConfigureAwait(false);
{ }
jobExecuter.Execute(context); catch (BackgroundJobExecutionException)
{
var nextTryTime = CalculateNextTryTime(jobInfo, clock);
AsyncHelper.RunSync(() => store.DeleteAsync(jobInfo.Id)); if (nextTryTime.HasValue)
{
jobInfo.NextTryTime = nextTryTime.Value;
} }
catch (BackgroundJobExecutionException) else
{ {
var nextTryTime = CalculateNextTryTime(jobInfo, clock); jobInfo.IsAbandoned = true;
if (nextTryTime.HasValue)
{
jobInfo.NextTryTime = nextTryTime.Value;
}
else
{
jobInfo.IsAbandoned = true;
}
TryUpdate(store, jobInfo);
} }
await TryUpdateAsync(store, jobInfo).ConfigureAwait(false);
} }
catch (Exception ex) }
{ catch (Exception ex)
Logger.LogException(ex); {
jobInfo.IsAbandoned = true; Logger.LogException(ex);
TryUpdate(store, jobInfo); jobInfo.IsAbandoned = true;
} await TryUpdateAsync(store, jobInfo).ConfigureAwait(false);
} }
} }
} }
protected virtual void TryUpdate(IBackgroundJobStore store, BackgroundJobInfo jobInfo) protected virtual async Task TryUpdateAsync(IBackgroundJobStore store, BackgroundJobInfo jobInfo)
{ {
try try
{ {
AsyncHelper.RunSync(() => store.UpdateAsync(jobInfo)); await store.UpdateAsync(jobInfo).ConfigureAwait(false);
} }
catch (Exception updateEx) catch (Exception updateEx)
{ {

4
framework/src/Volo.Abp.BackgroundJobs/Volo/Abp/BackgroundJobs/DefaultBackgroundJobManager.cs

@ -32,7 +32,7 @@ namespace Volo.Abp.BackgroundJobs
public virtual async Task<string> EnqueueAsync<TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan? delay = null) public virtual async Task<string> EnqueueAsync<TArgs>(TArgs args, BackgroundJobPriority priority = BackgroundJobPriority.Normal, TimeSpan? delay = null)
{ {
var jobName = BackgroundJobNameAttribute.GetName<TArgs>(); var jobName = BackgroundJobNameAttribute.GetName<TArgs>();
var jobId = await EnqueueAsync(jobName, args, priority, delay); var jobId = await EnqueueAsync(jobName, args, priority, delay).ConfigureAwait(false);
return jobId.ToString(); return jobId.ToString();
} }
@ -53,7 +53,7 @@ namespace Volo.Abp.BackgroundJobs
jobInfo.NextTryTime = Clock.Now.Add(delay.Value); jobInfo.NextTryTime = Clock.Now.Add(delay.Value);
} }
await Store.InsertAsync(jobInfo); await Store.InsertAsync(jobInfo).ConfigureAwait(false);
return jobInfo.Id; return jobInfo.Id;
} }

55
framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/AsyncPeriodicBackgroundWorkerBase.cs

@ -0,0 +1,55 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Volo.Abp.Threading;
namespace Volo.Abp.BackgroundWorkers
{
public abstract class AsyncPeriodicBackgroundWorkerBase : BackgroundWorkerBase
{
protected IServiceScopeFactory ServiceScopeFactory { get; }
protected AbpTimer Timer { get; }
protected AsyncPeriodicBackgroundWorkerBase(
AbpTimer timer,
IServiceScopeFactory serviceScopeFactory)
{
ServiceScopeFactory = serviceScopeFactory;
Timer = timer;
Timer.Elapsed += Timer_Elapsed;
}
public override async Task StartAsync(CancellationToken cancellationToken = default)
{
await base.StartAsync(cancellationToken).ConfigureAwait(false);
Timer.Start(cancellationToken);
}
public override async Task StopAsync(CancellationToken cancellationToken = default)
{
Timer.Stop(cancellationToken);
await base.StopAsync(cancellationToken).ConfigureAwait(false);
}
private void Timer_Elapsed(object sender, System.EventArgs e)
{
try
{
using (var scope = ServiceScopeFactory.CreateScope())
{
AsyncHelper.RunSync(
() => DoWorkAsync(new PeriodicBackgroundWorkerContext(scope.ServiceProvider))
);
}
}
catch (Exception ex)
{
Logger.LogException(ex);
}
}
protected abstract Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext);
}
}

14
framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerContext.cs

@ -0,0 +1,14 @@
using System;
namespace Volo.Abp.BackgroundWorkers
{
public class PeriodicBackgroundWorkerContext
{
public IServiceProvider ServiceProvider { get; }
public PeriodicBackgroundWorkerContext(IServiceProvider serviceProvider)
{
ServiceProvider = serviceProvider;
}
}
}

4
framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/BackgroundWorkerManager.cs

@ -56,7 +56,7 @@ namespace Volo.Abp.BackgroundWorkers
foreach (var worker in _backgroundWorkers) foreach (var worker in _backgroundWorkers)
{ {
await worker.StartAsync(cancellationToken); await worker.StartAsync(cancellationToken).ConfigureAwait(false);
} }
} }
@ -66,7 +66,7 @@ namespace Volo.Abp.BackgroundWorkers
foreach (var worker in _backgroundWorkers) foreach (var worker in _backgroundWorkers)
{ {
await worker.StopAsync(cancellationToken); await worker.StopAsync(cancellationToken).ConfigureAwait(false);
} }
} }
} }

26
framework/src/Volo.Abp.BackgroundWorkers/Volo/Abp/BackgroundWorkers/PeriodicBackgroundWorkerBase.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Volo.Abp.Threading; using Volo.Abp.Threading;
@ -11,35 +12,38 @@ namespace Volo.Abp.BackgroundWorkers
/// </summary> /// </summary>
public abstract class PeriodicBackgroundWorkerBase : BackgroundWorkerBase public abstract class PeriodicBackgroundWorkerBase : BackgroundWorkerBase
{ {
protected readonly AbpTimer Timer; protected IServiceScopeFactory ServiceScopeFactory { get; }
protected AbpTimer Timer { get; }
/// <summary> protected PeriodicBackgroundWorkerBase(
/// Initializes a new instance of the <see cref="PeriodicBackgroundWorkerBase"/> class. AbpTimer timer,
/// </summary> IServiceScopeFactory serviceScopeFactory)
/// <param name="timer">A timer.</param>
protected PeriodicBackgroundWorkerBase(AbpTimer timer)
{ {
ServiceScopeFactory = serviceScopeFactory;
Timer = timer; Timer = timer;
Timer.Elapsed += Timer_Elapsed; Timer.Elapsed += Timer_Elapsed;
} }
public override async Task StartAsync(CancellationToken cancellationToken = default) public override async Task StartAsync(CancellationToken cancellationToken = default)
{ {
await base.StartAsync(cancellationToken); await base.StartAsync(cancellationToken).ConfigureAwait(false);
Timer.Start(cancellationToken); Timer.Start(cancellationToken);
} }
public override async Task StopAsync(CancellationToken cancellationToken = default) public override async Task StopAsync(CancellationToken cancellationToken = default)
{ {
Timer.Stop(cancellationToken); Timer.Stop(cancellationToken);
await base.StopAsync(cancellationToken); await base.StopAsync(cancellationToken).ConfigureAwait(false);
} }
private void Timer_Elapsed(object sender, System.EventArgs e) private void Timer_Elapsed(object sender, System.EventArgs e)
{ {
try try
{ {
DoWork(); using (var scope = ServiceScopeFactory.CreateScope())
{
DoWork(new PeriodicBackgroundWorkerContext(scope.ServiceProvider));
}
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -50,6 +54,6 @@ namespace Volo.Abp.BackgroundWorkers
/// <summary> /// <summary>
/// Periodic works should be done by implementing this method. /// Periodic works should be done by implementing this method.
/// </summary> /// </summary>
protected abstract void DoWork(); protected abstract void DoWork(PeriodicBackgroundWorkerContext workerContext);
} }
} }

18
framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs

@ -175,7 +175,7 @@ namespace Volo.Abp.Caching
cachedBytes = await Cache.GetAsync( cachedBytes = await Cache.GetAsync(
NormalizeKey(key), NormalizeKey(key),
CancellationTokenProvider.FallbackToProvider(token) CancellationTokenProvider.FallbackToProvider(token)
); ).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -250,22 +250,22 @@ namespace Volo.Abp.Caching
CancellationToken token = default) CancellationToken token = default)
{ {
token = CancellationTokenProvider.FallbackToProvider(token); token = CancellationTokenProvider.FallbackToProvider(token);
var value = await GetAsync(key, hideErrors, token); var value = await GetAsync(key, hideErrors, token).ConfigureAwait(false);
if (value != null) if (value != null)
{ {
return value; return value;
} }
using (await SyncSemaphore.LockAsync(token)) using (await SyncSemaphore.LockAsync(token).ConfigureAwait(false))
{ {
value = await GetAsync(key, hideErrors, token); value = await GetAsync(key, hideErrors, token).ConfigureAwait(false);
if (value != null) if (value != null)
{ {
return value; return value;
} }
value = await factory(); value = await factory().ConfigureAwait(false);
await SetAsync(key, value, optionsFactory?.Invoke(), hideErrors, token); await SetAsync(key, value, optionsFactory?.Invoke(), hideErrors, token).ConfigureAwait(false);
} }
return value; return value;
@ -331,7 +331,7 @@ namespace Volo.Abp.Caching
Serializer.Serialize(value), Serializer.Serialize(value),
options ?? DefaultCacheOptions, options ?? DefaultCacheOptions,
CancellationTokenProvider.FallbackToProvider(token) CancellationTokenProvider.FallbackToProvider(token)
); ).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -387,7 +387,7 @@ namespace Volo.Abp.Caching
try try
{ {
await Cache.RefreshAsync(NormalizeKey(key), CancellationTokenProvider.FallbackToProvider(token)); await Cache.RefreshAsync(NormalizeKey(key), CancellationTokenProvider.FallbackToProvider(token)).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -443,7 +443,7 @@ namespace Volo.Abp.Caching
try try
{ {
await Cache.RemoveAsync(NormalizeKey(key), CancellationTokenProvider.FallbackToProvider(token)); await Cache.RemoveAsync(NormalizeKey(key), CancellationTokenProvider.FallbackToProvider(token)).ConfigureAwait(false);
} }
catch (Exception ex) catch (Exception ex)
{ {

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

Loading…
Cancel
Save