Browse Source

Merge branch 'dev' of https://github.com/naderjavid/abp into dev

pull/12869/head
root 5 years ago
parent
commit
529ebc161c
  1. 16
      .github/workflows/auto-pr.yml
  2. 2
      common.props
  3. 7
      deploy/_run_all.ps1
  4. 94
      docs/en/Blog-Posts/2022-01-11 v5_1_Preview/POST.md
  5. BIN
      docs/en/Blog-Posts/2022-01-11 v5_1_Preview/abp-community-talks-2022-1.png
  6. 111
      docs/en/Community-Articles/2022-01-10-How-to-test-Blazor-components-in-ABP/POST.md
  7. 76
      docs/en/Connection-Strings.md
  8. 70
      docs/en/Entity-Framework-Core.md
  9. 8
      docs/en/Tutorials/Part-10.md
  10. 2
      docs/zh-Hans/Entities.md
  11. 1211
      docs/zh-Hans/Tutorials/Part-10.md
  12. 2
      docs/zh-Hans/Tutorials/Part-2.md
  13. 4
      docs/zh-Hans/Tutorials/Part-3.md
  14. 2
      docs/zh-Hans/Tutorials/Part-4.md
  15. 2
      docs/zh-Hans/Tutorials/Part-5.md
  16. 2
      docs/zh-Hans/Tutorials/Part-6.md
  17. 4
      docs/zh-Hans/Tutorials/Part-8.md
  18. 2
      docs/zh-Hans/Tutorials/Part-9.md
  19. BIN
      docs/zh-Hans/Tutorials/images/blazor-bookstore-book-list-with-authors.png
  20. BIN
      docs/zh-Hans/Tutorials/images/book-create-modal-with-author.png
  21. BIN
      docs/zh-Hans/Tutorials/images/bookstore-angular-author-selection.png
  22. BIN
      docs/zh-Hans/Tutorials/images/bookstore-books-with-authorname-angular.png
  23. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs
  24. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/sweetalert2/abp-sweetalert2.js
  25. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationAppService.cs
  26. 4
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditLogInfo.cs
  27. 4
      framework/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AuditingHelper.cs
  28. 15
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
  29. 89
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
  30. 1
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs
  31. 10
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmGlobalPackagesChecker.cs
  32. 84
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
  33. 22
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNpmPackageAdder.cs
  34. 153
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs
  35. 1
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs
  36. 2
      framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/AbpDbContext.cs
  37. 23
      framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs
  38. 6
      framework/src/Volo.Abp.EventBus.Kafka/Volo/Abp/EventBus/Kafka/KafkaDistributedEventBus.cs
  39. 6
      framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs
  40. 6
      framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventBus.cs
  41. 6
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/DistributedEventBusBase.cs
  42. 33
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs
  43. 52
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventHandlerInvoker.cs
  44. 8
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventHandlerInvokerCacheItem.cs
  45. 34
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventHandlerMethodExecutor.cs
  46. 9
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandlerInvoker.cs
  47. 5
      framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs
  48. 132
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
  49. 5
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelDiscoveryDocumentCacheItem.cs
  50. 33
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs
  51. 5
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs
  52. 20
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs
  53. 18
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapSettingProvider.cs
  54. 11
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs
  55. 55
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingDefinitionProvider.cs
  56. 2
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs
  57. 73
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs
  58. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json
  59. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json
  60. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json
  61. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json
  62. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json
  63. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json
  64. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json
  65. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json
  66. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json
  67. 7
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json
  68. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json
  69. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json
  70. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json
  71. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json
  72. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json
  73. 8
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json
  74. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json
  75. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json
  76. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json
  77. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json
  78. 4
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json
  79. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json
  80. 6
      framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json
  81. 10
      framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/AbpClaimTypes.cs
  82. 14
      framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs
  83. 128
      framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventHandlerInvoker_Tests.cs
  84. 9
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs
  85. 9
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs
  86. 20
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs
  87. 46
      framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/TestLdapSettingValueProvider.cs
  88. 4
      modules/account/Volo.Abp.Account.abpmdl.json
  89. 11
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.abppkg.analyze.json
  90. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/ar.json
  91. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/de-DE.json
  92. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
  93. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/es.json
  94. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/fi.json
  95. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/fr.json
  96. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/hi.json
  97. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/it.json
  98. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/pt-BR.json
  99. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/sk.json
  100. 1
      modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/sl.json

16
.github/workflows/auto-pr.yml

@ -1,10 +1,10 @@
name: Merge branch dev with rel-5.0
name: Merge branch dev with rel-5.1
on:
push:
branches:
- rel-5.0
- rel-5.1
jobs:
merge-dev-with-rel-5-0:
merge-dev-with-rel-5-1:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@ -12,13 +12,13 @@ jobs:
ref: dev
- name: Reset promotion branch
run: |
git fetch origin rel-5.0:rel-5.0
git reset --hard rel-5.0
git fetch origin rel-5.1:rel-5.1
git reset --hard rel-5.1
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
branch: auto-merge/rel-5-0/${{github.run_number}}
title: Merge branch dev with rel-5.0
body: This PR generated automatically to merge dev with rel-5.0. Please review the changed files before merging to prevent any errors that may occur.
branch: auto-merge/rel-5-1/${{github.run_number}}
title: Merge branch dev with rel-5.1
body: This PR generated automatically to merge dev with rel-5.1. Please review the changed files before merging to prevent any errors that may occur.
reviewers: ${{github.actor}}
token: ${{ github.token }}

2
common.props

@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
<Version>5.1.0</Version>
<Version>5.2.0</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
<PackageIconUrl>https://abp.io/assets/abp_nupkg.png</PackageIconUrl>
<PackageProjectUrl>https://abp.io/</PackageProjectUrl>

7
deploy/_run_all.ps1

@ -0,0 +1,7 @@
./1-fetch-and-build.ps1
./2-nuget-pack.ps1
./3-nuget-push.ps1
./4-npm-publish-mvc.ps1
./5-npm-publish-angular.ps1
./6-git-commit.ps1
echo "Create a new release on GitHub manually and run the step 8..."

94
docs/en/Blog-Posts/2022-01-11 v5_1_Preview/POST.md

@ -0,0 +1,94 @@
# ABP.IO Platform 5.1 RC.1 Has Been Released
Today, we are releasing the [ABP Framework](https://abp.io/) and the [ABP Commercial](https://commercial.abp.io/) version **5.1 RC** (Release Candidate). This blog post introduces the new features and important changes in this new version.
> **The planned release date for the [5.1 stable](https://github.com/abpframework/abp/milestone/64) version is February 8, 2022**.
Please try this version and provide feedback for a more stable ABP version 5.1! Thank you all.
## Get Started with the 5.1 RC
follow the steps below to try the version 5.1 RC today;
1) **Upgrade** the ABP CLI to the version `5.1.0-rc.1` using a command line terminal:
````bash
dotnet tool update Volo.Abp.Cli -g --version 5.1.0-rc.1
````
**or install** if you haven't installed before:
````bash
dotnet tool install Volo.Abp.Cli -g --version 5.1.0-rc.1
````
2) Create a **new application** with the `--preview` option:
````bash
abp new BookStore --preview
````
See the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all the available options.
> You can also use the *Direct Download* tab on the [Get Started](https://abp.io/get-started) page by selecting the **Preview checkbox**.
You can use any IDE that supports .NET 6.0 development (e.g. [Visual Studio 2022](https://visualstudio.microsoft.com/downloads/)).
### Migration Notes & Breaking Changes
TODO: Startup template changes
## What's new with 5.1?
In this section, I will introduce some major features released with this version.
### DRAFT list of things done
#### ABP Framework
* Use new hosting model for the app template. [#10928](https://github.com/abpframework/abp/pull/10928) - what to do for existing solutions?
* Async application initialization methods on the AbpModule class [#6828](https://github.com/abpframework/abp/issues/6828)
* Angular 13?
* [#10552](https://github.com/abpframework/abp/pull/10696) Used file scoped namespaces :)
* Support markdown in CMS-Kit comments [#10792](https://github.com/abpframework/abp/pull/10792)
* eShopOnAbp is getting mature
* Nightly builds are working again
* Coming: New ABP.IO design!
All issues & PRs in [5.1 milesone](https://github.com/abpframework/abp/milestone/60?closed=1).
#### ABP Commercial
* CMS Kit Pro: URL forwarding
* LeptonX is coming for ABP Blazor and MVC UI too (share the sample dashboard)
### Header 1
TODO
## Community News
### ABP Community Talks 2021.1
![abp-community-talks-2022-1](abp-community-talks-2022-1.png)
This is the second episode of the ABP Community Talks and we are talking about microservice development with the ABP Framework, based on the [eShopOnAbp](https://github.com/abpframework/eShopOnAbp) reference solution. This live meeting will be at **January 20, 2022, 17:00 (UTC)** on YouTube.
**Join this event on the Kommunity platform: https://kommunity.com/volosoft/events/abp-community-talks-20221-microservice-development-acd0f44b**
You can also [subscribe to the Volosoft channel](https://www.youtube.com/channel/UCO3XKlpvq8CA5MQNVS6b3dQ) for reminders for further ABP events and videos.
### New ABP Community posts
Here, some of the recent posts added to the [ABP community](https://community.abp.io/):
* [Minimal API development with the ABP Framework](https://community.abp.io/articles/minimal-api-with-abp-hello-world-part-1-sg5i44p8) by [@antosubash](https://github.com/antosubash) (three parts, video tutorial).
* [Integrating the Syncfusion MVC Components to the ABP MVC UI](https://community.abp.io/articles/integrating-the-syncfusion-mvc-components-to-the-abp-mvc-ui-0gpkr1if) by [@EngincanV](https://github.com/EngincanV).
* [Add Tailwind CSS to your ABP Blazor UI](https://community.abp.io/articles/add-tailwindcss-to-your-abp-blazor-ui-vidiwzcy) by [@antosubash](https://github.com/antosubash) (video tutorial).
* [Import external users into the users Table from an ABP Framework application](https://community.abp.io/articles/import-external-users-into-the-users-table-from-an-abp-framework-application-7lnyw415) by [@bartvanhoey](https://github.com/bartvanhoey).
Thanks to the ABP Community for all the contents they have published. You can also [post your ABP and .NET related (text or video) contents](https://community.abp.io/articles/submit) to the ABP Community.
## Conclusion
In this blog post, I summarized the news about that new version and the ABP Community. Please try it and provide feedback by opening issues on [the GitHub repository](https://github.com/abpframework/abp). Thank you all!

BIN
docs/en/Blog-Posts/2022-01-11 v5_1_Preview/abp-community-talks-2022-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 KiB

111
docs/en/Community-Articles/2022-01-10-How-to-test-Blazor-components-in-ABP/POST.md

@ -0,0 +1,111 @@
# How to Test Blazor Components in ABP
## Source Code
You can find the source of the example solution used in this article [here](https://github.com/abpframework/abp-samples/tree/master/BlazorPageUniTest).
In this article, I will use [bUnit](https://github.com/bUnit-dev/bUnit) for a simple test of a Blazor component.
## Getting Started
Use the ABP CLI to create a blazor app
`abp new BookStore -t app -u blazor`
Then add the `BookStore.Blazor.Tests` xunit test project to the solution, and add [bUnit](https://github.com/bUnit-dev/bUnit) package and `ProjectReference` to the test project.
The contents of `BookStore.Blazor.Tests.csproj`
```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="bunit" Version="1.2.49" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
<PackageReference Include="Volo.Abp.Authorization.Abstractions" Version="5.0.1" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\BookStore.Blazor\BookStore.Blazor.csproj" />
<ProjectReference Include="..\BookStore.EntityFrameworkCore.Tests\BookStore.EntityFrameworkCore.Tests.csproj" />
</ItemGroup>
</Project>
```
Create `BookStoreBlazorTestModule` that depends on `AbpAspNetCoreComponentsModule` and `BookStoreEntityFrameworkCoreTestModule`.
```cs
[DependsOn(
typeof(AbpAspNetCoreComponentsModule),
typeof(BookStoreEntityFrameworkCoreTestModule)
)]
public class BookStoreBlazorTestModule : AbpModule
{
}
```
Create a `BookStoreBlazorTestBase` class and add the `CreateTestContext` method. The `CreateTestContext` have key code.
It uses ABP's `ServiceProvider` as a fallback `ServiceProvider` and add all ABP's services to the `TestContext`.
```cs
public abstract class BookStoreBlazorTestBase : BookStoreTestBase<BookStoreBlazorTestModule>
{
protected virtual TestContext CreateTestContext()
{
var testContext = new TestContext();
testContext.Services.AddFallbackServiceProvider(ServiceProvider);
foreach (var service in ServiceProvider.GetRequiredService<IAbpApplicationWithExternalServiceProvider>().Services)
{
testContext.Services.Add(service);
}
testContext.Services.AddBlazorise().AddBootstrap5Providers().AddFontAwesomeIcons();
return testContext;
}
}
```
Finally, we add an `Index_Tests` class to test the `Index` component.
```cs
public class Index_Tests : BookStoreBlazorTestBase
{
[Fact]
public void Index_Test()
{
using (var ctx = CreateTestContext())
{
// Act
var cut = ctx.RenderComponent<BookStore.Blazor.Pages.Index>();
// Assert
cut.Find(".lead").InnerHtml.Contains("Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.").ShouldBeTrue();
cut.Find("#username").InnerHtml.Contains("Welcome admin").ShouldBeTrue();
}
}
}
```
## Reference document
https://github.com/bUnit-dev/bUnit
https://docs.microsoft.com/en-us/aspnet/core/blazor/test

76
docs/en/Connection-Strings.md

@ -1,15 +1,17 @@
# Connection Strings
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;
> Connection string system is especially needed when you want to create or use a modular system. If you have a monolithic application with a single database, you can go with the [ABP startup solution template](Startup-Templates/Application.md), which is properly configured for you.
* 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.
ABP Framework is designed to be [modular](Module-Development-Basics.md) and [multi-tenancy](Multi-Tenancy.md) aware. Connection string management is also designed to support these scenarios;
* 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 database providers.
* Allows to set separate connection string and use a separate database per tenant (in a SaaS application).
It also supports hybrid scenarios;
* 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 modules into databases (e.g., all modules into a single shared database or two modules to database A, three modules to database B, one module to database C and rest of the modules to database D)
* 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).
* Allows to separate databases per tenant per module (which might be hard 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.
@ -29,15 +31,19 @@ See the following configuration:
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.
* `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` (the `AbpIdentityServer` connection string) is used by the [IdentityServer](Modules/IdentityServer.md) module.
* `MyPermissionDb` (the `AbpPermissionManagement` connection string) 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.
[Pre-built application modules](Modules/Index.md) define constants for the connection string names. For example, the [IdentityServer module](Modules/IdentityServer.md) defines a ` ConnectionStringName ` constant in the ` AbpIdentityServerDbProperties ` class (located in the ` Volo.Abp.IdentityServer ` namespace). Other modules similarly define constants, so you can investigate the connection string name.
### AbpDbConnectionOptions
ABP actually uses the `AbpDbConnectionOptions` to get the connection strings. If you set the connection strings as explained above, `AbpDbConnectionOptions` is automatically filled. However, you can set or override the connection strings using [the options pattern](Options.md). You can configure the `AbpDbConnectionOptions` in the `ConfigureServices` method of your [module](Module-Development-Basics.md) as shown below:
`AbpDbConnectionOptions` is the options class that is used to set the connection strings and configure database structures.
#### Setting the connection strings
ABP uses the `AbpDbConnectionOptions` to get the connection strings. If you configure the connection strings as explained above, `AbpDbConnectionOptions` is automatically filled. However, you can set or override the connection strings using [the options pattern](Options.md). You can configure the `AbpDbConnectionOptions` in the `ConfigureServices` method of your [module](Module-Development-Basics.md) as shown below:
````csharp
public override void ConfigureServices(ServiceConfigurationContext context)
@ -50,6 +56,52 @@ public override void ConfigureServices(ServiceConfigurationContext context)
}
````
#### Configuring the database structures
`Databases` property of the `AbpDbConnectionOptions` class is used to group multiple connection strings (of multiple modules) to a single connection string.
See the following connection strings:
````json
"ConnectionStrings": {
"Default": "Server=localhost;Database=MyMainDb;Trusted_Connection=True;",
"AbpIdentity": "Server=localhost;Database=MySecondaryDb;Trusted_Connection=True;",
"AbpIdentityServer": "Server=localhost;Database=MySecondaryDb;Trusted_Connection=True;",
"AbpPermissionManagement": "Server=localhost;Database=MySecondaryDb;Trusted_Connection=True;"
}
````
In this example, we've defined four connection strings, but the last three of them are the same; `AbpIdentity`, `AbpIdentityServer` and `AbpPermissionManagement` uses the same database, named `MySecondaryDb`. The main application and the other modules use the `Default` connection string, hence the `MyMainDb` database.
What we want to do here is to group three modules (`AbpIdentity`, `AbpIdentityServer` and `AbpPermissionManagement`) in a single database, but we needed to specify each one manually. Because the fallback connection string is the `Default` one, if we don't specify it for a module.
To eliminate the repetitive connection string definition, we can configure the `AbpDbConnectionOptions.Databases` property to group these connection strings, as shown in the following code (we place that in the `ConfigureServices` method of our [module class](Module-Development-Basics.md)):
````csharp
Configure<AbpDbConnectionOptions>(options =>
{
options.Databases.Configure("MySecondaryDb", db =>
{
db.MappedConnections.Add("AbpIdentity");
db.MappedConnections.Add("AbpIdentityServer");
db.MappedConnections.Add("AbpPermissionManagement");
});
});
````
Then we can change the `appsettings.json` file as shown in the following code block:
````json
"ConnectionStrings": {
"Default": "Server=localhost;Database=MyMainDb;Trusted_Connection=True;",
"MySecondaryDb": "Server=localhost;Database=MySecondaryDb;Trusted_Connection=True;"
}
````
`MySecondaryDb` becomes the new connection string for the mapped connections.
> ABP first looks for the module-specific connection string, then looks if a database mapping is available, finally fallbacks to the `Default` connection string.
## Set the Connection String Name
A module typically has a unique connection string name associated to its `DbContext` class using the `ConnectionStringName` attribute. Example:
@ -62,15 +114,13 @@ public class IdentityServerDbContext
}
````
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).
For [Entity Framework Core](Entity-Framework-Core.md) and [MongoDB](MongoDB.md), write this to your `DbContext` class (and the interface if it has). In this way, ABP uses the specified connection string for the related `DbContext` instances.
## 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` project that contains related classes and the migration files for that database. This project mainly defines a *YourProjectName*DbContext that calls the `Configure...()` methods of the used modules, like `builder.ConfigurePermissionManagement()`.
The startup template (with EF Core ORM) comes with a single database and a `.EntityFrameworkCore` project that contains related classes and the migration files for that database. This project mainly defines a `YourProjectNameDbContext` class 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. See the [EF Core Migrations](Entity-Framework-Core-Migrations.md) document to learn how to create and use a different database for a desired module.

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

@ -4,7 +4,7 @@ This document explains how to integrate EF Core as an ORM provider to ABP based
## Installation
`Volo.Abp.EntityFrameworkCore` is the main nuget package for the EF Core integration. Install it to your project (for a layered application, to your data/infrastructure layer):
`Volo.Abp.EntityFrameworkCore` is the main NuGet package for the EF Core integration. Install it to your project (for a layered application, to your data/infrastructure layer):
```` shell
Install-Package Volo.Abp.EntityFrameworkCore
@ -30,15 +30,13 @@ namespace MyCompany.MyProject
### 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.
Entity Framework Core supports various database management systems ([see all](https://docs.microsoft.com/en-us/ef/core/providers/)). ABP framework and this document don't depend on any specific DBMS. If you are creating a [reusable application module](Modules/Index.md), avoid to depend on a specific DBMS package. However, in a final application you eventually will select a DBMS.
If you are creating a [reusable application module](Modules/Index.md), avoid to depend on a specific DBMS package. However, in a final application you eventually will select a DBMS.
See [Switch to Another DBMS for Entity Framework Core](Entity-Framework-Core-Other-DBMS.md) document to learn how to switch the DBMS.
> See [Switch to Another DBMS for Entity Framework Core](Entity-Framework-Core-Other-DBMS.md) document to learn how to switch the DBMS.
## Creating DbContext
You can create your DbContext as you normally do. It should be derived from `AbpDbContext<T>` as shown below:
Your `DbContext` class should be derived from `AbpDbContext<T>` as shown below:
````C#
using Microsoft.EntityFrameworkCore;
@ -107,7 +105,7 @@ protected override void OnModelCreating(ModelBuilder builder)
### Configure the Connection String Selection
If you have multiple databases in your application, you can configure the connection string name for your DbContext using the `[ConnectionStringName]` attribute. Example:
If you have multiple databases in your application, you can configure the connection string name for your `DbContext` using the `[ConnectionStringName]` attribute. Example:
```csharp
[ConnectionStringName("MySecondConnString")]
@ -119,9 +117,65 @@ 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 (see [the connection strings document](Connection-Strings.md) for more information).
### AbpDbContextOptions
`AbpDbContextOptions` is used to configure the `DbContext` options. When you create a new solution with the ABP's application startup template, you will see a simple configuration (in the `EntityFrameworkCore` integration project's module class) as shown below:
````csharp
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer();
});
````
That configuration configures the default DBMS as SQL Server for all the `DbContext`s of the application. That configuration was a shorthand notation and it can be done with the following code block:
````csharp
Configure<AbpDbContextOptions>(options =>
{
options.Configure(opts =>
{
opts.UseSqlServer();
});
});
````
`options.Configure(...)` method has more options to configure. For example, you can set `DbContextOptions` (EF Core's native options) as shown below:
````csharp
Configure<AbpDbContextOptions>(options =>
{
options.Configure(opts =>
{
opts.DbContextOptions.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
});
});
````
If you have a single `DbContext` or you have multiple `DbContext`s but want to use the same DBMS and configuration for all, you can leave it as is. However, if you need to configure a different DBMS or customize the configuration for a specific `DbContext`, you can specify it as shown below:
````csharp
Configure<AbpDbContextOptions>(options =>
{
// Default configuration for all DbContexts
options.Configure(opts =>
{
opts.UseSqlServer();
});
// Customized configuration for a specific DbContext
options.Configure<MyOtherDbContext>(opts =>
{
opts.UseMySQL();
});
});
````
> See [Switch to Another DBMS for Entity Framework Core](Entity-Framework-Core-Other-DBMS.md) document to learn how to configure the DBMS.
## Registering DbContext To Dependency Injection
Use `AddAbpDbContext` method in your module to register your DbContext class for [dependency injection](Dependency-Injection.md) system.
Use `AddAbpDbContext` method in your module to register your `DbContext` class for [dependency injection](Dependency-Injection.md) system.
````C#
using Microsoft.Extensions.DependencyInjection;

8
docs/en/Tutorials/Part-10.md

@ -325,7 +325,7 @@ This new method will be used from the UI to get a list of authors and fill a dro
### BookAppService
Open the `BookAppService` interface in the `Books` folder of the `Acme.BookStore.Application` project and replace the file content with the following code:
Open the `BookAppService` class in the `Books` folder of the `Acme.BookStore.Application` project and replace the file content with the following code:
{{if DB=="EF"}}
@ -449,7 +449,7 @@ namespace Acme.BookStore.Books
{
return sorting.Replace(
"authorName",
"author.Name",
"author.Name",
StringComparison.OrdinalIgnoreCase
);
}
@ -533,7 +533,7 @@ namespace Acme.BookStore.Books
{
input.Sorting = nameof(Book.Name);
}
//Get the IQueryable<Book> from the repository
var queryable = await Repository.GetQueryableAsync();
@ -582,7 +582,7 @@ namespace Acme.BookStore.Books
.ToArray();
var queryable = await _authorRepository.GetQueryableAsync();
var authors = await AsyncExecuter.ToListAsync(
queryable.Where(a => authorIds.Contains(a.Id))
);

2
docs/zh-Hans/Entities.md

@ -26,7 +26,7 @@ public class Book : Entity<Guid>
如果你的实体Id类型为 `Guid`,有一些好的实践可以实现:
* 创建一个构造函数,获取ID作为参数传递给基类.
* 如果没有为GUID Id斌值,**ABP框架会在保存时设置它**,但是在将实体保存到数据库之前最好在实体上有一个有效的Id.
* 如果没有为GUID Id赋值,**ABP框架会在保存时设置它**,但是在将实体保存到数据库之前最好在实体上有一个有效的Id.
* 如果使用带参数的构造函数创建实体,那么还要创建一个 `private` 或 `protected` 构造函数. 当数据库提供程序从数据库读取你的实体时(反序列化时)将使用它.
* 不要使用 `Guid.NewGuid()` 来设置Id! 在创建实体的代码中**使用[`IGuidGenerator`服务](Guid-Generation.md)**传递Id参数. `IGuidGenerator`经过优化可以产生连续的GUID.这对于关系数据库中的聚集索引非常重要.

1211
docs/zh-Hans/Tutorials/Part-10.md

File diff suppressed because it is too large

2
docs/zh-Hans/Tutorials/Part-2.md

@ -16,7 +16,7 @@
本教程分为以下部分:
- [Part 1: 创建服务端](Part-1.md)
- **Part 2: 图书列表页面**(本章)
- **Part 2: 图书列表页面 (本章)**
- [Part 3: 创建,更新和删除图书](Part-3.md)
- [Part 4: 集成测试](Part-4.md)
- [Part 5: 授权](Part-5.md)

4
docs/zh-Hans/Tutorials/Part-3.md

@ -17,7 +17,7 @@
- [Part 1: 创建服务端](Part-1.md)
- [Part 2: 图书列表页面](Part-2.md)
- **Part 3: 创建,更新和删除图书**(本章)
- **Part 3: 创建,更新和删除图书 (本章)**
- [Part 4: 集成测试](Part-4.md)
- [Part 5: 授权](Part-5.md)
- [Part 6: 作者: 领域层](Part-6.md)
@ -1596,4 +1596,4 @@ namespace Acme.BookStore.Blazor
## 下一章
查看本教程的[下一章](Part-4.md).
查看本教程的[下一章](Part-4.md).

2
docs/zh-Hans/Tutorials/Part-4.md

@ -18,7 +18,7 @@
- [Part 1: 创建服务端](Part-1.md)
- [Part 2: 图书列表页面](Part-2.md)
- [Part 3: 创建,更新和删除图书](Part-3.md)
- **Part 4: 集成测试**(本章)
- **Part 4: 集成测试 (本章)**
- [Part 5: 授权](Part-5.md)
- [Part 6: 作者: 领域层](Part-6.md)
- [Part 7: 作者: 数据库集成](Part-7.md)

2
docs/zh-Hans/Tutorials/Part-5.md

@ -19,7 +19,7 @@
- [Part 2: 图书列表页面](Part-2.md)
- [Part 3: 创建,更新和删除图书](Part-2.md)
- [Part 4: 集成测试](Part-4.md)
- **Part 5: 授权**(本章)
- **Part 5: 授权 (本章)**
- [Part 6: 作者: 领域层](Part-6.md)
- [Part 7: 作者: 数据库集成](Part-7.md)
- [Part 8: 作者: 应用服务层](Part-8.md)

2
docs/zh-Hans/Tutorials/Part-6.md

@ -20,7 +20,7 @@
- [Part 3: 创建,更新和删除图书](Part-2.md)
- [Part 4: 集成测试](Part-4.md)
- [Part 5: 授权](Part-5.md)
- **Part 6: 作者: 领域层**(本章)
- **Part 6: 作者: 领域层 (本章)**
- [Part 7: 作者: 数据库集成](Part-7.md)
- [Part 8: 作者: 应用服务层](Part-8.md)
- [Part 9: 作者: 用户页面](Part-9.md)

4
docs/zh-Hans/Tutorials/Part-8.md

@ -22,7 +22,7 @@
- [Part 5: 授权](Part-5.md)
- [Part 6: 作者: 领域层](Part-6.md)
- [Part 7: 作者: 数据库集成](Part-7.md)
- [Part 8: 作者: 应用服务层](本章)
- **Part 8: 作者: 应用服务层 (本章)**
- [Part 9: 作者: 用户页面](Part-9.md)
- [Part 10: 图书到作者的关系](Part-10.md)
@ -391,7 +391,7 @@ authorsPermission.AddChild(
CreateMap<Author, AuthorDto>();
````
## 种子数据
## 数据种子
如同图书管理部分所做的, 在数据库中生成一些初始作者实体. 不仅当第一次运行应用程序时是有用的, 对自动化测试也是很有用的.

2
docs/zh-Hans/Tutorials/Part-9.md

@ -23,7 +23,7 @@
- [Part 6: 作者: 领域层](Part-6.md)
- [Part 7: 作者: 数据库集成](Part-7.md)
- [Part 8: 作者: 应用服务层](Part-8.md)
- [Part 9: 作者: 用户页面](本章)
- **Part 9: 作者: 用户页面 (本章)**
- [Part 10: 图书到作者的关系](Part-10.md)
## 下载源码

BIN
docs/zh-Hans/Tutorials/images/blazor-bookstore-book-list-with-authors.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

BIN
docs/zh-Hans/Tutorials/images/book-create-modal-with-author.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
docs/zh-Hans/Tutorials/images/bookstore-angular-author-selection.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
docs/zh-Hans/Tutorials/images/bookstore-books-with-authorname-angular.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

4
framework/src/Volo.Abp.AspNetCore.Mvc.Contracts/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/CurrentUserDto.cs

@ -15,6 +15,10 @@ public class CurrentUserDto
public Guid? ImpersonatorTenantId { get; set; }
public string ImpersonatorUserName { get; set; }
public string ImpersonatorTenantName { get; set; }
public string UserName { get; set; }
public string Name { get; set; }

3
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/sweetalert2/abp-sweetalert2.js

@ -100,10 +100,11 @@ var abp = abp || {};
abp.event.on('abp.configurationInitialized', function () {
var l = abp.localization.getResource('AbpUi');
abp.libs.sweetAlert.config.default.confirmButtonText = l('Yes');
abp.libs.sweetAlert.config.default.confirmButtonText = l('Ok');
abp.libs.sweetAlert.config.default.denyButtonText = l('No');
abp.libs.sweetAlert.config.default.cancelButtonText = l('Cancel');
abp.libs.sweetAlert.config.confirm.title = l('AreYouSure');
abp.libs.sweetAlert.config.confirm.confirmButtonText = l('Yes');
abp.libs.sweetAlert.config.confirm.showCancelButton = true;
abp.libs.sweetAlert.config.confirm.reverseButtons = true;
});

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

@ -129,6 +129,8 @@ public class AbpApplicationConfigurationAppService : ApplicationService, IAbpApp
TenantId = _currentUser.TenantId,
ImpersonatorUserId = _currentUser.FindImpersonatorUserId(),
ImpersonatorTenantId = _currentUser.FindImpersonatorTenantId(),
ImpersonatorUserName = _currentUser.FindImpersonatorUserName(),
ImpersonatorTenantName = _currentUser.FindImpersonatorTenantName(),
UserName = _currentUser.UserName,
SurName = _currentUser.SurName,
Name = _currentUser.Name,

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

@ -23,6 +23,10 @@ public class AuditLogInfo : IHasExtraProperties
public Guid? ImpersonatorTenantId { get; set; }
public string ImpersonatorUserName { get; set; }
public string ImpersonatorTenantName { get; set; }
public DateTime ExecutionTime { get; set; }
public int ExecutionDuration { get; set; }

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

@ -136,9 +136,11 @@ public class AuditingHelper : IAuditingHelper, ITransientDependency
UserName = CurrentUser.UserName,
ClientId = CurrentClient.Id,
CorrelationId = CorrelationIdProvider.Get(),
ExecutionTime = Clock.Now,
ImpersonatorUserId = CurrentUser.FindImpersonatorUserId(),
ImpersonatorUserName = CurrentUser.FindImpersonatorUserName(),
ImpersonatorTenantId = CurrentUser.FindImpersonatorTenantId(),
ExecutionTime = Clock.Now
ImpersonatorTenantName = CurrentUser.FindImpersonatorTenantName(),
};
ExecutePreContributors(auditInfo);

15
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs

@ -92,6 +92,21 @@ public class AuthService : IAuthService, ITransientDependency
File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8);
}
public async Task DeviceLoginAsync()
{
var configuration = new IdentityClientConfiguration(
CliUrls.AccountAbpIo,
"role email abpio abpio_www abpio_commercial openid offline_access",
"abp-cli",
"1q2w3e*",
OidcConstants.GrantTypes.DeviceCode
);
var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration);
File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8);
}
public async Task LogoutAsync()
{
string accessToken = null;

89
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs

@ -42,52 +42,70 @@ public class LoginCommand : IConsoleCommand, ITransientDependency
public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
if (commandLineArgs.Target.IsNullOrEmpty())
if (!commandLineArgs.Options.ContainsKey("device"))
{
throw new CliUsageException(
"Username name is missing!" +
Environment.NewLine + Environment.NewLine +
GetUsageInfo()
);
}
var organization = commandLineArgs.Options.GetOrNull(Options.Organization.Short, Options.Organization.Long);
if (await HasMultipleOrganizationAndThisNotSpecified(commandLineArgs, organization))
{
return;
}
var password = commandLineArgs.Options.GetOrNull(Options.Password.Short, Options.Password.Long);
if (password == null)
{
Console.Write("Password: ");
password = ConsoleHelper.ReadSecret();
if (password.IsNullOrWhiteSpace())
if (commandLineArgs.Target.IsNullOrEmpty())
{
throw new CliUsageException(
"Password is missing!" +
"Username name is missing!" +
Environment.NewLine + Environment.NewLine +
GetUsageInfo()
);
}
}
try
{
await AuthService.LoginAsync(
commandLineArgs.Target,
password,
organization
);
var organization = commandLineArgs.Options.GetOrNull(Options.Organization.Short, Options.Organization.Long);
if (await HasMultipleOrganizationAndThisNotSpecified(commandLineArgs, organization))
{
return;
}
var password = commandLineArgs.Options.GetOrNull(Options.Password.Short, Options.Password.Long);
if (password == null)
{
Console.Write("Password: ");
password = ConsoleHelper.ReadSecret();
if (password.IsNullOrWhiteSpace())
{
throw new CliUsageException(
"Password is missing!" +
Environment.NewLine + Environment.NewLine +
GetUsageInfo()
);
}
}
try
{
await AuthService.LoginAsync(
commandLineArgs.Target,
password,
organization
);
}
catch (Exception ex)
{
LogCliError(ex, commandLineArgs);
return;
}
Logger.LogInformation($"Successfully logged in as '{commandLineArgs.Target}'");
}
catch (Exception ex)
else
{
LogCliError(ex, commandLineArgs);
return;
}
try
{
await AuthService.DeviceLoginAsync();
}
catch (Exception ex)
{
LogCliError(ex, commandLineArgs);
return;
}
Logger.LogInformation($"Successfully logged in as '{commandLineArgs.Target}'");
var loginInfo = await AuthService.GetLoginInfoAsync();
Logger.LogInformation($"Successfully logged in as '{loginInfo.Username}'");
}
}
private async Task<bool> HasMultipleOrganizationAndThisNotSpecified(CommandLineArgs commandLineArgs, string organization)
@ -178,6 +196,7 @@ public class LoginCommand : IConsoleCommand, ITransientDependency
sb.AppendLine("Usage:");
sb.AppendLine(" abp login <username>");
sb.AppendLine(" abp login <username> -p <password>");
sb.AppendLine(" abp login <username> --device");
sb.AppendLine("");
sb.AppendLine("Example:");
sb.AppendLine("");

1
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs

@ -182,6 +182,7 @@ public abstract class AppTemplateBase : TemplateInfo
}
else
{
context.Symbols.Add("PUBLIC-REDIS");
context.Symbols.Add("public-website");
}

10
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmGlobalPackagesChecker.cs

@ -24,10 +24,6 @@ public class NpmGlobalPackagesChecker : ITransientDependency
{
InstallYarn();
}
if (!installedNpmPackages.Contains(" gulp@"))
{
InstallGulp();
}
}
protected virtual string GetInstalledNpmPackages()
@ -41,10 +37,4 @@ public class NpmGlobalPackagesChecker : ITransientDependency
Logger.LogInformation("Installing yarn...");
CmdHelper.RunCmd("npm install yarn -g");
}
protected virtual void InstallGulp()
{
Logger.LogInformation("Installing gulp...");
CmdHelper.RunCmd("npm install gulp -g");
}
}

84
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs

@ -11,6 +11,8 @@ using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NuGet.Versioning;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection;
@ -23,6 +25,7 @@ public class NpmPackagesUpdater : ITransientDependency
{
public ILogger<NpmPackagesUpdater> Logger { get; set; }
protected ICancellationTokenProvider CancellationTokenProvider { get; }
public InstallLibsCommand InstallLibsCommand { get; }
public ICmdHelper CmdHelper { get; }
private readonly PackageJsonFileFinder _packageJsonFileFinder;
@ -35,17 +38,21 @@ public class NpmPackagesUpdater : ITransientDependency
NpmGlobalPackagesChecker npmGlobalPackagesChecker,
ICancellationTokenProvider cancellationTokenProvider,
CliHttpClientFactory cliHttpClientFactory,
InstallLibsCommand ınstallLibsCommand,
ICmdHelper cmdHelper)
{
_packageJsonFileFinder = packageJsonFileFinder;
_npmGlobalPackagesChecker = npmGlobalPackagesChecker;
CancellationTokenProvider = cancellationTokenProvider;
InstallLibsCommand = ınstallLibsCommand;
CmdHelper = cmdHelper;
_cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger<NpmPackagesUpdater>.Instance;
}
public async Task Update(string rootDirectory, bool includePreviews = false, bool includeReleaseCandidates = false, bool switchToStable = false, string version = null)
public async Task Update(string rootDirectory, bool includePreviews = false,
bool includeReleaseCandidates = false,
bool switchToStable = false, string version = null)
{
var fileList = _packageJsonFileFinder.Find(rootDirectory);
@ -60,7 +67,9 @@ public class NpmPackagesUpdater : ITransientDependency
async Task UpdateAsync(string file)
{
var updated = await UpdatePackagesInFile(file, includePreviews, includeReleaseCandidates, switchToStable, version);
var updated = await UpdatePackagesInFile(file, includePreviews, includeReleaseCandidates,
switchToStable,
version);
packagesUpdated.TryAdd(file, updated);
}
@ -88,10 +97,10 @@ public class NpmPackagesUpdater : ITransientDependency
RunYarn(fileDirectory);
}
if (!IsAngularProject(fileDirectory) && GulpFileExistAsync(fileDirectory))
if (!IsAngularProject(fileDirectory))
{
Thread.Sleep(1000);
RunGulp(fileDirectory);
RunInstallLibsAsync(fileDirectory);
}
}
}
@ -108,20 +117,13 @@ public class NpmPackagesUpdater : ITransientDependency
return await Task.FromResult(File.Exists(Path.Combine(directoryName, ".npmrc")));
}
private static bool GulpFileExistAsync(string directoryName)
{
return File.Exists(Path.Combine(directoryName, "gulpfile.js"));
}
private async Task CreateNpmrcFileAsync(string directoryName)
{
var fileName = Path.Combine(directoryName, ".npmrc");
var abpRegistry = "@abp:registry=https://www.myget.org/F/abp-nightly/npm";
var voloRegistry = await GetVoloRegistryAsync();
if (await NpmrcFileExistAsync(directoryName))
{
var fileContent = File.ReadAllText(fileName);
if (!fileContent.Contains(abpRegistry))
@ -129,11 +131,6 @@ public class NpmPackagesUpdater : ITransientDependency
fileContent += Environment.NewLine + abpRegistry;
}
if (!fileContent.Contains(voloRegistry))
{
fileContent += Environment.NewLine + voloRegistry;
}
File.WriteAllText(fileName, fileContent);
return;
@ -142,42 +139,10 @@ public class NpmPackagesUpdater : ITransientDependency
using var fs = File.Create(fileName);
var content = new UTF8Encoding(true)
.GetBytes(abpRegistry + Environment.NewLine + voloRegistry);
.GetBytes(abpRegistry);
fs.Write(content, 0, content.Length);
}
private async Task<string> GetVoloRegistryAsync()
{
var apikey = await GetApiKeyAsync();
if (string.IsNullOrWhiteSpace(apikey))
{
return "";
}
return "@volo:registry=https://www.myget.org/F/abp-commercial/auth/" + apikey + "/npm/";
}
public async Task<string> GetApiKeyAsync()
{
try
{
var client = _cliHttpClientFactory.CreateClient();
using (var response = await client.GetHttpResponseMessageWithRetryAsync(
url: $"{CliUrls.WwwAbpIo}api/myget/apikey/",
cancellationToken: CancellationTokenProvider.Token,
logger: Logger
))
{
return Encoding.Default.GetString(await response.Content.ReadAsByteArrayAsync());
}
}
catch (Exception)
{
return string.Empty;
}
}
private static bool IsAngularProject(string fileDirectory)
{
return File.Exists(Path.Combine(fileDirectory, "angular.json"));
@ -202,7 +167,8 @@ public class NpmPackagesUpdater : ITransientDependency
foreach (var abpPackage in abpPackages)
{
var updated = await TryUpdatingPackage(filePath, abpPackage, includePreviews, includeReleaseCandidates, switchToStable, specifiedVersion);
var updated = await TryUpdatingPackage(filePath, abpPackage, includePreviews, includeReleaseCandidates,
switchToStable, specifiedVersion);
if (updated)
{
@ -236,15 +202,19 @@ public class NpmPackagesUpdater : ITransientDependency
return false;
}
if (SemanticVersion.Parse(specifiedVersion) <= SemanticVersion.Parse(currentVersion.RemovePreFix("~", "^")))
if (SemanticVersion.Parse(specifiedVersion) <=
SemanticVersion.Parse(currentVersion.RemovePreFix("~", "^")))
{
return false;
}
version = specifiedVersion.EnsureStartsWith('^');
}
else
{
if ((includePreviews || (!switchToStable && (currentVersion != null && currentVersion.Contains("-preview")))) && !includeReleaseCandidates)
if ((includePreviews ||
(!switchToStable && (currentVersion != null && currentVersion.Contains("-preview")))) &&
!includeReleaseCandidates)
{
version = "preview";
}
@ -328,16 +298,18 @@ public class NpmPackagesUpdater : ITransientDependency
abpPackages
.AddRange(properties.Where(p => p.Name.StartsWith("@abp/") || p.Name.StartsWith("@volo/"))
.ToList());
.ToList());
}
return abpPackages;
}
protected virtual void RunGulp(string fileDirectory)
protected virtual async Task RunInstallLibsAsync(string fileDirectory)
{
Logger.LogInformation($"Running Gulp on {fileDirectory}");
CmdHelper.RunCmd($"cd {fileDirectory} && gulp");
var args = new CommandLineArgs("install-libs");
args.Options.Add(InstallLibsCommand.Options.WorkingDirectory.Short, fileDirectory);
await InstallLibsCommand.ExecuteAsync(args);
}
protected virtual void RunYarn(string fileDirectory)

22
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNpmPackageAdder.cs

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -26,6 +26,7 @@ public class ProjectNpmPackageAdder : ITransientDependency
public SourceCodeDownloadService SourceCodeDownloadService { get; }
public AngularSourceCodeAdder AngularSourceCodeAdder { get; }
public IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
public InstallLibsCommand InstallLibsCommand { get; }
public ICmdHelper CmdHelper { get; }
private readonly CliHttpClientFactory _cliHttpClientFactory;
public ILogger<ProjectNpmPackageAdder> Logger { get; set; }
@ -35,12 +36,14 @@ public class ProjectNpmPackageAdder : ITransientDependency
SourceCodeDownloadService sourceCodeDownloadService,
AngularSourceCodeAdder angularSourceCodeAdder,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
InstallLibsCommand ınstallLibsCommand,
ICmdHelper cmdHelper)
{
JsonSerializer = jsonSerializer;
SourceCodeDownloadService = sourceCodeDownloadService;
AngularSourceCodeAdder = angularSourceCodeAdder;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
InstallLibsCommand = ınstallLibsCommand;
CmdHelper = cmdHelper;
_cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger<ProjectNpmPackageAdder>.Instance;
@ -109,14 +112,14 @@ public class ProjectNpmPackageAdder : ITransientDependency
);
}
public Task AddMvcPackageAsync(string directory, NpmPackageInfo npmPackage, string version = null,
bool skipGulpCommand = false)
public async Task AddMvcPackageAsync(string directory, NpmPackageInfo npmPackage, string version = null,
bool skipInstallingLibs = false)
{
var packageJsonFilePath = Path.Combine(directory, "package.json");
if (!File.Exists(packageJsonFilePath) ||
File.ReadAllText(packageJsonFilePath).Contains($"\"{npmPackage.Name}\""))
{
return Task.CompletedTask;
return;
}
Logger.LogInformation($"Installing '{npmPackage.Name}' package to the project '{packageJsonFilePath}'...");
@ -134,16 +137,15 @@ public class ProjectNpmPackageAdder : ITransientDependency
Logger.LogInformation("yarn add " + npmPackage.Name + versionPostfix);
CmdHelper.RunCmd("yarn add " + npmPackage.Name + versionPostfix);
if (skipGulpCommand)
if (skipInstallingLibs)
{
return Task.CompletedTask;
return;
}
Logger.LogInformation("gulp");
CmdHelper.RunCmd("gulp");
await InstallLibsCommand.ExecuteAsync(
new CommandLineArgs("install-libs")
);
}
return Task.CompletedTask;
}
private string DetectAbpVersionOrNull(string packageJsonFile)

153
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs

@ -1,4 +1,4 @@
using System;
using System;
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
@ -519,14 +519,23 @@ public class SolutionModuleAdder : ITransientDependency
foreach (var nugetPackage in module.NugetPackages)
{
var isProjectTiered = await IsProjectTiered(projectFiles);
var nugetTarget =
await IsProjectTiered(projectFiles) && nugetPackage.TieredTarget != NuGetPackageTarget.Undefined
isProjectTiered && nugetPackage.TieredTarget != NuGetPackageTarget.Undefined
? nugetPackage.TieredTarget
: nugetPackage.Target;
if (webPackagesWillBeAddedToBlazorServerProject && nugetTarget == NuGetPackageTarget.Web)
if (webPackagesWillBeAddedToBlazorServerProject)
{
nugetTarget = NuGetPackageTarget.BlazorServer;
if ( nugetTarget == NuGetPackageTarget.Web)
{
nugetTarget = NuGetPackageTarget.BlazorServer;
}
else if (!isProjectTiered && nugetTarget == NuGetPackageTarget.SignalR)
{
nugetTarget = NuGetPackageTarget.BlazorServer;
}
}
var targetProjectFile = ProjectFinder.FindNuGetTargetProjectFile(projectFiles, nugetTarget);
@ -590,7 +599,7 @@ public class SolutionModuleAdder : ITransientDependency
}
var dbMigrationsProject = projectFiles.FirstOrDefault(p => p.EndsWith(".DbMigrations.csproj"))
?? projectFiles.FirstOrDefault(p => p.EndsWith(".EntityFrameworkCore.csproj"));
?? projectFiles.FirstOrDefault(p => p.EndsWith(".EntityFrameworkCore.csproj")) ;
if (dbMigrationsProject == null)
{
@ -679,74 +688,74 @@ public class SolutionModuleAdder : ITransientDependency
module.EfCoreConfigureMethodName = $"{module.Name}.EntityFrameworkCore:Configure{moduleProjectName}";
module.NugetPackages = new List<NugetPackageInfo>
{
new NugetPackageInfo
{
new NugetPackageInfo
{
Name = $"{module.Name}.Application",
ModuleClass = $"{module.Name}.{moduleProjectName}ApplicationModule",
Target = NuGetPackageTarget.Application
},
new NugetPackageInfo
{
Name = $"{module.Name}.Application.Contracts",
ModuleClass = $"{module.Name}.{moduleProjectName}ApplicationContractsModule",
Target = NuGetPackageTarget.ApplicationContracts
},
new NugetPackageInfo
{
Name = $"{module.Name}.Blazor.WebAssembly",
ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorWebAssemblyModule",
Target = NuGetPackageTarget.BlazorWebAssembly
},
new NugetPackageInfo
{
Name = $"{module.Name}.Blazor.Server",
ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorServerModule",
Target = NuGetPackageTarget.BlazorServer
},
new NugetPackageInfo
{
Name = $"{module.Name}.Domain",
ModuleClass = $"{module.Name}.{moduleProjectName}DomainModule",
Target = NuGetPackageTarget.Domain
},
new NugetPackageInfo
{
Name = $"{module.Name}.Domain.Shared",
ModuleClass = $"{module.Name}.{moduleProjectName}DomainSharedModule",
Target = NuGetPackageTarget.DomainShared
},
new NugetPackageInfo
{
Name = $"{module.Name}.EntityFrameworkCore",
ModuleClass = $"{module.Name}.EntityFrameworkCore.{moduleProjectName}EntityFrameworkCoreModule",
Target = NuGetPackageTarget.EntityFrameworkCore
},
new NugetPackageInfo
{
Name = $"{module.Name}.HttpApi",
ModuleClass = $"{module.Name}.{moduleProjectName}HttpApiModule",
Target = NuGetPackageTarget.HttpApi
},
new NugetPackageInfo
{
Name = $"{module.Name}.HttpApi.Client",
ModuleClass = $"{module.Name}.{moduleProjectName}HttpApiClientModule",
Target = NuGetPackageTarget.HttpApiClient
},
new NugetPackageInfo
{
Name = $"{module.Name}.MongoDB",
ModuleClass = $"{module.Name}.MongoDB.{moduleProjectName}MongoDbModule",
Target = NuGetPackageTarget.MongoDB
},
new NugetPackageInfo
{
Name = $"{module.Name}.Web",
ModuleClass = $"{module.Name}.Web.{moduleProjectName}WebModule",
Target = NuGetPackageTarget.Web
},
};
Name = $"{module.Name}.Application",
ModuleClass = $"{module.Name}.{moduleProjectName}ApplicationModule",
Target = NuGetPackageTarget.Application
},
new NugetPackageInfo
{
Name = $"{module.Name}.Application.Contracts",
ModuleClass = $"{module.Name}.{moduleProjectName}ApplicationContractsModule",
Target = NuGetPackageTarget.ApplicationContracts
},
new NugetPackageInfo
{
Name = $"{module.Name}.Blazor.WebAssembly",
ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorWebAssemblyModule",
Target = NuGetPackageTarget.BlazorWebAssembly
},
new NugetPackageInfo
{
Name = $"{module.Name}.Blazor.Server",
ModuleClass = $"{module.Name}.Blazor.{moduleProjectName}BlazorServerModule",
Target = NuGetPackageTarget.BlazorServer
},
new NugetPackageInfo
{
Name = $"{module.Name}.Domain",
ModuleClass = $"{module.Name}.{moduleProjectName}DomainModule",
Target = NuGetPackageTarget.Domain
},
new NugetPackageInfo
{
Name = $"{module.Name}.Domain.Shared",
ModuleClass = $"{module.Name}.{moduleProjectName}DomainSharedModule",
Target = NuGetPackageTarget.DomainShared
},
new NugetPackageInfo
{
Name = $"{module.Name}.EntityFrameworkCore",
ModuleClass = $"{module.Name}.EntityFrameworkCore.{moduleProjectName}EntityFrameworkCoreModule",
Target = NuGetPackageTarget.EntityFrameworkCore
},
new NugetPackageInfo
{
Name = $"{module.Name}.HttpApi",
ModuleClass = $"{module.Name}.{moduleProjectName}HttpApiModule",
Target = NuGetPackageTarget.HttpApi
},
new NugetPackageInfo
{
Name = $"{module.Name}.HttpApi.Client",
ModuleClass = $"{module.Name}.{moduleProjectName}HttpApiClientModule",
Target = NuGetPackageTarget.HttpApiClient
},
new NugetPackageInfo
{
Name = $"{module.Name}.MongoDB",
ModuleClass = $"{module.Name}.MongoDB.{moduleProjectName}MongoDbModule",
Target = NuGetPackageTarget.MongoDB
},
new NugetPackageInfo
{
Name = $"{module.Name}.Web",
ModuleClass = $"{module.Name}.Web.{moduleProjectName}WebModule",
Target = NuGetPackageTarget.Web
},
};
module.NpmPackages = new List<NpmPackageInfo>();

1
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Program.cs

@ -18,6 +18,7 @@ public class Program
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning)
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning)
.MinimumLevel.Override("System.Net.Http.HttpClient", LogEventLevel.Warning)
.MinimumLevel.Override("Volo.Abp.IdentityModel", LogEventLevel.Information)
#if DEBUG
.MinimumLevel.Override("Volo.Abp.Cli", LogEventLevel.Debug)
#else

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

@ -486,7 +486,7 @@ public abstract class AbpDbContext<TDbContext> : DbContext, IAbpEfCoreDbContext,
entry.Reload();
entry.Entity.As<ISoftDelete>().IsDeleted = true;
entry.State = EntityState.Modified;
SetDeletionAuditProperties(entry);
}
protected virtual bool IsHardDeleted(EntityEntry entry)

23
framework/src/Volo.Abp.EventBus.Azure/Volo/Abp/EventBus/Azure/AzureDistributedEventBus.cs

@ -39,13 +39,15 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen
IOptions<AbpAzureEventBusOptions> abpAzureEventBusOptions,
IAzureServiceBusSerializer serializer,
IAzureServiceBusMessageConsumerFactory messageConsumerFactory,
IPublisherPool publisherPool)
IPublisherPool publisherPool,
IEventHandlerInvoker eventHandlerInvoker)
: base(serviceScopeFactory,
currentTenant,
unitOfWorkManager,
abpDistributedEventBusOptions,
guidGenerator,
clock)
clock,
eventHandlerInvoker)
{
_options = abpAzureEventBusOptions.Value;
_serializer = serializer;
@ -87,7 +89,7 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen
public override async Task PublishFromOutboxAsync(OutgoingEventInfo outgoingEvent, OutboxConfig outboxConfig)
{
await PublishAsync(outgoingEvent.EventName, outgoingEvent.EventData);
await PublishAsync(outgoingEvent.EventName, outgoingEvent.EventData, outgoingEvent.Id);
}
public override async Task ProcessFromInboxAsync(IncomingEventInfo incomingEvent, InboxConfig inboxConfig)
@ -188,15 +190,28 @@ public class AzureDistributedEventBus : DistributedEventBusBase, ISingletonDepen
unitOfWork.AddOrReplaceDistributedEvent(eventRecord);
}
protected virtual async Task PublishAsync(string eventName, object eventData)
protected virtual Task PublishAsync(string eventName, object eventData)
{
var body = _serializer.Serialize(eventData);
return PublishAsync(eventName, body, null);
}
protected virtual async Task PublishAsync(
string eventName,
byte[] body,
Guid? eventId)
{
var message = new ServiceBusMessage(body)
{
Subject = eventName
};
if (message.MessageId.IsNullOrWhiteSpace())
{
message.MessageId = (eventId ?? GuidGenerator.Create()).ToString("N");
}
var publisher = await _publisherPool.GetAsync(
_options.TopicName,
_options.ConnectionName);

6
framework/src/Volo.Abp.EventBus.Kafka/Volo/Abp/EventBus/Kafka/KafkaDistributedEventBus.cs

@ -39,14 +39,16 @@ public class KafkaDistributedEventBus : DistributedEventBusBase, ISingletonDepen
IKafkaSerializer serializer,
IProducerPool producerPool,
IGuidGenerator guidGenerator,
IClock clock)
IClock clock,
IEventHandlerInvoker eventHandlerInvoker)
: base(
serviceScopeFactory,
currentTenant,
unitOfWorkManager,
abpDistributedEventBusOptions,
guidGenerator,
clock)
clock,
eventHandlerInvoker)
{
AbpKafkaEventBusOptions = abpKafkaEventBusOptions.Value;
MessageConsumerFactory = messageConsumerFactory;

6
framework/src/Volo.Abp.EventBus.RabbitMQ/Volo/Abp/EventBus/RabbitMq/RabbitMqDistributedEventBus.cs

@ -44,14 +44,16 @@ public class RabbitMqDistributedEventBus : DistributedEventBusBase, ISingletonDe
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IGuidGenerator guidGenerator,
IClock clock)
IClock clock,
IEventHandlerInvoker eventHandlerInvoker)
: base(
serviceScopeFactory,
currentTenant,
unitOfWorkManager,
distributedEventBusOptions,
guidGenerator,
clock)
clock,
eventHandlerInvoker)
{
ConnectionPool = connectionPool;
Serializer = serializer;

6
framework/src/Volo.Abp.EventBus.Rebus/Volo/Abp/EventBus/Rebus/RebusDistributedEventBus.cs

@ -38,14 +38,16 @@ public class RebusDistributedEventBus : DistributedEventBusBase, ISingletonDepen
IOptions<AbpRebusEventBusOptions> abpEventBusRebusOptions,
IRebusSerializer serializer,
IGuidGenerator guidGenerator,
IClock clock) :
IClock clock,
IEventHandlerInvoker eventHandlerInvoker) :
base(
serviceScopeFactory,
currentTenant,
unitOfWorkManager,
abpDistributedEventBusOptions,
guidGenerator,
clock)
clock,
eventHandlerInvoker)
{
Rebus = rebus;
Serializer = serializer;

6
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Distributed/DistributedEventBusBase.cs

@ -22,11 +22,13 @@ public abstract class DistributedEventBusBase : EventBusBase, IDistributedEventB
IUnitOfWorkManager unitOfWorkManager,
IOptions<AbpDistributedEventBusOptions> abpDistributedEventBusOptions,
IGuidGenerator guidGenerator,
IClock clock
IClock clock,
IEventHandlerInvoker eventHandlerInvoker
) : base(
serviceScopeFactory,
currentTenant,
unitOfWorkManager)
unitOfWorkManager,
eventHandlerInvoker)
{
GuidGenerator = guidGenerator;
Clock = clock;

33
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventBusBase.cs

@ -22,14 +22,18 @@ public abstract class EventBusBase : IEventBus
protected IUnitOfWorkManager UnitOfWorkManager { get; }
protected IEventHandlerInvoker EventHandlerInvoker { get; }
protected EventBusBase(
IServiceScopeFactory serviceScopeFactory,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager)
IUnitOfWorkManager unitOfWorkManager,
IEventHandlerInvoker eventHandlerInvoker)
{
ServiceScopeFactory = serviceScopeFactory;
CurrentTenant = currentTenant;
UnitOfWorkManager = unitOfWorkManager;
EventHandlerInvoker = eventHandlerInvoker;
}
/// <inheritdoc/>
@ -210,32 +214,7 @@ public abstract class EventBusBase : IEventBus
using (CurrentTenant.Change(GetEventDataTenantId(eventData)))
{
if (ReflectionHelper.IsAssignableToGenericType(handlerType, typeof(ILocalEventHandler<>)))
{
var method = typeof(ILocalEventHandler<>)
.MakeGenericType(eventType)
.GetMethod(
nameof(ILocalEventHandler<object>.HandleEventAsync),
new[] { eventType }
);
await ((Task)method.Invoke(eventHandlerWrapper.EventHandler, new[] { eventData }));
}
else if (ReflectionHelper.IsAssignableToGenericType(handlerType, typeof(IDistributedEventHandler<>)))
{
var method = typeof(IDistributedEventHandler<>)
.MakeGenericType(eventType)
.GetMethod(
nameof(IDistributedEventHandler<object>.HandleEventAsync),
new[] { eventType }
);
await ((Task)method.Invoke(eventHandlerWrapper.EventHandler, new[] { eventData }));
}
else
{
throw new AbpException("The object instance is not an event handler. Object type: " + handlerType.AssemblyQualifiedName);
}
await EventHandlerInvoker.InvokeAsync(eventHandlerWrapper.EventHandler, eventData, eventType);
}
}
catch (TargetInvocationException ex)

52
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventHandlerInvoker.cs

@ -0,0 +1,52 @@
using System;
using System.Collections.Concurrent;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.EventBus;
public class EventHandlerInvoker : IEventHandlerInvoker, ISingletonDependency
{
private readonly ConcurrentDictionary<string, EventHandlerInvokerCacheItem> _cache;
public EventHandlerInvoker()
{
_cache = new ConcurrentDictionary<string, EventHandlerInvokerCacheItem>();
}
public async Task InvokeAsync(IEventHandler eventHandler, object eventData, Type eventType)
{
var cacheItem = _cache.GetOrAdd($"{eventHandler.GetType().FullName}-{eventType.FullName}", _ =>
{
var item = new EventHandlerInvokerCacheItem();
if (typeof(ILocalEventHandler<>).MakeGenericType(eventType).IsInstanceOfType(eventHandler))
{
item.Local = (IEventHandlerMethodExecutor)Activator.CreateInstance(typeof(LocalEventHandlerMethodExecutor<>).MakeGenericType(eventType));
}
if (typeof(IDistributedEventHandler<>).MakeGenericType(eventType).IsInstanceOfType(eventHandler))
{
item.Distributed = (IEventHandlerMethodExecutor)Activator.CreateInstance(typeof(DistributedEventHandlerMethodExecutor<>).MakeGenericType(eventType));
}
return item;
});
if (cacheItem.Local != null)
{
await cacheItem.Local.ExecutorAsync(eventHandler, eventData);
}
if (cacheItem.Distributed != null)
{
await cacheItem.Distributed.ExecutorAsync(eventHandler, eventData);
}
if (cacheItem.Local == null && cacheItem.Distributed == null)
{
throw new AbpException("The object instance is not an event handler. Object type: " + eventHandler.GetType().AssemblyQualifiedName);
}
}
}

8
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventHandlerInvokerCacheItem.cs

@ -0,0 +1,8 @@
namespace Volo.Abp.EventBus;
public class EventHandlerInvokerCacheItem
{
public IEventHandlerMethodExecutor Local { get; set; }
public IEventHandlerMethodExecutor Distributed { get; set; }
}

34
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventHandlerMethodExecutor.cs

@ -0,0 +1,34 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.EventBus.Distributed;
namespace Volo.Abp.EventBus;
public delegate Task EventHandlerMethodExecutorAsync(IEventHandler target, object parameter);
public interface IEventHandlerMethodExecutor
{
EventHandlerMethodExecutorAsync ExecutorAsync { get; }
}
public class LocalEventHandlerMethodExecutor<TEvent> : IEventHandlerMethodExecutor
where TEvent : class
{
public EventHandlerMethodExecutorAsync ExecutorAsync => (target, parameter) => target.As<ILocalEventHandler<TEvent>>().HandleEventAsync(parameter.As<TEvent>());
public Task ExecuteAsync(IEventHandler target, TEvent parameters)
{
return ExecutorAsync(target, parameters);
}
}
public class DistributedEventHandlerMethodExecutor<TEvent> : IEventHandlerMethodExecutor
where TEvent : class
{
public EventHandlerMethodExecutorAsync ExecutorAsync => (target, parameter) => target.As<IDistributedEventHandler<TEvent>>().HandleEventAsync(parameter.As<TEvent>());
public Task ExecuteAsync(IEventHandler target, TEvent parameters)
{
return ExecutorAsync(target, parameters);
}
}

9
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventHandlerInvoker.cs

@ -0,0 +1,9 @@
using System;
using System.Threading.Tasks;
namespace Volo.Abp.EventBus;
public interface IEventHandlerInvoker
{
Task InvokeAsync(IEventHandler eventHandler, object eventData, Type eventType);
}

5
framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/Local/LocalEventBus.cs

@ -33,8 +33,9 @@ public class LocalEventBus : EventBusBase, ILocalEventBus, ISingletonDependency
IOptions<AbpLocalEventBusOptions> options,
IServiceScopeFactory serviceScopeFactory,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager)
: base(serviceScopeFactory, currentTenant, unitOfWorkManager)
IUnitOfWorkManager unitOfWorkManager,
IEventHandlerInvoker eventHandlerInvoker)
: base(serviceScopeFactory, currentTenant, unitOfWorkManager, eventHandlerInvoker)
{
Options = options.Value;
Logger = NullLogger<LocalEventBus>.Instance;

132
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs

@ -5,7 +5,6 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
@ -114,22 +113,34 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
}
protected virtual async Task<string> GetTokenEndpoint(IdentityClientConfiguration configuration)
protected virtual async Task<IdentityModelDiscoveryDocumentCacheItem> GetDiscoveryResponse(IdentityClientConfiguration configuration)
{
//TODO: Can use (configuration.Authority + /connect/token) directly?
var tokenEndpointUrlCacheKey = CalculateDiscoveryDocumentCacheKey(configuration);
var discoveryDocumentCacheItem = await DiscoveryDocumentCache.GetAsync(tokenEndpointUrlCacheKey);
if (discoveryDocumentCacheItem == null)
{
var discoveryResponse = await GetDiscoveryResponse(configuration);
DiscoveryDocumentResponse discoveryResponse;
using (var httpClient = HttpClientFactory.CreateClient(HttpClientName))
{
var request = new DiscoveryDocumentRequest
{
Address = configuration.Authority,
Policy =
{
RequireHttps = configuration.RequireHttps
}
};
IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage?.Invoke(request);
discoveryResponse = await httpClient.GetDiscoveryDocumentAsync(request);
}
if (discoveryResponse.IsError)
{
throw new AbpException($"Could not retrieve the OpenId Connect discovery document! " +
$"ErrorType: {discoveryResponse.ErrorType}. Error: {discoveryResponse.Error}");
}
discoveryDocumentCacheItem = new IdentityModelDiscoveryDocumentCacheItem(discoveryResponse.TokenEndpoint);
discoveryDocumentCacheItem = new IdentityModelDiscoveryDocumentCacheItem(discoveryResponse.TokenEndpoint, discoveryResponse.DeviceAuthorizationEndpoint);
await DiscoveryDocumentCache.SetAsync(tokenEndpointUrlCacheKey, discoveryDocumentCacheItem,
new DistributedCacheEntryOptions
{
@ -137,30 +148,11 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
});
}
return discoveryDocumentCacheItem.TokenEndpoint;
}
protected virtual async Task<DiscoveryDocumentResponse> GetDiscoveryResponse(IdentityClientConfiguration configuration)
{
using (var httpClient = HttpClientFactory.CreateClient(HttpClientName))
{
var request = new DiscoveryDocumentRequest
{
Address = configuration.Authority,
Policy =
{
RequireHttps = configuration.RequireHttps
}
};
IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage?.Invoke(request);
return await httpClient.GetDiscoveryDocumentAsync(request);
}
return discoveryDocumentCacheItem;
}
protected virtual async Task<TokenResponse> GetTokenResponse(IdentityClientConfiguration configuration)
{
var tokenEndpoint = await GetTokenEndpoint(configuration);
using (var httpClient = HttpClientFactory.CreateClient(HttpClientName))
{
AddHeaders(httpClient);
@ -169,25 +161,30 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
{
case OidcConstants.GrantTypes.ClientCredentials:
return await httpClient.RequestClientCredentialsTokenAsync(
await CreateClientCredentialsTokenRequestAsync(tokenEndpoint, configuration),
await CreateClientCredentialsTokenRequestAsync(configuration),
CancellationTokenProvider.Token
);
case OidcConstants.GrantTypes.Password:
return await httpClient.RequestPasswordTokenAsync(
await CreatePasswordTokenRequestAsync(tokenEndpoint, configuration),
await CreatePasswordTokenRequestAsync(configuration),
CancellationTokenProvider.Token
);
case OidcConstants.GrantTypes.DeviceCode:
return await RequestDeviceAuthorizationAsync(httpClient, configuration);
default:
throw new AbpException("Grant type was not implemented: " + configuration.GrantType);
}
}
}
protected virtual Task<PasswordTokenRequest> CreatePasswordTokenRequestAsync(string tokenEndpoint, IdentityClientConfiguration configuration)
protected virtual async Task<PasswordTokenRequest> CreatePasswordTokenRequestAsync(IdentityClientConfiguration configuration)
{
var discoveryResponse = await GetDiscoveryResponse(configuration);
var request = new PasswordTokenRequest
{
Address = tokenEndpoint,
Address = discoveryResponse.TokenEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret,
@ -197,27 +194,90 @@ public class IdentityModelAuthenticationService : IIdentityModelAuthenticationSe
IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage?.Invoke(request);
AddParametersToRequestAsync(configuration, request);
await AddParametersToRequestAsync(configuration, request);
return Task.FromResult(request);
return request;
}
protected virtual Task<ClientCredentialsTokenRequest> CreateClientCredentialsTokenRequestAsync(string tokenEndpoint, IdentityClientConfiguration configuration)
protected virtual async Task<ClientCredentialsTokenRequest> CreateClientCredentialsTokenRequestAsync(IdentityClientConfiguration configuration)
{
var discoveryResponse = await GetDiscoveryResponse(configuration);
var request = new ClientCredentialsTokenRequest
{
Address = tokenEndpoint,
Address = discoveryResponse.TokenEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret
};
IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage?.Invoke(request);
AddParametersToRequestAsync(configuration, request);
await AddParametersToRequestAsync(configuration, request);
return request;
}
protected virtual async Task<TokenResponse> RequestDeviceAuthorizationAsync(HttpClient httpClient, IdentityClientConfiguration configuration)
{
var discoveryResponse = await GetDiscoveryResponse(configuration);
var request = new DeviceAuthorizationRequest()
{
Address = discoveryResponse.DeviceAuthorizationEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret,
};
IdentityModelHttpRequestMessageOptions.ConfigureHttpRequestMessage?.Invoke(request);
await AddParametersToRequestAsync(configuration, request);
var response = await httpClient.RequestDeviceAuthorizationAsync(request);
if (response.IsError)
{
throw new AbpException(response.ErrorDescription);
}
Logger.LogInformation($"First copy your one-time code: {response.UserCode}");
Logger.LogInformation($"Open {response.VerificationUri} in your browser...");
for (var i = 0; i < ((response.ExpiresIn ?? 300) / response.Interval + 1); i++)
{
await Task.Delay(response.Interval * 1000);
var tokenResponse = await httpClient.RequestDeviceTokenAsync(new DeviceTokenRequest
{
Address = discoveryResponse.TokenEndpoint,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret,
DeviceCode = response.DeviceCode
});
return Task.FromResult(request);
if (tokenResponse.IsError)
{
switch (tokenResponse.Error)
{
case "slow_down":
case "authorization_pending":
break;
case "expired_token":
throw new AbpException("This 'device_code' has expired. (expired_token)");
case "access_denied":
throw new AbpException("User denies the request(access_denied)");
}
}
if (!tokenResponse.IsError)
{
return tokenResponse;
}
}
throw new AbpException("Timeout!");
}
protected virtual Task AddParametersToRequestAsync(IdentityClientConfiguration configuration, ProtocolRequest request)
{
foreach (var pair in configuration.Where(p => p.Key.StartsWith("[o]", StringComparison.OrdinalIgnoreCase)))

5
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelDiscoveryDocumentCacheItem.cs

@ -9,14 +9,17 @@ public class IdentityModelDiscoveryDocumentCacheItem
{
public string TokenEndpoint { get; set; }
public string DeviceAuthorizationEndpoint { get; set; }
public IdentityModelDiscoveryDocumentCacheItem()
{
}
public IdentityModelDiscoveryDocumentCacheItem(string tokenEndpoint)
public IdentityModelDiscoveryDocumentCacheItem(string tokenEndpoint, string deviceAuthorizationEndpoint)
{
TokenEndpoint = tokenEndpoint;
DeviceAuthorizationEndpoint = deviceAuthorizationEndpoint;
}
public static string CalculateCacheKey(IdentityClientConfiguration configuration)

33
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpAbpLdapOptionsManager.cs

@ -1,33 +0,0 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Volo.Abp.Options;
using Volo.Abp.Settings;
namespace Volo.Abp.Ldap;
public class AbpAbpLdapOptionsManager : AbpDynamicOptionsManager<AbpLdapOptions>
{
protected ISettingProvider SettingProvider { get; }
public AbpAbpLdapOptionsManager(IOptionsFactory<AbpLdapOptions> factory, ISettingProvider settingProvider)
: base(factory)
{
SettingProvider = settingProvider;
}
protected override async Task OverrideOptionsAsync(string name, AbpLdapOptions options)
{
options.ServerHost = await GetSettingOrDefaultValue(LdapSettingNames.ServerHost, options.ServerHost);
options.ServerPort = await SettingProvider.GetAsync(LdapSettingNames.ServerPort, options.ServerPort);
options.BaseDc = await GetSettingOrDefaultValue(LdapSettingNames.BaseDc, options.BaseDc);
options.UserName = await GetSettingOrDefaultValue(LdapSettingNames.UserName, options.UserName);
options.Password = await GetSettingOrDefaultValue(LdapSettingNames.Password, options.Password);
}
protected virtual async Task<string> GetSettingOrDefaultValue(string name, string defaultValue)
{
var value = await SettingProvider.GetOrNullAsync(name);
return value.IsNullOrWhiteSpace() ? defaultValue : value;
}
}

5
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapModule.cs

@ -18,11 +18,6 @@ public class AbpLdapModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDynamicOptions<AbpLdapOptions, AbpAbpLdapOptionsManager>();
var configuration = context.Services.GetConfiguration();
Configure<AbpLdapOptions>(configuration.GetSection("Ldap"));
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpLdapModule>();

20
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/AbpLdapOptions.cs

@ -1,20 +0,0 @@
namespace Volo.Abp.Ldap;
public class AbpLdapOptions
{
public string ServerHost { get; set; }
public int ServerPort { get; set; }
public string BaseDc { get; set; }
/// <summary>
/// BindDN
/// </summary>
public string UserName { get; set; }
/// <summary>
///BindPassword
/// </summary>
public string Password { get; set; }
}

18
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/ILdapSettingProvider.cs

@ -0,0 +1,18 @@
using System.Threading.Tasks;
namespace Volo.Abp.Ldap;
public interface ILdapSettingProvider
{
public Task<string> GetServerHostAsync();
public Task<int> GetServerPortAsync();
public Task<string> GetBaseDcAsync();
public Task<string> GetDomainAsync();
public Task<string> GetUserNameAsync();
public Task<string> GetPasswordAsync();
}

11
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapManager.cs

@ -2,7 +2,6 @@
using System.Threading.Tasks;
using LdapForNet;
using LdapForNet.Native;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.DependencyInjection;
@ -12,11 +11,11 @@ namespace Volo.Abp.Ldap;
public class LdapManager : ILdapManager, ITransientDependency
{
public ILogger<LdapManager> Logger { get; set; }
protected IOptions<AbpLdapOptions> LdapOptions { get; }
protected ILdapSettingProvider LdapSettingProvider { get; }
public LdapManager(IOptions<AbpLdapOptions> ldapOptions)
public LdapManager(ILdapSettingProvider ldapSettingProvider)
{
LdapOptions = ldapOptions;
LdapSettingProvider = ldapSettingProvider;
Logger = NullLogger<LdapManager>.Instance;
}
@ -52,9 +51,7 @@ public class LdapManager : ILdapManager, ITransientDependency
protected virtual async Task ConnectAsync(ILdapConnection ldapConnection)
{
await LdapOptions.SetAsync();
ldapConnection.Connect(LdapOptions.Value.ServerHost, LdapOptions.Value.ServerPort);
ldapConnection.Connect(await LdapSettingProvider.GetServerHostAsync(), await LdapSettingProvider.GetServerPortAsync());
}
protected virtual async Task AuthenticateLdapConnectionAsync(ILdapConnection connection, string username, string password)

55
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingDefinitionProvider.cs

@ -0,0 +1,55 @@
using Volo.Abp.Ldap.Localization;
using Volo.Abp.Localization;
using Volo.Abp.Settings;
namespace Volo.Abp.Ldap;
public class LdapSettingDefinitionProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(
new SettingDefinition(
LdapSettingNames.ServerHost,
"",
L("DisplayName:Abp.Ldap.ServerHost"),
L("Description:Abp.Ldap.ServerHost")),
new SettingDefinition(
LdapSettingNames.ServerPort,
"389",
L("DisplayName:Abp.Ldap.ServerPort"),
L("Description:Abp.Ldap.ServerPort")),
new SettingDefinition(
LdapSettingNames.BaseDc,
"",
L("DisplayName:Abp.Ldap.BaseDc"),
L("Description:Abp.Ldap.BaseDc")),
new SettingDefinition(
LdapSettingNames.Domain,
"",
L("DisplayName:Abp.Ldap.Domain"),
L("Description:Abp.Ldap.Domain")),
new SettingDefinition(
LdapSettingNames.UserName,
"",
L("DisplayName:Abp.Ldap.UserName"),
L("Description:Abp.Ldap.UserName")),
new SettingDefinition(
LdapSettingNames.Password,
"",
L("DisplayName:Abp.Ldap.Password"),
L("Description:Abp.Ldap.Password"),
isEncrypted: true)
);
}
private static LocalizableString L(string name)
{
return LocalizableString.Create<LdapResource>(name);
}
}

2
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingNames.cs

@ -8,6 +8,8 @@ public static class LdapSettingNames
public const string BaseDc = "Abp.Ldap.BaseDc";
public const string Domain = "Abp.Ldap.Domain";
public const string UserName = "Abp.Ldap.UserName";
public const string Password = "Abp.Ldap.Password";

73
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/LdapSettingProvider.cs

@ -1,49 +1,46 @@
using Volo.Abp.Ldap.Localization;
using Volo.Abp.Localization;
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings;
namespace Volo.Abp.Ldap;
public class LdapSettingProvider : SettingDefinitionProvider
public class LdapSettingProvider : ILdapSettingProvider, ITransientDependency
{
public override void Define(ISettingDefinitionContext context)
protected ISettingProvider SettingProvider { get; }
public LdapSettingProvider(ISettingProvider settingProvider)
{
SettingProvider = settingProvider;
}
public async Task<string> GetServerHostAsync()
{
return await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerHost);
}
public async Task<int> GetServerPortAsync()
{
return (await SettingProvider.GetOrNullAsync(LdapSettingNames.ServerPort))?.To<int>() ?? default;
}
public async Task<string> GetBaseDcAsync()
{
return await SettingProvider.GetOrNullAsync(LdapSettingNames.BaseDc);
}
public async Task<string> GetDomainAsync()
{
return await SettingProvider.GetOrNullAsync(LdapSettingNames.Domain);
}
public async Task<string> GetUserNameAsync()
{
context.Add(
new SettingDefinition(
LdapSettingNames.ServerHost,
"",
L("DisplayName:Abp.Ldap.ServerHost"),
L("Description:Abp.Ldap.ServerHost")),
new SettingDefinition(
LdapSettingNames.ServerPort,
"389",
L("DisplayName:Abp.Ldap.ServerPort"),
L("Description:Abp.Ldap.ServerPort")),
new SettingDefinition(
LdapSettingNames.BaseDc,
"",
L("DisplayName:Abp.Ldap.BaseDc"),
L("Description:Abp.Ldap.BaseDc")),
new SettingDefinition(
LdapSettingNames.UserName,
"",
L("DisplayName:Abp.Ldap.UserName"),
L("Description:Abp.Ldap.UserName")),
new SettingDefinition(
LdapSettingNames.Password,
"",
L("DisplayName:Abp.Ldap.Password"),
L("Description:Abp.Ldap.Password"),
isEncrypted: true)
);
return await SettingProvider.GetOrNullAsync(LdapSettingNames.UserName);
}
private static LocalizableString L(string name)
public async Task<string> GetPasswordAsync()
{
return LocalizableString.Create<LdapResource>(name);
return await SettingProvider.GetOrNullAsync(LdapSettingNames.Password);
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ar.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "منفذ الخادم",
"DisplayName:Abp.Ldap.BaseDc": "مكون المجال الأساسي",
"Description:Abp.Ldap.BaseDc": "مكون المجال الأساسي",
"DisplayName:Abp.Ldap.Domain": "اختصاص",
"Description:Abp.Ldap.Domain": "اختصاص",
"DisplayName:Abp.Ldap.UserName": "اسم المستخدم",
"Description:Abp.Ldap.UserName": "اسم المستخدم",
"DisplayName:Abp.Ldap.Password": "كلمة السر",
"Description:Abp.Ldap.Password": "كلمة السر"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/cs.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Port serveru",
"DisplayName:Abp.Ldap.BaseDc": "Komponenta základní domény",
"Description:Abp.Ldap.BaseDc": "Komponenta základní domény",
"DisplayName:Abp.Ldap.Domain": "Doména",
"Description:Abp.Ldap.Domain": "Doména",
"DisplayName:Abp.Ldap.UserName": "uživatelské jméno",
"Description:Abp.Ldap.UserName": "uživatelské jméno",
"DisplayName:Abp.Ldap.Password": "Heslo",
"Description:Abp.Ldap.Password": "Heslo"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/de-DE.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Server-Port",
"DisplayName:Abp.Ldap.BaseDc": "Basisdomänenkomponente",
"Description:Abp.Ldap.BaseDc": "Basisdomänenkomponente",
"DisplayName:Abp.Ldap.Domain": "Domain",
"Description:Abp.Ldap.Domain": "Domain",
"DisplayName:Abp.Ldap.UserName": "Benutzername",
"Description:Abp.Ldap.UserName": "Benutzername",
"DisplayName:Abp.Ldap.Password": "Passwort",
"Description:Abp.Ldap.Password": "Passwort"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en-GB.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Server port",
"DisplayName:Abp.Ldap.BaseDc": "Base domain component",
"Description:Abp.Ldap.BaseDc": "Base domain component",
"DisplayName:Abp.Ldap.Domain": "Domain",
"Description:Abp.Ldap.Domain": "Domain",
"DisplayName:Abp.Ldap.UserName": "Username",
"Description:Abp.Ldap.UserName": "Username",
"DisplayName:Abp.Ldap.Password": "Password",
"Description:Abp.Ldap.Password": "Password"
}
}
}

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/en.json

@ -3,16 +3,14 @@
"texts": {
"DisplayName:Abp.Ldap.ServerHost": "Server host",
"Description:Abp.Ldap.ServerHost": "Server host",
"DisplayName:Abp.Ldap.ServerPort": "Server port",
"Description:Abp.Ldap.ServerPort": "Server port",
"DisplayName:Abp.Ldap.BaseDc": "Base domain component",
"Description:Abp.Ldap.BaseDc": "Base domain component",
"DisplayName:Abp.Ldap.Domain": "Domain",
"Description:Abp.Ldap.Domain": "Domain",
"DisplayName:Abp.Ldap.UserName": "Username",
"Description:Abp.Ldap.UserName": "Username",
"DisplayName:Abp.Ldap.Password": "Password",
"Description:Abp.Ldap.Password": "Password"
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/es.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Puerto del servidor",
"DisplayName:Abp.Ldap.BaseDc": "Dominio base",
"Description:Abp.Ldap.BaseDc": "Dominio base",
"DisplayName:Abp.Ldap.Domain": "Dominio",
"Description:Abp.Ldap.Domain": "Dominio",
"DisplayName:Abp.Ldap.UserName": "Nombre de usuario",
"Description:Abp.Ldap.UserName": "Nombre de usuario",
"DisplayName:Abp.Ldap.Password": "Contraseña",
"Description:Abp.Ldap.Password": "Contraseña"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fi.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Palvelimen portti",
"DisplayName:Abp.Ldap.BaseDc": "Perustoimialueen komponentti",
"Description:Abp.Ldap.BaseDc": "Perustoimialueen komponentti",
"DisplayName:Abp.Ldap.Domain": "Verkkotunnus",
"Description:Abp.Ldap.Domain": "Verkkotunnus",
"DisplayName:Abp.Ldap.UserName": "Käyttäjätunnus",
"Description:Abp.Ldap.UserName": "Käyttäjätunnus",
"DisplayName:Abp.Ldap.Password": "Salasana",
"Description:Abp.Ldap.Password": "Salasana"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/fr.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Port de serveur",
"DisplayName:Abp.Ldap.BaseDc": "Composant de domaine de base",
"Description:Abp.Ldap.BaseDc": "Composant de domaine de base",
"DisplayName:Abp.Ldap.Domain": "Domaine",
"Description:Abp.Ldap.Domain": "Domaine",
"DisplayName:Abp.Ldap.UserName": "Nom d'utilisateur",
"Description:Abp.Ldap.UserName": "Nom d'utilisateur",
"DisplayName:Abp.Ldap.Password": "Mot de passe",
"Description:Abp.Ldap.Password": "Mot de passe"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hi.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "सर्वर पोर्ट",
"DisplayName:Abp.Ldap.BaseDc": "बेस डोमेन घटक",
"Description:Abp.Ldap.BaseDc": "बेस डोमेन घटक",
"DisplayName:Abp.Ldap.Domain": "कार्यक्षेत्र",
"Description:Abp.Ldap.Domain": "कार्यक्षेत्र",
"DisplayName:Abp.Ldap.UserName": "उपयोगकर्ता नाम",
"Description:Abp.Ldap.UserName": "उपयोगकर्ता नाम",
"DisplayName:Abp.Ldap.Password": "कुंजिका",
"Description:Abp.Ldap.Password": "कुंजिका"
}
}
}

7
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/hu.json

@ -3,18 +3,15 @@
"texts": {
"DisplayName:Abp.Ldap.ServerHost": "Szerver host",
"Description:Abp.Ldap.ServerHost": "Az LDAP ksizolgáló szerver hostneve vagy IP címe",
"DisplayName:Abp.Ldap.ServerPort": "Szerver port",
"Description:Abp.Ldap.ServerPort": "LDAP kommunikáció portja",
"DisplayName:Abp.Ldap.BaseDc": "Bázis tartomány-komponens",
"Description:Abp.Ldap.BaseDc": "Bázis tartomány-komponens",
"DisplayName:Abp.Ldap.Domain": "Tartomány",
"Description:Abp.Ldap.Domain": "Tartomány",
"DisplayName:Abp.Ldap.UserName": "Felhasználónév",
"Description:Abp.Ldap.UserName": "Felhasználónév",
"DisplayName:Abp.Ldap.Password": "Jelszó",
"Description:Abp.Ldap.Password": "Jelszó"
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/is.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Server port",
"DisplayName:Abp.Ldap.BaseDc": "Grunn léna hlutur",
"Description:Abp.Ldap.BaseDc": "Grunn léna hluturt",
"DisplayName:Abp.Ldap.Domain": "Lén",
"Description:Abp.Ldap.Domain": "Lén",
"DisplayName:Abp.Ldap.UserName": "Notanda nafn",
"Description:Abp.Ldap.UserName": "Notanda nafn",
"DisplayName:Abp.Ldap.Password": "Lykilorð",
"Description:Abp.Ldap.Password": "Lykilorð"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/it.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Porta del server",
"DisplayName:Abp.Ldap.BaseDc": "Componente del dominio di base",
"Description:Abp.Ldap.BaseDc": "Componente del dominio di base",
"DisplayName:Abp.Ldap.Domain": "Dominio",
"Description:Abp.Ldap.Domain": "Dominio",
"DisplayName:Abp.Ldap.UserName": "Nome utente",
"Description:Abp.Ldap.UserName": "Nome utente",
"DisplayName:Abp.Ldap.Password": "Password",
"Description:Abp.Ldap.Password": "Password"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/nl.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Server poort",
"DisplayName:Abp.Ldap.BaseDc": "Basisdomein component",
"Description:Abp.Ldap.BaseDc": "Basisdomein component",
"DisplayName:Abp.Ldap.Domain": "Domain",
"Description:Abp.Ldap.Domain": "Domain",
"DisplayName:Abp.Ldap.UserName": "Gebruikersnaam",
"Description:Abp.Ldap.UserName": "Gebruikersnaam",
"DisplayName:Abp.Ldap.Password": "Wachtwoord",
"Description:Abp.Ldap.Password": "Wachtwoord"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pl-PL.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Port serwera",
"DisplayName:Abp.Ldap.BaseDc": "Podstawowy składnik domeny",
"Description:Abp.Ldap.BaseDc": "Podstawowy składnik domeny",
"DisplayName:Abp.Ldap.Domain": "Domena",
"Description:Abp.Ldap.Domain": "Domena",
"DisplayName:Abp.Ldap.UserName": "Nazwa użytkownika",
"Description:Abp.Ldap.UserName": "Nazwa użytkownika",
"DisplayName:Abp.Ldap.Password": "Hasło",
"Description:Abp.Ldap.Password": "Hasło"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/pt-BR.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Porta do servidor",
"DisplayName:Abp.Ldap.BaseDc": "Componente de domínio base",
"Description:Abp.Ldap.BaseDc": "Componente de domínio base",
"DisplayName:Abp.Ldap.Domain": "Domínio",
"Description:Abp.Ldap.Domain": "Domínio",
"DisplayName:Abp.Ldap.UserName": "Nome do usuário",
"Description:Abp.Ldap.UserName": "Nome do usuário",
"DisplayName:Abp.Ldap.Password": "Senha",
"Description:Abp.Ldap.Password": "Senha"
}
}
}

8
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ro-RO.json

@ -3,17 +3,15 @@
"texts": {
"DisplayName:Abp.Ldap.ServerHost": "Server host",
"Description:Abp.Ldap.ServerHost": "Server host",
"DisplayName:Abp.Ldap.ServerPort": "Server port",
"Description:Abp.Ldap.ServerPort": "Server port",
"DisplayName:Abp.Ldap.BaseDc": "Componenta domeniului de bază",
"Description:Abp.Ldap.BaseDc": "Componenta domeniului de bază",
"DisplayName:Abp.Ldap.Domain": "Domeniu",
"Description:Abp.Ldap.Domain": "Domeniu",
"DisplayName:Abp.Ldap.UserName": "Nume de utilizator",
"Description:Abp.Ldap.UserName": "Nume de utilizator",
"DisplayName:Abp.Ldap.Password": "Parola",
"Description:Abp.Ldap.Password": "Parola"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/ru.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Порт сервера",
"DisplayName:Abp.Ldap.BaseDc": "Компонент базового домена",
"Description:Abp.Ldap.BaseDc": "Компонент базового домена",
"DisplayName:Abp.Ldap.Domain": "Домен",
"Description:Abp.Ldap.Domain": "Домен",
"DisplayName:Abp.Ldap.UserName": "Имя пользователя",
"Description:Abp.Ldap.UserName": "Имя пользователя",
"DisplayName:Abp.Ldap.Password": "Пароль",
"Description:Abp.Ldap.Password": "Пароль"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sk.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Server post",
"DisplayName:Abp.Ldap.BaseDc": "Základný komponent domény",
"Description:Abp.Ldap.BaseDc": "Základný komponent domény",
"DisplayName:Abp.Ldap.Domain": "doména",
"Description:Abp.Ldap.Domain": "doména",
"DisplayName:Abp.Ldap.UserName": "Používateľské meno",
"Description:Abp.Ldap.UserName": "Používateľské meno",
"DisplayName:Abp.Ldap.Password": "Heslo",
"Description:Abp.Ldap.Password": "Heslo"
}
}
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/sl.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Vrata strežnika",
"DisplayName:Abp.Ldap.BaseDc": "Komponenta osnovne domene",
"Description:Abp.Ldap.BaseDc": "Komponenta osnovne domene",
"DisplayName:Abp.Ldap.Domain": "domena",
"Description:Abp.Ldap.Domain": "domena",
"DisplayName:Abp.Ldap.UserName": "Uporabniško ime",
"Description:Abp.Ldap.UserName": "Uporabniško ime",
"DisplayName:Abp.Ldap.Password": "Geslo",
"Description:Abp.Ldap.Password": "Geslo"
}
}
}

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/tr.json

@ -3,16 +3,14 @@
"texts": {
"DisplayName:Abp.Ldap.ServerHost": "Sunucu Ana Bilgisayarı",
"Description:Abp.Ldap.ServerHost": "Sunucu Ana Bilgisayarı",
"DisplayName:Abp.Ldap.ServerPort": "Sunucu portu",
"Description:Abp.Ldap.ServerPort": "Sunucu portu",
"DisplayName:Abp.Ldap.BaseDc": "Temel alan bileşeni",
"Description:Abp.Ldap.BaseDc": "Temel alan bileşeni",
"DisplayName:Abp.Ldap.Domain": "Alan adı",
"Description:Abp.Ldap.Domain": "Alan adı",
"DisplayName:Abp.Ldap.UserName": "Kullanıcı adı",
"Description:Abp.Ldap.UserName": "Kullanıcı adı",
"DisplayName:Abp.Ldap.Password": "Parola",
"Description:Abp.Ldap.Password": "Parola"
}

4
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/vi.json

@ -7,9 +7,11 @@
"Description:Abp.Ldap.ServerPort": "Cổng máy chủ",
"DisplayName:Abp.Ldap.BaseDc": "Thành phần miền cơ sở",
"Description:Abp.Ldap.BaseDc": "Thành phần miền cơ sở",
"DisplayName:Abp.Ldap.Domain": "Lãnh địa",
"Description:Abp.Ldap.Domain": "Lãnh địa",
"DisplayName:Abp.Ldap.UserName": "tên tài khoản",
"Description:Abp.Ldap.UserName": "tên tài khoản",
"DisplayName:Abp.Ldap.Password": "Mật khẩu",
"Description:Abp.Ldap.Password": "Mật khẩu"
}
}
}

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hans.json

@ -3,16 +3,14 @@
"texts": {
"DisplayName:Abp.Ldap.ServerHost": "服务器主机",
"Description:Abp.Ldap.ServerHost": "服务器主机",
"DisplayName:Abp.Ldap.ServerPort": "服务器端口",
"Description:Abp.Ldap.ServerPort": "服务器端口",
"DisplayName:Abp.Ldap.BaseDc": "基域组件",
"Description:Abp.Ldap.BaseDc": "基域组件",
"DisplayName:Abp.Ldap.Domain": "域",
"Description:Abp.Ldap.Domain": "域",
"DisplayName:Abp.Ldap.UserName": "用户名",
"Description:Abp.Ldap.UserName": "用户名",
"DisplayName:Abp.Ldap.Password": "密码",
"Description:Abp.Ldap.Password": "密码"
}

6
framework/src/Volo.Abp.Ldap/Volo/Abp/Ldap/Localization/zh-Hant.json

@ -3,16 +3,14 @@
"texts": {
"DisplayName:Abp.Ldap.ServerHost": "服務器主機",
"Description:Abp.Ldap.ServerHost": "服務器主機",
"DisplayName:Abp.Ldap.ServerPort": "服務器端口",
"Description:Abp.Ldap.ServerPort": "服務器端口",
"DisplayName:Abp.Ldap.BaseDc": "基域組件",
"Description:Abp.Ldap.BaseDc": "基域組件",
"DisplayName:Abp.Ldap.Domain": "域",
"Description:Abp.Ldap.Domain": "域",
"DisplayName:Abp.Ldap.UserName": "用戶名",
"Description:Abp.Ldap.UserName": "用戶名",
"DisplayName:Abp.Ldap.Password": "密碼",
"Description:Abp.Ldap.Password": "密碼"
}

10
framework/src/Volo.Abp.Security/Volo/Abp/Security/Claims/AbpClaimTypes.cs

@ -77,4 +77,14 @@ public static class AbpClaimTypes
/// Default: "impersonator_userid".
/// </summary>
public static string ImpersonatorUserId { get; set; } = "impersonator_userid";
/// <summary>
/// Default: "impersonator_tenantname".
/// </summary>
public static string ImpersonatorTenantName { get; set; } = "impersonator_tenantname";
/// <summary>
/// Default: "impersonator_username".
/// </summary>
public static string ImpersonatorUserName { get; set; } = "impersonator_username";
}

14
framework/src/Volo.Abp.Security/Volo/Abp/Users/CurrentUserExtensions.cs

@ -35,7 +35,7 @@ public static class CurrentUserExtensions
public static Guid? FindImpersonatorTenantId([NotNull] this ICurrentUser currentUser)
{
var impersonatorTenantId = currentUser.FindClaimValue(AbpClaimTypes.ImpersonatorTenantId);
if (impersonatorTenantId == null || impersonatorTenantId.IsNullOrWhiteSpace())
if (impersonatorTenantId.IsNullOrWhiteSpace())
{
return null;
}
@ -50,7 +50,7 @@ public static class CurrentUserExtensions
public static Guid? FindImpersonatorUserId([NotNull] this ICurrentUser currentUser)
{
var impersonatorUserId = currentUser.FindClaimValue(AbpClaimTypes.ImpersonatorUserId);
if (impersonatorUserId == null || impersonatorUserId.IsNullOrWhiteSpace())
if (impersonatorUserId.IsNullOrWhiteSpace())
{
return null;
}
@ -61,4 +61,14 @@ public static class CurrentUserExtensions
return null;
}
public static string FindImpersonatorTenantName([NotNull] this ICurrentUser currentUser)
{
return currentUser.FindClaimValue(AbpClaimTypes.ImpersonatorTenantName);
}
public static string FindImpersonatorUserName([NotNull] this ICurrentUser currentUser)
{
return currentUser.FindClaimValue(AbpClaimTypes.ImpersonatorUserName);
}
}

128
framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/EventHandlerInvoker_Tests.cs

@ -0,0 +1,128 @@
using System;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Events;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.EventBus.Local;
using Xunit;
namespace Volo.Abp.EventBus;
public class EventHandlerInvoker_Tests : EventBusTestBase
{
private readonly IEventHandlerInvoker _eventHandlerInvoker;
public EventHandlerInvoker_Tests()
{
_eventHandlerInvoker = GetRequiredService<IEventHandlerInvoker>();
}
[Fact]
public async Task Should_Invoke_LocalEventHandler_With_MyEventData()
{
var localHandler = new MyLocalEventHandler();
var eventData = new MyEventData();
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType());
localHandler.MyEventDataCount.ShouldBe(2);
localHandler.EntityChangedEventDataCount.ShouldBe(0);
localHandler.EntityChangedEventDataCount.ShouldBe(0);
}
[Fact]
public async Task Should_Invoke_LocalEventHandler_Created_And_Changed_Once()
{
var localHandler = new MyLocalEventHandler();
var eventData = new EntityCreatedEventData<MyEntity>(new MyEntity());
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType());
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, typeof(EntityChangedEventData<MyEntity>));
localHandler.MyEventDataCount.ShouldBe(0);
localHandler.EntityChangedEventDataCount.ShouldBe(1);
localHandler.EntityChangedEventDataCount.ShouldBe(1);
}
[Fact]
public async Task Should_Invoke_DistributedEventHandler_With_MyEventData()
{
var localHandler = new MyDistributedEventHandler();
var eventData = new MyEventData();
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType());
localHandler.MyEventDataCount.ShouldBe(1);
localHandler.EntityCreatedCount.ShouldBe(0);
}
[Fact]
public async Task Should_Invoke_DistributedEventHandler_With_EntityCreatedEto()
{
var localHandler = new MyDistributedEventHandler();
var eventData = new EntityCreatedEto<MyEntity>(new MyEntity());
await _eventHandlerInvoker.InvokeAsync(localHandler, eventData, eventData.GetType());
localHandler.MyEventDataCount.ShouldBe(0);
localHandler.EntityCreatedCount.ShouldBe(1);
}
public class MyEventData
{
}
public class MyEntity : Entity<Guid>
{
}
public class MyDistributedEventHandler : IDistributedEventHandler<MyEventData>,
IDistributedEventHandler<EntityCreatedEto<MyEntity>>
{
public int MyEventDataCount { get; set; }
public int EntityCreatedCount { get; set; }
public Task HandleEventAsync(MyEventData eventData)
{
MyEventDataCount++;
return Task.CompletedTask;
}
public Task HandleEventAsync(EntityCreatedEto<MyEntity> eventData)
{
EntityCreatedCount++;
return Task.CompletedTask;
}
}
public class MyLocalEventHandler : ILocalEventHandler<MyEventData>,
IDistributedEventHandler<MyEventData>,
IDistributedEventHandler<EntityCreatedEventData<MyEntity>>,
IDistributedEventHandler<EntityChangedEventData<MyEntity>>
{
public int MyEventDataCount { get; set; }
public int EntityCreatedEventDataCount { get; set; }
public int EntityChangedEventDataCount { get; set; }
public Task HandleEventAsync(MyEventData eventData)
{
MyEventDataCount++;
return Task.CompletedTask;
}
public Task HandleEventAsync(EntityCreatedEventData<MyEntity> eventData)
{
EntityCreatedEventDataCount++;
return Task.CompletedTask;
}
public Task HandleEventAsync(EntityChangedEventData<MyEntity> eventData)
{
EntityChangedEventDataCount++;
return Task.CompletedTask;
}
}
}

9
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/AbpLdapTestModule.cs

@ -1,5 +1,6 @@
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;
using Volo.Abp.Settings;
namespace Volo.Abp.Ldap;
@ -12,13 +13,9 @@ public class AbpLdapTestModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpLdapOptions>(options =>
Configure<AbpSettingOptions>(options =>
{
options.ServerHost = "192.168.0.3";
options.ServerPort = 389;
options.BaseDc = "dc=abp,dc=io";
options.UserName = "admin";
options.Password = "123qwe";
options.ValueProviders.Add<TestLdapSettingValueProvider>();
});
}
}

9
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapManager_Tests.cs

@ -1,10 +1,13 @@
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Shouldly;
using Volo.Abp.Testing;
using Xunit;
namespace Volo.Abp.Ldap;
/// <summary>
/// docker run --name ldap -d --env LDAP_ORGANISATION="abp" --env LDAP_DOMAIN="abp.io" --env LDAP_ADMIN_PASSWORD="123qwe" -p 389:389 -p 636:639 osixia/openldap
/// </summary>
public class LdapManager_Tests : AbpIntegratedTest<AbpLdapTestModule>
{
private readonly ILdapManager _ldapManager;
@ -22,7 +25,7 @@ public class LdapManager_Tests : AbpIntegratedTest<AbpLdapTestModule>
[Fact(Skip = "Required Ldap environment")]
public async Task AuthenticateAsync()
{
(await _ldapManager.AuthenticateAsync("cn=abp,dc=abp,dc=io", "123qwe")).ShouldBe(true);
(await _ldapManager.AuthenticateAsync("cn=admin,dc=abp,dc=io", "123qwe")).ShouldBe(true);
(await _ldapManager.AuthenticateAsync("cn=abp,dc=abp,dc=io", "123123")).ShouldBe(false);
(await _ldapManager.AuthenticateAsync("NoExists", "123qwe")).ShouldBe(false);
}

20
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/LdapOptions_Tests.cs

@ -1,20 +0,0 @@
using Microsoft.Extensions.Options;
using Shouldly;
using Volo.Abp.Testing;
using Xunit;
namespace Volo.Abp.Ldap;
public class LdapOptions_Tests : AbpIntegratedTest<AbpLdapTestModule>
{
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
{
options.UseAutofac();
}
[Fact]
public void Should_Resolve_AbpAbpLdapOptionsFactory()
{
GetRequiredService<IOptions<AbpLdapOptions>>().ShouldBeOfType(typeof(AbpAbpLdapOptionsManager));
}
}

46
framework/test/Volo.Abp.Ldap.Tests/Volo/Abp/Ldap/TestLdapSettingValueProvider.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Settings;
namespace Volo.Abp.Ldap;
public class TestLdapSettingValueProvider : ISettingValueProvider, ITransientDependency
{
public const string ProviderName = "Test";
public string Name => ProviderName;
public Task<string> GetOrNullAsync(SettingDefinition setting)
{
switch (setting.Name)
{
case LdapSettingNames.ServerHost:
return Task.FromResult("localhost");
case LdapSettingNames.ServerPort:
return Task.FromResult("389");
case LdapSettingNames.BaseDc:
return Task.FromResult("dc=abp,dc=io");
case LdapSettingNames.Domain:
return Task.FromResult<string>(null);
case LdapSettingNames.UserName:
return Task.FromResult("admin");
case LdapSettingNames.Password:
return Task.FromResult("123qwe");
default:
return Task.FromResult<string>(null);
}
}
public Task<List<SettingValue>> GetAllAsync(SettingDefinition[] settings)
{
throw new NotImplementedException();
}
}

4
modules/account/Volo.Abp.Account.abpmdl.json

@ -37,6 +37,10 @@
"Volo.Abp.Account.Blazor": {
"path": "src/Volo.Abp.Account.Blazor/Volo.Abp.Account.Blazor.abppkg.json",
"folder": "src"
},
"Volo.Abp.Account.Installer": {
"path": "src/Volo.Abp.Account.Installer/Volo.Abp.Account.Installer.abppkg.json",
"folder": "src"
}
}
}

11
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo.Abp.Account.Application.Contracts.abppkg.analyze.json

@ -0,0 +1,11 @@
{
"name": "Volo.Abp.Account.Application.Contracts",
"hash": "eda5b3412f7e1dd8dc07761a04f3a064",
"contents": [
{
"namespace": "Volo.Abp.Account",
"contentType": "abpModule",
"name": "AbpAccountApplicationContractsModule"
}
]
}

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/ar.json

@ -1,6 +1,7 @@
{
"culture": "ar",
"texts": {
"Menu:Account": "حساب",
"UserName": "اسم المستخدم",
"EmailAddress": "البريد الإلكتروني",
"UserNameOrEmailAddress": "اسم المستخدم أو البريد الإلكتروني",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/de-DE.json

@ -1,6 +1,7 @@
{
"culture": "de-DE",
"texts": {
"Menu:Account": "Account",
"UserName": "Benutzername",
"EmailAddress": "E-Mail-Adresse",
"UserNameOrEmailAddress": "Benutzername oder E-Mail-Adresse",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json

@ -1,6 +1,7 @@
{
"culture": "en",
"texts": {
"Menu:Account": "Account",
"UserName": "Username",
"EmailAddress": "Email address",
"UserNameOrEmailAddress": "Username or email address",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/es.json

@ -1,6 +1,7 @@
{
"culture": "es",
"texts": {
"Menu:Account": "Cuenta",
"UserName": "Nombre de usuario",
"EmailAddress": "Dirección de correo electrónico",
"UserNameOrEmailAddress": "Nombre de usuario o dirección de correo electrónico",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/fi.json

@ -1,6 +1,7 @@
{
"culture": "fi",
"texts": {
"Menu:Account": "Tili",
"UserName": "Käyttäjätunnus",
"EmailAddress": "Sähköpostiosoite",
"UserNameOrEmailAddress": "Käyttäjänimi tai Sähköpostiosoite",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/fr.json

@ -1,6 +1,7 @@
{
"culture": "fr",
"texts": {
"Menu:Account": "Compte",
"UserName": "Nom d'utilisateur",
"EmailAddress": "Adresse e-mail",
"UserNameOrEmailAddress": "Nom d'utilisateur ou adresse e-mail",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/hi.json

@ -1,6 +1,7 @@
{
"culture": "hi",
"texts": {
"Menu:Account": "लेखा",
"UserName": "उपयोगकर्ता नाम",
"EmailAddress": "ईमेल पता",
"UserNameOrEmailAddress": "उपयोगकर्ता का नाम या ईमेल पता",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/it.json

@ -1,6 +1,7 @@
{
"culture": "it",
"texts": {
"Menu:Account": "Account",
"UserName": "Nome utente",
"EmailAddress": "Indirizzo e-mail",
"UserNameOrEmailAddress": "Username o Indirizzo e-mail",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/pt-BR.json

@ -1,6 +1,7 @@
{
"culture": "pt-BR",
"texts": {
"Menu:Account": "Conta",
"UserName": "Usuário",
"EmailAddress": "E-mail",
"UserNameOrEmailAddress": "Usuário ou e-mail",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/sk.json

@ -1,6 +1,7 @@
{
"culture": "sk",
"texts": {
"Menu:Account": "Účet",
"UserName": "Používateľské meno",
"EmailAddress": "Emailová adresa",
"UserNameOrEmailAddress": "Používateľské meno alebo emailová adresa",

1
modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/sl.json

@ -1,6 +1,7 @@
{
"culture": "sl",
"texts": {
"Menu:Account": "Račun",
"UserName": "Uporabniško ime",
"EmailAddress": "E-poštni naslov",
"UserNameOrEmailAddress": "Uporabniško ime ali e-poštni naslov",

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

Loading…
Cancel
Save