diff --git a/.github/workflows/auto-pr.yml b/.github/workflows/auto-pr.yml
index 987a3ada1b..be8ad519d4 100644
--- a/.github/workflows/auto-pr.yml
+++ b/.github/workflows/auto-pr.yml
@@ -4,7 +4,7 @@ on:
branches:
- rel-4.2
jobs:
- merge-dev-with-rel:
+ merge-dev-with-rel-4-2:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -12,8 +12,8 @@ jobs:
ref: dev
- name: Reset promotion branch
run: |
- git fetch origin $GITHUB_REF:$GITHUB_REF
- git reset --hard $GITHUB_REF
+ git fetch origin rel-4.2:rel-4.2
+ git reset --hard rel-4.2
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json
index c190a91470..a292da5f9b 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/en.json
@@ -198,6 +198,21 @@
"Language": "Language",
"Optional": "Optional",
"CreateArticleLanguageInfo": "The language in which the post is written",
- "Enum:ContentSource:2": "Video Post"
+ "Enum:ContentSource:2": "Video Post",
+ "VideoPreview": "Video Preview",
+ "VideoPreviewErrorMessage": "Given video url couldn't retrieve from Youtube. This can be caused by either video is private or the given URL is not available.",
+ "DeleteCoverImage": "Delete Cover Image",
+ "DeleteCoverImageConfirmationMessage": "Are you sure you want to delete the cover image for \"{0}\"?",
+ "DeleteCoverImageSuccessMessage": "Cover image successfully deleted",
+ "PaymentsOf": "Payments of",
+ "ShowPaymentsOfOrganization": "Show payments",
+ "Date": "Date",
+ "Products": "Products",
+ "TotalAmount": "Total amount",
+ "Currency": "Currency",
+ "Gateway": "Gateway",
+ "State": "State",
+ "FailReason": "Fail reason"
+
}
}
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json
index 9ac7e39b9e..1884b0025f 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Admin/Localization/Resources/tr.json
@@ -159,6 +159,10 @@
"UnlimitedQuestionCount": "Sınırsız soru sayısı",
"Language": "Dil",
"Optional": "Opsiyonel",
- "CreateArticleLanguageInfo": "Makalenin yazıldığı dil"
+ "CreateArticleLanguageInfo": "Makalenin yazıldığı dil",
+ "Enum:ContentSource:2": "Video İçerik",
+ "DeleteCoverImage": "Kapak Fotoğrafını Sil",
+ "DeleteCoverImageConfirmationMessage": "Kapak fotoğrafını \"{0}\" isimli makale için silmek istediğinize emin misiniz?",
+ "DeleteCoverImageSuccessMessage": "Kapak fotoğrafı başarılı bir şekilde silinmiştir"
}
}
\ No newline at end of file
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
index c6eb1ad645..4de287778f 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Commercial/Localization/Resources/en.json
@@ -34,6 +34,13 @@
"JoinOurMarketingNewsletter": "Join our marketing newsletter",
"WouldLikeToReceiveMarketingMaterials": "I would like to receive marketing materials like product deals & special offers.",
"StartUsingYourLicenseNow": "Start using your license now!",
- "WelcomePage": "Welcome Page"
+ "WelcomePage": "Welcome Page",
+ "UnsubscriptionExpireEmail": "Unsubscribe from license expire date reminder emails",
+ "UnsubscribeLicenseExpireEmailReminderMessage": "This email subscription only contains reminding your license expiration date.",
+ "UnsubscribeFromLicenseExpireEmails": "If you don't want to receive the emails about your license expiration date, you can unsubscribe at any time you want.",
+ "Unsubscribe": "Unsubscribe",
+ "NotOrganizationMember": "You are not member of any organization.",
+ "UnsubscribeLicenseExpirationEmailSuccessTitle": "Successfully unsubscribed",
+ "UnsubscribeLicenseExpirationEmailSuccessMessage": "You will not receive license expiration date reminder emails anymore."
}
}
\ No newline at end of file
diff --git a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json
index 5bf922f012..9c1e434ac1 100644
--- a/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json
+++ b/abp_io/AbpIoLocalization/AbpIoLocalization/Community/Localization/Resources/en.json
@@ -132,6 +132,10 @@
"ChooseYourContentType": "Please choose the way you want to add your content.",
"PostContentViaGithub": "I want to add my article with GitHub in accordance with the markdown rules.",
"PostContentViaYoutube": "I want to share my videos available on Youtube here.",
- "PostContentViaExternalSource": "I want to add the content I published on another platform here."
+ "PostContentViaExternalSource": "I want to add the content I published on another platform here.",
+ "GitHubUserNameValidationMessage": "Your Github username can not include whitespace, please be sure your Github username is correct.",
+ "PersonalSiteUrlValidationMessage": "Your personal site URL can not include whitespace, please be sure your personal site URL is correct.",
+ "TwitterUserNameValidationMessage": "Your Twitter username can not include whitespace, please be sure your Twitter username is correct.",
+ "LinkedinUrlValidationMessage": "Your Linkedin URL can not include whitespace, please be sure your Linkedin URL is correct."
}
}
diff --git a/common.props b/common.props
index 5254c91876..593fe92213 100644
--- a/common.props
+++ b/common.props
@@ -1,7 +1,7 @@
- latest
- 4.3.0
+ latest
+ 4.3.0$(NoWarn);CS1591;CS0436https://abp.io/assets/abp_nupkg.pnghttps://abp.io/
diff --git a/docs/en/Application-Services.md b/docs/en/Application-Services.md
index 7fe9825f2a..5d779ec8c9 100644
--- a/docs/en/Application-Services.md
+++ b/docs/en/Application-Services.md
@@ -43,12 +43,14 @@ public class Book : AggregateRoot
{
if (string.IsNullOrWhiteSpace(name))
{
- throw new ArgumentException($"name can not be empty or white space!");
+ throw new ArgumentException(
+ $"name can not be empty or white space!");
}
if (name.Length > MaxNameLength)
{
- throw new ArgumentException($"name can not be longer than {MaxNameLength} chars!");
+ throw new ArgumentException(
+ $"name can not be longer than {MaxNameLength} chars!");
}
return name;
@@ -349,8 +351,9 @@ public class DistrictAppService
protected async override Task GetEntityByIdAsync(DistrictKey id)
{
+ var queryable = await Repository.GetQueryableAsync();
return await AsyncQueryableExecuter.FirstOrDefaultAsync(
- Repository.Where(d => d.CityId == id.CityId && d.Name == id.Name)
+ queryable.Where(d => d.CityId == id.CityId && d.Name == id.Name)
);
}
}
diff --git a/docs/en/AspNet-Boilerplate-Migration-Guide.md b/docs/en/AspNet-Boilerplate-Migration-Guide.md
index f4c2ec712b..52a2fced6a 100644
--- a/docs/en/AspNet-Boilerplate-Migration-Guide.md
+++ b/docs/en/AspNet-Boilerplate-Migration-Guide.md
@@ -184,7 +184,7 @@ public class PersonAppService : ApplicationService, IPersonAppService
}
````
-ABP Framework's repository doesn't have this method. Instead, it implements the `IQueryable` itself. So, you can directly use LINQ on the repository:
+ABP Framework's repository have `GetQueryableAsync` instead:
````csharp
public class PersonAppService : ApplicationService, IPersonAppService
@@ -198,14 +198,15 @@ public class PersonAppService : ApplicationService, IPersonAppService
public async Task DoIt()
{
- var people = await _personRepository
+ var queryable = await _personRepository.GetQueryableAsync();
+ var people = await queryable
.Where(p => p.BirthYear > 2000) //Use LINQ extension methods
.ToListAsync();
}
}
````
-> Note that in order to use the async LINQ extension methods (like `ToListAsync` here), you may need to depend on the database provider (like EF Core) since these methods are defined in the database provider package, they are not standard LINQ methods.
+> Note that in order to use the async LINQ extension methods (like `ToListAsync` here), you may need to depend on the database provider (like EF Core) since these methods are defined in the database provider package, they are not standard LINQ methods. See the [repository document](Repositories.md) for alternative approaches for async query execution.
#### FirstOrDefault(predicate), Single()... Methods
diff --git a/docs/en/Best-Practices/Entity-Framework-Core-Integration.md b/docs/en/Best-Practices/Entity-Framework-Core-Integration.md
index f487f9d61d..04ddeaeba4 100644
--- a/docs/en/Best-Practices/Entity-Framework-Core-Integration.md
+++ b/docs/en/Best-Practices/Entity-Framework-Core-Integration.md
@@ -144,7 +144,7 @@ public virtual async Task FindByNormalizedUserNameAsync(
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
- return await DbSet
+ return await (await GetDbSetAsync())
.IncludeDetails(includeDetails)
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
@@ -175,14 +175,15 @@ public static IQueryable IncludeDetails(
}
````
-* **Do** use the `IncludeDetails` extension method in the repository methods just like used in the example code above (see FindByNormalizedUserNameAsync).
+* **Do** use the `IncludeDetails` extension method in the repository methods just like used in the example code above (see `FindByNormalizedUserNameAsync`).
- **Do** override `WithDetails` method of the repository for aggregates root which have **sub collections**. Example:
````C#
-public override IQueryable WithDetails()
+public override async Task> WithDetailsAsync()
{
- return GetQueryable().IncludeDetails(); // Uses the extension method defined above
+ // Uses the extension method defined above
+ return (await GetQueryableAsync()).IncludeDetails();
}
````
diff --git a/docs/en/Best-Practices/MongoDB-Integration.md b/docs/en/Best-Practices/MongoDB-Integration.md
index 74a0e429f1..90f7871a70 100644
--- a/docs/en/Best-Practices/MongoDB-Integration.md
+++ b/docs/en/Best-Practices/MongoDB-Integration.md
@@ -128,7 +128,7 @@ public async Task FindByNormalizedUserNameAsync(
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
- return await GetMongoQueryable()
+ return await (await GetMongoQueryableAsync())
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken)
@@ -139,8 +139,8 @@ public async Task FindByNormalizedUserNameAsync(
`GetCancellationToken` fallbacks to the `ICancellationTokenProvider.Token` to obtain the cancellation token if it is not provided by the caller code.
* **Do** ignore the `includeDetails` parameters for the repository implementation since MongoDB loads the aggregate root as a whole (including sub collections) by default.
-* **Do** use the `GetMongoQueryable()` method to obtain an `IQueryable` to perform queries wherever possible. Because;
- * `GetMongoQueryable()` method automatically uses the `ApplyDataFilters` method to filter the data based on the current data filters (like soft delete and multi-tenancy).
+* **Do** use the `GetMongoQueryableAsync()` method to obtain an `IQueryable` to perform queries wherever possible. Because;
+ * `GetMongoQueryableAsync()` method automatically uses the `ApplyDataFilters` method to filter the data based on the current data filters (like soft delete and multi-tenancy).
* Using `IQueryable` makes the code as much as similar to the EF Core repository implementation and easy to write and read.
* **Do** implement data filtering if it is not possible to use the `GetMongoQueryable()` method.
diff --git a/docs/en/Best-Practices/Repositories.md b/docs/en/Best-Practices/Repositories.md
index c0058df433..4f646a7d94 100644
--- a/docs/en/Best-Practices/Repositories.md
+++ b/docs/en/Best-Practices/Repositories.md
@@ -42,24 +42,6 @@ Task FindByNormalizedUserNameAsync(
);
````
-* **Do** create a **synchronous extension** method for each asynchronous repository method. Example:
-
-````C#
-public static class IdentityUserRepositoryExtensions
-{
- public static IdentityUser FindByNormalizedUserName(
- this IIdentityUserRepository repository,
- [NotNull] string normalizedUserName)
- {
- return AsyncHelper.RunSync(
- () => repository.FindByNormalizedUserNameAsync(normalizedUserName)
- );
- }
-}
-````
-
-This will allow synchronous code to use the repository methods easier.
-
* **Do** add an optional `bool includeDetails = true` parameter (default value is `true`) for every repository method which returns a **single entity**. Example:
````C#
diff --git a/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/POST.md b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/POST.md
new file mode 100644
index 0000000000..d16afb4244
--- /dev/null
+++ b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/POST.md
@@ -0,0 +1,241 @@
+# ABP Framework 4.2 RC Has Been Published
+
+Today, we have released the [ABP Framework](https://abp.io/) and the [ABP Commercial](https://commercial.abp.io/) 4.2.0 RC (Release Candidate). This blog post introduces the new features and important changes in this new version.
+
+> **The planned release date for the [4.2.0 final](https://github.com/abpframework/abp/milestone/48) version is January 28, 2021**.
+
+## Get Started with the 4.2 RC
+
+If you want to try the version `4.2.0` today, follow the steps below;
+
+1) **Upgrade** the ABP CLI to the version `4.2.0-rc.2` using a command line terminal:
+
+````bash
+dotnet tool update Volo.Abp.Cli -g --version 4.2.0-rc.2
+````
+
+**or install** if you haven't installed before:
+
+````bash
+dotnet tool install Volo.Abp.Cli -g --version 4.2.0-rc.2
+````
+
+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**.
+
+## What's new with the ABP Framework 4.2
+
+## IRepository.GetQueryableAsync()
+
+> **This version comes with an important change about using `IQueryable` features over the [repositories](https://docs.abp.io/en/abp/4.2/Repositories). It is suggested to read this section carefully and apply in your applications.**
+
+`IRepository` interface inherits `IQueryable`, so you can directly use the standard LINQ extension methods, like `Where`, `OrderBy`, `First`, `Sum`... etc.
+
+**Example: Using LINQ directly over the repository object**
+
+````csharp
+public class BookAppService : ApplicationService, IBookAppService
+{
+ private readonly IRepository _bookRepository;
+
+ public BookAppService(IRepository bookRepository)
+ {
+ _bookRepository = bookRepository;
+ }
+
+ public async Task DoItInOldWayAsync()
+ {
+ //Apply any standard LINQ extension method
+ var query = _bookRepository
+ .Where(x => x.Price > 10)
+ .OrderBy(x => x.Name);
+
+ //Execute the query asynchronously
+ var books = await AsyncExecuter.ToListAsync(query);
+ }
+}
+````
+
+*See [the documentation](https://docs.abp.io/en/abp/4.2/Repositories#iqueryable-async-operations) if you wonder what is the `AsyncExecuter`.*
+
+Beginning from the version 4.2, the recommended way is using `IRepository.GetQueryableAsync()` to obtain an `IQueryable`, then use the LINQ extension methods over it.
+
+**Example: Using the new GetQueryableAsync method**
+
+````csharp
+public async Task DoItInNewWayAsync()
+{
+ //Use GetQueryableAsync to obtain the IQueryable first
+ var queryable = await _bookRepository.GetQueryableAsync();
+
+ //Then apply any standard LINQ extension method
+ var query = queryable
+ .Where(x => x.Price > 10)
+ .OrderBy(x => x.Name);
+
+ //Finally, execute the query asynchronously
+ var books = await AsyncExecuter.ToListAsync(query);
+}
+````
+
+ABP may start a database transaction when you get an `IQueryable` (If current [Unit Of Work](https://docs.abp.io/en/abp/latest/Unit-Of-Work) is transactional). In this new way, it is possible to **start the database transaction in an asynchronous way**. Previously, we could not get the advantage of asynchronous while starting the transactions.
+
+> **The new way has a significant performance and scalability gain. The old usage (directly using LINQ over the repositories) will be removed in the next major version.** You have a lot of time for the change, but we recommend to immediately take the action since the old usage has a big scalability problem.
+
+#### About IRepository Async Extension Methods
+
+Using IRepository Async Extension Methods has no such a problem. The examples below are pretty fine:
+
+````csharp
+var countAll = await _personRepository
+ .CountAsync();
+
+var count = await _personRepository
+ .CountAsync(x => x.Name.StartsWith("A"));
+
+var book1984 = await _bookRepository
+ .FirstOrDefaultAsync(x => x.Name == "John");
+````
+
+See the [repository documentation](https://docs.abp.io/en/abp/4.2/Repositories#iqueryable-async-operations) to understand the relation between `IQueryable` and asynchronous operations.
+
+### Repository Bulk Operations
+
+This version adds the following methods to the repositories:
+
+* `InsertManyAsync`
+* `UpdateManyAsync`
+* `DeleteManyAsync`
+
+The purpose of these methods to insert, update or delete many entities in one call with a better performance.
+
+Currently, **MongoDB** provider implements these methods as a single bulk operation since MongoDB API natively supports. But current **Entity Framework Core** implementation is not a real bulk operation. Instead, it does its best with the native API of the EF Core. If you want to implement in a more performant way, you can [customize the bulk operations](https://docs.abp.io/en/abp/4.2/Entity-Framework-Core#customize-bulk-operations) with your own implementation or by using a library. We could find a good open source library for EF Core 5.0 to implement it.
+
+### Selecting DBMS on Template Creation
+
+[ABP CLI](https://docs.abp.io/en/abp/4.2/CLI#new) now has an option to specify the DBMS when you use EF Core as the database provider.
+
+**Example: Select MySQL as the DBMS**
+
+````bash
+abp new BookStore -dbms mysql --preview
+````
+
+Available options: `SqlServer` (default), `MySQL`, `SQLite`, `Oracle-Devart`, `PostgreSQL`. See the [documentation](https://docs.abp.io/en/abp/latest/Entity-Framework-Core-Other-DBMS) to use any other DBMS or switch the DBMS later.
+
+One change related to this feature is that: Now, the startup template doesn't come with an **initial migration** file. This is because the database migrations are different based on your DBMS preference and should be re-created. However, when you first run the `.DbMigrator` application, it will create the initial migration and create the database just like before.
+
+> See The Initial Migration section in the [Getting Started](https://docs.abp.io/en/abp/4.2/Getting-Started-Running-Solution?DB=EF#database-migrations) document if you have problems on running the `.DbMigrator` application first time.
+
+### Swagger UI Login / Authorization
+
+Testing the swagger UI was requiring some additional work, especially your authentication server is separated from the application that hosts the Swagger UI.
+
+With the version 4.2, the startup templates come with the authorization pre-configured for you. An Authorize button is available when you open the Swagger UI:
+
+
+
+When you click, it opens a modal to authorize:
+
+
+
+When you click to the Authorize button here, you are redirected to the login page to login with your username and password (default username is `admin` and password is `1q2w3E*`).
+
+> Remember to select the Scopes (typically **select all**) you want to use before clicking to the Authorize button.
+
+### Angular Unit Testing
+
+We've improved the modules and the startup template to setup and write unit tests easier with the Angular UI. See the [Angular Unit Testing document](https://docs.abp.io/en/abp/4.2/UI/Angular/Testing) for details.
+
+### Other News
+
+* Improved HTTP **request-response performance** by resolving dependencies in a deferred way in the action/page filters, interceptors and some other services.
+* Removed `MultipleActiveResultSets` from connection strings for new templates for SQL Server, since the new EF Core gives a warning when using it. If you want to use it, you need to change the connection string yourself.
+* Added `HardDeleteAsync` extension method that takes a predicate to delete multiple entities. This extension method is available if the entity [Soft Delete](https://docs.abp.io/en/abp/latest/Data-Filtering).
+* Implemented the [Page Alerts](https://docs.abp.io/en/abp/4.2/UI/Angular/Page-Alerts) for the **Angular UI**.
+* Implemented [Page Progress](https://docs.abp.io/en/abp/4.2/UI/Blazor/Page-Progress) for the **Blazor UI**. It automatically shows an undetermined progress bar on top of the page while performing an AJAX request. It also proves an API to you if you need to show/hide the progress bar in your code.
+
+## What's new with the ABP Commercial 4.2
+
+### Microservice Startup Template
+
+The new [Microservice Startup Template](https://docs.abp.io/en/commercial/4.2/startup-templates/microservice/index) is a generic solution to start a new microservice solution.
+
+While we accept that every microservice solution will be different and every system has its own design requirements and trade-offs, we believe such a startup solution is a very useful starting point for most of the solutions, and a useful example for others.
+
+
+
+*Figure: A simplified overall diagram of the microservice solution.*
+
+You can [follow the documentation](https://docs.abp.io/en/commercial/4.2/startup-templates/microservice/index) to get started with this startup template. **This template should be considered as an early release**. We will improve it and write a lot of guides.
+
+If you want to use the ABP Suite to create your solution, then you need to first upgrade it:
+
+````bash
+abp suite update
+````
+
+If you want, you can directly create a new solution from the command line:
+
+````bash
+abp new Volosoft.MyMicroserviceSystem -t microservice-pro --preview
+````
+
+Company Name is optional. Solution name could be *MyMicroserviceSystem* for this example.
+
+### Public Website in the Startup Templates
+
+As mentioned in the previous release post, we've added a *Public Website* application to the startup templates. It is configured to authenticate through the IdentityServer with a single sign-on system.
+
+You can use this application to create a landing page for your actual application or a corporate website for your business. An example screenshot:
+
+
+
+It uses the same *Lepton Theme*, so you can apply [all the styles](https://commercial.abp.io/themes). The Public Website has a different layout and also has a different setting for the styling (that can be configured in the *Settings / Lepton Theme* page of the main web application).
+
+> *Public Website* is optional and you need to select the "Public Website" option while creating a new solution using the ABP Suite, or use the `--with-public-website` option while using the `abp new` CLI command.
+
+### Easy CRM Blazor UI
+
+[Easy CRM](https://docs.abp.io/en/commercial/latest/samples/easy-crm) is an example application built with the ABP Commercial. MVC (Razor Pages) and Angular UI implementations were already provided. With the version 4.2, we are providing the Blazor UI implementation for this application.
+
+
+
+### Other News
+
+* Implemented Iyzico as a payment gateway provider for the [payment module](https://commercial.abp.io/modules/Volo.Payment) in addition to Paypal, Stripe, 2Checkout and Payu providers.
+* ABP Suite supports the new microservice template creation, public website and DBMS selection options.
+* Swagger authorization and other features mentioned in the ABP Framework section are already implemented for the ABP Commercial too.
+
+## ABP Community News
+
+### Sharing Video Contents
+
+[community.abp.io](https://community.abp.io/) is a place to share ABP related contents. It started with publishing articles. Now, it supports to publish video contents. [See this example](https://community.abp.io/articles/be-a-superhero-on-day-1-with-abp.io-wvifcy9s). All you need to do is to create a video and upload to YouTube. Then you can [submit](https://community.abp.io/articles/submit) the YouTube link to the ABP Community website.
+
+### Multi-language support
+
+We planned ABP Community to publish English-only contents. However, we see that people want to share contents in other languages too. Now, **it is possible to submit a content in any language**. Just select the Language option while submitting your content.
+
+**When you submit a non-English content, it is not visible to all the visitors by default**. Visitors can see a non-English content only if their browser language or the selected language matches to the content language (there is a language selection at the end of the website).
+
+### External Contents
+
+If you want to publish your content anywhere else, but want to post a link of your content, you can select *External Content* option while submitting the post. For example, [this article](https://community.abp.io/articles/aspnet-boilerplate-to-abp-framework-xml-to-json-localization-conversion-0mxyjrzj) is an external article and also written in Chinese language.
+
+## About the Next Release
+
+The next feature version will be 4.3.0. It is planned to release the 4.3 RC (Release Candidate) on March 11 and the final version on March 25, 2021.
+
+We decided to slow down the feature development for the [next milestone](https://github.com/abpframework/abp/milestone/49). We will continue to improve the existing features and introduce new ones, sure, but wanted to have more time for the planning, documentation, creating guides and improving the development experience.
+
+## Feedback
+
+Please check out the ABP Framework 4.2.0 RC and [provide feedback](https://github.com/abpframework/abp/issues/new) to help us to release a more stable version. **The planned release date for the [4.2.0 final](https://github.com/abpframework/abp/milestone/48) version is January 28, 2021**.
diff --git a/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/easy-crm.png b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/easy-crm.png
new file mode 100644
index 0000000000..02c47777a4
Binary files /dev/null and b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/easy-crm.png differ
diff --git a/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/microservice-template-diagram.png b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/microservice-template-diagram.png
new file mode 100644
index 0000000000..2c6df5ab74
Binary files /dev/null and b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/microservice-template-diagram.png differ
diff --git a/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/public-website.jpg b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/public-website.jpg
new file mode 100644
index 0000000000..b5784519bd
Binary files /dev/null and b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/public-website.jpg differ
diff --git a/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/swagger-authorize-modal.png b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/swagger-authorize-modal.png
new file mode 100644
index 0000000000..52b43f248e
Binary files /dev/null and b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/swagger-authorize-modal.png differ
diff --git a/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/swagger-authorize.png b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/swagger-authorize.png
new file mode 100644
index 0000000000..650a212fe5
Binary files /dev/null and b/docs/en/Blog-Posts/2021-01-14 v4_2_Preview/swagger-authorize.png differ
diff --git a/docs/en/Blog-Posts/2021-01-28 v4_2_Release_Stable/POST.md b/docs/en/Blog-Posts/2021-01-28 v4_2_Release_Stable/POST.md
new file mode 100644
index 0000000000..fac8484411
--- /dev/null
+++ b/docs/en/Blog-Posts/2021-01-28 v4_2_Release_Stable/POST.md
@@ -0,0 +1,53 @@
+# ABP.IO Platform 4.2 Final Has Been Released!
+
+[ABP Framework](https://abp.io/) and [ABP Commercial](https://commercial.abp.io/) 4.2 versions have been released today.
+
+## What's New With 4.2?
+
+Since all the new features are already explained in details with the [4.2 RC Announcement Post](https://blog.abp.io/abp/ABP-IO-Platform-v4-2-RC-Has-Been-Released), I will not repeat all the details again. See the [RC Blog Post](https://blog.abp.io/abp/ABP-IO-Platform-v4-2-RC-Has-Been-Released) for all the features and enhancements.
+
+## Creating New Solutions
+
+You can create a new solution with the ABP Framework version 4.2 by either using the `abp new` command or using the **direct download** tab on the [get started page](https://abp.io/get-started).
+
+> See the [getting started document](https://docs.abp.io/en/abp/latest/Getting-Started) for details.
+
+## How to Upgrade an Existing Solution
+
+### Install/Update the ABP CLI
+
+First of all, install the ABP CLI or upgrade to the latest version.
+
+If you haven't installed yet:
+
+```bash
+dotnet tool install -g Volo.Abp.Cli
+```
+
+To update an existing installation:
+
+```bash
+dotnet tool update -g Volo.Abp.Cli
+```
+
+### ABP UPDATE Command
+
+[ABP CLI](https://docs.abp.io/en/abp/latest/CLI) provides a handy command to update all the ABP related NuGet and NPM packages in your solution with a single command:
+
+```bash
+abp update
+```
+
+Run this command in the root folder of your solution.
+
+## Migration Guide
+
+Check [the migration guide](https://docs.abp.io/en/abp/latest/Migration-Guides/Abp-4_2) for the applications with the version 4.x upgrading to the version 4.2.
+
+> It is strongly recommended to check the migration guide for this version. Especially, the new `IRepository.GetQueryableAsync()` method is a core change should be considered after upgrading the solution.
+
+## About the Next Version
+
+The next feature version will be 4.3. It is planned to release the 4.3 RC (Release Candidate) on March 11 and the final version on March 25, 2021.
+
+We decided to slow down the feature development for the [next milestone](https://github.com/abpframework/abp/milestone/49). We will continue to improve the existing features and introduce new ones, sure, but wanted to have more time for the planning, documentation, creating guides and improving the development experience.
\ No newline at end of file
diff --git a/docs/en/CSRF-Anti-Forgery.md b/docs/en/CSRF-Anti-Forgery.md
index 720edc5924..ee684aaa52 100644
--- a/docs/en/CSRF-Anti-Forgery.md
+++ b/docs/en/CSRF-Anti-Forgery.md
@@ -144,4 +144,19 @@ Let's talk about why.
First, take a look at [Angular's code](https://github.com/angular/angular/blob/master/packages/common/http/src/xsrf.ts#L81)
-It does not intercept any request that starts with `http://` or `https://`. There is a good reason for that. Any cross-site request does not need this token for security. This verification is only valid if the request is made to the same domain from which the web page is served. So, simply put, if you serve everything from a single domain, you just use a relative path.
\ No newline at end of file
+It does not intercept any request that starts with `http://` or `https://`. There is a good reason for that. Any cross-site request does not need this token for security. This verification is only valid if the request is made to the same domain from which the web page is served. So, simply put, if you serve everything from a single domain, you just use a relative path.
+
+If you serve your APIs from the root, i.e. no context root (https://testdomain.com/api/identity/users), leave `url` empty as follows:
+
+```typescript
+export const environment = {
+ production: true,
+ // ....
+ apis: {
+ default: {
+ url: '', // <- should be empty string, not '/'
+ // ...
+ },
+ },
+} as Config.Environment;
+```
diff --git a/docs/en/Caching.md b/docs/en/Caching.md
index 042f13ffe0..7dbf02d875 100644
--- a/docs/en/Caching.md
+++ b/docs/en/Caching.md
@@ -242,12 +242,15 @@ In addition, all of the `IDistributedCache` (and `IDistributedCache<
## Batch Operations
-ABP's distributed cache interfaces provide methods to perform batch get/set methods those improves the performance when you want to get or set multiple cache items in a single method call.
+ABP's distributed cache interfaces provide methods to perform batch methods those improves the performance when you want to batch operation multiple cache items in a single method call.
* `SetManyAsync` and `SetMany` methods can be used to set multiple values to the cache.
* `GetManyAsync` and `GetMany` methods can be used to retrieve multiple values from the cache.
+* `GetOrAddManyAsync` and `GetOrAddMany` methods can be used to retrieve multiple values and set missing values from the cache
+* `RefreshManyAsync` and `RefreshMany` methods can be used to resets the sliding expiration timeout of multiple values from the cache
+* `RemoveManyAsync` and `RemoveMany` methods can be used to remove multiple values from the cache
-> These are not standard methods of the ASP.NET Core caching. So, some providers may not support them. They are supported by the [ABP Redis Cache integration package](Redis-Cache.md). If the provider doesn't support, it fallbacks to `SetAsync` and `GetAsync` methods (called once for each item).
+> These are not standard methods of the ASP.NET Core caching. So, some providers may not support them. They are supported by the [ABP Redis Cache integration package](Redis-Cache.md). If the provider doesn't support, it fallbacks to `SetAsync` and `GetAsync` ... methods (called once for each item).
## Advanced Topics
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/POST.md b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/POST.md
new file mode 100644
index 0000000000..f30f31d541
--- /dev/null
+++ b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/POST.md
@@ -0,0 +1,103 @@
+## Using MatBlazor UI Components With the ABP Framework
+
+Hi, in this step by step article, I will show you how to integrate [MatBlazor](https://www.matblazor.com/), a blazor UI components into ABP Framework-based applications.
+
+
+
+*(A screenshot from the example application developed in this article)*
+
+## Create the Project
+
+> First thing is to create the project. ABP Framework offers startup templates to get into business faster.
+
+In this article, I will create a new startup template with EF Core as a database provider and Blazor for UI framework. But if you already have a project with Blazor UI, you don't need to create a new startup template, you can directly implement the following steps to your existing project.
+
+> If you already have a project with the Blazor UI, you can skip this section.
+
+* Before starting the development, we will create a new solution named `MatBlazorSample` (or whatever you want). We will create a new startup template with EF Core as a database provider and Blazor for UI framework by using [ABP CLI](https://docs.abp.io/en/abp/latest/CLI):
+
+````bash
+abp new MatBlazorSample -u blazor
+````
+
+This will create new project inside of `aspnet-core`, so:
+
+````bash
+cd aspnet-core
+````
+
+and
+
+````bash
+dotnet restore
+````
+
+* Our project boilerplate will be ready after the download is finished. Then, we can open the solution in the Visual Studio (or any other IDE) and run the `MatBlazorSample.DbMigrator` to create the database and seed initial data (which creates the admin user, admin role, permissions etc.)
+
+
+
+* After database and initial data created,
+* Run the `MatBlazorSample.HttpApi.Host` to see our server side working and
+* Run the `MatBlazorSample.Blazor` to see our UI working properly.
+
+> _Default login credentials for admin: username is **admin** and password is **1q2w3E\***_
+
+## Install MatBlazor
+
+You can follow [this documentation](https://www.matblazor.com/) to install MatBlazor packages into your computer.
+
+### Adding MatBlazor NuGet Packages
+
+```bash
+Install-Package MatBlazor
+```
+
+### Register MatBlazor Resources
+
+1. Add the following line to the HEAD section of the `wwwroot/index.html` file within the `MatBlazorSample.Blazor` project:
+
+ ```Razor
+
+
+
+
+
+ ```
+
+2. In the `MatBlazorSampleBlazorModule` class, call the `AddMatBlazor()` method from your project's `ConfigureServices()` method:
+
+ ```csharp
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ var environment = context.Services.GetSingletonInstance();
+ var builder = context.Services.GetSingletonInstance();
+ // ...
+ builder.Services.AddMatBlazor();
+ }
+ ```
+
+3. Register the **MatBlazorSample.Blazor** namespace in the `_Imports.razor` file:
+
+ ```Razor
+ @using MatBlazor
+ ```
+
+## The Sample Application
+
+We have created a sample application with [Table](https://www.matblazor.com/Table) example.
+
+### The Source Code
+
+You can download the source code from [here](https://github.com/abpframework/abp-samples/tree/master/MatBlazorSample).
+
+The related files for this example are marked in the following screenshots.
+
+
+
+
+
+
+
+## Conclusion
+
+In this article, I've explained how to use [MatBlazor](https://www.matblazor.com/) components in your application. ABP Framework is designed so that it can work with any UI library/framework.
\ No newline at end of file
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/example-result.png b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/example-result.png
new file mode 100644
index 0000000000..89a2fecdce
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/example-result.png differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/initial-project.png b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/initial-project.png
new file mode 100644
index 0000000000..85e71d5692
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/initial-project.png differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-app-contract.png b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-app-contract.png
new file mode 100644
index 0000000000..8108cdc606
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-app-contract.png differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-application.png b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-application.png
new file mode 100644
index 0000000000..7f07af97e1
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-application.png differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-web.png b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-web.png
new file mode 100644
index 0000000000..0034aec095
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Integrate-the-MatBlazor-Blazor-Component/table-web.png differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/POST.md b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/POST.md
new file mode 100644
index 0000000000..7a854291d5
--- /dev/null
+++ b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/POST.md
@@ -0,0 +1,343 @@
+# How to Use PrimeNG Components with the ABP Angular UI
+
+## Introduction
+
+In this article, we will use components of the [PrimeNG](https://www.primefaces.org/primeng/) that is a popular UI component library for Angular with the ABP Framework Angular UI that will be generated via [ABP CLI](https://docs.abp.io/en/abp/latest/CLI).
+
+We will create an organization units page and use PrimeNG's [OrganizationChart](https://primefaces.org/primeng/showcase/#/organizationchart) and [Table](https://primefaces.org/primeng/showcase/#/table) components on the page.
+
+
+
+The UI shown above contains many PrimeNG components. You can reach the source code of this rich UI. Take a look at the source code section below.
+
+> This article does not cover any backend code. I used mock data to provide data source to the components.
+
+## Pre-Requirements
+
+The following tools should be installed on your development machine:
+
+* [.NET Core 5.0+](https://www.microsoft.com/net/download/dotnet-core/)
+* [Node v12 or v14](https://nodejs.org/)
+* [VS Code](https://code.visualstudio.com/) or another IDE
+
+## Source Code
+
+I have prepared a sample project that contains more PrimeNG components than described in this article. You can download the source code [on GitHub](https://github.com/abpframework/abp-samples/tree/master/PrimengSample).
+
+## Creating a New Solution
+
+In this step, we will create a new solution that contains Angular UI and backend startup templates. If you have a startup template with Angular UI, you can skip this step.
+
+Run the following command to install the ABP CLI:
+
+```bash
+dotnet tool install -g Volo.Abp.Cli
+```
+
+...or update:
+
+```bash
+dotnet tool update -g Volo.Abp.Cli
+```
+
+Create a new solution named `AbpPrimengSample` by running the following command:
+
+```bash
+abp new AbpPrimengSample -u angular -csf
+```
+
+See the [ABP CLI documentation](https://docs.abp.io/en/abp/latest/CLI) for all available options.
+
+You can also use the Direct Download tab on the [Get Started](https://abp.io/get-started) page.
+
+## Running the Solution
+
+You can run the solution as described in [here](https://docs.abp.io/en/abp/latest/Getting-Started-Running-Solution?UI=NG&DB=EF&Tiered=No).
+
+## PrimeNG Setup
+
+Open the `angular` folder and run the following command to install packages:
+
+```bash
+npm install
+```
+
+Next, we need to install `primeng` and required packages (`primeicons` and `@angular/cdk`) for the library. Run the command below to install these packages:
+
+```bash
+npm install primeng primeicons @angular/cdk --save
+```
+
+The packages we have installed;
+
+ - `primeng` is the main package that is a component library.
+ - `primeicons` is an icon font library. Many PrimeNG components use this font internally.
+ - `@angular/cdk` is a component dev kit created by the Angular team. Some PrimeNG modules depend on it.
+
+As the last step of the setup, we should add the required style files for the library to `angular.json`:
+
+```js
+//angular.json
+
+"projects": {
+ "AbpPrimengSample": {
+ //...
+ "styles": {
+ "node_modules/primeicons/primeicons.css",
+ "node_modules/primeng/resources/themes/saga-blue/theme.css",
+ "node_modules/primeng/resources/primeng.min.css",
+ //...other styles
+ }
+ }
+}
+```
+
+We have added the `primeng.min.css`, Saga Blue theme's `theme.css`, and `primeicons.css` files to the project. You can choose another theme instead of the Sage Blue. See available themes on the [Get Started](https://www.primefaces.org/primeng/showcase/#/setup) document of the PrimeNG.
+
+
+> You have to restart the running `ng serve` process to see the effect of the changes you made in the `angular.json`.
+
+
+## Creating the Organization Units Page
+
+Run the following command to create a new module named `OrganizationUnits`:
+
+```bash
+npm run ng -- generate module organization-units --route organization-units --module app.module
+```
+
+Then open the `src/route.provider.ts` and add a new route as an array element to add a navigation link labeled "Organization Units" to the menu:
+
+```js
+//route.provider.ts
+
+import { eThemeSharedRouteNames } from '@abp/ng.theme.shared';
+//...
+
+routesService.add([
+ //...
+ {
+ path: '/organization-units',
+ name: 'Organization Units',
+ parentName: eThemeSharedRouteNames.Administration,
+ iconClass: 'fas fa-sitemap',
+ layout: eLayoutType.application,
+ },
+]);
+```
+
+We have created a lazy-loadable module and defined a menu navigation link. We can navigate to the page as shown below:
+
+
+
+## Using the PrimeNG Components
+
+### Implementing the Organization Chart Component
+
+When you would like to use any component from PrimeNG, you have to import the component's module to your module. Since we will use the `OrganizationChart` on the organization units page, we need to import `OrganizationChartModule` into `OrganizationUnitsModule`.
+
+Open the `src/organization-units/organization-units.module.ts` and add the `OrganizationChartModule` to the imports array as shown below:
+
+```js
+import { OrganizationChartModule } from 'primeng/organizationchart';
+//...
+
+@NgModule({
+ //...
+ imports: [
+ //...
+ OrganizationChartModule
+ ],
+})
+export class OrganizationUnitsModule {}
+```
+
+> Since NGCC need to work in some cases, restarting the `ng serve` process would be good when you import any modules from `primeng` package to your module.
+
+Let's define a mock data source for the `OrganizationChartComponent` and add the component to the page.
+
+Open the `src/organization-units/organization-units.component.ts` and add two variables as shown below:
+
+```js
+//...
+import { TreeNode } from 'primeng/api';
+
+@Component(/* component metadata*/)
+export class OrganizationUnitsComponent implements OnInit {
+ //...
+
+ organizationUnits: TreeNode[] = [
+ {
+ label: 'Management',
+ expanded: true,
+ children: [
+ {
+ label: 'Selling',
+ expanded: true,
+ children: [
+ {
+ label: 'Customer Relations',
+ },
+ {
+ label: 'Marketing',
+ },
+ ],
+ },
+ {
+ label: 'Supporting',
+ expanded: true,
+ children: [
+ {
+ label: 'Buying',
+ },
+ {
+ label: 'Human Resources',
+ },
+ ],
+ },
+ ],
+ },
+ ];
+
+ selectedUnit: TreeNode;
+```
+
+- First variable is `organizationUnits`. It provides mock data source to `OrganizationChartComponent`.
+- Second variable is `selectedUnit`. It keeps chosen unit on the chart.
+
+Then, open the `src/organization-units/organization-units.component.html` and replace the file content with the following:
+
+```html
+
+
+
Organization Units
+
+
+
+
+
+```
+
+We have implemented the `OrganizationChart`. The final UI looks like below:
+
+
+
+## Implementing the Table Component
+
+In order to use the `TableComponent`, we have to import the `TableModule` to the `OrganizationUnitsModule`.
+
+Open the `organization-units.module.ts` and add `TableModule` to the imports array as shown below:
+
+```js
+import { TableModule } from 'primeng/table';
+//...
+
+@NgModule({
+ //...
+ imports: [
+ //...
+ TableModule
+ ],
+})
+export class OrganizationUnitsModule {}
+```
+
+Open the `organization-units.component.ts` and add a variable named `members` with initial value and add a getter named `tableData` as shown below:
+
+```js
+//...
+export class OrganizationUnitsComponent implements OnInit {
+ //...
+
+ members = [
+ {
+ fullName: 'John Doe',
+ username: 'John.Doe',
+ phone: '+1-202-555-0125',
+ email: 'john.doe@example.com',
+ parent: 'Customer Relations',
+ },
+ {
+ fullName: 'Darrion Walter',
+ username: 'Darrion.Walter',
+ phone: '+1-262-155-0355',
+ email: 'Darrion_Walter@example.com',
+ parent: 'Marketing',
+ },
+ {
+ fullName: 'Rosa Labadie',
+ username: 'Rosa.Labadie',
+ phone: '+1-262-723-2255',
+ email: 'Rosa.Labadie@example.com',
+ parent: 'Marketing',
+ },
+ {
+ fullName: 'Adelle Hills',
+ username: 'Adelle.Hills',
+ phone: '+1-491-112-9011',
+ email: 'Adelle.Hills@example.com',
+ parent: 'Buying',
+ },
+ {
+ fullName: 'Brian Hane',
+ username: 'Brian.Hane',
+ phone: '+1-772-509-1823',
+ email: 'Brian.Hane@example.com',
+ parent: 'Human Resources',
+ },
+ ];
+
+ get tableData() {
+ return this.members.filter(user => user.parent === this.selectedUnit.label);
+ }
+```
+
+What we have done above?
+
+- We defined a variable named `members` to provide mock data to the table.
+- We have defined a getter named `tableData` to provide filtered data source to the table using `members` variable.
+
+We are now ready to add the table to the HTML template.
+
+Open the `organization-units.component.html`, find the `p-organizationChart` tag and place the following code to the bottom of this tag:
+
+```html
+
+
Members of {{ selectedUnit.label }}
+
+
+
+
+
Name
+
Username
+
Email
+
Phone
+
+
+
+
+
{{ member.fullName }}
+
{{ member.username }}
+
{{ member.email }}
+
{{ member.phone }}
+
+
+
+
+```
+
+We have added a new `div` that contains the `TableComponent`. The table appears when an organization unit is selected.
+The table contains 4 columns which are name, username, email, and phone for displaying the members' information.
+
+After adding the table, the final UI looks like this:
+
+
+
+
+## Conclusion
+
+We have implemented the PrimeNG component library on the ABP Angular UI project and used two components on a page in a short time. You can use any PrimeNG components by following the documentation. The ABP Angular UI will not block you in any case.
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/intro.gif b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/intro.gif
new file mode 100644
index 0000000000..5f96a65422
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/intro.gif differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/organization-chart.jpg b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/organization-chart.jpg
new file mode 100644
index 0000000000..9d18f35ba1
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/organization-chart.jpg differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/organization-units-menu-item.jpg b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/organization-units-menu-item.jpg
new file mode 100644
index 0000000000..dc6111f553
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/organization-units-menu-item.jpg differ
diff --git a/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/table.gif b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/table.gif
new file mode 100644
index 0000000000..d27dcb26bd
Binary files /dev/null and b/docs/en/Community-Articles/2021-01-20-How-to-Use-PrimeNG-Components-with-the-ABP-Angular-UI/table.gif differ
diff --git a/docs/en/Dependency-Injection.md b/docs/en/Dependency-Injection.md
index 335e829461..f94901ad84 100644
--- a/docs/en/Dependency-Injection.md
+++ b/docs/en/Dependency-Injection.md
@@ -1,6 +1,6 @@
# Dependency Injection
-ABP's Dependency Injection system is developed based on Microsoft's [dependency injection extension](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection) library (Microsoft.Extensions.DependencyInjection nuget package). So, it's documentation is valid in ABP too.
+ABP's Dependency Injection system is developed based on Microsoft's [dependency injection extension](https://medium.com/volosoft/asp-net-core-dependency-injection-best-practices-tips-tricks-c6e9c67f9d96) library (Microsoft.Extensions.DependencyInjection nuget package). So, it's documentation is valid in ABP too.
> While ABP has no core dependency to any 3rd-party DI provider, it's required to use a provider that supports dynamic proxying and some other advanced features to make some ABP features properly work. Startup templates come with Autofac installed. See [Autofac integration](Autofac-Integration.md) document for more information.
diff --git a/docs/en/Domain-Driven-Design-Implementation-Guide.md b/docs/en/Domain-Driven-Design-Implementation-Guide.md
index 9341df703b..cf2ce6bf14 100644
--- a/docs/en/Domain-Driven-Design-Implementation-Guide.md
+++ b/docs/en/Domain-Driven-Design-Implementation-Guide.md
@@ -754,7 +754,8 @@ namespace IssueTracking.Issues
{
var daysAgo30 = DateTime.Now.Subtract(TimeSpan.FromDays(30));
- return await DbSet.Where(i =>
+ var dbSet = await GetDbSetAsync();
+ return await dbSet.Where(i =>
//Open
!i.IsClosed &&
@@ -906,7 +907,8 @@ public class EfCoreIssueRepository :
public async Task> GetIssuesAsync(ISpecification spec)
{
- return await DbSet
+ var dbSet = await GetDbSetAsync();
+ return await dbSet
.Where(spec.ToExpression())
.ToListAsync();
}
@@ -952,8 +954,9 @@ public class IssueAppService : ApplicationService, IIssueAppService
public async Task DoItAsync()
{
+ var queryable = await _issueRepository.GetQueryableAsync();
var issues = AsyncExecuter.ToListAsync(
- _issueRepository.Where(new InActiveIssueSpecification())
+ queryable.Where(new InActiveIssueSpecification())
);
}
}
@@ -996,8 +999,9 @@ public class IssueAppService : ApplicationService, IIssueAppService
public async Task DoItAsync(Guid milestoneId)
{
+ var queryable = await _issueRepository.GetQueryableAsync();
var issues = AsyncExecuter.ToListAsync(
- _issueRepository
+ queryable
.Where(
new InActiveIssueSpecification()
.And(new MilestoneSpecification(milestoneId))
diff --git a/docs/en/Entity-Framework-Core.md b/docs/en/Entity-Framework-Core.md
index b2b216397a..a2c0e79996 100644
--- a/docs/en/Entity-Framework-Core.md
+++ b/docs/en/Entity-Framework-Core.md
@@ -236,7 +236,8 @@ public class BookRepository
public async Task DeleteBooksByType(BookType type)
{
- await DbContext.Database.ExecuteSqlRawAsync(
+ var dbContext = await GetDbContextAsync();
+ await dbContext.Database.ExecuteSqlRawAsync(
$"DELETE FROM Books WHERE Type = {(int)type}"
);
}
@@ -344,7 +345,7 @@ You have different options when you want to load the related entities while quer
#### Repository.WithDetails
-`IRepository.WithDetails(...)` can be used to include one relation collection/property to the query.
+`IRepository.WithDetailsAsync(...)` can be used to get an `IQueryable` by including one relation collection/property.
**Example: Get an order with lines**
@@ -355,7 +356,7 @@ using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Domain.Services;
-namespace MyCrm
+namespace AbpDemo.Orders
{
public class OrderManager : DomainService
{
@@ -368,35 +369,39 @@ namespace MyCrm
public async Task TestWithDetails(Guid id)
{
- var query = _orderRepository
- .WithDetails(x => x.Lines)
- .Where(x => x.Id == id);
-
+ //Get a IQueryable by including sub collections
+ var queryable = await _orderRepository.WithDetailsAsync(x => x.Lines);
+
+ //Apply additional LINQ extension methods
+ var query = queryable.Where(x => x.Id == id);
+
+ //Execute the query and get the result
var order = await AsyncExecuter.FirstOrDefaultAsync(query);
}
}
}
````
-> `AsyncExecuter` is used to execute async LINQ extensions without depending on the EF Core. If you add EF Core NuGet package reference to your project, then you can directly use `await _orderRepository.WithDetails(x => x.Lines).FirstOrDefaultAsync()`. But, this time you depend on the EF Core in your domain layer. See the [repository document](Repositories.md) to learn more.
+> `AsyncExecuter` is used to execute async LINQ extensions without depending on the EF Core. If you add EF Core NuGet package reference to your project, then you can directly use `await query.FirstOrDefaultAsync()`. But, this time you depend on the EF Core in your domain layer. See the [repository document](Repositories.md) to learn more.
**Example: Get a list of orders with their lines**
````csharp
public async Task TestWithDetails()
{
- var query = _orderRepository
- .WithDetails(x => x.Lines);
+ //Get a IQueryable by including sub collections
+ var queryable = await _orderRepository.WithDetailsAsync(x => x.Lines);
- var orders = await AsyncExecuter.ToListAsync(query);
+ //Execute the query and get the result
+ var orders = await AsyncExecuter.ToListAsync(queryable);
}
````
-> `WithDetails` method can get more than one expression parameter if you need to include more than one navigation property or collection.
+> `WithDetailsAsync` method can get more than one expression parameter if you need to include more than one navigation property or collection.
#### DefaultWithDetailsFunc
-If you don't pass any expression to the `WithDetails` method, then it includes all the details using the `DefaultWithDetailsFunc` option you provide.
+If you don't pass any expression to the `WithDetailsAsync` method, then it includes all the details using the `DefaultWithDetailsFunc` option you provide.
You can configure `DefaultWithDetailsFunc` for an entity in the `ConfigureServices` method of your [module](Module-Development-Basics.md) in your `EntityFrameworkCore` project.
@@ -419,12 +424,15 @@ Then you can use the `WithDetails` without any parameter:
````csharp
public async Task TestWithDetails()
{
- var query = _orderRepository.WithDetails();
- var orders = await AsyncExecuter.ToListAsync(query);
+ //Get a IQueryable by including all sub collections
+ var queryable = await _orderRepository.WithDetailsAsync();
+
+ //Execute the query and get the result
+ var orders = await AsyncExecuter.ToListAsync(queryable);
}
````
-`WithDetails()` executes the expression you've setup as the `DefaultWithDetailsFunc`.
+`WithDetailsAsync()` executes the expression you've setup as the `DefaultWithDetailsFunc`.
#### Repository Get/Find Methods
@@ -466,7 +474,7 @@ public async Task TestWithDetails()
#### Alternatives
-The repository patters tries to encapsulate the EF Core, so your options are limited. If you need an advanced scenario, you can follow one of the options;
+The repository pattern tries to encapsulate the EF Core, so your options are limited. If you need an advanced scenario, you can follow one of the options;
* Create a custom repository method and use the complete EF Core API.
* Reference to the `Volo.Abp.EntityFrameworkCore` package from your project. In this way, you can directly use `Include` and `ThenInclude` in your code.
@@ -550,24 +558,15 @@ See also [lazy loading document](https://docs.microsoft.com/en-us/ef/core/queryi
In most cases, you want to hide EF Core APIs behind a repository (this is the main purpose of the repository pattern). However, if you want to access the `DbContext` instance over the repository, you can use `GetDbContext()` or `GetDbSet()` extension methods. Example:
````csharp
-public class BookService
+public async Task TestAsync()
{
- private readonly IRepository _bookRepository;
-
- public BookService(IRepository bookRepository)
- {
- _bookRepository = bookRepository;
- }
-
- public void Foo()
- {
- DbContext dbContext = _bookRepository.GetDbContext();
- DbSet books = _bookRepository.GetDbSet();
- }
+ var dbContext = await _orderRepository.GetDbContextAsync();
+ var dbSet = await _orderRepository.GetDbSetAsync();
+ //var dbSet = dbContext.Set(); //Alternative, when you have the DbContext
}
````
-* `GetDbContext` returns a `DbContext` reference instead of `BookStoreDbContext`. You can cast it, however in most cases you don't need it.
+* `GetDbContextAsync` returns a `DbContext` reference instead of `BookStoreDbContext`. You can cast it if you need. However, you don't need it in most cases.
> Important: You must reference to the `Volo.Abp.EntityFrameworkCore` package from the project you want to access to the `DbContext`. This breaks encapsulation, but this is what you want in that case.
@@ -742,32 +741,36 @@ If you have better logic or using an external library for bulk operations, you c
- You may use example template below:
```csharp
-public class MyCustomEfCoreBulkOperationProvider : IEfCoreBulkOperationProvider, ITransientDependency
-{
- public async Task DeleteManyAsync(IEfCoreRepository repository,
- IEnumerable entities,
- bool autoSave,
- CancellationToken cancellationToken)
+public class MyCustomEfCoreBulkOperationProvider
+ : IEfCoreBulkOperationProvider, ITransientDependency
+{
+ public async Task DeleteManyAsync(
+ IEfCoreRepository repository,
+ IEnumerable entities,
+ bool autoSave,
+ CancellationToken cancellationToken)
where TDbContext : IEfCoreDbContext
where TEntity : class, IEntity
{
// Your logic here.
}
- public async Task InsertManyAsync(IEfCoreRepository repository,
- IEnumerable entities,
- bool autoSave,
- CancellationToken cancellationToken)
+ public async Task InsertManyAsync(
+ IEfCoreRepository repository,
+ IEnumerable entities,
+ bool autoSave,
+ CancellationToken cancellationToken)
where TDbContext : IEfCoreDbContext
where TEntity : class, IEntity
{
// Your logic here.
}
- public async Task UpdateManyAsync(IEfCoreRepository repository,
- IEnumerable entities,
- bool autoSave,
- CancellationToken cancellationToken)
+ public async Task UpdateManyAsync(
+ IEfCoreRepository repository,
+ IEnumerable entities,
+ bool autoSave,
+ CancellationToken cancellationToken)
where TDbContext : IEfCoreDbContext
where TEntity : class, IEntity
{
@@ -779,3 +782,4 @@ public class MyCustomEfCoreBulkOperationProvider : IEfCoreBulkOperationProvider,
## See Also
* [Entities](Entities.md)
+* [Repositories](Repositories.md)
diff --git a/docs/en/Getting-Started-Running-Solution.md b/docs/en/Getting-Started-Running-Solution.md
index d1f02c887b..163a3890b2 100644
--- a/docs/en/Getting-Started-Running-Solution.md
+++ b/docs/en/Getting-Started-Running-Solution.md
@@ -25,53 +25,41 @@ Check the **connection string** in the `appsettings.json` file under the {{if Ti
}
````
-The solution is configured to use **Entity Framework Core** with **MS SQL Server** by default. EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers, so you can use any supported DBMS. See [the Entity Framework integration document](Entity-Framework-Core.md) to learn how to [switch to another DBMS](Entity-Framework-Core-Other-DBMS.md).
-
-### Apply the Migrations
-
-The solution uses the [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli). So, you need to apply migrations to create the database. There are two ways of applying the database migrations.
+> **About the Connection Strings and Database Management Systems**
+>
+> The solution is configured to use **Entity Framework Core** with **MS SQL Server** by default. However, if you've selected another DBMS using the `-dbms` parameter on the ABP CLI `new` command (like `-dbms MySQL`), the connection string might be different for you.
+>
+> EF Core supports [various](https://docs.microsoft.com/en-us/ef/core/providers/) database providers and you can use any supported DBMS. See [the Entity Framework integration document](Entity-Framework-Core.md) to learn how to [switch to another DBMS](Entity-Framework-Core-Other-DBMS.md) if you need later.
-#### Apply Migrations Using the DbMigrator
+### Database Migrations
-The solution comes with a `.DbMigrator` console application which applies migrations and also **seeds the initial data**. It is useful on **development** as well as on **production** environment.
+The solution uses the [Entity Framework Core Code First Migrations](https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli). It comes with a `.DbMigrator` console application which **applies the migrations** and also **seeds the initial data**. It is useful on **development** as well as on **production** environment.
> `.DbMigrator` project has its own `appsettings.json`. So, if you have changed the connection string above, you should also change this one.
-Right click to the `.DbMigrator` project and select **Set as StartUp Project**
-
-
-
- Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below:
+### The Initial Migration
- 
-
-> Initial [seed data](Data-Seeding.md) creates the `admin` user in the database (with the password is `1q2w3E*`) which is then used to login to the application. So, you need to use `.DbMigrator` at least once for a new database.
+`.DbMigrator` application automatically **creates the Initial migration** on first run.
-#### Using EF Core Update-Database Command
+**If you are using Visual Studio, you can skip to the *Running the DbMigrator* section.** However, other IDEs (e.g. Rider) may have problems for the first run since it adds the initial migration and compiles the project. In this case, open a command line terminal in the folder of the `.DbMigrator` project and run the following command:
-Ef Core has `Update-Database` command which creates database if necessary and applies pending migrations.
-
-{{ if UI == "MVC" }}
-
-Right click to the {{if Tiered == "Yes"}}`.IdentityServer`{{else}}`.Web`{{end}} project and select **Set as StartUp project**:
+````bash
+dotnet run
+````
-{{ else if UI != "MVC" }}
+For the next time, you can just run it in your IDE as you normally do.
-Right click to the `.HttpApi.Host` project and select **Set as StartUp Project**:
+### Running the DbMigrator
-{{ end }}
+Right click to the `.DbMigrator` project and select **Set as StartUp Project**

-Open the **Package Manager Console**, select `.EntityFrameworkCore.DbMigrations` project as the **Default Project** and run the `Update-Database` command:
-
-
+ Hit F5 (or Ctrl+F5) to run the application. It will have an output like shown below:
-This will create a new database based on the configured connection string.
+ 
-> **Using the `.DbMigrator` tool is the suggested way**, because it also seeds the initial data to be able to properly run the web application.
->
-> If you just use the `Update-Database` command, you will have an empty database, so you can not login to the application since there is no initial admin user in the database. You can use the `Update-Database` command in development time when you don't need to seed the database. However, using the `.DbMigrator` application is easier and you can always use it to migrate the schema and seed the database.
+> Initial [seed data](Data-Seeding.md) creates the `admin` user in the database (with the password is `1q2w3E*`) which is then used to login to the application. So, you need to use `.DbMigrator` at least once for a new database.
{{ else if DB == "Mongo" }}
diff --git a/docs/en/Migration-Guides/Abp-4_2.md b/docs/en/Migration-Guides/Abp-4_2.md
new file mode 100644
index 0000000000..084ae24caa
--- /dev/null
+++ b/docs/en/Migration-Guides/Abp-4_2.md
@@ -0,0 +1,101 @@
+# ABP version 4.2 Migration Guide
+
+This version has no breaking changes but there is an important change on the repositories that should be applied for your application for an important performance and scalability gain.
+
+## IRepository.GetQueryableAsync
+
+`IRepository` interface inherits `IQueryable`, so you can directly use the standard LINQ extension methods, like `Where`, `OrderBy`, `First`, `Sum`... etc.
+
+**Example: Using LINQ directly over the repository object**
+
+````csharp
+public class BookAppService : ApplicationService, IBookAppService
+{
+ private readonly IRepository _bookRepository;
+
+ public BookAppService(IRepository bookRepository)
+ {
+ _bookRepository = bookRepository;
+ }
+
+ public async Task DoItInOldWayAsync()
+ {
+ //Apply any standard LINQ extension method
+ var query = _bookRepository
+ .Where(x => x.Price > 10)
+ .OrderBy(x => x.Name);
+
+ //Execute the query asynchronously
+ var books = await AsyncExecuter.ToListAsync(query);
+ }
+}
+````
+
+*See [the documentation](https://docs.abp.io/en/abp/4.2/Repositories#iqueryable-async-operations) if you wonder what is the `AsyncExecuter`.*
+
+**Beginning from the version 4.2, the recommended way is using `IRepository.GetQueryableAsync()` to obtain an `IQueryable`, then use the LINQ extension methods over it.**
+
+**Example: Using the new GetQueryableAsync method**
+
+````csharp
+public async Task DoItInNewWayAsync()
+{
+ //Use GetQueryableAsync to obtain the IQueryable first
+ var queryable = await _bookRepository.GetQueryableAsync();
+
+ //Then apply any standard LINQ extension method
+ var query = queryable
+ .Where(x => x.Price > 10)
+ .OrderBy(x => x.Name);
+
+ //Finally, execute the query asynchronously
+ var books = await AsyncExecuter.ToListAsync(query);
+}
+````
+
+ABP may start a database transaction when you get an `IQueryable` (If current [Unit Of Work](https://docs.abp.io/en/abp/latest/Unit-Of-Work) is transactional). In this new way, it is possible to **start the database transaction in an asynchronous way**. Previously, we could not get the advantage of asynchronous while starting the transactions.
+
+> **The new way has a significant performance and scalability gain. The old usage (directly using LINQ over the repositories) will be removed in the next major version (5.0).** You have a lot of time for the change, but we recommend to immediately take the action since the old usage has a big **scalability problem**.
+
+### Actions to Take
+
+* Use the repository's queryable feature as explained before.
+* If you've overridden `CreateFilteredQuery` in a class derived from `CrudAppService`, you should override the `CreateFilteredQueryAsync` instead and remove the `CreateFilteredQuery` in your class.
+* If you've overridden `WithDetails` in your custom repositories, remove it and override `WithDetailsAsync` instead.
+* If you've used `DbContext` or `DbSet` properties in your custom repositories, use `GetDbContextAsync()` and `GetDbSetAsync()` methods instead of them.
+
+You can re-build your solution and check the `Obsolete` warnings to find some of the usages need to change.
+
+#### About IRepository Async Extension Methods
+
+Using IRepository Async Extension Methods has no such a problem. The examples below are pretty fine:
+
+````csharp
+var countAll = await _personRepository
+ .CountAsync();
+
+var count = await _personRepository
+ .CountAsync(x => x.Name.StartsWith("A"));
+
+var book1984 = await _bookRepository
+ .FirstOrDefaultAsync(x => x.Name == "John");
+````
+
+See the [repository documentation](https://docs.abp.io/en/abp/4.2/Repositories#iqueryable-async-operations) to understand the relation between `IQueryable` and asynchronous operations.
+
+## .NET Package Upgrades
+
+ABP uses the latest 5.0.* .NET packages. If your application is using 5.0.0 packages, you may get an error on build. We recommend to depend on the .NET packages like `5.0.*` in the `.csproj` files to use the latest patch versions.
+
+Example:
+
+````xml
+
+````
+
+## Blazorise Library Upgrade
+
+If you are upgrading to 4.2, you also need also upgrade the following packages in your Blazor application;
+
+* `Blazorise.Bootstrap` to `0.9.3-preview6`
+* `Blazorise.Icons.FontAwesome` to `0.9.3-preview6`
\ No newline at end of file
diff --git a/docs/en/Migration-Guides/Index.md b/docs/en/Migration-Guides/Index.md
index 5973ee0a0d..26fe825f50 100644
--- a/docs/en/Migration-Guides/Index.md
+++ b/docs/en/Migration-Guides/Index.md
@@ -1,5 +1,6 @@
# ABP Framework Migration Guides
-* [3.3.x to 4.0 Migration Guide](Abp-4_0.md)
-* [2.9.x to 3.0 Migration Guide](../UI/Angular/Migration-Guide-v3.md)
+* [4.x to 4.2](Abp-4_2.md)
+* [3.3.x to 4.0](Abp-4_0.md)
+* [2.9.x to 3.0](../UI/Angular/Migration-Guide-v3.md)
diff --git a/docs/en/MongoDB.md b/docs/en/MongoDB.md
index 7fae9c3892..a12d216b3d 100644
--- a/docs/en/MongoDB.md
+++ b/docs/en/MongoDB.md
@@ -149,7 +149,7 @@ public class Book : AggregateRoot
}
```
-(`BookType` is a simple enum here) And you want to create a new `Book` entity in a [domain service](Domain-Services.md):
+(`BookType` is a simple `enum` here) And you want to create a new `Book` entity in a [domain service](Domain-Services.md):
```csharp
public class BookManager : DomainService
@@ -215,7 +215,8 @@ public class BookRepository :
BookType type,
CancellationToken cancellationToken = default(CancellationToken))
{
- await Collection.DeleteManyAsync(
+ var collection = await GetCollectionAsync(cancellationToken);
+ await collection.DeleteManyAsync(
Builders.Filter.Eq(b => b.Type, type),
cancellationToken
);
@@ -253,7 +254,7 @@ public async override Task DeleteAsync(
### Access to the MongoDB API
-In most cases, you want to hide MongoDB APIs behind a repository (this is the main purpose of the repository). However, if you want to access the MongoDB API over the repository, you can use `GetDatabase()` or `GetCollection()` extension methods. Example:
+In most cases, you want to hide MongoDB APIs behind a repository (this is the main purpose of the repository). However, if you want to access the MongoDB API over the repository, you can use `GetDatabaseAsync()`, `GetCollectionAsync()` or `GetAggregateAsync()` extension methods. Example:
```csharp
public class BookService
@@ -265,10 +266,11 @@ public class BookService
_bookRepository = bookRepository;
}
- public void Foo()
+ public async Task FooAsync()
{
- IMongoDatabase database = _bookRepository.GetDatabase();
- IMongoCollection books = _bookRepository.GetCollection();
+ IMongoDatabase database = await _bookRepository.GetDatabaseAsync();
+ IMongoCollection books = await _bookRepository.GetCollectionAsync();
+ IAggregateFluent bookAggregate = await _bookRepository.GetAggregateAsync();
}
}
```
@@ -390,36 +392,45 @@ If you have better logic or using an external library for bulk operations, you c
- You may use example template below:
```csharp
-public class MyCustomMongoDbBulkOperationProvider : IMongoDbBulkOperationProvider, ITransientDependency
+public class MyCustomMongoDbBulkOperationProvider
+ : IMongoDbBulkOperationProvider, ITransientDependency
{
- public async Task DeleteManyAsync(IMongoDbRepository repository,
- IEnumerable entities,
- IClientSessionHandle sessionHandle,
- bool autoSave,
- CancellationToken cancellationToken)
+ public async Task DeleteManyAsync(
+ IMongoDbRepository repository,
+ IEnumerable entities,
+ IClientSessionHandle sessionHandle,
+ bool autoSave,
+ CancellationToken cancellationToken)
where TEntity : class, IEntity
{
// Your logic here.
}
- public async Task InsertManyAsync(IMongoDbRepository repository,
- IEnumerable entities,
- IClientSessionHandle sessionHandle,
- bool autoSave,
- CancellationToken cancellationToken)
+ public async Task InsertManyAsync(
+ IMongoDbRepository repository,
+ IEnumerable entities,
+ IClientSessionHandle sessionHandle,
+ bool autoSave,
+ CancellationToken cancellationToken)
where TEntity : class, IEntity
{
// Your logic here.
}
- public async Task UpdateManyAsync(IMongoDbRepository repository,
- IEnumerable entities,
- IClientSessionHandle sessionHandle,
- bool autoSave,
- CancellationToken cancellationToken)
+ public async Task UpdateManyAsync(
+ IMongoDbRepository repository,
+ IEnumerable entities,
+ IClientSessionHandle sessionHandle,
+ bool autoSave,
+ CancellationToken cancellationToken)
where TEntity : class, IEntity
{
// Your logic here.
}
}
-```
\ No newline at end of file
+```
+
+## See Also
+
+* [Entities](Entities.md)
+* [Repositories](Repositories.md)
\ No newline at end of file
diff --git a/docs/en/Repositories.md b/docs/en/Repositories.md
index 5ad3107ca6..3d0ea84821 100644
--- a/docs/en/Repositories.md
+++ b/docs/en/Repositories.md
@@ -13,84 +13,178 @@ ABP can provide a **default generic repository** for each aggregate root or enti
**Example usage of a default generic repository:**
````C#
-public class PersonAppService : ApplicationService
-{
- private readonly IRepository _personRepository;
+using System;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
- public PersonAppService(IRepository personRepository)
+namespace Demo
+{
+ public class PersonAppService : ApplicationService
{
- _personRepository = personRepository;
- }
+ private readonly IRepository _personRepository;
- public async Task Create(CreatePersonDto input)
- {
- var person = new Person { Name = input.Name, Age = input.Age };
+ public PersonAppService(IRepository personRepository)
+ {
+ _personRepository = personRepository;
+ }
- await _personRepository.InsertAsync(person);
- }
+ public async Task CreateAsync(CreatePersonDto input)
+ {
+ var person = new Person(input.Name);
- public List GetList(string nameFilter)
- {
- var people = _personRepository
- .Where(p => p.Name.Contains(nameFilter))
- .ToList();
+ await _personRepository.InsertAsync(person);
+ }
- return people
- .Select(p => new PersonDto {Id = p.Id, Name = p.Name, Age = p.Age})
- .ToList();
+ public async Task GetCountAsync(string filter)
+ {
+ return await _personRepository.CountAsync(p => p.Name.Contains(filter));
+ }
}
}
````
-> See the "*IQueryable & Async Operations*" section below to understand how you can use **async extension methods**, like `ToListAsync()` (which is strongly suggested) instead of `ToList()`.
-
In this example;
* `PersonAppService` simply injects `IRepository` in it's constructor.
-* `Create` method uses `InsertAsync` to save a newly created entity.
-* `GetList` method uses the standard LINQ `Where` and `ToList` methods to filter and get a list of people from the data source.
+* `CreateAsync` method uses `InsertAsync` to save the new entity.
+* `GetCountAsync` method gets a filtered count of all people in the database.
-> The example above uses hand-made mapping between [entities](Entities.md) and [DTO](Data-Transfer-Objects.md)s. See [object to object mapping document](Object-To-Object-Mapping.md) for an automatic way of mapping.
+### Standard Repository Methods
Generic Repositories provides some standard CRUD features out of the box:
-* Provides `Insert` method to save a new entity.
+* `GetAsync`: Returns a single entity by its `Id` or a predicate (lambda expression).
+ * Throws `EntityNotFoundException` if the requested entity was not found.
+ * Throws `InvalidOperationException` if there are multiple entities with given predicate.
+* `FindAsync`: Returns a single entity by its `Id` or a predicate (lambda expression).
+ * Returns `null` if the requested entity was not found.
+ * Throws `InvalidOperationException` if there are multiple entities with given predicate.
+* `InsertAsync`: Inserts a new entity to the database.
+* `UpdateAsync`: Updates an existing entity in the database.
+* `DeleteAsync`: Deletes the given entity from database.
+ * This method has an overload that takes a predicate (lambda expression) to delete multiple entities satisfies the given condition.
+* `GetListAsync`: Returns the list of all entities in the database.
+* `GetPagedListAsync`: Returns a limited list of entities. Gets `skipCount`, `maxResultCount` and `sorting` parameters.
+* `GetCountAsync`: Gets count of all entities in the database.
+
+There are overloads of these methods.
+
* Provides `Update` and `Delete` methods to update or delete an entity by entity object or it's id.
* Provides `Delete` method to delete multiple entities by a filter.
-* Implements `IQueryable`, so you can use LINQ and extension methods like `FirstOrDefault`, `Where`, `OrderBy`, `ToList` and so on...
-### Basic Repositories
+### Querying / LINQ over the Repositories
-Standard `IRepository` interface extends standard `IQueryable` and you can freely query using standard LINQ methods. However, some ORM providers or database systems may not support standard `IQueryable` interface.
+Repositories provide the `GetQueryableAsync()` method that returns an `IQueryable` object. You can use this object to perform LINQ queries on the entities in the database.
-ABP provides `IBasicRepository` and `IBasicRepository` interfaces to support such scenarios. You can extend these interfaces (and optionally derive from `BasicRepositoryBase`) to create custom repositories for your entities.
+**Example: Use LINQ with the repositories**
-Depending on `IBasicRepository` but not depending on `IRepository` has an advantage to make possible to work with all data sources even if they don't support `IQueryable`. But major vendors, like Entity Framework, NHibernate or MongoDb already support `IQueryable`.
+````csharp
+using System;
+using System.Linq;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using Volo.Abp.Application.Services;
+using Volo.Abp.Domain.Repositories;
-So, working with `IRepository` is the **suggested** way for typical applications. But reusable module developers may consider `IBasicRepository` to support a wider range of data sources.
+namespace Demo
+{
+ public class PersonAppService : ApplicationService
+ {
+ private readonly IRepository _personRepository;
-### Read Only Repositories
+ public PersonAppService(IRepository personRepository)
+ {
+ _personRepository = personRepository;
+ }
-There are also `IReadOnlyRepository` and `IReadOnlyBasicRepository` interfaces for who only want to depend on querying capabilities of the repositories.
+ public async Task> GetListAsync(string filter)
+ {
+ //Obtain the IQueryable
+ IQueryable queryable = await _personRepository.GetQueryableAsync();
-### Generic Repository without a Primary Key
+ //Create a query
+ var query = from person in queryable
+ where person.Name == filter
+ orderby person.Name
+ select person;
-If your entity does not have an Id primary key (it may have a composite primary key for instance) then you cannot use the `IRepository` (or basic/readonly versions) defined above. In that case, you can inject and use `IRepository` for your entity.
+ //Execute the query to get list of people
+ var people = query.ToList();
-> `IRepository` has a few missing methods those normally works with the `Id` property of an entity. Because of the entity has no `Id` property in that case, these methods are not available. One example is the `Get` method that gets an id and returns the entity with given id. However, you can still use `IQueryable` features to query entities by standard LINQ methods.
+ //Convert to DTO and return to the client
+ return people.Select(p => new PersonDto {Name = p.Name}).ToList();
+ }
+ }
+}
+````
+
+You could also use the LINQ extension methods:
+
+````csharp
+public async Task> GetListAsync(string filter)
+{
+ //Obtain the IQueryable
+ IQueryable queryable = await _personRepository.GetQueryableAsync();
+
+ //Execute a query
+ var people = queryable
+ .Where(p => p.Name.Contains(filter))
+ .OrderBy(p => p.Name)
+ .ToList();
+
+ //Convert to DTO and return to the client
+ return people.Select(p => new PersonDto {Name = p.Name}).ToList();
+}
+````
+
+Any standard LINQ method can be used over the `IQueryable` returned from the repository.
+
+> This sample uses `ToList()` method, but it is **strongly suggested to use the asynchronous methods** to perform database queries, like `ToListAsync()` for this example.
+>
+> See the **IQueryable & Async Operations** section to learn how you can do it.
+
+### Bulk Operations
+
+There are some methods to perform bulk operations in the database;
+
+* `InsertManyAsync`
+* `UpdateManyAsync`
+* `DeleteManyAsync`
+
+These methods work with multiple entities and can take advantage of bulk operations if supported by the underlying database provider.
+
+> Optimistic concurrency control may not be possible when you use `UpdateManyAsync` and `DeleteManyAsync` methods.
### Soft / Hard Delete
`DeleteAsync` method of the repository doesn't delete the entity if the entity is a **soft-delete** entity (that implements `ISoftDelete`). Soft-delete entities are marked as "deleted" in the database. Data Filter system ensures that the soft deleted entities are not retrieved from database normally.
-If your entity is a soft-delete entity, you can use the `HardDeleteAsync` method to really delete the entity from database in case of you need it.
+If your entity is a soft-delete entity, you can use the `HardDeleteAsync` method to physically delete the entity from database in case of you need it.
+
+> See the [Data Filtering](Data-Filtering.md) documentation for more about soft-delete.
+
+## Other Generic Repository Types
+
+Standard `IRepository` interface exposes the standard `IQueryable` and you can freely query using the standard LINQ methods. This is fine for most of the applications. However, some ORM providers or database systems may not support standard `IQueryable` interface. If you want to use such providers, you can't rely on the `IQueryable`.
+
+### Basic Repositories
+
+ABP provides `IBasicRepository` and `IBasicRepository` interfaces to support such scenarios. You can extend these interfaces (and optionally derive from `BasicRepositoryBase`) to create custom repositories for your entities.
+
+Depending on `IBasicRepository` but not depending on `IRepository` has an advantage to make possible to work with all data sources even if they don't support `IQueryable`.
-See the [Data Filtering](Data-Filtering.md) documentation for more about soft-delete.
+Major vendors, like Entity Framework, NHibernate or MongoDB already support `IQueryable`. So, working with `IRepository` is the **suggested** way for typical applications. But reusable module developers may consider `IBasicRepository` to support a wider range of data sources.
-## Bulk Operations
-You can execute bulk operations with `InsertManyAsync`, `UpdateManyAsync`, `DeleteManyAsync` methods.
+### Read Only Repositories
-> **WARNING:** ConcurrencyStamp can't be checked at bulk operations!
+There are also `IReadOnlyRepository` and `IReadOnlyBasicRepository` interfaces for who only want to depend on querying capabilities of the repositories.
+
+### Generic Repository without a Primary Key
+
+If your entity does not have an Id primary key (it may have a composite primary key for instance) then you cannot use the `IRepository` (or basic/readonly versions) defined above. In that case, you can inject and use `IRepository` for your entity.
+
+> `IRepository` has a few missing methods those normally works with the `Id` property of an entity. Because of the entity has no `Id` property in that case, these methods are not available. One example is the `Get` method that gets an id and returns the entity with given id. However, you can still use `IQueryable` features to query entities by standard LINQ methods.
## Custom Repositories
@@ -128,7 +222,8 @@ public class PersonRepository : EfCoreRepository, IPe
public async Task FindByNameAsync(string name)
{
- return await DbContext.Set()
+ var dbSet = await GetDbSetAsync();
+ return await dbSet.Set()
.Where(p => p.Name == name)
.FirstOrDefaultAsync();
}
@@ -141,12 +236,13 @@ You can directly access the data access provider (`DbContext` in this case) to p
## IQueryable & Async Operations
-`IRepository` inherits from `IQueryable`, that means you can **directly use LINQ extension methods** on it, as shown in the example of the "*Generic Repositories*" section above.
+`IRepository` provides `GetQueryableAsync()` to obtain an `IQueryable`, that means you can **directly use LINQ extension methods** on it, as shown in the example of the "*Querying / LINQ over the Repositories*" section above.
**Example: Using the `Where(...)` and the `ToList()` extension methods**
````csharp
-var people = _personRepository
+var queryable = await _personRepository.GetQueryableAsync();
+var people = queryable
.Where(p => p.Name.Contains(nameFilter))
.ToList();
````
@@ -175,7 +271,8 @@ When you add the NuGet package to your project, you can take full power of the E
**Example: Directly using the `ToListAsync()` after adding the EF Core package**
````csharp
-var people = _personRepository
+var queryable = await _personRepository.GetQueryableAsync();
+var people = queryable
.Where(p => p.Name.Contains(nameFilter))
.ToListAsync();
````
@@ -191,7 +288,8 @@ If you are using [MongoDB](MongoDB.md), you need to add the [Volo.Abp.MongoDB](h
**Example: Cast `IQueryable` to `IMongoQueryable` and use `ToListAsync()`**
````csharp
-var people = ((IMongoQueryable)_personRepository
+var queryable = await _personRepository.GetQueryableAsync();
+var people = ((IMongoQueryable) queryable
.Where(p => p.Name.Contains(nameFilter)))
.ToListAsync();
````
@@ -218,10 +316,11 @@ The standard LINQ extension methods are supported: *AllAsync, AnyAsync, AverageA
This approach still **has a limitation**. You need to call the extension method directly on the repository object. For example, the below usage is **not supported**:
```csharp
-var count = await _bookRepository.Where(x => x.Name.Contains("A")).CountAsync();
+var queryable = await _bookRepository.GetQueryableAsync();
+var count = await queryable.Where(x => x.Name.Contains("A")).CountAsync();
```
-This is because the object returned from the `Where` method is not a repository object, it is a standard `IQueryable` interface. See the other options for such cases.
+This is because the `CountAsync()` method in this example is called on a `IQueryable` interface, not on the repository object. See the other options for such cases.
This method is suggested **wherever possible**.
@@ -258,8 +357,11 @@ namespace AbpDemo
public async Task> GetListAsync(string name)
{
+ //Obtain the IQueryable
+ var queryable = await _productRepository.GetQueryableAsync();
+
//Create the query
- var query = _productRepository
+ var query = queryable
.Where(p => p.Name.Contains(name))
.OrderBy(p => p.Name);
diff --git a/docs/en/Road-Map.md b/docs/en/Road-Map.md
index 6f4213a6bd..0920639106 100644
--- a/docs/en/Road-Map.md
+++ b/docs/en/Road-Map.md
@@ -18,4 +18,4 @@ You can always check the milestone planning and the prioritized backlog issues o
The backlog items are subject to change. We are adding new items and changing priorities based on the community feedbacks and goals of the project.
-Vote for your favorite feature on the related GitHub issues (and write your thoughts). You can create an issue on [the GitHub repository](https://github.com/abpframework/abp) for your feature requests, but first search in in the existing issues.
\ No newline at end of file
+Vote for your favorite feature on the related GitHub issues (and write your thoughts). You can create an issue on [the GitHub repository](https://github.com/abpframework/abp) for your feature requests, but first search in the existing issues.
diff --git a/docs/en/Samples/Index.md b/docs/en/Samples/Index.md
index b5dd0fab29..18312e4b55 100644
--- a/docs/en/Samples/Index.md
+++ b/docs/en/Samples/Index.md
@@ -17,6 +17,9 @@ A simple CRUD application to show basic principles of developing an application
* **Book Store: Razor Pages UI & Entity Framework Core**
* [Tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=MVC&DB=EF)
* [Source code](https://github.com/abpframework/abp-samples/tree/master/BookStore-Mvc-EfCore)
+* **Book Store: Blazor UI & Entity Framework Core**
+ * [Tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=Blazor&DB=EF)
+ * [Source code](https://github.com/abpframework/abp-samples/tree/master/BookStore-Blazor-EfCore)
* **Book Store: Angular UI & MongoDB**
* [Tutorial](https://docs.abp.io/en/abp/latest/Tutorials/Part-1?UI=NG&DB=Mongo)
* [Source code](https://github.com/abpframework/abp-samples/tree/master/BookStore-Angular-MongoDb)
diff --git a/docs/en/Specifications.md b/docs/en/Specifications.md
index 036baa749e..bfe1d031d3 100644
--- a/docs/en/Specifications.md
+++ b/docs/en/Specifications.md
@@ -122,7 +122,8 @@ namespace MyProject
public async Task> GetCustomersCanBuyAlcohol()
{
- var query = _customerRepository.Where(
+ var queryable = await _customerRepository.GetQueryableAsync();
+ var query = queryable.Where(
new Age18PlusCustomerSpecification().ToExpression()
);
@@ -137,7 +138,8 @@ namespace MyProject
Actually, using the `ToExpression()` method is not necessary since the specifications are automatically casted to Expressions. This would also work:
````csharp
-var query = _customerRepository.Where(
+var queryable = await _customerRepository.GetQueryableAsync();
+var query = queryable.Where(
new Age18PlusCustomerSpecification()
);
````
diff --git a/docs/en/Startup-Templates/Module.md b/docs/en/Startup-Templates/Module.md
index 2dc0896c65..84b7525944 100644
--- a/docs/en/Startup-Templates/Module.md
+++ b/docs/en/Startup-Templates/Module.md
@@ -1,4 +1,4 @@
-# MVC Module Startup Template
+# Module Startup Template
This template can be used to create a **reusable [application module](../Modules/Index.md)** based on the [module development best practices & conventions](../Best-Practices/Index.md). It is also suitable for creating **microservices** (with or without UI).
@@ -20,6 +20,20 @@ abp new Acme.IssueManagement -t module
- `Acme.IssueManagement` is the solution name, like *YourCompany.YourProduct*. You can use single level, two-levels or three-levels naming.
+### Specify the UI Framework
+
+This template provides multiple UI frameworks:
+
+* `mvc`: ASP.NET Core MVC UI with Razor Pages (default)
+* `blazor`: Blazor UI
+* `angular`: Angular UI
+
+Use `-u` or `--ui` option to specify the UI framework:
+
+````bash
+abp new Acme.IssueManagement -t module -u angular
+````
+
### Without User Interface
The template comes with an MVC UI by default. You can use `--no-ui` option to not include the UI layer.
@@ -160,3 +174,91 @@ You should run the application with the given order:
- First, run the `.IdentityServer` since other applications depends on it.
- Then run the `.HttpApi.Host` since it is used by the `.Web.Host` application.
- Finally, you can run the `.Web.Host` project and login to the application using `admin` as the username and `1q2w3E*` as the password.
+
+## UI
+
+### Angular UI
+
+If you choose `Angular` as the UI framework (using the `-u angular` option), the solution will have a folder called `angular` in it. This is where the client-side code is located. When you open that folder in an IDE, the folder structure will look like below:
+
+
+
+* _angular/projects/issue-management_ folder contains the Angular module project.
+* _angular/projects/dev-app_ folder contains a development application that runs your module.
+
+The server-side is similar to the solution described above. `*.HttpApi.Host` project serves the API and the `Angular` demo application consumes it. You will not need to run the `.Web.Host` project though.
+
+#### How to Run the Angular Development App
+
+For module development, you will need the `dev-app` project up and running. So, here is how we can start the development server.
+
+First, we need to install dependencies:
+
+1. Open your terminal at the root folder, i.e. `angular`.
+2. Run `yarn` or `npm install`.
+
+The dependencies will be installed and some of them are ABP modules published as NPM packages. To see all ABP packages, you can run the following command in the `angular` folder:
+
+```bash
+yarn list --pattern abp
+```
+
+> There is no equivalent of this command in npm.
+
+The module you will develop depends on two of these ABP packages: _@abp/ng.core_ and _@abp/ng.theme.shared_. Rest of the ABP modules are included in _package.json_ because of the `dev-app` project.
+
+Once all dependencies are installed, follow the steps below to serve your development app:
+
+1. Make sure `.IdentityServer` and `*.HttpApi.Host` projects are up and running.
+2. Open your terminal at the root folder, i.e. `angular`.
+3. Run `yarn start` or `npm start`.
+
+
+
+The issue management page is empty in the beginning. You may change the content in `IssueManagementComponent` at the _angular/projects/issue-management/src/lib/issue-management.component.ts_ path and observe that the view changes accordingly.
+
+Now, let's have a closer look at some key elements of your project.
+
+#### Main Module
+
+`IssueManagementModule` at the _angular/projects/issue-management/src/lib/issue-management.module.ts_ path is the main module of your module project. There are a few things worth mentioning in it:
+
+- Essential ABP modules, i.e. `CoreModule` and `ThemeSharedModule`, are imported.
+- `IssueManagementRoutingModule` is imported.
+- `IssueManagementComponent` is declared.
+- It is prepared for configurability. The `forLazy` static method enables [a configuration to be passed to the module when it is loaded by the router](https://volosoft.com/blog/how-to-configure-angular-modules-loaded-by-the-router).
+
+
+#### Main Routing Module
+
+`IssueManagementRoutingModule` at the _angular/projects/issue-management/src/lib/issue-management-routing.module.ts_ path is the main routing module of your module project. It currently does two things:
+
+- Loads `DynamicLayoutComponent` at base path it is given.
+- Loads `IssueManagementComponent` as child to the layout, again at the given base path.
+
+You can rearrange this module to load more than one component at different routes, but you need to update the route provider at _angular/projects/issue-management/config/src/providers/route.provider.ts_ to match the new routing structure with the routes in the menu. Please check [Modifying the Menu](../UI/Angular/Modifying-the-Menu.md) to see how route providers work.
+
+#### Config Module
+
+There is a config module at the _angular/projects/issue-management/config/src/issue-management-config.module.ts_ path. The static `forRoot` method of this module is supposed to be called at the route level. So, you may assume the following will take place:
+
+```js
+@NgModule({
+ imports: [
+ /* other imports */
+
+ IssueManagementConfigModule.forRoot(),
+ ],
+
+ /* rest of the module meta data */
+})
+export class AppModule {}
+```
+
+You can use this static method to configure an application that uses your module project. An example of such configuration is already implemented and the `ISSUE_MANAGEMENT_ROUTE_PROVIDERS` token is provided here. The method can take options which enables further configuration possibilities.
+
+The difference between the `forRoot` method of the config module and the `forLazy` method of the main module is that, for smallest bundle size, the former should only be used when you have to configure an app before your module is even loaded.
+
+#### Testing Angular UI
+
+Please see the [testing document](../UI/Angular/Testing.md).
diff --git a/docs/en/Tutorials/Part-1.md b/docs/en/Tutorials/Part-1.md
index 3348679420..4667b8e539 100644
--- a/docs/en/Tutorials/Part-1.md
+++ b/docs/en/Tutorials/Part-1.md
@@ -189,6 +189,8 @@ Add-Migration "Created_Book_Entity"

+> If you get an error like "*Your startup project ... doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work*", right click to the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project and **Set as the Startup Project** and try again.
+
This will create a new migration class inside the `Migrations` folder of the `Acme.BookStore.EntityFrameworkCore.DbMigrations` project.
Before updating the database, read the section below to learn how to seed some initial data to the database.
diff --git a/docs/en/Tutorials/Part-10.md b/docs/en/Tutorials/Part-10.md
index a9de3a062e..ec68dfe955 100644
--- a/docs/en/Tutorials/Part-10.md
+++ b/docs/en/Tutorials/Part-10.md
@@ -364,10 +364,11 @@ namespace Acme.BookStore.Books
public override async Task GetAsync(Guid id)
{
- await CheckGetPolicyAsync();
+ //Get the IQueryable from the repository
+ var queryable = await Repository.GetQueryableAsync();
//Prepare a query to join books and authors
- var query = from book in Repository
+ var query = from book in queryable
join author in _authorRepository on book.AuthorId equals author.Id
where book.Id == id
select new { book, author };
@@ -384,17 +385,24 @@ namespace Acme.BookStore.Books
return bookDto;
}
- public override async Task> GetListAsync(
- PagedAndSortedResultRequestDto input)
+ public override async Task> GetListAsync(PagedAndSortedResultRequestDto input)
{
- await CheckGetListPolicyAsync();
+ //Set a default sorting, if not provided
+ if (input.Sorting.IsNullOrWhiteSpace())
+ {
+ input.Sorting = nameof(Book.Name);
+ }
+
+ //Get the IQueryable from the repository
+ var queryable = await Repository.GetQueryableAsync();
//Prepare a query to join books and authors
- var query = from book in Repository
+ var query = from book in queryable
join author in _authorRepository on book.AuthorId equals author.Id
- orderby input.Sorting
+ orderby input.Sorting //TODO: Can not sort like that!
select new {book, author};
+ //Paging
query = query
.Skip(input.SkipCount)
.Take(input.MaxResultCount);
@@ -437,7 +445,7 @@ Let's see the changes we've done:
* Injected `IAuthorRepository` to query from the authors.
* Overrode the `GetAsync` method of the base `CrudAppService`, which returns a single `BookDto` object with the given `id`.
* Used a simple LINQ expression to join books and authors and query them together for the given book id.
- * Used `AsyncExecuter.FirstOrDefaultAsync(...)` to execute the query and get a result. `AsyncExecuter` was previously used in the `AuthorAppService`. Check the [repository documentation](../Repositories.md) to understand why we've used it.
+ * Used `AsyncExecuter.FirstOrDefaultAsync(...)` to execute the query and get a result. It is a way to use asynchronous LINQ extensions without depending on the database provider API. Check the [repository documentation](../Repositories.md) to understand why we've used it.
* Throws an `EntityNotFoundException` which results an `HTTP 404` (not found) result if requested book was not present in the database.
* Finally, created a `BookDto` object using the `ObjectMapper`, then assigning the `AuthorName` manually.
* Overrode the `GetListAsync` method of the base `CrudAppService`, which returns a list of books. The logic is similar to the previous method, so you can easily understand the code.
@@ -487,8 +495,6 @@ namespace Acme.BookStore.Books
public async override Task GetAsync(Guid id)
{
- await CheckGetPolicyAsync();
-
var book = await Repository.GetAsync(id);
var bookDto = ObjectMapper.Map(book);
@@ -501,17 +507,18 @@ namespace Acme.BookStore.Books
public async override Task>
GetListAsync(PagedAndSortedResultRequestDto input)
{
- await CheckGetListPolicyAsync();
-
//Set a default sorting, if not provided
if (input.Sorting.IsNullOrWhiteSpace())
{
input.Sorting = nameof(Book.Name);
}
+
+ //Get the IQueryable from the repository
+ var queryable = await Repository.GetQueryableAsync();
//Get the books
var books = await AsyncExecuter.ToListAsync(
- Repository
+ queryable
.OrderBy(input.Sorting)
.Skip(input.SkipCount)
.Take(input.MaxResultCount)
@@ -553,8 +560,10 @@ namespace Acme.BookStore.Books
.Distinct()
.ToArray();
+ var queryable = await _authorRepository.GetQueryableAsync();
+
var authors = await AsyncExecuter.ToListAsync(
- _authorRepository.Where(a => authorIds.Contains(a.Id))
+ queryable.Where(a => authorIds.Contains(a.Id))
);
return authors.ToDictionary(x => x.Id, x => x);
diff --git a/docs/en/Tutorials/Part-7.md b/docs/en/Tutorials/Part-7.md
index 97d28691ae..e14237fd59 100644
--- a/docs/en/Tutorials/Part-7.md
+++ b/docs/en/Tutorials/Part-7.md
@@ -70,7 +70,7 @@ This is just like done for the `Book` entity before, so no need to explain again
## Create a new Database Migration
-Open the **Package Manager Console** on Visual Studio and ensure that the **Default project** is `Acme.BookStore.EntityFrameworkCore.DbMigrations` in the Package Manager Console, as shown on the picture below. Also, set the `Acme.BookStore.Web` (or `Acme.BookStore.HttpApi.Host`, depending on your solution) as the **startup project** (right click it on the solution explorer and click to "Set as Startup Project").
+Open the **Package Manager Console** on Visual Studio and ensure that the **Default project** is `Acme.BookStore.EntityFrameworkCore.DbMigrations` in the Package Manager Console, as shown on the picture below. Also, set this project as the **startup project** (right click it on the solution explorer and click to "Set as Startup Project").
Run the following command to create a new database migration:
@@ -127,7 +127,8 @@ namespace Acme.BookStore.Authors
public async Task FindByNameAsync(string name)
{
- return await DbSet.FirstOrDefaultAsync(author => author.Name == name);
+ var dbSet = await GetDbSetAsync();
+ return await dbSet.FirstOrDefaultAsync(author => author.Name == name);
}
public async Task> GetListAsync(
@@ -136,7 +137,8 @@ namespace Acme.BookStore.Authors
string sorting,
string filter = null)
{
- return await DbSet
+ var dbSet = await GetDbSetAsync();
+ return await dbSet
.WhereIf(
!filter.IsNullOrWhiteSpace(),
author => author.Name.Contains(filter)
@@ -186,8 +188,8 @@ namespace Acme.BookStore.Authors
public async Task FindByNameAsync(string name)
{
- return await GetMongoQueryable()
- .FirstOrDefaultAsync(author => author.Name == name);
+ var queryable = await GetMongoQueryableAsync();
+ return await queryable.FirstOrDefaultAsync(author => author.Name == name);
}
public async Task> GetListAsync(
@@ -196,7 +198,8 @@ namespace Acme.BookStore.Authors
string sorting,
string filter = null)
{
- return await GetMongoQueryable()
+ var queryable = await GetMongoQueryableAsync();
+ return await queryable
.WhereIf>(
!filter.IsNullOrWhiteSpace(),
author => author.Name.Contains(filter)
diff --git a/docs/en/Tutorials/Part-8.md b/docs/en/Tutorials/Part-8.md
index b7c805c17e..6ab14c714c 100644
--- a/docs/en/Tutorials/Part-8.md
+++ b/docs/en/Tutorials/Part-8.md
@@ -172,6 +172,7 @@ using System.Threading.Tasks;
using Acme.BookStore.Permissions;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos;
+using Volo.Abp.Domain.Repositories;
namespace Acme.BookStore.Authors
{
@@ -230,12 +231,10 @@ public async Task> GetListAsync(GetAuthorListDto input
input.Filter
);
- var totalCount = await AsyncExecuter.CountAsync(
- _authorRepository.WhereIf(
- !input.Filter.IsNullOrWhiteSpace(),
- author => author.Name.Contains(input.Filter)
- )
- );
+ var totalCount = input.Filter == null
+ ? await _authorRepository.CountAsync()
+ : await _authorRepository.CountAsync(
+ author => author.Name.Contains(input.Filter));
return new PagedResultDto(
totalCount,
@@ -246,7 +245,7 @@ public async Task> GetListAsync(GetAuthorListDto input
* Default sorting is "by author name" which is done in the beginning of the method in case of it wasn't sent by the client.
* Used the `IAuthorRepository.GetListAsync` to get a paged, sorted and filtered list of authors from the database. We had implemented it in the previous part of this tutorial. Again, it actually was not needed to create such a method since we could directly query over the repository, but wanted to demonstrate how to create custom repository methods.
-* Directly queried from the `AuthorRepository` while getting the count of the authors. We preferred to use the `AsyncExecuter` service which allows us to perform async queries without depending on the EF Core. However, you could depend on the EF Core package and directly use the `_authorRepository.WhereIf(...).ToListAsync()` method. See the [repository document](../Repositories.md) to read the alternative approaches and the discussion.
+* Directly queried from the `AuthorRepository` while getting the count of the authors. If a filter is sent, then we are using it to filter entities while getting the count.
* Finally, returning a paged result by mapping the list of `Author`s to a list of `AuthorDto`s.
### CreateAsync
diff --git a/docs/en/UI/Angular/Ellipsis-Directive.md b/docs/en/UI/Angular/Ellipsis-Directive.md
new file mode 100644
index 0000000000..c462331574
--- /dev/null
+++ b/docs/en/UI/Angular/Ellipsis-Directive.md
@@ -0,0 +1,83 @@
+# Ellipsis
+
+Text inside an HTML element can be truncated easily with an ellipsis by using CSS. To make this even easier, you can use the `EllipsisDirective` which has been exposed by the `@abp/ng.theme.shared` package.
+
+
+## Getting Started
+
+In order to use the `EllipsisDirective` in an HTML template, the **`ThemeSharedModule`** should be imported into your module like this:
+
+```js
+// ...
+import { ThemeSharedModule } from '@abp/ng.theme.shared';
+
+@NgModule({
+ //...
+ imports: [..., ThemeSharedModule],
+})
+export class MyFeatureModule {}
+```
+
+or **if you would not like to import** the `ThemeSharedModule`, you can import the **`EllipsisModule`** as shown below:
+
+
+```js
+// ...
+import { EllipsisModule } from '@abp/ng.theme.shared';
+
+@NgModule({
+ //...
+ imports: [..., EllipsisModule],
+})
+export class MyFeatureModule {}
+```
+
+## Usage
+
+The `EllipsisDirective` is very easy to use. The directive's selector is **`abpEllipsis`**. By adding the `abpEllipsis` attribute to an HTML element, you can activate the `EllipsisDirective` for the HTML element.
+
+See an example usage:
+
+```html
+
+ Lorem ipsum dolor sit, amet consectetur adipisicing elit. Laboriosam commodi quae aspernatur,
+ corporis velit et suscipit id consequuntur amet minima expedita cum reiciendis dolorum
+ cupiditate? Voluptas eaque voluptatum odio deleniti quo vel illum nemo accusamus nulla ratione
+ impedit dolorum expedita necessitatibus fugiat ullam beatae, optio eum cupiditate ducimus
+ architecto.
+
+```
+
+The `abpEllipsis` attribute has been added to the `
` element that containing very long text inside to activate the `EllipsisDirective`.
+
+See the result:
+
+
+
+The long text has been truncated by using the directive.
+
+The UI before using the directive looks like this:
+
+
+
+### Specifying Max Width of an HTML Element
+
+An HTML element max width can be specified as shown below:
+
+```html
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Cumque, optio!
+
+
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Cumque, optio!
+
+
+
+ Lorem ipsum dolor sit amet consectetur adipisicing elit. Cumque, optio!
+
+```
+
+See the result:
+
+
\ No newline at end of file
diff --git a/docs/en/UI/Angular/Environment.md b/docs/en/UI/Angular/Environment.md
index 8c6fb28ce7..9802eb6264 100644
--- a/docs/en/UI/Angular/Environment.md
+++ b/docs/en/UI/Angular/Environment.md
@@ -138,10 +138,10 @@ You can use the `getEnvironment` or `getEnvironment$` method of `EnvironmentServ
```js
// this.environment is instance of EnvironmentService
-const environment = this.environment.getAll();
+const environment = this.environment.getEnvironment();
// or
-this.environment.getAll$().subscribe(environment => {
+this.environment.getEnvironment$().subscribe(environment => {
// use environment here
})
```
@@ -166,7 +166,7 @@ This method returns the `url` of a specific API based on the key given as its on
#### How to Set the Environment
-`EnvironmentService` has a method named `setState` which allow you to set the state value.
+`EnvironmentService` has a method named `setState` which allows you to set the state value.
```js
// this.environment is instance of EnvironmentService
diff --git a/docs/en/UI/Angular/Modal.md b/docs/en/UI/Angular/Modal.md
new file mode 100644
index 0000000000..f1583d4813
--- /dev/null
+++ b/docs/en/UI/Angular/Modal.md
@@ -0,0 +1,248 @@
+# Modal
+
+`ModalComponent` is a pre-built component exposed by `@abp/ng.theme.shared` package to show modals. The component uses the [`ng-bootstrap`](https://ng-bootstrap.github.io/)'s modal service inside to render a modal.
+
+The `abp-modal` provides some additional benefits:
+
+ - It is **flexible**. You can pass header, body, footer templates easily by adding the templates to the `abp-modal` content. It can also be implemented quickly.
+ - Provides several inputs be able to customize the modal and several outputs be able to listen to some events.
+ - Automatically detects the close button which has a `#abpClose` template variable and closes the modal when pressed this button.
+ - Automatically detects the `abp-button` and triggers its loading spinner when the `busy` input value of the modal component is true.
+ - Automatically checks if the form inside the modal **has changed, but not saved**. It warns the user by displaying a [confirmation popup](Confirmation-Service) in this case when a user tries to close the modal or refresh/close the tab of the browser.
+
+
+> Note: A modal can also be rendered by using the `ng-bootstrap` modal. For further information, see [Modal doc](https://ng-bootstrap.github.io/#/components/modal) on the `ng-bootstrap` documentation.
+
+## Getting Started
+
+In order to use the `abp-modal` in an HTML template, the **`ThemeSharedModule`** should be imported into your module like this:
+
+```js
+// ...
+import { ThemeSharedModule } from '@abp/ng.theme.shared';
+
+@NgModule({
+ //...
+ imports: [..., ThemeSharedModule],
+})
+export class MyFeatureModule {}
+```
+
+## Usage
+
+You can add the `abp-modal` to your component very quickly. See an example:
+
+```html
+
+
+
+
+
+
+
Modal Title
+
+
+
+
Modal content
+
+
+
+
+
+
+```
+
+```js
+// sample.component.ts
+
+@Component(/* component metadata */)
+export class SampleComponent {
+ isModelOpen = false
+}
+```
+
+
+
+
+See an example form inside a modal:
+
+```html
+
+
+
+
+
Book
+
+
+
+
+
+
+
+
+
+
+
+
+```
+
+```ts
+// book.component.ts
+
+import { Component } from '@angular/core';
+import { FormBuilder, Validators } from '@angular/forms';
+
+@Component(/* component metadata */)
+export class BookComponent {
+ form = this.fb.group({
+ author: [null, [Validators.required]],
+ name: [null, [Validators.required]],
+ price: [null, [Validators.required, Validators.min(0)]],
+ type: [null, [Validators.required]],
+ publishDate: [null, [Validators.required]],
+ });
+
+ inProgress: boolean;
+
+ isModalOpen: boolean;
+
+ constructor(private fb: FormBuilder, private service: BookService) {}
+
+ save() {
+ if (this.form.invalid) return;
+
+ this.inProgress = true;
+
+ this.service.save(this.form.value).subscribe(() => {
+ this.inProgress = false;
+ });
+ }
+}
+```
+
+The modal with form looks like this:
+
+
+
+## API
+
+### Inputs
+
+#### visible
+
+```js
+@Input() visible: boolean
+```
+
+**`visible`** is a boolean input that determines whether the modal is open. It is also can be used two-way binding.
+
+#### busy
+
+```js
+@Input() busy: boolean
+```
+
+**`busy`** is a boolean input that determines whether the busy status of the modal is true. When `busy` is true, the modal cannot be closed and the `abp-button` loading spinner is triggered.
+
+
+#### options
+
+```js
+@Input() options: NgbModalOptions
+```
+
+**`options`** is an input typed [NgbModalOptions](https://ng-bootstrap.github.io/#/components/modal/api#NgbModalOptions). It is configuration for the `ng-bootstrap` modal.
+
+#### suppressUnsavedChangesWarning
+
+```js
+@Input() suppressUnsavedChangesWarning: boolean
+```
+
+**`suppressUnsavedChangesWarning`** is a boolean input that determines whether the confirmation popup triggering active or not. It can also be set globally as shown below:
+
+```ts
+//app.module.ts
+
+// app.module.ts
+
+import { SUPPRESS_UNSAVED_CHANGES_WARNING } from '@abp/ng.theme.shared';
+
+// ...
+
+@NgModule({
+ // ...
+ providers: [{provide: SUPPRESS_UNSAVED_CHANGES_WARNING, useValue: true}]
+})
+export class AppModule {}
+```
+
+Note: The `suppressUnsavedChangesWarning` input of `abp-modal` value overrides the `SUPPRESS_UNSAVED_CHANGES_WARNING` injection token value.
+
+### Outputs
+
+#### visibleChange
+
+```js
+@Output() readonly visibleChange = new EventEmitter();
+```
+
+**`visibleChange`** is an event emitted when the modal visibility has changed. The event payload is a boolean.
+
+#### appear
+
+```js
+ @Output() readonly appear = new EventEmitter();
+```
+
+**`appear`** is an event emitted when the modal has opened.
+
+#### disappear
+
+```js
+ @Output() readonly disappear = new EventEmitter();
+```
+
+**`disappear`** is an event emitted when the modal has closed.
diff --git a/docs/en/UI/Angular/Page-Alerts.md b/docs/en/UI/Angular/Page-Alerts.md
index e59d620432..a27cee4abf 100644
--- a/docs/en/UI/Angular/Page-Alerts.md
+++ b/docs/en/UI/Angular/Page-Alerts.md
@@ -6,7 +6,7 @@ A page alert is useful for displaying an important message to the user. The ABP
You can simply import `PageAlertService` from `@abp/ng.theme.shared` and utilize it as follows:
-```typescript
+```js
import { PageAlertService } from '@abp/ng.theme.shared';
@Component({
@@ -30,7 +30,7 @@ export class MyComponent {
The method `show` accepts a single object that is type of `PageAlert`
-```typescript
+```js
export interface PageAlert {
type: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark';
message: string;
@@ -47,7 +47,7 @@ export interface PageAlert {
* `dismissible` (Optional): Default is `true`. If enabled, a button on the top right corner will be shown to the users so that they can dismiss the message.
* `messageLocalizationParams` and `titleLocalizationParams` (Optional): If the message and/or the title is a key for localization service and contains some parameters, these fields could be used to pass those parameters.
-### An example with Localization
+### An example with Localization
```typescript
this.service.show({
diff --git a/docs/en/UI/Angular/Router-Events.md b/docs/en/UI/Angular/Router-Events.md
new file mode 100644
index 0000000000..011d405b22
--- /dev/null
+++ b/docs/en/UI/Angular/Router-Events.md
@@ -0,0 +1,146 @@
+# Router Events Simplified
+
+`RouterEvents` is a utility service to provide an easy implementation for one of the most frequent needs in Angular templates: `TrackByFunction`. Please see [this page in Angular docs](https://angular.io/guide/template-syntax#ngfor-with-trackby) for its purpose.
+
+
+
+
+## Benefit
+
+You can use router events directly and filter them as seen below:
+
+```js
+import {
+ NavigationEnd,
+ NavigationError,
+ NavigationCancel,
+ Router,
+} from '@angular/router';
+import { filter } from 'rxjs/operators';
+
+@Injectable()
+class SomeService {
+ navigationFinish$ = this.router.events.pipe(
+ filter(
+ event =>
+ event instanceof NavigationEnd ||
+ event instanceof NavigationError ||
+ event instanceof NavigationCancel,
+ ),
+ );
+ /* Observable */
+
+ constructor(private router: Router) {}
+}
+```
+
+However, `RouterEvents` makes filtering router events easier.
+
+```js
+import { RouterEvents } from '@abp/ng.core';
+
+@Injectable()
+class SomeService {
+ navigationFinish$ = this.routerEvents.getNavigationEvents('End', 'Error', 'Cancel');
+ /* Observable */
+
+ constructor(private routerEvents: RouterEvents) {}
+}
+```
+
+`RouterEvents` also delivers improved type-safety. In the example above, `navigationFinish$` has inferred type of `Observable` whereas it would have `Observable` when router events are filtered directly.
+
+
+
+
+## Usage
+
+You do not have to provide `RouterEvents` at the module or component level, because it is already **provided in root**. You can inject and start using it immediately in your components.
+
+
+### How to Get Specific Navigation Events
+
+You can use `getNavigationEvents` to get a stream of navigation events matching given event keys.
+
+```js
+import { RouterEvents } from '@abp/ng.core';
+import { merge } from 'rxjs';
+import { mapTo } from 'rxjs/operators';
+
+@Injectable()
+class SomeService {
+ navigationStart$ = this.routerEvents.getNavigationEvents('Start');
+ /* Observable */
+
+ navigationFinish$ = this.routerEvents.getNavigationEvents('End', 'Error', 'Cancel');
+ /* Observable */
+
+ loading$ = merge(
+ this.navigationStart$.pipe(mapTo(true)),
+ this.navigationFinish$.pipe(mapTo(false)),
+ );
+ /* Observable */
+
+ constructor(private routerEvents: RouterEvents) {}
+}
+```
+
+
+### How to Get All Navigation Events
+
+You can use `getAllNavigationEvents` to get a stream of all navigation events without passing any keys.
+
+```js
+import { RouterEvents, NavigationStart } from '@abp/ng.core';
+import { map } from 'rxjs/operators';
+
+@Injectable()
+class SomeService {
+ navigationEvent$ = this.routerEvents.getAllNavigationEvents();
+ /* Observable */
+
+ loading$ = this.navigationEvent$.pipe(
+ map(event => event instanceof NavigationStart),
+ );
+ /* Observable */
+
+ constructor(private routerEvents: RouterEvents) {}
+}
+```
+
+
+### How to Get Specific Router Events
+
+You can use `getEvents` to get a stream of router events matching given event constructors.
+
+```js
+import { RouterEvents } from '@abp/ng.core';
+import { ActivationEnd, ChildActivationEnd } from '@angular/router';
+
+@Injectable()
+class SomeService {
+ moduleActivation$ = this.routerEvents.getEvents(ActivationEnd, ChildActivationEnd);
+ /* Observable */
+
+ constructor(private routerEvents: RouterEvents) {}
+}
+```
+
+
+### How to Get All Router Events
+
+You can use `getEvents` to get a stream of all router events without passing any event constructors. This is nothing different from accessing `events` property of `Router` and is added to the service just for convenience.
+
+```js
+import { RouterEvents } from '@abp/ng.core';
+import { ActivationEnd, ChildActivationEnd } from '@angular/router';
+
+@Injectable()
+class SomeService {
+ routerEvent$ = this.routerEvents.getAllEvents();
+ /* Observable */
+
+ constructor(private routerEvents: RouterEvents) {}
+}
+```
+
diff --git a/docs/en/UI/Angular/Testing.md b/docs/en/UI/Angular/Testing.md
index 7b93d48585..bf6d3e1b26 100644
--- a/docs/en/UI/Angular/Testing.md
+++ b/docs/en/UI/Angular/Testing.md
@@ -10,7 +10,7 @@ In Angular, unit tests use [Karma](https://karma-runner.github.io/) and [Jasmine
An over-simplified spec file looks like this:
-```ts
+```js
import { CoreTestingModule } from "@abp/ng.core/testing";
import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
@@ -59,7 +59,7 @@ Although you can test your code with Angular TestBed, you may find [Angular Test
The simple example above can be written with Angular Testing Library as follows:
-```ts
+```js
import { CoreTestingModule } from "@abp/ng.core/testing";
import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
@@ -95,7 +95,7 @@ describe("MyComponent", () => {
Very similar, as you can see. The real difference kicks in when we use queries and fire events.
-```ts
+```js
// other imports
import { getByLabelText, screen } from "@testing-library/angular";
import userEvent from "@testing-library/user-event";
@@ -131,7 +131,7 @@ One thing to remember is that Karma runs tests in real browser instances. That m
We have prepared a simple function with which you can clear any leftover DOM elements after each test.
-```ts
+```js
// other imports
import { clearPage } from "@abp/ng.core/testing";
@@ -159,7 +159,7 @@ Some components, modals, in particular, work off-detection-cycle. In other words
For this purpose, we have prepared a `wait` function.
-```ts
+```js
// other imports
import { wait } from "@abp/ng.core/testing";
@@ -187,7 +187,7 @@ The `wait` function takes a second parameter, i.e. timeout (default: `0`). Try n
Here is an example test suite. It doesn't cover all, but gives quite a good idea about what the testing experience will be like.
-```ts
+```js
import { clearPage, CoreTestingModule, wait } from "@abp/ng.core/testing";
import { ThemeBasicTestingModule } from "@abp/ng.theme.basic/testing";
import { ThemeSharedTestingModule } from "@abp/ng.theme.shared/testing";
@@ -374,3 +374,7 @@ Finally, don't forget to run your CI tests with the following command:
```sh
npm test -- --prod
```
+
+## See Also
+
+* [ABP Community Video - Unit Testing with the Angular UI](https://community.abp.io/articles/unit-testing-with-the-angular-ui-p4l550q3)
diff --git a/docs/en/UI/Angular/images/ellipsis-directive-before.jpg b/docs/en/UI/Angular/images/ellipsis-directive-before.jpg
new file mode 100644
index 0000000000..dc534d9a97
Binary files /dev/null and b/docs/en/UI/Angular/images/ellipsis-directive-before.jpg differ
diff --git a/docs/en/UI/Angular/images/ellipsis-directive-result1.jpg b/docs/en/UI/Angular/images/ellipsis-directive-result1.jpg
new file mode 100644
index 0000000000..fe693f4c8c
Binary files /dev/null and b/docs/en/UI/Angular/images/ellipsis-directive-result1.jpg differ
diff --git a/docs/en/UI/Angular/images/ellipsis-directive-result2.jpg b/docs/en/UI/Angular/images/ellipsis-directive-result2.jpg
new file mode 100644
index 0000000000..3a416bbc05
Binary files /dev/null and b/docs/en/UI/Angular/images/ellipsis-directive-result2.jpg differ
diff --git a/docs/en/UI/Angular/images/modal-result-1.jpg b/docs/en/UI/Angular/images/modal-result-1.jpg
new file mode 100644
index 0000000000..89dbbc0cb1
Binary files /dev/null and b/docs/en/UI/Angular/images/modal-result-1.jpg differ
diff --git a/docs/en/UI/Angular/images/modal-result-2.jpg b/docs/en/UI/Angular/images/modal-result-2.jpg
new file mode 100644
index 0000000000..e17f2631ab
Binary files /dev/null and b/docs/en/UI/Angular/images/modal-result-2.jpg differ
diff --git a/docs/en/UI/AspNetCore/Bundling-Minification.md b/docs/en/UI/AspNetCore/Bundling-Minification.md
index 9d88a37135..aeaea6c2e6 100644
--- a/docs/en/UI/AspNetCore/Bundling-Minification.md
+++ b/docs/en/UI/AspNetCore/Bundling-Minification.md
@@ -165,7 +165,27 @@ public class MyWebExtensionModule : AbpModule
}
````
-> It's not possible to configure unnamed bundle tag helpers by code, because their name are not known at the development time. It's suggested to always use a name for a bundle tag helper.
+You can also use the `ConfigureAll` method to configure all existing bundles:
+
+````C#
+[DependsOn(typeof(MyWebModule))]
+public class MyWebExtensionModule : AbpModule
+{
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options
+ .ScriptBundles
+ .ConfigureAll(bundle => {
+ bundle.AddFiles(
+ "/scripts/my-extension-script.js"
+ );
+ });
+ });
+ }
+}
+````
## Bundle Contributors
diff --git a/docs/en/UI/AspNetCore/Data-Tables.md b/docs/en/UI/AspNetCore/Data-Tables.md
index b97d49d562..d5181b2da9 100644
--- a/docs/en/UI/AspNetCore/Data-Tables.md
+++ b/docs/en/UI/AspNetCore/Data-Tables.md
@@ -110,7 +110,7 @@ The `createAjax` also supports you to customize request parameters and handle th
**Example:**
````csharp
-var inputAction = function () {
+var inputAction = function (requestData, dataTableSettings) {
return {
id: $('#Id').val(),
name: $('#Name').val(),
@@ -131,6 +131,15 @@ var responseCallback = function(result) {
ajax: abp.libs.datatables.createAjax(acme.bookStore.books.book.getList, inputAction, responseCallback)
````
+If you don't need access or modify the `requestData` or the `dataTableSettings`, you can specify a simple object as the second parameter.
+
+````js
+ajax: abp.libs.datatables.createAjax(
+ acme.bookStore.books.book.getList,
+ { id: $('#Id').val(), name: $('#Name').val() }
+)
+````
+
### Row Actions
`rowAction` is an option defined by the ABP Framework to the column definitions to show a drop down button to take actions for a row in the table.
diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json
index 517da0239f..7fd7762ad4 100644
--- a/docs/en/docs-nav.json
+++ b/docs/en/docs-nav.json
@@ -681,6 +681,10 @@
{
"text": "Page Alerts",
"path": "UI/Blazor/Page-Alerts.md"
+ },
+ {
+ "text": "Page Progress",
+ "path": "UI/Blazor/Page-Progress.md"
}
]
},
@@ -803,6 +807,10 @@
"text": "Easy *ngFor trackBy",
"path": "UI/Angular/Track-By-Service.md"
},
+ {
+ "text": "Router Events",
+ "path": "UI/Angular/Router-Events.md"
+ },
{
"text": "Inserting Scripts & Styles to DOM",
"path": "UI/Angular/Dom-Insertion-Service.md"
@@ -815,6 +823,10 @@
"text": "Projecting Angular Content",
"path": "UI/Angular/Content-Projection-Service.md"
},
+ {
+ "text": "Modal",
+ "path": "UI/Angular/Modal.md"
+ },
{
"text": "Confirmation Popup",
"path": "UI/Angular/Confirmation-Service.md"
@@ -826,6 +838,10 @@
{
"text": "Page Alerts",
"path": "UI/Angular/Page-Alerts.md"
+ },
+ {
+ "text": "Ellipsis",
+ "path": "UI/Angular/Ellipsis-Directive.md"
}
]
},
@@ -1052,10 +1068,6 @@
{
"text": "CLI",
"path": "CLI.md"
- },
- {
- "text": "API Documentation",
- "path": "{ApiDocumentationUrl}"
}
]
},
diff --git a/docs/en/images/angular-module-dev-app-project.png b/docs/en/images/angular-module-dev-app-project.png
new file mode 100644
index 0000000000..08e0e9fd6c
Binary files /dev/null and b/docs/en/images/angular-module-dev-app-project.png differ
diff --git a/docs/en/images/angular-module-folder-structure.png b/docs/en/images/angular-module-folder-structure.png
new file mode 100644
index 0000000000..ae2333b295
Binary files /dev/null and b/docs/en/images/angular-module-folder-structure.png differ
diff --git a/docs/zh-Hans/Best-Practices/Application-Services.md b/docs/zh-Hans/Best-Practices/Application-Services.md
index 82a5dc8aba..c99d67d518 100644
--- a/docs/zh-Hans/Best-Practices/Application-Services.md
+++ b/docs/zh-Hans/Best-Practices/Application-Services.md
@@ -199,7 +199,7 @@ Task VoteAsync(Guid id, VoteType type);
#### 查询数据
-* **不推荐** 在应用程序服务方法中使用linq/sql查询来自数据库的数据. 让仓储负责从数据源执行linq/sql查询.
+* **不推荐** 在应用服务方法中使用linq/sql查询来自数据库的数据. 让仓储负责从数据源执行linq/sql查询.
#### 额外的属性
@@ -210,11 +210,16 @@ Task VoteAsync(Guid id, VoteType type);
* **推荐** 总是从数据库中获取所有的相关实体以对他们执行操作.
* **推荐** 更新实体后调用存储的Update/UpdateAsync方法.因为并非所有数据库API都支持更改跟踪和自动更新.
+#### 处理文件
+
+* **不推荐** 在应用服务中使用任何web组件, 例如`IFormFile`和`Stream`. 如果你想接收一个文件, 可以使用`byte[]`.
+* **推荐** 使用`Controller`来处理文件上传, 然后将文件的`byte[]`传递给应用服务的方法。
+
#### 使用其他应用服务
-* **不推荐** 使用相同 **模块/应用程序** 的其他应用服务. 相反;
+* **不推荐** 在同一个模块/应用中使用其他应用服务. 相反;
* 使用领域层执行所需的任务.
- * 提取新类并在应用程序服务之间共享, 在必要时代码重用. 但要小心不要结合两个用例. 它们在开始时可能看起来相似, 但可能会随时间演变为不同的方向. 请谨慎使用代码共享.
+ * 提取新类并在应用服务之间共享, 在必要时代码重用. 但要小心不要结合两个用例. 它们在开始时可能看起来相似, 但可能会随时间演变为不同的方向. 请谨慎使用代码共享.
* **可以** 在以下情况下使用其他应用服务;
* 它们是另一个模块/微服务的一部分.
- * 当前模块仅引用已使用模块的application contracts.
\ No newline at end of file
+ * 当前模块仅引用已使用模块的application contracts.
diff --git a/docs/zh-Hans/Caching.md b/docs/zh-Hans/Caching.md
index 0557ddcb4d..a75199ce47 100644
--- a/docs/zh-Hans/Caching.md
+++ b/docs/zh-Hans/Caching.md
@@ -192,6 +192,18 @@ public class BookService : ITransientDependency
}
````
+## 批量操作
+
+ABP的分布式缓存接口定义了以下批量操作方法,当你需要在一个方法中调用多次缓存操作时,这些方法可以提高性能
+
+* `SetManyAsync` 和 `SetMany` 方法可以用来设置多个值.
+* `GetManyAsync` 和 `GetMany` 方法可以用来从缓存中获取多个值.
+* `GetOrAddManyAsync` 和 `GetOrAddMany` 方法可以用来从缓存中获取并添加缺少的值.
+* `RefreshManyAsync` 和 `RefreshMany` 方法可以来用重置多个值的滚动过期时间.
+* `RemoveManyAsync` 和 `RemoveMany` 方法呆以用来删除多个值.
+
+> 这些不是标准的ASP.NET Core缓存方法, 所以某些提供程序可能不支持. [ABP Redis集成包](Redis-Cache.md)实现了它们. 如果提供程序不支持,会回退到 `SetAsync` 和 `GetAsync` ... 方法(循环调用).
+
### DistributedCacheOptions
TODO
\ No newline at end of file
diff --git a/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md b/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md
index b8abe99cdc..1e9ae77f36 100644
--- a/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md
+++ b/docs/zh-Hans/Customizing-Application-Modules-Overriding-Services.md
@@ -243,7 +243,7 @@ ObjectExtensionManager.Instance
这是定义实体属性的另一种方法( 有关 `ObjectExtensionManager` 更多信息,请参阅[文档](Object-Extensions.md)). 这次我们设置了 `CheckPairDefinitionOnMapping` 为false,在将实体映射到DTO时会跳过定义检查.
-如果你不喜欢这种方法,但想简单的向多个对象(DTO)添加单个属, `AddOrUpdateProperty` 可以使用类型数组添加额外的属性:
+如果你不喜欢这种方法,但想简单的向多个对象(DTO)添加单个属性, `AddOrUpdateProperty` 可以使用类型数组添加额外的属性:
````csharp
ObjectExtensionManager.Instance
diff --git a/docs/zh-Hans/Domain-Driven-Design-Implementation-Guide.md b/docs/zh-Hans/Domain-Driven-Design-Implementation-Guide.md
index db434ab365..47cab8c02e 100644
--- a/docs/zh-Hans/Domain-Driven-Design-Implementation-Guide.md
+++ b/docs/zh-Hans/Domain-Driven-Design-Implementation-Guide.md
@@ -1315,7 +1315,7 @@ namespace IssueTracking.Users
#### 输出DTO最佳实践
-* 保持**数量较少**的输出DTO,尽可能**重用输入DTO**(例外:不要将输入DTO作为输出DTO).
+* 保持**数量较少**的输出DTO,尽可能**重用输出DTO**(例外:不要将输入DTO作为输出DTO).
* 输出DTO可以包含比用例需要的属性**更多**的属性.
* 针对 **Create** 和 **Update** 方法,返回实体的DTO.
@@ -1767,7 +1767,7 @@ public async Task ChangeTitleAsync(Issue issue, string title)
如前所述,领域驱动设计中的*业务逻辑*分为两部分(各层):领域逻辑和应用逻辑
-
+
领域逻辑是系统的*核心领域规则*组成,而应用逻辑则满足特定的*用例*.
@@ -1783,7 +1783,7 @@ public async Task ChangeTitleAsync(Issue issue, string title)
* 一个**后台管理系统**,UI使用Angular,通过REST API请求数据.内部员工使用这个系统来维护数据(例如,编辑商品说明).
* 一个**移动端应用程序**,它比公开的网站UI上更加简洁.它通过REST API或其它技术(例如,TCP sockets)请求数据.
-
+
每个应用程序都有不同的**需求**,不同的**用例**(应用服务方法),不同的DTO,不同的**验证**和**授权**规则等.
@@ -1976,4 +1976,4 @@ public class IssueAppService
* "*Domain Driven Design*" by Eric Evans
* "*Implementing Domain Driven Design*" by Vaughn Vernon
-* "*Clean Architecture*" by Robert C. Martin
\ No newline at end of file
+* "*Clean Architecture*" by Robert C. Martin
diff --git a/docs/zh-Hans/MongoDB.md b/docs/zh-Hans/MongoDB.md
index 2ceeb1e00c..af63642a41 100644
--- a/docs/zh-Hans/MongoDB.md
+++ b/docs/zh-Hans/MongoDB.md
@@ -211,7 +211,7 @@ public async override Task DeleteAsync(
#### 访问MongoDB API
-大多数情况下,你想要将MongoDB API隐藏在仓储后面(这是仓储的主要目的).如果你想在仓储之上访问MongoDB API,你可以使用`GetDatabase()`或`GetCollection()`方法.例如:
+大多数情况下,你想要将MongoDB API隐藏在仓储后面(这是仓储的主要目的).如果你想在仓储之上访问MongoDB API,你可以使用`GetDatabaseAsync()`, `GetAggregateAsync()` 或`GetCollectionAsync()`方法.例如:
```csharp
public class BookService
@@ -223,10 +223,11 @@ public class BookService
_bookRepository = bookRepository;
}
- public void Foo()
+ public async Task FooAsync()
{
- IMongoDatabase database = _bookRepository.GetDatabase();
- IMongoCollection books = _bookRepository.GetCollection();
+ IMongoDatabase database = await _bookRepository.GetDatabaseAsync();
+ IMongoCollection books = await _bookRepository.GetCollectionAsync();
+ IAggregateFluent bookAggregate = await _bookRepository.GetAggregateAsync();
}
}
```
diff --git a/docs/zh-Hans/PlugIn-Modules.md b/docs/zh-Hans/PlugIn-Modules.md
new file mode 100644
index 0000000000..48a507ac7d
--- /dev/null
+++ b/docs/zh-Hans/PlugIn-Modules.md
@@ -0,0 +1,233 @@
+# 模块化插件
+
+可以将[模块](Module-Development-Basics.md)加载为插件.这意味着你可能不需要在解决方案中引用模块的程序集,就可以像其它模块一样在启动应用时加载该模块.
+
+## 基本用法
+
+`IServiceCollection.AddApplication()` 扩展方法可以获取配置插件源的选项.
+
+**示例: 从文件夹加载插件**
+
+````csharp
+using Microsoft.AspNetCore.Builder;
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.Modularity.PlugIns;
+
+namespace MyPlugInDemo.Web
+{
+ public class Startup
+ {
+ public void ConfigureServices(IServiceCollection services)
+ {
+ services.AddApplication(options =>
+ {
+ options.PlugInSources.AddFolder(@"D:\Temp\MyPlugIns");
+ });
+ }
+
+ public void Configure(IApplicationBuilder app)
+ {
+ app.InitializeApplication();
+ }
+ }
+}
+````
+
+* 这是典型的ASP.NET Core应用程序的`Startup`类.
+* `PlugInSources.AddFolder`从指定的目录中加载程序集(通常为dll).
+
+就这样.ABP将在这个目录中发现这些模块,像其它常规一样配置和初始化它们.
+
+### 插件源
+
+`options.PlugInSources`类实际上是`IPlugInSource`接口的一系列实现并且 `AddFolder`方法仅仅是以下表达式的便捷方法:
+
+````csharp
+options.PlugInSources.Add(new FolderPlugInSource(@"D:\Temp\MyPlugIns"));
+````
+
+> `AddFolder()`方法仅在给定目录下查找程序集文件,而不在子目录中查找.你可以传递一个`SearchOption.AllDirectories`参数作为第二个参数,来递归地查找它的子目录.
+
+这里有两个内置插件源的示例:
+
+* `PlugInSources.AddFiles()`方法获取程序集(通常是dll)文件列表.这是使用`FilePlugInSource`类的快捷方式.
+* `PlugInSources.AddTypes()`方法获取模块类类型的列表.如果实用化此方法,则需要自己加载模块的程序集,但是在需要时它提供了灵活性.这是使用`TypePlugInSource`类的快捷方式.
+
+如果需要,你可以创建自己的`IPlugInSource`的接口实现,并像其它方法一样添加到`options.PlugInSources`中.
+
+## 示例:创建一个简单的插件
+
+在一个解决方案中创建一个简单的**类库项目**
+
+
+
+你可以在模块中添加需要使用的ABP框架包.至少,你应该为这个项目添加包`Volo.Abp.Core`:
+
+````
+Install-Package Volo.Abp.Core
+````
+
+每个[模块](Module-Development-Basics.md)必须声明为一个继承自`AbpModule`的类.这里是一个简单的模块类,用于解析一个服务并在应用启动时对其初始化:
+
+````csharp
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp;
+using Volo.Abp.Modularity;
+
+namespace MyPlugIn
+{
+ public class MyPlungInModule : AbpModule
+ {
+ public override void OnApplicationInitialization(ApplicationInitializationContext context)
+ {
+ var myService = context.ServiceProvider
+ .GetRequiredService();
+
+ myService.Initialize();
+ }
+ }
+}
+````
+
+`MyService`可以是注册在[依赖注入](Dependency-Injection.md)系统中的任意类,如下所示:
+
+````csharp
+using Microsoft.Extensions.Logging;
+using Volo.Abp.DependencyInjection;
+
+namespace MyPlugIn
+{
+ public class MyService : ITransientDependency
+ {
+ private readonly ILogger _logger;
+
+ public MyService(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ public void Initialize()
+ {
+ _logger.LogInformation("MyService has been initialized");
+ }
+ }
+}
+````
+
+编译这个项目,打开build目录,找到`MyPlugIn.dll`:
+
+
+
+将`MyPlugIn.dll`复制到到插件目录中(此实例为`D:\Temp\MyPlugIns`).
+
+如果你已经按照上述方式配置了主应用程序(参见“基础用法”部分),那么在应用程序启动时,你可以看到“MyService has been initialized(MyService已经初始化)的日志.
+
+## 示例:创建一个Razor Pages插件
+
+创建内部带视图的插件需要更多的注意.
+
+> 这个示例假设你已经使用应用程序启动模板和MVC / Razor Pages UI[创建了一个新的Web应用程序](https://abp.io/get-started).
+
+在解决方案中创建一个新的**类库**项目:
+
+
+
+编辑这个`.csproj`文件内容:
+
+````xml
+
+
+
+ net5.0
+ Library
+ true
+
+
+
+
+
+
+
+````
+
+* 将`Sdk`修改为`Microsoft.NET.Sdk.Web`.
+* 添加了`OutputType`和`IsPackable`属性.
+* 添加了`Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared`NuGet包.
+
+> 不需要[Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared) 包.你可以引用更基础的程序包,例如[Volo.Abp.AspNetCore.Mvc](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc/). 但是,如果需要构建一个UI视图/组件,建议参考[Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared](https://www.nuget.org/packages/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared)程序包,因为它是最高级的程序包,不依赖于特定[theme](UI/AspNetCore/Theming.md).如果依赖特定主题没有问题,则可以直接引用该主题的程序包,以便能够使用插件中特定于主题的功能.
+
+接下来在插件中创建模块类:
+
+````csharp
+using System.IO;
+using System.Reflection;
+using Microsoft.AspNetCore.Mvc.ApplicationParts;
+using Microsoft.Extensions.DependencyInjection;
+using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
+using Volo.Abp.Modularity;
+
+namespace MyMvcUIPlugIn
+{
+ [DependsOn(typeof(AbpAspNetCoreMvcUiThemeSharedModule))]
+ public class MyMvcUIPlugInModule : AbpModule
+ {
+ public override void PreConfigureServices(ServiceConfigurationContext context)
+ {
+ PreConfigure(mvcBuilder =>
+ {
+ // 添加插件程序集
+ mvcBuilder.PartManager.ApplicationParts.Add(new AssemblyPart(typeof(MyMvcUIPlugInModule).Assembly));
+
+ // 添加视图程序集
+ var viewDllPath = Path.Combine(Path.GetDirectoryName(typeof(MyMvcUIPlugInModule).Assembly.Location), "MyMvcUIPlugIn.Views.dll");
+ var viewAssembly = new CompiledRazorAssemblyPart(Assembly.LoadFrom(viewDllPath));
+ mvcBuilder.PartManager.ApplicationParts.Add(viewAssembly);
+ });
+ }
+ }
+}
+````
+
+* 由于我们添加了相关的NuGet包,因此取决于`AbpAspNetCoreMvcUiThemeSharedModule`.
+* 添加插件程序集到ASP.NET Core MVC的`PartManager`中.这是ASP.NET Core所必需的.否则,你插件中的控制器将无法正常工作.
+* 添加插件的视图程序集到ASP.NET Core MVC的`PartManager`中.这是ASP.NET Core所必需的.否则,你在插件中的视图将不起作用.
+
+现在,你可以在`Pages`目录下添加一个razor页面,例如`MyPlugInPage.cshtml`:
+
+````html
+@page
+@model MyMvcUIPlugIn.Pages.MyPlugInPage
+
Welcome to my plug-in page
+
This page is located inside a plug-in module! :)
+````
+
+现在,你可以构建插件项目.它将产生以下输出:
+
+
+
+将`MyMvcUIPlugIn.dll`和`MyMvcUIPlugIn.Views.dll`复制到到插件目录下(此示例中为`D:\Temp\MyPlugIns`).
+
+如果你已经按照上述方式配置了主应用程序(参见“基础用法”部分),那么在应用程序启动的时候,你应该能够访问`/MyPlugInPage`URL:
+
+
+
+## 讨论
+
+在现实世界中,你的插件可能具有一些外部依赖性.另外,你的应用程序可能被设计为支持插件.所有这些都是你自己的系统要求.ABP做的仅仅是在应用程序启动时加载模块.你在这些模块中执行什么操作由你决定.
+
+但是,我们可以为一些常见情况提供一些建议.
+
+### 库依赖
+
+对于包/dll依赖,你可以将相关的dll复制到插件目录下.ABP会自动将所有程序集加载到该目录下,并且你的插件将按预期工作.
+
+> 请参见[Microsoft文档](https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/creating-app-with-plugin-support#plugin-with-library-dependencies).
+
+### 数据库模式
+
+如果你的模块使用关系型数据库和[Entity Framework Core](Entity-Framework-Core.md), 那么它需要在数据库中提供表.有多种不同的方法可确保在应用程序使用插件时创建表.一些例子;
+
+1. 插件可以检查数据库表是否存在,并在应用程序启动时创建表,或者如果插件已更新且需要进行某些架构更改时,则会迁移它们.你可以使用EF Core的迁移API来做到这一点.
+2. 你可以改进`DbMigrator`应用程序,用于查找插件的迁移并执行它们.
+
+可能还有其它解决方案.例如,如果你的数据库管理员不允许你在应用程序代码中更改数据库模式,则可能需要手动将SQL文件发送给数据库管理员,以将其应用于数据库.
diff --git a/docs/zh-Hans/Redis-Cache.md b/docs/zh-Hans/Redis-Cache.md
new file mode 100644
index 0000000000..cb82a640d5
--- /dev/null
+++ b/docs/zh-Hans/Redis-Cache.md
@@ -0,0 +1 @@
+TODO...
\ No newline at end of file
diff --git a/docs/zh-Hans/UI/AspNetCore/Bundling-Minification.md b/docs/zh-Hans/UI/AspNetCore/Bundling-Minification.md
index 6a229714c1..dd688f256c 100644
--- a/docs/zh-Hans/UI/AspNetCore/Bundling-Minification.md
+++ b/docs/zh-Hans/UI/AspNetCore/Bundling-Minification.md
@@ -167,7 +167,27 @@ public class MyWebExtensionModule : AbpModule
}
````
-> 无法通过代码配置未命名的bundle tag helpers, 因为它们的名称在开发时是未知的. 建议始终使用bundle tag helper的名称.
+你也可以使用 `ConfigureAll` 方法配置所有现有的捆绑包:
+
+````C#
+[DependsOn(typeof(MyWebModule))]
+public class MyWebExtensionModule : AbpModule
+{
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options
+ .ScriptBundles
+ .ConfigureAll(bundle => {
+ bundle.AddFiles(
+ "/scripts/my-extension-script.js"
+ );
+ });
+ });
+ }
+}
+````
### Bundle 贡献者
diff --git a/docs/zh-Hans/docs-nav.json b/docs/zh-Hans/docs-nav.json
index 5d231099c9..4f47dd2760 100644
--- a/docs/zh-Hans/docs-nav.json
+++ b/docs/zh-Hans/docs-nav.json
@@ -313,7 +313,8 @@
"path": "Module-Development-Basics.md"
},
{
- "text": "模块插件"
+ "text": "模块插件",
+ "path": "PlugIn-Modules.md"
},
{
"text": "自定义应用模块",
diff --git a/docs/zh-Hans/images/simple-plug-in-dll-file.png b/docs/zh-Hans/images/simple-plug-in-dll-file.png
new file mode 100644
index 0000000000..3155708d68
Binary files /dev/null and b/docs/zh-Hans/images/simple-plug-in-dll-file.png differ
diff --git a/docs/zh-Hans/images/simple-plugin-library.png b/docs/zh-Hans/images/simple-plugin-library.png
new file mode 100644
index 0000000000..9fefd57dda
Binary files /dev/null and b/docs/zh-Hans/images/simple-plugin-library.png differ
diff --git a/docs/zh-Hans/images/simple-plugin-output.png b/docs/zh-Hans/images/simple-plugin-output.png
new file mode 100644
index 0000000000..71f6a78c0e
Binary files /dev/null and b/docs/zh-Hans/images/simple-plugin-output.png differ
diff --git a/docs/zh-Hans/images/simple-razor-plug-in-dll-file.png b/docs/zh-Hans/images/simple-razor-plug-in-dll-file.png
new file mode 100644
index 0000000000..06b7a565fe
Binary files /dev/null and b/docs/zh-Hans/images/simple-razor-plug-in-dll-file.png differ
diff --git a/docs/zh-Hans/images/simple-razor-plugin.png b/docs/zh-Hans/images/simple-razor-plugin.png
new file mode 100644
index 0000000000..92e0e00d29
Binary files /dev/null and b/docs/zh-Hans/images/simple-razor-plugin.png differ
diff --git a/framework/Volo.Abp.sln b/framework/Volo.Abp.sln
index 046230a7c1..bef083d7f1 100644
--- a/framework/Volo.Abp.sln
+++ b/framework/Volo.Abp.sln
@@ -369,6 +369,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Compone
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.AspNetCore.Components.UI.BasicTheme.WebAssembly", "src\Volo.Abp.AspNetCore.Components.UI.BasicTheme.WebAssembly\Volo.Abp.AspNetCore.Components.UI.BasicTheme.WebAssembly.csproj", "{616282F9-6901-4098-B515-EBDF41C57C4F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.EventBus.Abstractions", "src\Volo.Abp.EventBus.Abstractions\Volo.Abp.EventBus.Abstractions.csproj", "{8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1099,6 +1101,10 @@ Global
{616282F9-6901-4098-B515-EBDF41C57C4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{616282F9-6901-4098-B515-EBDF41C57C4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{616282F9-6901-4098-B515-EBDF41C57C4F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1285,6 +1291,7 @@ Global
{B9133C38-AC24-4E2F-B581-D124CF410CDF} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{FFA80CA2-3DEE-4EFE-8120-80342A0BEA52} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{616282F9-6901-4098-B515-EBDF41C57C4F} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
+ {8FDB3BF7-AD89-43F6-8DEB-C3E29B8801FE} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}
diff --git a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs
index 0aeb97e89d..eaf5c753fd 100644
--- a/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs
+++ b/framework/src/Volo.Abp.AspNetCore.MultiTenancy/Volo/Abp/AspNetCore/MultiTenancy/MultiTenancyMiddleware.cs
@@ -1,7 +1,14 @@
-using System.Threading.Tasks;
+using System;
+using System.Globalization;
+using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Localization;
+using Microsoft.AspNetCore.RequestLocalization;
+using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.DependencyInjection;
+using Volo.Abp.Localization;
using Volo.Abp.MultiTenancy;
+using Volo.Abp.Settings;
namespace Volo.Abp.AspNetCore.MultiTenancy
{
@@ -21,10 +28,71 @@ namespace Volo.Abp.AspNetCore.MultiTenancy
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
var tenant = await _tenantConfigurationProvider.GetAsync(saveResolveResult: true);
- using (_currentTenant.Change(tenant?.Id, tenant?.Name))
+ if (tenant?.Id != _currentTenant.Id)
+ {
+ using (_currentTenant.Change(tenant?.Id, tenant?.Name))
+ {
+ var requestCulture = await TryGetRequestCultureAsync(context);
+ if (requestCulture != null)
+ {
+ CultureInfo.CurrentCulture = requestCulture.Culture;
+ CultureInfo.CurrentUICulture = requestCulture.UICulture;
+ AbpRequestCultureCookieHelper.SetCultureCookie(
+ context,
+ requestCulture
+ );
+ }
+
+ await next(context);
+ }
+ }
+ else
{
await next(context);
}
}
+
+ private async Task TryGetRequestCultureAsync(HttpContext httpContext)
+ {
+ var requestCultureFeature = httpContext.Features.Get();
+
+ /* If requestCultureFeature == null, that means the RequestLocalizationMiddleware was not used
+ * and we don't want to set the culture. */
+ if (requestCultureFeature == null)
+ {
+ return null;
+ }
+
+ /* If requestCultureFeature.Provider is not null, that means RequestLocalizationMiddleware
+ * already picked a language, so we don't need to set the default. */
+ if (requestCultureFeature.Provider != null)
+ {
+ return null;
+ }
+
+ var settingProvider = httpContext.RequestServices.GetRequiredService();
+ var defaultLanguage = await settingProvider.GetOrNullAsync(LocalizationSettingNames.DefaultLanguage);
+ if (defaultLanguage.IsNullOrWhiteSpace())
+ {
+ return null;
+ }
+
+ string culture;
+ string uiCulture;
+
+ if (defaultLanguage.Contains(';'))
+ {
+ var splitted = defaultLanguage.Split(';');
+ culture = splitted[0];
+ uiCulture = splitted[1];
+ }
+ else
+ {
+ culture = defaultLanguage;
+ uiCulture = defaultLanguage;
+ }
+
+ return new RequestCulture(culture, uiCulture);
+ }
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs
index 4b4a0e6301..ae013c4343 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.Client/Volo/Abp/AspNetCore/Mvc/Client/MvcCachedApplicationConfigurationClientHelper.cs
@@ -7,7 +7,8 @@ namespace Volo.Abp.AspNetCore.Mvc.Client
{
public static string CreateCacheKey(ICurrentUser currentUser)
{
- return $"ApplicationConfiguration_{currentUser.Id?.ToString("N") ?? "Anonymous"}_{CultureInfo.CurrentUICulture.Name}";
+ var userKey = currentUser.Id?.ToString("N") ?? "Anonymous";
+ return $"ApplicationConfiguration_{userKey}_{CultureInfo.CurrentUICulture.Name}";
}
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs
index afc4ec6a4a..acb2ae9fac 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationCollection.cs
@@ -9,11 +9,13 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{
private readonly ConcurrentDictionary _bundles;
private readonly ConcurrentDictionary>> _lazyBundleConfigurationActions;
+ private readonly List> _lazyAllBundleConfigurationActions;
public BundleConfigurationCollection()
{
_bundles = new ConcurrentDictionary();
_lazyBundleConfigurationActions = new ConcurrentDictionary>>();
+ _lazyAllBundleConfigurationActions = new List>();
}
///
@@ -90,6 +92,12 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
}
}
+ lock (_lazyAllBundleConfigurationActions)
+ {
+ _lazyAllBundleConfigurationActions.ForEach(c => c.Invoke(bundle));
+ }
+
+
return bundle;
}
@@ -123,6 +131,29 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return this;
}
+ ///
+ /// Configures all bundles.
+ /// This method also works for lazy bundles (those are created using razor tag helpers).
+ ///
+ /// Configure action
+ /// Returns this object for chained calls.
+ public BundleConfigurationCollection ConfigureAll([NotNull] Action configureAction)
+ {
+ Check.NotNull(configureAction, nameof(configureAction));
+
+ foreach (var bundle in _bundles)
+ {
+ configureAction.Invoke(bundle.Value);
+ }
+
+ lock (_lazyAllBundleConfigurationActions)
+ {
+ _lazyAllBundleConfigurationActions.Add(configureAction);
+ }
+
+ return this;
+ }
+
///
/// Gets a bundle.
///
@@ -140,4 +171,4 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return bundle;
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js
index 431d9093f7..55c604cf4a 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/dom-event-handlers.js
@@ -159,7 +159,7 @@
abp.dom.initializers.initializeDatepickers = function ($rootElement) {
$rootElement
- .findWithSelf('input.datepicker,input[type=date]')
+ .findWithSelf('input.datepicker,input[type=date][abp-data-datepicker!=false]')
.each(function () {
var $input = $(this);
$input
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js
index a4d32550f8..75d080feda 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/bootstrap/modal-manager.js
@@ -39,7 +39,7 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f
var _$modal = null;
var _$form = null;
- var _modalId = 'Modal_' + (Math.floor((Math.random() * 1000000))) + new Date().getTime();
+ var _modalId = 'Abp_Modal_' + (Math.floor((Math.random() * 1000000))) + new Date().getTime();
var _modalObject = null;
var _publicApi = null;
@@ -56,7 +56,12 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f
function _createContainer() {
_removeContainer();
_$modalContainer = $('');
- $('body').prepend(_$modalContainer);
+ var existsModals = $('[id^="Abp_Modal_"]');
+ if (existsModals.length) {
+ existsModals.last().after(_$modalContainer)
+ } else {
+ $('body').prepend(_$modalContainer);
+ }
return _$modalContainer;
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
index b0c4873b59..9895097d99 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js
@@ -30,7 +30,7 @@
var htmlEncode = function (html) {
return $('').text(html).html();
}
-
+
var _createDropdownItem = function (record, fieldItem, tableInstance) {
var $li = $('');
var $a = $('');
@@ -90,15 +90,15 @@
}
$button.append(htmlEncode(firstItem.text));
}
-
+
if (firstItem.enabled && !firstItem.enabled({ record: record, table: tableInstance })) {
$button.addClass('disabled');
}
-
+
if (firstItem.action) {
$button.click(function (e) {
e.preventDefault();
-
+
if (!$(this).hasClass('disabled')) {
if (firstItem.confirmMessage) {
abp.message.confirm(firstItem.confirmMessage({ record: record, table: tableInstance }))
@@ -217,7 +217,7 @@
var renderRowActions = function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var columns;
-
+
if (tableInstance.aoColumns) {
columns = tableInstance.aoColumns;
} else {
@@ -334,7 +334,10 @@
};
}
return function (requestData, callback, settings) {
- var input = inputAction ? inputAction(requestData, settings) : {};
+ var input = typeof inputAction === 'function'
+ ? inputAction(requestData, settings)
+ : typeof inputAction === 'object'
+ ? inputAction : {};
//Paging
if (settings.oInit.paging) {
@@ -463,7 +466,7 @@
datatables.defaultConfigurations.scrollX = true;
- datatables.defaultConfigurations.responsive = true;
+ datatables.defaultConfigurations.responsive = true;
datatables.defaultConfigurations.language = function () {
return {
@@ -484,6 +487,6 @@
};
};
- datatables.defaultConfigurations.dom = '<"dataTable_filters"f>rt<"row dataTable_footer"<"col-auto"l><"col-auto"i><"col"p>>';
+ datatables.defaultConfigurations.dom = '<"dataTable_filters"f>rt<"row dataTable_footer"<"col-auto"l><"col-auto mr-auto"i><"col-auto"p>>';
})(jQuery);
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs
index 449747d0cc..a2d02bb3fe 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/RazorPages/AbpPageModel.cs
@@ -27,6 +27,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.RazorPages
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
protected IClock Clock => LazyServiceProvider.LazyGetRequiredService();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
index 52f1d251cb..85822414cf 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpController.cs
@@ -25,6 +25,7 @@ namespace Volo.Abp.AspNetCore.Mvc
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
protected IUnitOfWorkManager UnitOfWorkManager => LazyServiceProvider.LazyGetRequiredService();
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
index 8cbba0fc46..873c532ba3 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
@@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AspNetCore.Mvc.Auditing;
-using Volo.Abp.AspNetCore.Mvc.Content;
+using Volo.Abp.AspNetCore.Mvc.ContentFormatters;
using Volo.Abp.AspNetCore.Mvc.Conventions;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.Features;
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
index 2ac02b8ac5..215f31b855 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpViewComponent.cs
@@ -10,6 +10,7 @@ namespace Volo.Abp.AspNetCore.Mvc
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
protected Type ObjectMapperContext { get; set; }
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
index 5cd1333f34..135b506e69 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProvider.cs
@@ -25,17 +25,20 @@ namespace Volo.Abp.AspNetCore.Mvc
{
public ILogger Logger { get; set; }
+ private readonly AspNetCoreApiDescriptionModelProviderOptions _options;
private readonly IApiDescriptionGroupCollectionProvider _descriptionProvider;
- private readonly AbpAspNetCoreMvcOptions _options;
+ private readonly AbpAspNetCoreMvcOptions _abpAspNetCoreMvcOptions;
private readonly AbpApiDescriptionModelOptions _modelOptions;
public AspNetCoreApiDescriptionModelProvider(
+ IOptions options,
IApiDescriptionGroupCollectionProvider descriptionProvider,
- IOptions options,
+ IOptions abpAspNetCoreMvcOptions,
IOptions modelOptions)
{
- _descriptionProvider = descriptionProvider;
_options = options.Value;
+ _descriptionProvider = descriptionProvider;
+ _abpAspNetCoreMvcOptions = abpAspNetCoreMvcOptions.Value;
_modelOptions = modelOptions.Value;
Logger = NullLogger.Instance;
@@ -82,14 +85,14 @@ namespace Volo.Abp.AspNetCore.Mvc
var controllerModel = moduleModel.GetOrAddController(
controllerType.FullName,
- CalculateControllerName(controllerType, setting),
+ _options.ControllerNameGenerator(controllerType, setting),
controllerType,
_modelOptions.IgnoredInterfaces
);
var method = apiDescription.ActionDescriptor.GetMethodInfo();
- var uniqueMethodName = GetUniqueActionName(method);
+ var uniqueMethodName = _options.ActionNameGenerator(method);
if (controllerModel.Actions.ContainsKey(uniqueMethodName))
{
Logger.LogWarning(
@@ -119,44 +122,6 @@ namespace Volo.Abp.AspNetCore.Mvc
AddParameterDescriptionsToModel(actionModel, method, apiDescription);
}
- private static string CalculateControllerName(Type controllerType, ConventionalControllerSetting setting)
- {
- var controllerName = controllerType.Name.RemovePostFix("Controller")
- .RemovePostFix(ApplicationService.CommonPostfixes);
-
- if (setting?.UrlControllerNameNormalizer != null)
- {
- controllerName =
- setting.UrlControllerNameNormalizer(
- new UrlControllerNameNormalizerContext(setting.RootPath, controllerName));
- }
-
- return controllerName;
- }
-
- private static string GetUniqueActionName(MethodInfo method)
- {
- var methodNameBuilder = new StringBuilder(method.Name);
-
- var parameters = method.GetParameters();
- if (parameters.Any())
- {
- methodNameBuilder.Append("By");
-
- for (var i = 0; i < parameters.Length; i++)
- {
- if (i > 0)
- {
- methodNameBuilder.Append("And");
- }
-
- methodNameBuilder.Append(parameters[i].Name.ToPascalCase());
- }
- }
-
- return methodNameBuilder.ToString();
- }
-
private static List GetSupportedVersions(Type controllerType, MethodInfo method,
ConventionalControllerSetting setting)
{
@@ -377,7 +342,7 @@ namespace Volo.Abp.AspNetCore.Mvc
[CanBeNull]
private ConventionalControllerSetting FindSetting(Type controllerType)
{
- foreach (var controllerSetting in _options.ConventionalControllers.ConventionalControllerSettings)
+ foreach (var controllerSetting in _abpAspNetCoreMvcOptions.ConventionalControllers.ConventionalControllerSettings)
{
if (controllerSetting.ControllerTypes.Contains(controllerType))
{
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs
new file mode 100644
index 0000000000..4cd607e07a
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AspNetCoreApiDescriptionModelProviderOptions.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using Volo.Abp.Application.Services;
+using Volo.Abp.AspNetCore.Mvc.Conventions;
+
+namespace Volo.Abp.AspNetCore.Mvc
+{
+ public class AspNetCoreApiDescriptionModelProviderOptions
+ {
+ public Func ControllerNameGenerator { get; set; }
+
+ public Func ActionNameGenerator { get; set; }
+
+ public AspNetCoreApiDescriptionModelProviderOptions()
+ {
+ ControllerNameGenerator = (controllerType, setting) =>
+ {
+ var controllerName = controllerType.Name.RemovePostFix("Controller")
+ .RemovePostFix(ApplicationService.CommonPostfixes);
+
+ if (setting?.UrlControllerNameNormalizer != null)
+ {
+ controllerName =
+ setting.UrlControllerNameNormalizer(
+ new UrlControllerNameNormalizerContext(setting.RootPath, controllerName));
+ }
+
+ return controllerName;
+ };
+
+ ActionNameGenerator = (method) =>
+ {
+ var methodNameBuilder = new StringBuilder(method.Name);
+
+ var parameters = method.GetParameters();
+ if (parameters.Any())
+ {
+ methodNameBuilder.Append("By");
+
+ for (var i = 0; i < parameters.Length; i++)
+ {
+ if (i > 0)
+ {
+ methodNameBuilder.Append("And");
+ }
+
+ methodNameBuilder.Append(parameters[i].Name.ToPascalCase());
+ }
+ }
+
+ return methodNameBuilder.ToString();
+ };
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/InternalRemoteStreamContent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/InternalRemoteStreamContent.cs
deleted file mode 100644
index aaaa849f4f..0000000000
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/InternalRemoteStreamContent.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.IO;
-using Microsoft.AspNetCore.Http;
-using Volo.Abp.Content;
-
-namespace Volo.Abp.AspNetCore.Mvc.Content
-{
- internal class InternalRemoteStreamContent : IRemoteStreamContent
- {
- private readonly HttpContext _httpContext;
-
- public InternalRemoteStreamContent(HttpContext httpContext)
- {
- _httpContext = httpContext;
- }
-
- public string ContentType => _httpContext.Request.ContentType;
-
- public long? ContentLength => _httpContext.Request.ContentLength;
-
- public Stream GetStream()
- {
- return _httpContext.Request.Body;
- }
- }
-}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentInputFormatter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentInputFormatter.cs
similarity index 70%
rename from framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentInputFormatter.cs
rename to framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentInputFormatter.cs
index a4f5668b7d..ba07e28f77 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentInputFormatter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentInputFormatter.cs
@@ -1,10 +1,10 @@
using System;
using System.Threading.Tasks;
-using Microsoft.Net.Http.Headers;
using Microsoft.AspNetCore.Mvc.Formatters;
+using Microsoft.Net.Http.Headers;
using Volo.Abp.Content;
-namespace Volo.Abp.AspNetCore.Mvc.Content
+namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters
{
public class RemoteStreamContentInputFormatter : InputFormatter
{
@@ -20,9 +20,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Content
public override Task ReadRequestBodyAsync(InputFormatterContext context)
{
- return InputFormatterResult.SuccessAsync(
- new InternalRemoteStreamContent(context.HttpContext)
- );
+ return InputFormatterResult.SuccessAsync(new RemoteStreamContent(context.HttpContext.Request.Body)
+ {
+ ContentType = context.HttpContext.Request.ContentType
+ });
}
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs
similarity index 65%
rename from framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs
rename to framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs
index 706e514254..685822a4b6 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Content/RemoteStreamContentOutputFormatter.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentOutputFormatter.cs
@@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc.Formatters;
using Microsoft.Net.Http.Headers;
using Volo.Abp.Content;
-namespace Volo.Abp.AspNetCore.Mvc.Content
+namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters
{
public class RemoteStreamContentOutputFormatter : OutputFormatter
{
@@ -21,9 +21,16 @@ namespace Volo.Abp.AspNetCore.Mvc.Content
public override async Task WriteResponseBodyAsync(OutputFormatterWriteContext context)
{
var remoteStream = (IRemoteStreamContent)context.Object;
- using (var stream = remoteStream.GetStream())
+
+ if (remoteStream != null)
{
- await stream.CopyToAsync(context.HttpContext.Response.Body);
+ context.HttpContext.Response.ContentType = remoteStream.ContentType;
+
+ using (var stream = remoteStream.GetStream())
+ {
+ stream.Position = 0;
+ await stream.CopyToAsync(context.HttpContext.Response.Body);
+ }
}
}
}
diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
index 06b9c9a620..6b73aa26da 100644
--- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
+++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Localization/AbpLanguagesController.cs
@@ -1,7 +1,7 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Localization;
+using Microsoft.AspNetCore.Localization;
using Microsoft.AspNetCore.Mvc;
using System;
+using Microsoft.AspNetCore.RequestLocalization;
using Volo.Abp.Localization;
namespace Volo.Abp.AspNetCore.Mvc.Localization
@@ -20,12 +20,10 @@ namespace Volo.Abp.AspNetCore.Mvc.Localization
throw new AbpException("Unknown language: " + culture + ". It must be a valid culture!");
}
- string cookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture, uiCulture));
-
- Response.Cookies.Append(CookieRequestCultureProvider.DefaultCookieName, cookieValue, new CookieOptions
- {
- Expires = Clock.Now.AddYears(2)
- });
+ AbpRequestCultureCookieHelper.SetCultureCookie(
+ HttpContext,
+ new RequestCulture(culture, uiCulture)
+ );
if (!string.IsNullOrWhiteSpace(returnUrl))
{
diff --git a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
index a9d9316f41..616cbd3706 100644
--- a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
+++ b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpHub.cs
@@ -17,6 +17,7 @@ namespace Volo.Abp.AspNetCore.SignalR
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetService();
diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestCultureCookieHelper.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestCultureCookieHelper.cs
new file mode 100644
index 0000000000..0f27925496
--- /dev/null
+++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/RequestLocalization/AbpRequestCultureCookieHelper.cs
@@ -0,0 +1,23 @@
+using System;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Localization;
+
+namespace Microsoft.AspNetCore.RequestLocalization
+{
+ public static class AbpRequestCultureCookieHelper
+ {
+ public static void SetCultureCookie(
+ HttpContext httpContext,
+ RequestCulture requestCulture)
+ {
+ httpContext.Response.Cookies.Append(
+ CookieRequestCultureProvider.DefaultCookieName,
+ CookieRequestCultureProvider.MakeCookieValue(requestCulture),
+ new CookieOptions
+ {
+ Expires = DateTime.Now.AddYears(2)
+ }
+ );
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs b/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs
index 25707e3899..cb576ba1de 100644
--- a/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs
+++ b/framework/src/Volo.Abp.AutoMapper/Volo/Abp/AutoMapper/AbpAutoMapperModule.cs
@@ -25,7 +25,7 @@ namespace Volo.Abp.AutoMapper
{
context.Services.AddAutoMapperObjectMapper();
- context.Services.AddSingleton(provider => CreateMappings(provider));
+ context.Services.AddSingleton(CreateMappings);
context.Services.AddSingleton(provider => provider.GetRequiredService());
}
@@ -43,6 +43,8 @@ namespace Volo.Abp.AutoMapper
}
}
+ options.Configurators.Insert(0, ctx => ctx.MapperConfiguration.ConstructServicesUsing(serviceProvider.GetService));
+
void ValidateAll(IConfigurationProvider config)
{
foreach (var profileType in options.ValidatingProfiles)
@@ -60,7 +62,7 @@ namespace Volo.Abp.AutoMapper
return new MapperAccessor
{
- Mapper = new Mapper(mapperConfiguration, serviceProvider.GetService)
+ Mapper = new Mapper(mapperConfiguration)
};
}
}
diff --git a/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/AbpBackgroundJobQuartzOptions.cs b/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/AbpBackgroundJobQuartzOptions.cs
index e9ecb41c57..1f9836d57d 100644
--- a/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/AbpBackgroundJobQuartzOptions.cs
+++ b/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/AbpBackgroundJobQuartzOptions.cs
@@ -10,7 +10,7 @@ namespace Volo.Abp.BackgroundJobs.Quartz
public int RetryCount { get; set; }
public int RetryIntervalMillisecond { get; set; }
-
+
[NotNull]
public Func RetryStrategy
@@ -19,28 +19,28 @@ namespace Volo.Abp.BackgroundJobs.Quartz
set => _retryStrategy = Check.NotNull(value, nameof(value));
}
private Func _retryStrategy;
-
+
public AbpBackgroundJobQuartzOptions()
{
RetryCount = 3;
RetryIntervalMillisecond = 3000;
_retryStrategy = DefaultRetryStrategy;
}
-
+
private async Task DefaultRetryStrategy(int retryIndex, IJobExecutionContext executionContext, JobExecutionException exception)
{
exception.RefireImmediately = true;
-
- var retryCount = executionContext.JobDetail.JobDataMap.GetIntValue(QuartzBackgroundJobManager.JobDataPrefix+ nameof(RetryCount));
+
+ var retryCount = executionContext.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix+ nameof(RetryCount)).To();
if (retryIndex > retryCount)
{
exception.RefireImmediately = false;
exception.UnscheduleAllTriggers = true;
return;
}
-
- var retryInterval = executionContext.JobDetail.JobDataMap.GetIntValue(QuartzBackgroundJobManager.JobDataPrefix+ nameof(RetryIntervalMillisecond));
+
+ var retryInterval = executionContext.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix+ nameof(RetryIntervalMillisecond)).To();
await Task.Delay(retryInterval);
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzBackgroundJobManager.cs b/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzBackgroundJobManager.cs
index 83b74297a5..42e89ffb93 100644
--- a/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzBackgroundJobManager.cs
+++ b/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzBackgroundJobManager.cs
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Quartz;
using Volo.Abp.DependencyInjection;
+using Volo.Abp.Json;
namespace Volo.Abp.BackgroundJobs.Quartz
{
@@ -16,9 +17,12 @@ namespace Volo.Abp.BackgroundJobs.Quartz
protected AbpBackgroundJobQuartzOptions Options { get; }
- public QuartzBackgroundJobManager(IScheduler scheduler, IOptions options)
+ protected IJsonSerializer JsonSerializer { get; }
+
+ public QuartzBackgroundJobManager(IScheduler scheduler, IOptions options, IJsonSerializer jsonSerializer)
{
Scheduler = scheduler;
+ JsonSerializer = jsonSerializer;
Options = options.Value;
}
@@ -33,10 +37,10 @@ namespace Volo.Abp.BackgroundJobs.Quartz
{
var jobDataMap = new JobDataMap
{
- {nameof(TArgs), args},
- {JobDataPrefix+ nameof(Options.RetryCount), retryCount},
- {JobDataPrefix+ nameof(Options.RetryIntervalMillisecond), retryIntervalMillisecond},
- {JobDataPrefix+ RetryIndex, 0}
+ {nameof(TArgs), JsonSerializer.Serialize(args)},
+ {JobDataPrefix+ nameof(Options.RetryCount), retryCount.ToString()},
+ {JobDataPrefix+ nameof(Options.RetryIntervalMillisecond), retryIntervalMillisecond.ToString()},
+ {JobDataPrefix+ RetryIndex, "0"}
};
var jobDetail = JobBuilder.Create>().RequestRecovery().SetJobData(jobDataMap).Build();
diff --git a/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzJobExecutionAdapter.cs b/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzJobExecutionAdapter.cs
index b6759b256e..79776d0726 100644
--- a/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzJobExecutionAdapter.cs
+++ b/framework/src/Volo.Abp.BackgroundJobs.Quartz/Volo/Abp/BackgroundJobs/Quartz/QuartzJobExecutionAdapter.cs
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Quartz;
+using Volo.Abp.Json;
namespace Volo.Abp.BackgroundJobs.Quartz
{
@@ -16,15 +17,18 @@ namespace Volo.Abp.BackgroundJobs.Quartz
protected AbpBackgroundJobQuartzOptions BackgroundJobQuartzOptions { get; }
protected IServiceScopeFactory ServiceScopeFactory { get; }
protected IBackgroundJobExecuter JobExecuter { get; }
+ protected IJsonSerializer JsonSerializer { get; }
public QuartzJobExecutionAdapter(
IOptions options,
IOptions backgroundJobQuartzOptions,
IBackgroundJobExecuter jobExecuter,
- IServiceScopeFactory serviceScopeFactory)
+ IServiceScopeFactory serviceScopeFactory,
+ IJsonSerializer jsonSerializer)
{
JobExecuter = jobExecuter;
ServiceScopeFactory = serviceScopeFactory;
+ JsonSerializer = jsonSerializer;
Options = options.Value;
BackgroundJobQuartzOptions = backgroundJobQuartzOptions.Value;
Logger = NullLogger>.Instance;
@@ -34,7 +38,7 @@ namespace Volo.Abp.BackgroundJobs.Quartz
{
using (var scope = ServiceScopeFactory.CreateScope())
{
- var args = (TArgs) context.JobDetail.JobDataMap.Get(nameof(TArgs));
+ var args = JsonSerializer.Deserialize(context.JobDetail.JobDataMap.GetString(nameof(TArgs)));
var jobType = Options.GetJob(typeof(TArgs)).JobType;
var jobContext = new JobExecutionContext(scope.ServiceProvider, jobType, args);
try
@@ -44,16 +48,16 @@ namespace Volo.Abp.BackgroundJobs.Quartz
catch (Exception exception)
{
var jobExecutionException = new JobExecutionException(exception);
-
- var retryIndex = context.JobDetail.JobDataMap.GetIntValue(QuartzBackgroundJobManager.JobDataPrefix+ QuartzBackgroundJobManager.RetryIndex);
+
+ var retryIndex = context.JobDetail.JobDataMap.GetString(QuartzBackgroundJobManager.JobDataPrefix+ QuartzBackgroundJobManager.RetryIndex).To();
retryIndex++;
- context.JobDetail.JobDataMap.Put(QuartzBackgroundJobManager.JobDataPrefix+ QuartzBackgroundJobManager.RetryIndex, retryIndex);
-
+ context.JobDetail.JobDataMap.Put(QuartzBackgroundJobManager.JobDataPrefix+ QuartzBackgroundJobManager.RetryIndex, retryIndex.ToString());
+
await BackgroundJobQuartzOptions.RetryStrategy.Invoke(retryIndex, context, jobExecutionException);
-
+
throw jobExecutionException;
}
}
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
index 4a4d4df722..99d0f2a4c3 100644
--- a/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
+++ b/framework/src/Volo.Abp.BlazoriseUI/AbpCrudPageBase.cs
@@ -269,7 +269,7 @@ namespace Volo.Abp.BlazoriseUI
await GetEntitiesAsync();
- StateHasChanged();
+ await InvokeAsync(StateHasChanged);
}
protected virtual async Task OnDataGridReadAsync(DataGridReadDataEventArgs e)
@@ -282,7 +282,7 @@ namespace Volo.Abp.BlazoriseUI
await GetEntitiesAsync();
- StateHasChanged();
+ await InvokeAsync(StateHasChanged);
}
protected virtual async Task OpenCreateModalAsync()
@@ -295,7 +295,7 @@ namespace Volo.Abp.BlazoriseUI
// Mapper will not notify Blazor that binded values are changed
// so we need to notify it manually by calling StateHasChanged
- await InvokeAsync(() => StateHasChanged());
+ await InvokeAsync(StateHasChanged);
CreateModal.Show();
}
@@ -317,7 +317,7 @@ namespace Volo.Abp.BlazoriseUI
EditingEntityId = entity.Id;
EditingEntity = MapToEditingEntity(entityDto);
- await InvokeAsync(() => StateHasChanged());
+ await InvokeAsync(StateHasChanged);
EditModal.Show();
}
@@ -362,11 +362,8 @@ namespace Volo.Abp.BlazoriseUI
await CheckCreatePolicyAsync();
var createInput = MapToCreateInput(NewEntity);
await AppService.CreateAsync(createInput);
- await GetEntitiesAsync();
await OnCreatedEntityAsync();
-
- CreateModal.Hide();
}
}
@@ -375,9 +372,11 @@ namespace Volo.Abp.BlazoriseUI
return Task.CompletedTask;
}
- protected virtual Task OnCreatedEntityAsync()
+ protected virtual async Task OnCreatedEntityAsync()
{
- return Task.CompletedTask;
+ await GetEntitiesAsync();
+
+ CreateModal.Hide();
}
protected virtual async Task UpdateEntityAsync()
@@ -389,11 +388,8 @@ namespace Volo.Abp.BlazoriseUI
await CheckUpdatePolicyAsync();
var updateInput = MapToUpdateInput(EditingEntity);
await AppService.UpdateAsync(EditingEntityId, updateInput);
- await GetEntitiesAsync();
await OnUpdatedEntityAsync();
-
- EditModal.Hide();
}
}
@@ -402,9 +398,11 @@ namespace Volo.Abp.BlazoriseUI
return Task.CompletedTask;
}
- protected virtual Task OnUpdatedEntityAsync()
+ protected virtual async Task OnUpdatedEntityAsync()
{
- return Task.CompletedTask;
+ await GetEntitiesAsync();
+
+ EditModal.Hide();
}
protected virtual async Task DeleteEntityAsync(TListViewModel entity)
diff --git a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
index c54226dfb3..f2ef147188 100644
--- a/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
+++ b/framework/src/Volo.Abp.BlazoriseUI/Volo.Abp.BlazoriseUI.csproj
@@ -12,9 +12,9 @@
-
-
-
+
+
+
diff --git a/framework/src/Volo.Abp.Caching.StackExchangeRedis/Volo/Abp/Caching/StackExchangeRedis/AbpRedisCache.cs b/framework/src/Volo.Abp.Caching.StackExchangeRedis/Volo/Abp/Caching/StackExchangeRedis/AbpRedisCache.cs
index c3cb34f30c..fc45ccd05d 100644
--- a/framework/src/Volo.Abp.Caching.StackExchangeRedis/Volo/Abp/Caching/StackExchangeRedis/AbpRedisCache.cs
+++ b/framework/src/Volo.Abp.Caching.StackExchangeRedis/Volo/Abp/Caching/StackExchangeRedis/AbpRedisCache.cs
@@ -45,19 +45,26 @@ namespace Volo.Abp.Caching.StackExchangeRedis
MapMetadataMethod = type.GetMethod("MapMetadata", BindingFlags.Instance | BindingFlags.NonPublic);
- GetAbsoluteExpirationMethod = type.GetMethod("GetAbsoluteExpiration", BindingFlags.Static | BindingFlags.NonPublic);
+ GetAbsoluteExpirationMethod =
+ type.GetMethod("GetAbsoluteExpiration", BindingFlags.Static | BindingFlags.NonPublic);
- GetExpirationInSecondsMethod = type.GetMethod("GetExpirationInSeconds", BindingFlags.Static | BindingFlags.NonPublic);
+ GetExpirationInSecondsMethod =
+ type.GetMethod("GetExpirationInSeconds", BindingFlags.Static | BindingFlags.NonPublic);
- SetScript = type.GetField("SetScript", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null).ToString();
+ SetScript = type.GetField("SetScript", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null)
+ .ToString();
- AbsoluteExpirationKey = type.GetField("AbsoluteExpirationKey", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null).ToString();
+ AbsoluteExpirationKey = type.GetField("AbsoluteExpirationKey", BindingFlags.Static | BindingFlags.NonPublic)
+ ?.GetValue(null).ToString();
- SlidingExpirationKey = type.GetField("SlidingExpirationKey", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null).ToString();
+ SlidingExpirationKey = type.GetField("SlidingExpirationKey", BindingFlags.Static | BindingFlags.NonPublic)
+ ?.GetValue(null).ToString();
- DataKey = type.GetField("DataKey", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null).ToString();
+ DataKey = type.GetField("DataKey", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null).ToString();
- NotPresent = type.GetField("NotPresent", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null).To();
+ // ReSharper disable once PossibleNullReferenceException
+ NotPresent = type.GetField("NotPresent", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null)
+ .To();
}
public AbpRedisCache(IOptions optionsAccessor)
@@ -124,6 +131,42 @@ namespace Volo.Abp.Caching.StackExchangeRedis
await Task.WhenAll(PipelineSetMany(items, options));
}
+ public void RefreshMany(
+ IEnumerable keys)
+ {
+ keys = Check.NotNull(keys, nameof(keys));
+
+ GetAndRefreshMany(keys, false);
+ }
+
+ public async Task RefreshManyAsync(
+ IEnumerable keys,
+ CancellationToken token = default)
+ {
+ keys = Check.NotNull(keys, nameof(keys));
+
+ await GetAndRefreshManyAsync(keys, false, token);
+ }
+
+ public void RemoveMany(IEnumerable keys)
+ {
+ keys = Check.NotNull(keys, nameof(keys));
+
+ Connect();
+
+ RedisDatabase.KeyDelete(keys.Select(key => (RedisKey)(Instance + key)).ToArray());
+ }
+
+ public async Task RemoveManyAsync(IEnumerable keys, CancellationToken token = default)
+ {
+ keys = Check.NotNull(keys, nameof(keys));
+
+ token.ThrowIfCancellationRequested();
+ await ConnectAsync(token);
+
+ await RedisDatabase.KeyDeleteAsync(keys.Select(key => (RedisKey)(Instance + key)).ToArray());
+ }
+
protected virtual byte[][] GetAndRefreshMany(
IEnumerable keys,
bool getData)
diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
index d62411628e..1337206464 100644
--- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
+++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs
@@ -527,6 +527,198 @@ namespace Volo.Abp.Caching
return value;
}
+ public KeyValuePair[] GetOrAddMany(
+ IEnumerable keys,
+ Func, List>> factory,
+ Func optionsFactory = null,
+ bool? hideErrors = null,
+ bool considerUow = false)
+ {
+
+ KeyValuePair[] result;
+ var keyArray = keys.ToArray();
+
+ var cacheSupportsMultipleItems = Cache as ICacheSupportsMultipleItems;
+ if (cacheSupportsMultipleItems == null)
+ {
+ result = GetManyFallback(
+ keyArray,
+ hideErrors,
+ considerUow
+ );
+ }
+ else
+ {
+ var notCachedKeys = new List();
+ var cachedValues = new List>();
+ if (ShouldConsiderUow(considerUow))
+ {
+ var uowCache = GetUnitOfWorkCache();
+ foreach (var key in keyArray)
+ {
+ var value = uowCache.GetOrDefault(key)?.GetUnRemovedValueOrNull();
+ if (value != null)
+ {
+ cachedValues.Add(new KeyValuePair(key, value));
+ }
+ }
+
+ notCachedKeys = keyArray.Except(cachedValues.Select(x => x.Key)).ToList();
+ if (!notCachedKeys.Any())
+ {
+ return cachedValues.ToArray();
+ }
+ }
+
+ hideErrors = hideErrors ?? _distributedCacheOption.HideErrors;
+ byte[][] cachedBytes;
+
+ var readKeys = notCachedKeys.Any() ? notCachedKeys.ToArray() : keyArray;
+ try
+ {
+ cachedBytes = cacheSupportsMultipleItems.GetMany(readKeys.Select(NormalizeKey));
+ }
+ catch (Exception ex)
+ {
+ if (hideErrors == true)
+ {
+ HandleException(ex);
+ return ToCacheItemsWithDefaultValues(keyArray);
+ }
+
+ throw;
+ }
+
+ result = cachedValues.Concat(ToCacheItems(cachedBytes, readKeys)).ToArray();
+ }
+
+ if (result.All(x => x.Value != null))
+ {
+ return result;
+ }
+
+ var missingKeys = new List();
+ var missingValuesIndex = new List();
+ for (var i = 0; i < keyArray.Length; i++)
+ {
+ if (result[i].Value != null)
+ {
+ continue;
+ }
+
+ missingKeys.Add(keyArray[i]);
+ missingValuesIndex.Add(i);
+ }
+
+ var missingValues = factory.Invoke(missingKeys).ToArray();
+ var valueQueue = new Queue>(missingValues);
+
+ SetMany(missingValues, optionsFactory?.Invoke(), hideErrors, considerUow);
+
+ foreach (var index in missingValuesIndex)
+ {
+ result[index] = valueQueue.Dequeue();
+ }
+
+ return result;
+ }
+
+
+ public async Task[]> GetOrAddManyAsync(
+ IEnumerable keys,
+ Func, Task>>> factory,
+ Func optionsFactory = null,
+ bool? hideErrors = null,
+ bool considerUow = false,
+ CancellationToken token = default)
+ {
+ KeyValuePair[] result;
+ var keyArray = keys.ToArray();
+
+ var cacheSupportsMultipleItems = Cache as ICacheSupportsMultipleItems;
+ if (cacheSupportsMultipleItems == null)
+ {
+ result = await GetManyFallbackAsync(
+ keyArray,
+ hideErrors,
+ considerUow, token);
+ }
+ else
+ {
+ var notCachedKeys = new List();
+ var cachedValues = new List>();
+ if (ShouldConsiderUow(considerUow))
+ {
+ var uowCache = GetUnitOfWorkCache();
+ foreach (var key in keyArray)
+ {
+ var value = uowCache.GetOrDefault(key)?.GetUnRemovedValueOrNull();
+ if (value != null)
+ {
+ cachedValues.Add(new KeyValuePair(key, value));
+ }
+ }
+
+ notCachedKeys = keyArray.Except(cachedValues.Select(x => x.Key)).ToList();
+ if (!notCachedKeys.Any())
+ {
+ return cachedValues.ToArray();
+ }
+ }
+
+ hideErrors = hideErrors ?? _distributedCacheOption.HideErrors;
+ byte[][] cachedBytes;
+
+ var readKeys = notCachedKeys.Any() ? notCachedKeys.ToArray() : keyArray;
+ try
+ {
+ cachedBytes = await cacheSupportsMultipleItems.GetManyAsync(readKeys.Select(NormalizeKey), token);
+ }
+ catch (Exception ex)
+ {
+ if (hideErrors == true)
+ {
+ await HandleExceptionAsync(ex);
+ return ToCacheItemsWithDefaultValues(keyArray);
+ }
+
+ throw;
+ }
+
+ result = cachedValues.Concat(ToCacheItems(cachedBytes, readKeys)).ToArray();
+ }
+
+ if (result.All(x => x.Value != null))
+ {
+ return result;
+ }
+
+ var missingKeys = new List();
+ var missingValuesIndex = new List();
+ for (var i = 0; i < keyArray.Length; i++)
+ {
+ if (result[i].Value != null)
+ {
+ continue;
+ }
+
+ missingKeys.Add(keyArray[i]);
+ missingValuesIndex.Add(i);
+ }
+
+ var missingValues = (await factory.Invoke(missingKeys)).ToArray();
+ var valueQueue = new Queue>(missingValues);
+
+ await SetManyAsync(missingValues, optionsFactory?.Invoke(), hideErrors, considerUow, token);
+
+ foreach (var index in missingValuesIndex)
+ {
+ result[index] = valueQueue.Dequeue();
+ }
+
+ return result;
+ }
+
///
/// Sets the cache item value for the provided key.
///
@@ -924,6 +1116,71 @@ namespace Volo.Abp.Caching
}
}
+ public virtual void RefreshMany(
+ IEnumerable keys,
+ bool? hideErrors = null)
+ {
+ hideErrors = hideErrors ?? _distributedCacheOption.HideErrors;
+
+ try
+ {
+ if (Cache is ICacheSupportsMultipleItems cacheSupportsMultipleItems)
+ {
+ cacheSupportsMultipleItems.RefreshMany(keys.Select(NormalizeKey));
+ }
+ else
+ {
+ foreach (var key in keys)
+ {
+ Cache.Refresh(NormalizeKey(key));
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ if (hideErrors == true)
+ {
+ HandleException(ex);
+ return;
+ }
+
+ throw;
+ }
+ }
+
+ public virtual async Task RefreshManyAsync(
+ IEnumerable keys,
+ bool? hideErrors = null,
+ CancellationToken token = default)
+ {
+ hideErrors = hideErrors ?? _distributedCacheOption.HideErrors;
+
+ try
+ {
+ if (Cache is ICacheSupportsMultipleItems cacheSupportsMultipleItems)
+ {
+ await cacheSupportsMultipleItems.RefreshManyAsync(keys.Select(NormalizeKey), token);
+ }
+ else
+ {
+ foreach (var key in keys)
+ {
+ await Cache.RefreshAsync(NormalizeKey(key), token);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ if (hideErrors == true)
+ {
+ await HandleExceptionAsync(ex);
+ return;
+ }
+
+ throw;
+ }
+ }
+
///
/// Removes the cache item for given key from cache.
///
@@ -1027,6 +1284,130 @@ namespace Volo.Abp.Caching
}
}
+ public void RemoveMany(
+ IEnumerable keys,
+ bool? hideErrors = null,
+ bool considerUow = false)
+ {
+ var keyArray = keys.ToArray();
+
+ if (Cache is ICacheSupportsMultipleItems cacheSupportsMultipleItems)
+ {
+ void RemoveRealCache()
+ {
+ hideErrors = hideErrors ?? _distributedCacheOption.HideErrors;
+
+ try
+ {
+ cacheSupportsMultipleItems.RemoveMany(
+ keyArray.Select(NormalizeKey)
+ );
+ }
+ catch (Exception ex)
+ {
+ if (hideErrors == true)
+ {
+ HandleException(ex);
+ return;
+ }
+
+ throw;
+ }
+ }
+
+ if (ShouldConsiderUow(considerUow))
+ {
+ var uowCache = GetUnitOfWorkCache();
+
+ foreach (var key in keyArray)
+ {
+ if (uowCache.TryGetValue(key, out _))
+ {
+ uowCache[key].RemoveValue();
+ }
+ }
+
+ // ReSharper disable once PossibleNullReferenceException
+ UnitOfWorkManager.Current.OnCompleted(() =>
+ {
+ RemoveRealCache();
+ return Task.CompletedTask;
+ });
+ }
+ else
+ {
+ RemoveRealCache();
+ }
+ }
+ else
+ {
+ foreach (var key in keyArray)
+ {
+ Remove(key, hideErrors, considerUow);
+ }
+ }
+ }
+
+ public async Task RemoveManyAsync(
+ IEnumerable keys,
+ bool? hideErrors = null,
+ bool considerUow = false,
+ CancellationToken token = default)
+ {
+ var keyArray = keys.ToArray();
+
+ if (Cache is ICacheSupportsMultipleItems cacheSupportsMultipleItems)
+ {
+ async Task RemoveRealCache()
+ {
+ hideErrors = hideErrors ?? _distributedCacheOption.HideErrors;
+
+ try
+ {
+ await cacheSupportsMultipleItems.RemoveManyAsync(
+ keyArray.Select(NormalizeKey), token);
+ }
+ catch (Exception ex)
+ {
+ if (hideErrors == true)
+ {
+ await HandleExceptionAsync(ex);
+ return;
+ }
+
+ throw;
+ }
+ }
+
+ if (ShouldConsiderUow(considerUow))
+ {
+ var uowCache = GetUnitOfWorkCache();
+
+ foreach (var key in keyArray)
+ {
+ if (uowCache.TryGetValue(key, out _))
+ {
+ uowCache[key].RemoveValue();
+ }
+ }
+
+ // ReSharper disable once PossibleNullReferenceException
+ UnitOfWorkManager.Current.OnCompleted(RemoveRealCache);
+ }
+ else
+ {
+ await RemoveRealCache();
+ }
+ }
+ else
+ {
+ foreach (var key in keyArray)
+ {
+ await RemoveAsync(key, hideErrors, considerUow, token);
+ }
+ }
+ }
+
protected virtual void HandleException(Exception ex)
{
_ = HandleExceptionAsync(ex);
diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/ICacheSupportsMultipleItems.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/ICacheSupportsMultipleItems.cs
index af6f87021b..857385699d 100644
--- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/ICacheSupportsMultipleItems.cs
+++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/ICacheSupportsMultipleItems.cs
@@ -25,6 +25,24 @@ namespace Volo.Abp.Caching
IEnumerable> items,
DistributedCacheEntryOptions options,
CancellationToken token = default
- );
+ );
+
+ void RefreshMany(
+ IEnumerable keys
+ );
+
+ Task RefreshManyAsync(
+ IEnumerable keys,
+ CancellationToken token = default
+ );
+
+ void RemoveMany(
+ IEnumerable keys
+ );
+
+ Task RemoveManyAsync(
+ IEnumerable keys,
+ CancellationToken token = default
+ );
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs
index 2f74fd678b..f8e76fd9dd 100644
--- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs
+++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/IDistributedCache.cs
@@ -14,8 +14,8 @@ namespace Volo.Abp.Caching
public interface IDistributedCache : IDistributedCache
where TCacheItem : class
{
-
}
+
///
/// Represents a distributed cache of type.
/// Uses a generic cache key type of type.
@@ -128,6 +128,44 @@ namespace Volo.Abp.Caching
CancellationToken token = default
);
+ ///
+ /// Gets or Adds multiple cache items with the given keys. If any cache items not found for the given keys then adds cache items
+ /// provided by delegate and returns the provided cache items.
+ ///
+ /// The keys of cached items to be retrieved from the cache.
+ /// The factory delegate is used to provide the cache items when no cache items are found for the given .
+ /// The cache options for the factory delegate.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache.
+ /// The cache items.
+ KeyValuePair[] GetOrAddMany(
+ IEnumerable keys,
+ Func, List>> factory,
+ Func optionsFactory = null,
+ bool? hideErrors = null,
+ bool considerUow = false
+ );
+
+ ///
+ /// Gets or Adds multiple cache items with the given keys. If any cache items not found for the given keys then adds cache items
+ /// provided by delegate and returns the provided cache items.
+ ///
+ /// The keys of cached items to be retrieved from the cache.
+ /// The factory delegate is used to provide the cache items when no cache items are found for the given .
+ /// The cache options for the factory delegate.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache.
+ /// The for the task.
+ /// The cache items.
+ Task[]> GetOrAddManyAsync(
+ IEnumerable keys,
+ Func, Task>>> factory,
+ Func optionsFactory = null,
+ bool? hideErrors = null,
+ bool considerUow = false,
+ CancellationToken token = default
+ );
+
///
/// Sets the cache item value for the provided key.
///
@@ -219,6 +257,29 @@ namespace Volo.Abp.Caching
CancellationToken token = default
);
+ ///
+ /// Refreshes the cache value of the given keys, and resets their sliding expiration timeout.
+ /// Based on the implementation, this can be more efficient than setting multiple items individually.
+ ///
+ /// The keys of cached items to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ void RefreshMany(
+ IEnumerable keys,
+ bool? hideErrors = null);
+
+ ///
+ /// Refreshes the cache value of the given keys, and resets their sliding expiration timeout.
+ /// Based on the implementation, this can be more efficient than setting multiple items individually.
+ ///
+ /// The keys of cached items to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
+ Task RefreshManyAsync(
+ IEnumerable keys,
+ bool? hideErrors = null,
+ CancellationToken token = default);
+
///
/// Removes the cache item for given key from cache.
///
@@ -245,5 +306,32 @@ namespace Volo.Abp.Caching
bool considerUow = false,
CancellationToken token = default
);
+
+ ///
+ /// Removes the cache items for given keys from cache.
+ ///
+ /// The keys of cached items to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache.
+ void RemoveMany(
+ IEnumerable keys,
+ bool? hideErrors = null,
+ bool considerUow = false
+ );
+
+ ///
+ /// Removes the cache items for given keys from cache.
+ ///
+ /// The keys of cached items to be retrieved from the cache.
+ /// Indicates to throw or hide the exceptions for the distributed cache.
+ /// This will store the cache in the current unit of work until the end of the current unit of work does not really affect the cache.
+ /// The for the task.
+ /// The indicating that the operation is asynchronous.
+ Task RemoveManyAsync(
+ IEnumerable keys,
+ bool? hideErrors = null,
+ bool considerUow = false,
+ CancellationToken token = default
+ );
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
index 9208357d4a..6b23857233 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
@@ -1,5 +1,7 @@
using System.Text;
+using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Cli.Commands;
+using Volo.Abp.Cli.Http;
using Volo.Abp.Domain;
using Volo.Abp.IdentityModel;
using Volo.Abp.Json;
@@ -18,6 +20,9 @@ namespace Volo.Abp.Cli
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
+ context.Services.AddHttpClient(CliConsts.HttpClientName)
+ .ConfigurePrimaryHttpMessageHandler(() => new CliHttpClientHandler());
+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Configure(options =>
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
index 9125a0c8ab..f3cb291f56 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
@@ -22,7 +22,7 @@ namespace Volo.Abp.Cli.Auth
{
var configuration = new IdentityClientConfiguration(
CliUrls.AccountAbpIo,
- "role email abpio abpio_www abpio_commercial offline_access",
+ "role email abpio abpio_www abpio_commercial offline_access",
"abp-cli",
"1q2w3e*",
OidcConstants.GrantTypes.Password,
@@ -43,6 +43,7 @@ namespace Volo.Abp.Cli.Auth
public Task LogoutAsync()
{
FileHelper.DeleteIfExists(CliPaths.AccessToken);
+ FileHelper.DeleteIfExists(CliPaths.Lic);
return Task.CompletedTask;
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs
index b062388c7a..37dbbba318 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliConsts.cs
@@ -7,5 +7,7 @@
public const string BranchPrefix = "branch@";
public const string DocsLink = "https://docs.abp.io";
+
+ public const string HttpClientName = "AbpHttpClient";
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs
index 2b422446ca..068911ac8c 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliPaths.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using System.Text;
namespace Volo.Abp.Cli
{
@@ -10,7 +11,8 @@ namespace Volo.Abp.Cli
public static string Root => Path.Combine(AbpRootPath, "cli");
public static string AccessToken => Path.Combine(AbpRootPath, "cli", "access-token.bin");
public static string Build => Path.Combine(AbpRootPath, "build");
-
+ public static string Lic => Path.Combine(Path.GetTempPath(), Encoding.ASCII.GetString(new byte[] { 65, 98, 112, 76, 105, 99, 101, 110, 115, 101, 46, 98, 105, 110 }));
+
private static readonly string AbpRootPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".abp");
}
-}
+}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigrator.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigrator.cs
index 0a79b7760a..982ef77065 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigrator.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CreateMigrationAndRunMigrator.cs
@@ -26,12 +26,16 @@ namespace Volo.Abp.Cli.Commands
throw new Exception("DbMigrator is not found!");
}
- var output = CmdHelper.RunCmdAndGetOutput("cd \"" + commandLineArgs.Target + "\" && dotnet ef migrations add Initial -s " + dbMigratorProjectPath);
+ var output = CmdHelper.RunCmdAndGetOutput($"cd \"{commandLineArgs.Target}\" && dotnet ef migrations add Initial -s \"{dbMigratorProjectPath}\"");
if (output.Contains("Done.") && output.Contains("To undo this action") && output.Contains("ef migrations remove")) // Migration added successfully
{
CmdHelper.RunCmd("cd \"" + Path.GetDirectoryName(dbMigratorProjectPath) + "\" && dotnet run");
}
+ else
+ {
+ throw new Exception("Migrations failed: " + output);
+ }
}
private string GetDbMigratorProjectPath(string dbMigrationsFolderPath)
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
index 12810aebb9..f03c101c88 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
@@ -22,13 +22,17 @@ namespace Volo.Abp.Cli.Commands
public ICancellationTokenProvider CancellationTokenProvider { get; }
public IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
+
public LoginCommand(AuthService authService,
ICancellationTokenProvider cancellationTokenProvider,
- IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
+ IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
+ CliHttpClientFactory cliHttpClientFactory)
{
AuthService = authService;
CancellationTokenProvider = cancellationTokenProvider;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
+ _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger.Instance;
}
@@ -79,20 +83,19 @@ namespace Volo.Abp.Cli.Commands
{
var url = $"{CliUrls.WwwAbpIo}api/license/check-multiple-organizations?username={username}";
- using (var client = new CliHttpClient())
+ var client = _cliHttpClientFactory.CreateClient();
+
+ using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger))
{
- using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger))
+ if (!response.IsSuccessStatusCode)
{
- if (!response.IsSuccessStatusCode)
- {
- throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'");
- }
+ throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'");
+ }
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
- var responseContent = await response.Content.ReadAsStringAsync();
- return JsonSerializer.Deserialize(responseContent);
- }
+ var responseContent = await response.Content.ReadAsStringAsync();
+ return JsonSerializer.Deserialize(responseContent);
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
index 55247c71bb..c82c434916 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/NewCommand.cs
@@ -12,11 +12,13 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Auth;
+using Volo.Abp.Cli.Commands.Services;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.ProjectBuilding;
using Volo.Abp.Cli.ProjectBuilding.Building;
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
using Volo.Abp.Cli.ProjectBuilding.Templates.Console;
+using Volo.Abp.Cli.ProjectBuilding.Templates.Microservice;
using Volo.Abp.Cli.ProjectModification;
using Volo.Abp.Cli.Utils;
using Volo.Abp.DependencyInjection;
@@ -31,14 +33,17 @@ namespace Volo.Abp.Cli.Commands
protected TemplateProjectBuilder TemplateProjectBuilder { get; }
public ITemplateInfoProvider TemplateInfoProvider { get; }
+ public ConnectionStringProvider ConnectionStringProvider { get; }
public NewCommand(TemplateProjectBuilder templateProjectBuilder
, ITemplateInfoProvider templateInfoProvider,
- EfCoreMigrationManager efCoreMigrationManager)
+ EfCoreMigrationManager efCoreMigrationManager,
+ ConnectionStringProvider connectionStringProvider)
{
_efCoreMigrationManager = efCoreMigrationManager;
TemplateProjectBuilder = templateProjectBuilder;
TemplateInfoProvider = templateInfoProvider;
+ ConnectionStringProvider = connectionStringProvider;
Logger = NullLogger.Instance;
}
@@ -164,7 +169,7 @@ namespace Volo.Abp.Cli.Commands
databaseManagementSystem != DatabaseManagementSystem.NotSpecified &&
databaseManagementSystem != DatabaseManagementSystem.SQLServer)
{
- connectionString = GetNewConnectionStringByDbms(databaseManagementSystem, outputFolder);
+ connectionString = ConnectionStringProvider.GetByDbms(databaseManagementSystem, outputFolder);
}
commandLineArgs.Options.Add(CliConsts.Command, commandLineArgs.Command);
@@ -226,8 +231,6 @@ namespace Volo.Abp.Cli.Commands
}
}
- DeleteMigrationsIfNeeded(databaseProvider, databaseManagementSystem, outputFolder);
-
Logger.LogInformation($"'{projectName}' has been successfully created to '{outputFolder}'");
@@ -236,41 +239,10 @@ namespace Volo.Abp.Cli.Commands
var isCommercial = template == AppProTemplate.TemplateName;
OpenThanksPage(uiFramework, databaseProvider, isTiered || commandLineArgs.Options.ContainsKey("separate-identity-server"), isCommercial);
}
- }
-
- private string GetNewConnectionStringByDbms(DatabaseManagementSystem databaseManagementSystem, string outputFolder)
- {
- switch (databaseManagementSystem)
- {
- case DatabaseManagementSystem.MySQL:
- return "Server=localhost;Port=3306;Database=MyProjectName;Uid=root;Pwd=myPassword;";
- case DatabaseManagementSystem.PostgreSQL:
- return "User ID=root;Password=myPassword;Host=localhost;Port=5432;Database=MyProjectName;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;";
- //case DatabaseManagementSystem.Oracle:
- case DatabaseManagementSystem.OracleDevart:
- return "Data Source=MyProjectName;Integrated Security=yes;";
- case DatabaseManagementSystem.SQLite:
- return $"Data Source={Path.Combine(outputFolder,"database\\MyProjectName.db")};Version=3;";
- default:
- return null;
- }
- }
-
- private void DeleteMigrationsIfNeeded(DatabaseProvider databaseProvider, DatabaseManagementSystem databaseManagementSystem, string outputFolder)
- {
- if (databaseManagementSystem == DatabaseManagementSystem.NotSpecified || databaseManagementSystem == DatabaseManagementSystem.SQLServer)
- {
- return;
- }
-
- if (databaseProvider != DatabaseProvider.NotSpecified && databaseProvider != DatabaseProvider.EntityFrameworkCore)
+ else if (MicroserviceTemplateBase.IsMicroserviceTemplate(template))
{
- return;
+ OpenMicroserviceDocumentPage();
}
-
- Logger.LogInformation($"Deleting migrations...");
-
- _efCoreMigrationManager.RemoveAllMigrations(outputFolder);
}
private void OpenThanksPage(UiFramework uiFramework, DatabaseProvider databaseProvider, bool tiered, bool commercial)
@@ -282,19 +254,14 @@ namespace Volo.Abp.Cli.Commands
var tieredYesNo = tiered ? "yes" : "no";
var url = $"https://{urlPrefix}.abp.io/project-created-success?ui={uiFramework:g}&db={databaseProvider:g}&tiered={tieredYesNo}";
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- url = url.Replace("&", "^&");
- Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
- }
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
- {
- Process.Start("xdg-open", url);
- }
- else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
- {
- Process.Start("open", url);
- }
+ CmdHelper.OpenWebPage(url);
+ }
+
+ private void OpenMicroserviceDocumentPage()
+ {
+ var url = "https://docs.abp.io/en/commercial/latest/startup-templates/microservice/index";
+
+ CmdHelper.OpenWebPage(url);
}
private bool GetCreateSolutionFolderPreference(CommandLineArgs commandLineArgs)
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs
new file mode 100644
index 0000000000..b0da7f9db0
--- /dev/null
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/Services/ConnectionStringProvider.cs
@@ -0,0 +1,30 @@
+using System.IO;
+using Volo.Abp.Cli.ProjectBuilding.Building;
+using Volo.Abp.DependencyInjection;
+
+namespace Volo.Abp.Cli.Commands.Services
+{
+ public class ConnectionStringProvider : ITransientDependency
+ {
+ public string GetByDbms(DatabaseManagementSystem databaseManagementSystem, string outputFolder = "")
+ {
+ switch (databaseManagementSystem)
+ {
+ case DatabaseManagementSystem.NotSpecified:
+ case DatabaseManagementSystem.SQLServer:
+ return "Server=localhost;Database=MyProjectName;Trusted_Connection=True";
+ case DatabaseManagementSystem.MySQL:
+ return "Server=localhost;Port=3306;Database=MyProjectName;Uid=root;Pwd=myPassword;";
+ case DatabaseManagementSystem.PostgreSQL:
+ return "Host=localhost;Port=5432;Database=MyProjectName;User ID=root;Password=myPassword;Pooling=true;MinimumPoolSize=0;MaximumPoolSize=100;Connection Lifetime=0;";
+ //case DatabaseManagementSystem.Oracle:
+ case DatabaseManagementSystem.OracleDevart:
+ return "Data Source=MyProjectName;Integrated Security=yes;";
+ case DatabaseManagementSystem.SQLite:
+ return $"Data Source={Path.Combine(outputFolder , "MyProjectName.db")};".Replace("\\", "\\\\");
+ default:
+ return null;
+ }
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClientExtensions.cs
similarity index 73%
rename from framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs
rename to framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClientExtensions.cs
index d853067abf..9976542f05 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClient.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClientExtensions.cs
@@ -13,29 +13,9 @@ using Microsoft.Extensions.Logging;
namespace Volo.Abp.Cli.Http
{
- public class CliHttpClient : HttpClient
+ public static class CliHttpClientExtensions
{
- public static TimeSpan DefaultTimeout { get; set; } = TimeSpan.FromMinutes(1);
-
- public CliHttpClient(TimeSpan? timeout = null)
- : base(new CliHttpClientHandler())
- {
- Timeout = timeout ?? DefaultTimeout;
-
- AddAuthentication(this);
- }
-
- public CliHttpClient(bool setBearerToken) : base(new CliHttpClientHandler())
- {
- Timeout = DefaultTimeout;
-
- if (setBearerToken)
- {
- AddAuthentication(this);
- }
- }
-
- private static void AddAuthentication(HttpClient client)
+ public static void AddAbpAuthenticationToken(this HttpClient httpClient)
{
if (!AuthService.IsLoggedIn())
{
@@ -45,12 +25,13 @@ namespace Volo.Abp.Cli.Http
var accessToken = File.ReadAllText(CliPaths.AccessToken, Encoding.UTF8);
if (!accessToken.IsNullOrEmpty())
{
- client.SetBearerToken(accessToken);
+ httpClient.SetBearerToken(accessToken);
}
}
- public async Task GetHttpResponseMessageWithRetryAsync
+ public static async Task GetHttpResponseMessageWithRetryAsync
(
+ this HttpClient httpClient,
string url,
CancellationToken? cancellationToken = null,
ILogger logger = null,
@@ -67,7 +48,12 @@ namespace Volo.Abp.Cli.Http
};
}
- cancellationToken ??= CancellationToken.None;
+ if (cancellationToken == null)
+ {
+ var cancellationTokenSource = new CancellationTokenSource();
+ cancellationTokenSource.CancelAfter(httpClient.Timeout);
+ cancellationToken = cancellationTokenSource.Token;
+ }
return await HttpPolicyExtensions
.HandleTransientHttpError()
@@ -92,8 +78,7 @@ namespace Volo.Abp.Cli.Http
$"Waiting {timeSpan.TotalSeconds} secs for the next try...");
}
})
- .ExecuteAsync(async () => await this.GetAsync(url, cancellationToken.Value));
+ .ExecuteAsync(async () => await httpClient.GetAsync(url, cancellationToken.Value));
}
-
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClientFactory.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClientFactory.cs
new file mode 100644
index 0000000000..a5608a1f88
--- /dev/null
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Http/CliHttpClientFactory.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Net.Http;
+using System.Threading;
+using Volo.Abp.DependencyInjection;
+using Volo.Abp.Threading;
+
+namespace Volo.Abp.Cli.Http
+{
+ public class CliHttpClientFactory : ISingletonDependency
+ {
+ public static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes(1);
+
+ private readonly IHttpClientFactory _clientFactory;
+ private readonly ICancellationTokenProvider _cancellationTokenProvider;
+
+ public CliHttpClientFactory(IHttpClientFactory clientFactory, ICancellationTokenProvider cancellationTokenProvider)
+ {
+ _clientFactory = clientFactory;
+ _cancellationTokenProvider = cancellationTokenProvider;
+ }
+
+ public HttpClient CreateClient(bool needsAuthentication = true, TimeSpan? timeout = null)
+ {
+ var httpClient = _clientFactory.CreateClient(CliConsts.HttpClientName);
+ httpClient.Timeout = timeout ?? DefaultTimeout;
+
+ if (needsAuthentication)
+ {
+ httpClient.AddAbpAuthenticationToken();
+ }
+
+ return httpClient;
+ }
+
+ public CancellationToken GetCancellationToken(TimeSpan? timeout = null)
+ {
+ if (timeout == null)
+ {
+ if (_cancellationTokenProvider == null)
+ {
+ var cancellationTokenSource = new CancellationTokenSource();
+ cancellationTokenSource.CancelAfter(DefaultTimeout);
+ return cancellationTokenSource.Token;
+ }
+ else
+ {
+ return _cancellationTokenProvider.Token;
+ }
+ }
+ else
+ {
+ var cancellationTokenSource = new CancellationTokenSource();
+ cancellationTokenSource.CancelAfter(Convert.ToInt32(timeout.Value.TotalMilliseconds));
+ return cancellationTokenSource.Token;
+ }
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
index 2aeb8ed90a..5ff4d39d4f 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Licensing/AbpIoApiKeyService.cs
@@ -25,16 +25,19 @@ namespace Volo.Abp.Cli.Licensing
private readonly ILogger _logger;
private DeveloperApiKeyResult _apiKeyResult = null;
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
public AbpIoApiKeyService(
IJsonSerializer jsonSerializer,
ICancellationTokenProvider cancellationTokenProvider,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
- ILogger logger)
+ ILogger logger,
+ CliHttpClientFactory cliHttpClientFactory)
{
JsonSerializer = jsonSerializer;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
_logger = logger;
+ _cliHttpClientFactory = cliHttpClientFactory;
CancellationTokenProvider = cancellationTokenProvider;
}
@@ -56,22 +59,21 @@ namespace Volo.Abp.Cli.Licensing
}
var url = $"{CliUrls.WwwAbpIo}api/license/api-key";
+ var client = _cliHttpClientFactory.CreateClient();
- using (var client = new CliHttpClient())
+ using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, _logger))
{
- using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, _logger))
+ if (!response.IsSuccessStatusCode)
{
- if (!response.IsSuccessStatusCode)
- {
- throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'");
- }
+ throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'");
+ }
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
- var responseContent = await response.Content.ReadAsStringAsync();
- return JsonSerializer.Deserialize(responseContent);
- }
+ var responseContent = await response.Content.ReadAsStringAsync();
+ return JsonSerializer.Deserialize(responseContent);
}
+
}
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs
index 057ffcc02d..7907baaa2d 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/NuGet/NuGetService.cs
@@ -23,6 +23,7 @@ namespace Volo.Abp.Cli.NuGet
protected ICancellationTokenProvider CancellationTokenProvider { get; }
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
private readonly IApiKeyService _apiKeyService;
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
private List _proPackageList;
private DeveloperApiKeyResult _apiKeyResult;
@@ -30,12 +31,14 @@ namespace Volo.Abp.Cli.NuGet
IJsonSerializer jsonSerializer,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
ICancellationTokenProvider cancellationTokenProvider,
- IApiKeyService apiKeyService)
+ IApiKeyService apiKeyService,
+ CliHttpClientFactory cliHttpClientFactory)
{
JsonSerializer = jsonSerializer;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
CancellationTokenProvider = cancellationTokenProvider;
_apiKeyService = apiKeyService;
+ _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger.Instance;
}
@@ -93,18 +96,17 @@ namespace Volo.Abp.Cli.NuGet
url = $"https://api.nuget.org/v3-flatcontainer/{packageId.ToLowerInvariant()}/index.json";
}
- using (var client = new CliHttpClient(setBearerToken: false))
+ var client = _cliHttpClientFactory.CreateClient(needsAuthentication: false);
+
+ using (var responseMessage = await client.GetHttpResponseMessageWithRetryAsync(
+ url,
+ cancellationToken: CancellationTokenProvider.Token,
+ logger: Logger
+ ))
{
- using (var responseMessage = await client.GetHttpResponseMessageWithRetryAsync(
- url,
- cancellationToken: CancellationTokenProvider.Token,
- logger: Logger
- ))
- {
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
- var responseContent = await responseMessage.Content.ReadAsStringAsync();
- return JsonSerializer.Deserialize(responseContent).Versions;
- }
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
+ var responseContent = await responseMessage.Content.ReadAsStringAsync();
+ return JsonSerializer.Deserialize(responseContent).Versions;
}
}
@@ -120,9 +122,8 @@ namespace Volo.Abp.Cli.NuGet
private async Task> GetProPackageListAsync()
{
- using var client = new CliHttpClient();
-
var url = $"{CliUrls.WwwAbpIo}api/app/nugetPackage/proPackageNames";
+ var client = _cliHttpClientFactory.CreateClient(needsAuthentication: true);
using (var responseMessage = await client.GetHttpResponseMessageWithRetryAsync(
url: url,
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
index 0462920fbb..bebe44542d 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/AbpIoSourceCodeStore.cs
@@ -9,6 +9,7 @@ using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
+using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Cli.Http;
using Volo.Abp.Cli.ProjectBuilding.Templates.App;
@@ -28,22 +29,23 @@ namespace Volo.Abp.Cli.ProjectBuilding
public ILogger Logger { get; set; }
protected AbpCliOptions Options { get; }
-
protected IJsonSerializer JsonSerializer { get; }
-
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
-
protected ICancellationTokenProvider CancellationTokenProvider { get; }
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
+
public AbpIoSourceCodeStore(
IOptions options,
IJsonSerializer jsonSerializer,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
- ICancellationTokenProvider cancellationTokenProvider)
+ ICancellationTokenProvider cancellationTokenProvider,
+ CliHttpClientFactory cliHttpClientFactory)
{
JsonSerializer = jsonSerializer;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
CancellationTokenProvider = cancellationTokenProvider;
+ _cliHttpClientFactory = cliHttpClientFactory;
Options = options.Value;
Logger = NullLogger.Instance;
@@ -134,24 +136,17 @@ namespace Volo.Abp.Cli.ProjectBuilding
try
{
- using (var client = new CliHttpClient(TimeSpan.FromMinutes(10)))
+ var client = _cliHttpClientFactory.CreateClient();
+ var stringContent = new StringContent(
+ JsonSerializer.Serialize(new GetLatestSourceCodeVersionDto { Name = name, IncludePreReleases = includePreReleases }),
+ Encoding.UTF8,
+ MimeTypes.Application.Json
+ );
+
+ using (var response = await client.PostAsync(url, stringContent, _cliHttpClientFactory.GetCancellationToken(TimeSpan.FromMinutes(10))))
{
- var response = await client.PostAsync(
- url,
- new StringContent(
- JsonSerializer.Serialize(
- new GetLatestSourceCodeVersionDto { Name = name, IncludePreReleases = includePreReleases }
- ),
- Encoding.UTF8,
- MimeTypes.Application.Json
- ),
- CancellationTokenProvider.Token
- );
-
await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
-
var result = await response.Content.ReadAsStringAsync();
-
return JsonSerializer.Deserialize(result).Version;
}
}
@@ -164,32 +159,25 @@ namespace Volo.Abp.Cli.ProjectBuilding
private async Task GetTemplateNugetVersionAsync(string name, string type, string version)
{
- var url = $"{CliUrls.WwwAbpIo}api/download/{type}/get-nuget-version/";
-
try
{
- using (var client = new CliHttpClient(TimeSpan.FromMinutes(10)))
- {
- var response = await client.PostAsync(
- url,
- new StringContent(
- JsonSerializer.Serialize(
- new GetTemplateNugetVersionDto { Name = name, Version = version}
- ),
- Encoding.UTF8,
- MimeTypes.Application.Json
- ),
- CancellationTokenProvider.Token
- );
+ var url = $"{CliUrls.WwwAbpIo}api/download/{type}/get-nuget-version/";
+ var client = _cliHttpClientFactory.CreateClient();
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
+ var stringContent = new StringContent(
+ JsonSerializer.Serialize(new GetTemplateNugetVersionDto { Name = name, Version = version }),
+ Encoding.UTF8,
+ MimeTypes.Application.Json
+ );
+ using (var response = await client.PostAsync(url, stringContent, _cliHttpClientFactory.GetCancellationToken(TimeSpan.FromMinutes(10))))
+ {
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
var result = await response.Content.ReadAsStringAsync();
-
return JsonSerializer.Deserialize(result).Version;
}
}
- catch (Exception ex)
+ catch (Exception)
{
return null;
}
@@ -199,38 +187,39 @@ namespace Volo.Abp.Cli.ProjectBuilding
{
var url = $"{CliUrls.WwwAbpIo}api/download/{input.Type}/";
+ HttpResponseMessage responseMessage = null;
+
try
{
- using (var client = new CliHttpClient(TimeSpan.FromMinutes(10)))
- {
- HttpResponseMessage responseMessage;
+ var client = _cliHttpClientFactory.CreateClient();
- if (input.TemplateSource.IsNullOrWhiteSpace())
- {
- responseMessage = await client.PostAsync(
- url,
- new StringContent(JsonSerializer.Serialize(input), Encoding.UTF8, MimeTypes.Application.Json),
- CancellationTokenProvider.Token
- );
- }
- else
- {
- responseMessage = await client.GetAsync(input.TemplateSource, CancellationTokenProvider.Token);
- }
+ if (input.TemplateSource.IsNullOrWhiteSpace())
+ {
+ responseMessage = await client.PostAsync(
+ url,
+ new StringContent(JsonSerializer.Serialize(input), Encoding.UTF8, MimeTypes.Application.Json),
+ _cliHttpClientFactory.GetCancellationToken(TimeSpan.FromMinutes(10))
+ );
+ }
+ else
+ {
+ responseMessage = await client.GetAsync(input.TemplateSource, _cliHttpClientFactory.GetCancellationToken());
+ }
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
+ var resultAsBytes = await responseMessage.Content.ReadAsByteArrayAsync();
+ responseMessage.Dispose();
- return await responseMessage.Content.ReadAsByteArrayAsync();
- }
+ return resultAsBytes;
}
catch (Exception ex)
{
- Console.WriteLine("Error occured while downloading source-code from {0} : {1}", url, ex.Message);
+ Console.WriteLine("Error occured while downloading source-code from {0} : {1}{2}{3}", url, responseMessage?.ToString(), Environment.NewLine, ex.Message);
throw;
}
}
- private bool IsNetworkSource(string source)
+ private static bool IsNetworkSource(string source)
{
return source.ToLower().StartsWith("http");
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs
index 621631af2a..e97d7443d4 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Analyticses/CliAnalyticsCollect.cs
@@ -18,15 +18,18 @@ namespace Volo.Abp.Cli.ProjectBuilding.Analyticses
private readonly IJsonSerializer _jsonSerializer;
private readonly ILogger _logger;
private readonly IRemoteServiceExceptionHandler _remoteServiceExceptionHandler;
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
public CliAnalyticsCollect(
ICancellationTokenProvider cancellationTokenProvider,
IJsonSerializer jsonSerializer,
- IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
+ IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
+ CliHttpClientFactory cliHttpClientFactory)
{
_cancellationTokenProvider = cancellationTokenProvider;
_jsonSerializer = jsonSerializer;
_remoteServiceExceptionHandler = remoteServiceExceptionHandler;
+ _cliHttpClientFactory = cliHttpClientFactory;
_logger = NullLogger.Instance;
}
@@ -34,32 +37,31 @@ namespace Volo.Abp.Cli.ProjectBuilding.Analyticses
{
var postData = _jsonSerializer.Serialize(input);
var url = $"{CliUrls.WwwAbpIo}api/clianalytics/collect";
-
+
try
{
- using (var client = new CliHttpClient())
- {
- var responseMessage = await client.PostAsync(
- url,
- new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json),
- _cancellationTokenProvider.Token
- );
+ var client = _cliHttpClientFactory.CreateClient();
- if (!responseMessage.IsSuccessStatusCode)
- {
- var exceptionMessage = "Remote server returns '" + (int)responseMessage.StatusCode + "-" + responseMessage.ReasonPhrase + "'. ";
- var remoteServiceErrorMessage = await _remoteServiceExceptionHandler.GetAbpRemoteServiceErrorAsync(responseMessage);
+ var responseMessage = await client.PostAsync(
+ url,
+ new StringContent(postData, Encoding.UTF8, MimeTypes.Application.Json),
+ _cancellationTokenProvider.Token
+ );
- if (remoteServiceErrorMessage != null)
- {
- exceptionMessage += remoteServiceErrorMessage;
- }
+ if (!responseMessage.IsSuccessStatusCode)
+ {
+ var exceptionMessage = "Remote server returns '" + (int)responseMessage.StatusCode + "-" + responseMessage.ReasonPhrase + "'. ";
+ var remoteServiceErrorMessage = await _remoteServiceExceptionHandler.GetAbpRemoteServiceErrorAsync(responseMessage);
- _logger.LogInformation(exceptionMessage);
+ if (remoteServiceErrorMessage != null)
+ {
+ exceptionMessage += remoteServiceErrorMessage;
}
+
+ _logger.LogInformation(exceptionMessage);
}
}
- catch (Exception ex)
+ catch (Exception)
{
// ignored
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleInfo.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleInfo.cs
index fadd830c93..1d8da0e3b1 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleInfo.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleInfo.cs
@@ -21,5 +21,9 @@
public bool AngularUi { get; set; }
public bool MvcUi { get; set; }
+
+ public bool BlazorUi { get; set; }
+
+ public bool IsFreeToActiveLicenseOwners { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemovePublicRedisStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemovePublicRedisStep.cs
index 94056cbf5a..1299f5b15d 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemovePublicRedisStep.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemovePublicRedisStep.cs
@@ -1,4 +1,5 @@
-using System.Linq;
+using System;
+using System.Linq;
using Volo.Abp.Cli.ProjectBuilding.Files;
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
@@ -12,6 +13,12 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
context.Files.FirstOrDefault(f => f.Name.EndsWith("MyCompanyName.MyProjectName.HttpApi.HostWithIds.csproj"))?.RemoveTemplateCodeIfNot("PUBLIC-REDIS");
context.Files.FirstOrDefault(f => f.Name.EndsWith("MyCompanyName.MyProjectName.HttpApi.Host.csproj"))?.RemoveTemplateCodeIfNot("PUBLIC-REDIS");
context.Files.FirstOrDefault(f => f.Name.EndsWith("MyProjectNameHttpApiHostModule.cs"))?.RemoveTemplateCodeIfNot("PUBLIC-REDIS");
+
+ var appSettingsFiles = context.Files.Where(f => f.Name.EndsWith("appSettings.json", StringComparison.InvariantCultureIgnoreCase)).ToList();
+ foreach (var appSettings in appSettingsFiles)
+ {
+ appSettings.RemoveTemplateCodeIfNot("PUBLIC-REDIS");
+ }
}
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenameStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenameStep.cs
index abdb9e45f5..ce2c8c3b2a 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenameStep.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/SolutionRenameStep.cs
@@ -54,10 +54,14 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
if (_companyName != null)
{
RenameHelper.RenameAll(_entries, _companyNamePlaceHolder, _companyName);
+ RenameHelper.RenameAll(_entries, _companyNamePlaceHolder.ToCamelCase(), _companyName.ToCamelCase());
+ RenameHelper.RenameAll(_entries, _companyNamePlaceHolder.ToKebabCase(), _companyName.ToKebabCase());
}
else
{
RenameHelper.RenameAll(_entries, _companyNamePlaceHolder + "." + _projectNamePlaceHolder, _projectNamePlaceHolder);
+ RenameHelper.RenameAll(_entries, _companyNamePlaceHolder.ToCamelCase() + "." + _projectNamePlaceHolder.ToCamelCase(), _projectNamePlaceHolder.ToCamelCase());
+ RenameHelper.RenameAll(_entries, _companyNamePlaceHolder.ToKebabCase() + "/" + _projectNamePlaceHolder.ToKebabCase(), _projectNamePlaceHolder.ToKebabCase());
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs
index 8942103873..8f17b90702 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/TemplateCodeDeleteStep.cs
@@ -8,7 +8,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps
{
foreach (var file in context.Files)
{
- if (file.Name.EndsWith(".cs") || file.Name.EndsWith(".csproj") || file.Name.EndsWith(".cshtml"))
+ if (file.Name.EndsWith(".cs") || file.Name.EndsWith(".csproj") || file.Name.EndsWith(".cshtml") || file.Name.EndsWith(".json"))
{
file.RemoveTemplateCode();
file.RemoveTemplateCodeMarkers();
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/TemplateProjectBuildPipelineBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/TemplateProjectBuildPipelineBuilder.cs
index 7642a7d697..8b7cfeb440 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/TemplateProjectBuildPipelineBuilder.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/TemplateProjectBuildPipelineBuilder.cs
@@ -17,12 +17,6 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building
pipeline.Steps.Add(new ProjectReferenceReplaceStep());
pipeline.Steps.Add(new TemplateCodeDeleteStep());
-
- if (context.BuildArgs.ConnectionString != null)
- {
- pipeline.Steps.Add(new ConnectionStringChangeStep());
- }
-
pipeline.Steps.Add(new SolutionRenameStep());
if (context.Template.Name == AppProTemplate.TemplateName ||
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ModuleInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ModuleInfoProvider.cs
index 81bc704151..92bbe728c0 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ModuleInfoProvider.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/ModuleInfoProvider.cs
@@ -16,14 +16,18 @@ namespace Volo.Abp.Cli.ProjectBuilding
public ICancellationTokenProvider CancellationTokenProvider { get; }
public IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
+
public ModuleInfoProvider(
IJsonSerializer jsonSerializer,
ICancellationTokenProvider cancellationTokenProvider,
- IRemoteServiceExceptionHandler remoteServiceExceptionHandler)
+ IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
+ CliHttpClientFactory cliHttpClientFactory)
{
JsonSerializer = jsonSerializer;
CancellationTokenProvider = cancellationTokenProvider;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
+ _cliHttpClientFactory = cliHttpClientFactory;
}
public async Task GetAsync(string name)
@@ -47,17 +51,16 @@ namespace Volo.Abp.Cli.ProjectBuilding
private async Task> GetModuleListInternalAsync()
{
- using (var client = new CliHttpClient())
+ var client = _cliHttpClientFactory.CreateClient();
+
+ using (var responseMessage = await client.GetAsync(
+ $"{CliUrls.WwwAbpIo}api/download/modules/",
+ CancellationTokenProvider.Token
+ ))
{
- using (var responseMessage = await client.GetAsync(
- $"{CliUrls.WwwAbpIo}api/download/modules/",
- CancellationTokenProvider.Token
- ))
- {
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
- var result = await responseMessage.Content.ReadAsStringAsync();
- return JsonSerializer.Deserialize>(result);
- }
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(responseMessage);
+ var result = await responseMessage.Content.ReadAsStringAsync();
+ return JsonSerializer.Deserialize>(result);
}
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateInfoProvider.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateInfoProvider.cs
index b9308dd707..1a4bf3c05a 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateInfoProvider.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/TemplateInfoProvider.cs
@@ -24,13 +24,17 @@ namespace Volo.Abp.Cli.ProjectBuilding
public IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
public AuthService AuthService { get; }
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
+
public TemplateInfoProvider(ICancellationTokenProvider cancellationTokenProvider,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
- AuthService authService)
+ AuthService authService,
+ CliHttpClientFactory cliHttpClientFactory)
{
CancellationTokenProvider = cancellationTokenProvider;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
AuthService = authService;
+ _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger.Instance;
}
@@ -76,21 +80,19 @@ namespace Volo.Abp.Cli.ProjectBuilding
try
{
var url = $"{CliUrls.WwwAbpIo}api/license/check-user";
+ var client = _cliHttpClientFactory.CreateClient();
- using (var client = new CliHttpClient())
+ using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger))
{
- using (var response = await client.GetHttpResponseMessageWithRetryAsync(url, CancellationTokenProvider.Token, Logger))
+ if (!response.IsSuccessStatusCode)
{
- if (!response.IsSuccessStatusCode)
- {
- throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'");
- }
+ throw new Exception($"ERROR: Remote server returns '{response.StatusCode}'");
+ }
- await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
+ await RemoteServiceExceptionHandler.EnsureSuccessfulHttpResponseAsync(response);
- var responseContent = await response.Content.ReadAsStringAsync();
- return JsonSerializer.Deserialize(responseContent);
- }
+ var responseContent = await response.Content.ReadAsStringAsync();
+ return JsonSerializer.Deserialize(responseContent);
}
}
catch (Exception)
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs
index 8f52e03203..2a596b73a7 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/App/AppTemplateBase.cs
@@ -26,13 +26,14 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
SwitchDatabaseProvider(context, steps);
DeleteUnrelatedProjects(context, steps);
+ RemoveMigrations(context, steps);
ConfigurePublicWebSite(context, steps);
RemoveUnnecessaryPorts(context, steps);
RandomizeSslPorts(context, steps);
RandomizeStringEncryption(context, steps);
UpdateNuGetConfig(context, steps);
+ ChangeConnectionString(context, steps);
CleanupFolderHierarchy(context, steps);
- RemoveMigrations(context, steps);
return steps;
}
@@ -139,7 +140,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
steps.Add(new ChangePublicAuthPortStep());
}
- if (context.BuildArgs.DatabaseProvider != DatabaseProvider.NotSpecified || context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore)
+ if (context.BuildArgs.DatabaseProvider != DatabaseProvider.NotSpecified && context.BuildArgs.DatabaseProvider != DatabaseProvider.EntityFrameworkCore)
{
steps.Add(new RemoveEfCoreDependencyFromPublicStep());
}
@@ -286,9 +287,18 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.App
}
}
+ private static void ChangeConnectionString(ProjectBuildContext context, List steps)
+ {
+ if (context.BuildArgs.ConnectionString != null)
+ {
+ steps.Add(new ConnectionStringChangeStep());
+ }
+ }
+
private static void CleanupFolderHierarchy(ProjectBuildContext context, List steps)
{
- if (context.BuildArgs.UiFramework == UiFramework.Mvc && context.BuildArgs.MobileApp == MobileApp.None)
+ if ((context.BuildArgs.UiFramework == UiFramework.Mvc || context.BuildArgs.UiFramework == UiFramework.Blazor) &&
+ context.BuildArgs.MobileApp == MobileApp.None)
{
steps.Add(new MoveFolderStep("/aspnet-core/", "/"));
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Microservice/MicroserviceTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Microservice/MicroserviceTemplateBase.cs
index 13bfe3433e..52ff3c9c91 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Microservice/MicroserviceTemplateBase.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Microservice/MicroserviceTemplateBase.cs
@@ -12,6 +12,11 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.Microservice
{
}
+ public static bool IsMicroserviceTemplate(string templateName)
+ {
+ return templateName == MicroserviceProTemplate.TemplateName;
+ }
+
public override IEnumerable GetCustomSteps(ProjectBuildContext context)
{
var steps = new List();
@@ -29,21 +34,17 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.Microservice
{
case UiFramework.None:
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web"));
- steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.WebGateway"));
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Blazor"));
steps.Add(new RemoveFolderStep("/angular"));
break;
case UiFramework.Angular:
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web"));
- steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.WebGateway"));
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Blazor"));
break;
-
case UiFramework.Blazor:
steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.Web"));
- steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.WebGateway"));
steps.Add(new RemoveFolderStep("/angular"));
break;
@@ -53,12 +54,6 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.Microservice
steps.Add(new RemoveFolderStep("/angular"));
break;
}
-
- if (!context.BuildArgs.PublicWebSite)
- {
- steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.PublicWeb"));
- steps.Add(new RemoveProjectFromSolutionStep("MyCompanyName.MyProjectName.PublicWebGateway"));
- }
}
private static void RandomizeStringEncryption(ProjectBuildContext context, List steps)
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Module/ModuleTemplateBase.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Module/ModuleTemplateBase.cs
index ef8385d479..e26e4a6d25 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Module/ModuleTemplateBase.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Templates/Module/ModuleTemplateBase.cs
@@ -19,6 +19,7 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.Module
DeleteUnrelatedProjects(context, steps);
RandomizeSslPorts(context, steps);
UpdateNuGetConfig(context, steps);
+ ChangeConnectionString(context, steps);
CleanupFolderHierarchy(context, steps);
return steps;
@@ -76,6 +77,15 @@ namespace Volo.Abp.Cli.ProjectBuilding.Templates.Module
private static void UpdateNuGetConfig(ProjectBuildContext context, List steps)
{
steps.Add(new UpdateNuGetConfigStep("/aspnet-core/NuGet.Config"));
+ steps.Add(new UpdateNuGetConfigStep("/NuGet.Config"));
+ }
+
+ private static void ChangeConnectionString(ProjectBuildContext context, List steps)
+ {
+ if (context.BuildArgs.ConnectionString != null)
+ {
+ steps.Add(new ConnectionStringChangeStep());
+ }
}
private void CleanupFolderHierarchy(ProjectBuildContext context, List steps)
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationManager.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationManager.cs
index b26ca1be90..b15ffaa274 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationManager.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/EfCoreMigrationManager.cs
@@ -27,28 +27,6 @@ namespace Volo.Abp.Cli.ProjectModification
GetStartupProjectOption(startupProject));
}
- public void RemoveAllMigrations(string solutionFolder)
- {
- if (Directory.Exists(Path.Combine(solutionFolder, "aspnet-core")))
- {
- solutionFolder = Path.Combine(solutionFolder, "aspnet-core");
- }
-
- var srcFolder = Path.Combine(solutionFolder, "src");
-
- var migrationsFolder = Directory.GetDirectories(srcFolder)
- .FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore.DbMigrations"));
-
- if (migrationsFolder != null)
- {
- Directory.Delete(Path.Combine(migrationsFolder, "Migrations"), true);
- }
- else
- {
- Logger.LogWarning("No migration found to delete.");
- }
- }
-
protected virtual string ParseModuleName(string fullModuleName)
{
var words = fullModuleName?.Split('.');
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs
index 75e9156ce0..5434ede83f 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/MyGetPackageListFinder.cs
@@ -6,17 +6,23 @@ using Microsoft.Extensions.Logging.Abstractions;
using Newtonsoft.Json;
using Volo.Abp.Cli.Http;
using Volo.Abp.DependencyInjection;
+using Volo.Abp.Threading;
namespace Volo.Abp.Cli.ProjectModification
{
public class MyGetPackageListFinder : ISingletonDependency
{
- private MyGetApiResponse _response;
-
public ILogger Logger { get; set; }
- public MyGetPackageListFinder()
+ private MyGetApiResponse _response;
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
+ protected ICancellationTokenProvider CancellationTokenProvider { get; }
+
+ public MyGetPackageListFinder(CliHttpClientFactory cliHttpClientFactory,
+ ICancellationTokenProvider cancellationTokenProvider)
{
+ _cliHttpClientFactory = cliHttpClientFactory;
+ CancellationTokenProvider = cancellationTokenProvider;
Logger = NullLogger.Instance;
}
@@ -29,18 +35,20 @@ namespace Volo.Abp.Cli.ProjectModification
try
{
- using (var client = new CliHttpClient(TimeSpan.FromMinutes(10)))
+ var client = _cliHttpClientFactory.CreateClient();
+
+ using (var responseMessage = await client.GetAsync(
+ $"{CliUrls.WwwAbpIo}api/myget/packages/",
+ _cliHttpClientFactory.GetCancellationToken(TimeSpan.FromMinutes(10))))
{
- var responseMessage = await client.GetAsync(
- $"{CliUrls.WwwAbpIo}api/myget/packages/"
+ _response = JsonConvert.DeserializeObject(
+ Encoding.Default.GetString(await responseMessage.Content.ReadAsByteArrayAsync())
);
-
- _response = JsonConvert.DeserializeObject(Encoding.Default.GetString(await responseMessage.Content.ReadAsByteArrayAsync()));
}
}
- catch (Exception)
+ catch (Exception ex)
{
- Logger.LogError("Unable to get latest preview version.");
+ Logger.LogError("Unable to get latest preview version. Error: " + ex.Message);
throw;
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
index d8571843fe..bf23bc3786 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NpmPackagesUpdater.cs
@@ -27,15 +27,18 @@ namespace Volo.Abp.Cli.ProjectModification
private readonly PackageJsonFileFinder _packageJsonFileFinder;
private readonly NpmGlobalPackagesChecker _npmGlobalPackagesChecker;
private readonly Dictionary _fileVersionStorage = new Dictionary();
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
public NpmPackagesUpdater(
PackageJsonFileFinder packageJsonFileFinder,
NpmGlobalPackagesChecker npmGlobalPackagesChecker,
- ICancellationTokenProvider cancellationTokenProvider)
+ ICancellationTokenProvider cancellationTokenProvider,
+ CliHttpClientFactory cliHttpClientFactory)
{
_packageJsonFileFinder = packageJsonFileFinder;
_npmGlobalPackagesChecker = npmGlobalPackagesChecker;
CancellationTokenProvider = cancellationTokenProvider;
+ _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger.Instance;
}
@@ -151,16 +154,14 @@ namespace Volo.Abp.Cli.ProjectModification
{
try
{
- using (var client = new CliHttpClient(TimeSpan.FromMinutes(1)))
+ var client = _cliHttpClientFactory.CreateClient();
+ using (var response = await client.GetHttpResponseMessageWithRetryAsync(
+ url: $"{CliUrls.WwwAbpIo}api/myget/apikey/",
+ cancellationToken: CancellationTokenProvider.Token,
+ logger: Logger
+ ))
{
- 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());
- }
+ return Encoding.Default.GetString(await response.Content.ReadAsByteArrayAsync());
}
}
catch (Exception)
@@ -345,11 +346,20 @@ namespace Volo.Abp.Cli.ProjectModification
protected virtual List GetPackageVersionList(JProperty package)
{
- var versionListAsJson = CmdHelper.RunCmdAndGetOutput($"npm show {package.Name} versions");
+ var output = CmdHelper.RunCmdAndGetOutput($"npm show {package.Name} versions --json");
+
+ var versionListAsJson = ExtractVersions(output);
+
return JsonConvert.DeserializeObject(versionListAsJson)
.OrderByDescending(SemanticVersion.Parse, new VersionComparer()).ToList();
}
+ protected virtual string ExtractVersions(string output)
+ {
+ var arrayStart = output.IndexOf('[');
+ return output.Substring(arrayStart, output.IndexOf(']') - arrayStart + 1);
+ }
+
protected virtual bool SpecifiedVersionExists(string version, JProperty package)
{
var versionList = GetPackageVersionList(package);
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NuGetPackageTarget.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NuGetPackageTarget.cs
index 10274f3528..68b6e4fb44 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NuGetPackageTarget.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/NuGetPackageTarget.cs
@@ -13,6 +13,7 @@
EntityFrameworkCore = 8,
MongoDB = 9,
SignalR = 10,
- Blazor = 11
+ Blazor = 11,
+ IdentityServer = 12
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectFinder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectFinder.cs
index 0c02f8cb87..0ac4bb2a51 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectFinder.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectFinder.cs
@@ -22,6 +22,8 @@ namespace Volo.Abp.Cli.ProjectModification
{
case NuGetPackageTarget.Web:
return FindProjectEndsWith(projectFiles, assemblyNames, ".Web");
+ case NuGetPackageTarget.IdentityServer:
+ return FindProjectEndsWith(projectFiles, assemblyNames, ".IdentityServer");
case NuGetPackageTarget.EntityFrameworkCore:
return FindProjectEndsWith(projectFiles, assemblyNames, ".EntityFrameworkCore");
case NuGetPackageTarget.MongoDB:
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNugetPackageAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNugetPackageAdder.cs
index ee736f3aa0..6ebcad2c08 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNugetPackageAdder.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/ProjectNugetPackageAdder.cs
@@ -21,13 +21,15 @@ namespace Volo.Abp.Cli.ProjectModification
public class ProjectNugetPackageAdder : ITransientDependency
{
public ILogger Logger { get; set; }
+ public BundleCommand BundleCommand { get; }
protected IJsonSerializer JsonSerializer { get; }
protected ProjectNpmPackageAdder NpmPackageAdder { get; }
protected DerivedClassFinder ModuleClassFinder { get; }
protected ModuleClassDependcyAdder ModuleClassDependcyAdder { get; }
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
- public BundleCommand BundleCommand { get; }
+
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
public ProjectNugetPackageAdder(
IJsonSerializer jsonSerializer,
@@ -35,7 +37,8 @@ namespace Volo.Abp.Cli.ProjectModification
DerivedClassFinder moduleClassFinder,
ModuleClassDependcyAdder moduleClassDependcyAdder,
IRemoteServiceExceptionHandler remoteServiceExceptionHandler,
- BundleCommand bundleCommand)
+ BundleCommand bundleCommand,
+ CliHttpClientFactory cliHttpClientFactory)
{
JsonSerializer = jsonSerializer;
NpmPackageAdder = npmPackageAdder;
@@ -43,6 +46,7 @@ namespace Volo.Abp.Cli.ProjectModification
ModuleClassDependcyAdder = moduleClassDependcyAdder;
RemoteServiceExceptionHandler = remoteServiceExceptionHandler;
BundleCommand = bundleCommand;
+ _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger.Instance;
}
@@ -121,7 +125,7 @@ namespace Volo.Abp.Cli.ProjectModification
private Task AddToCsprojManuallyAsync(string projectFile, NugetPackageInfo package, string version = null)
{
var projectFileContent = File.ReadAllText(projectFile);
- var doc = new XmlDocument() {PreserveWhitespace = true};
+ var doc = new XmlDocument() { PreserveWhitespace = true };
doc.Load(StreamHelper.GenerateStreamFromString(projectFileContent));
var itemGroupNodes = doc.SelectNodes("/Project/ItemGroup");
@@ -162,7 +166,7 @@ namespace Volo.Abp.Cli.ProjectModification
private string GetAbpVersionOrNull(string projectFileContent)
{
- var doc = new XmlDocument() {PreserveWhitespace = true};
+ var doc = new XmlDocument() { PreserveWhitespace = true };
doc.Load(StreamHelper.GenerateStreamFromString(projectFileContent));
@@ -173,12 +177,11 @@ namespace Volo.Abp.Cli.ProjectModification
protected virtual async Task FindNugetPackageInfoAsync(string packageName)
{
- using (var client = new CliHttpClient())
- {
- var url = $"{CliUrls.WwwAbpIo}api/app/nugetPackage/byName/?name=" + packageName;
-
- var response = await client.GetAsync(url);
+ var url = $"{CliUrls.WwwAbpIo}api/app/nugetPackage/byName/?name=" + packageName;
+ var client = _cliHttpClientFactory.CreateClient();
+ using (var response = await client.GetAsync(url, _cliHttpClientFactory.GetCancellationToken()))
+ {
if (!response.IsSuccessStatusCode)
{
if (response.StatusCode == HttpStatusCode.NotFound)
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs
index 90f4ff5d8f..c84713ffcb 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectModification/SolutionModuleAdder.cs
@@ -7,7 +7,6 @@ using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
-using Volo.Abp.Cli.Bundling;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Cli.Commands.Services;
using Volo.Abp.Cli.Http;
@@ -22,6 +21,12 @@ namespace Volo.Abp.Cli.ProjectModification
public class SolutionModuleAdder : ITransientDependency
{
public ILogger Logger { get; set; }
+ public SourceCodeDownloadService SourceCodeDownloadService { get; }
+ public SolutionFileModifier SolutionFileModifier { get; }
+ public NugetPackageToLocalReferenceConverter NugetPackageToLocalReferenceConverter { get; }
+ public AngularModuleSourceCodeAdder AngularModuleSourceCodeAdder { get; }
+ public NewCommand NewCommand { get; }
+ public BundleCommand BundleCommand { get; }
protected IJsonSerializer JsonSerializer { get; }
protected ProjectNugetPackageAdder ProjectNugetPackageAdder { get; }
@@ -31,12 +36,9 @@ namespace Volo.Abp.Cli.ProjectModification
protected ProjectNpmPackageAdder ProjectNpmPackageAdder { get; }
protected NpmGlobalPackagesChecker NpmGlobalPackagesChecker { get; }
protected IRemoteServiceExceptionHandler RemoteServiceExceptionHandler { get; }
- public SourceCodeDownloadService SourceCodeDownloadService { get; }
- public SolutionFileModifier SolutionFileModifier { get; }
- public NugetPackageToLocalReferenceConverter NugetPackageToLocalReferenceConverter { get; }
- public AngularModuleSourceCodeAdder AngularModuleSourceCodeAdder { get; }
- public NewCommand NewCommand { get; }
- public BundleCommand BundleCommand { get; }
+
+ private readonly CliHttpClientFactory _cliHttpClientFactory;
+
public SolutionModuleAdder(
IJsonSerializer jsonSerializer,
@@ -52,7 +54,8 @@ namespace Volo.Abp.Cli.ProjectModification
NugetPackageToLocalReferenceConverter nugetPackageToLocalReferenceConverter,
AngularModuleSourceCodeAdder angularModuleSourceCodeAdder,
NewCommand newCommand,
- BundleCommand bundleCommand)
+ BundleCommand bundleCommand,
+ CliHttpClientFactory cliHttpClientFactory)
{
JsonSerializer = jsonSerializer;
ProjectNugetPackageAdder = projectNugetPackageAdder;
@@ -68,6 +71,7 @@ namespace Volo.Abp.Cli.ProjectModification
AngularModuleSourceCodeAdder = angularModuleSourceCodeAdder;
NewCommand = newCommand;
BundleCommand = bundleCommand;
+ _cliHttpClientFactory = cliHttpClientFactory;
Logger = NullLogger.Instance;
}
@@ -131,7 +135,7 @@ namespace Volo.Abp.Cli.ProjectModification
{
var blazorProject = projectFiles.FirstOrDefault(f => f.EndsWith(".Blazor.csproj"));
- if (blazorProject == null || !module.NugetPackages.Any(np=> np.Target == NuGetPackageTarget.Blazor))
+ if (blazorProject == null || !module.NugetPackages.Any(np => np.Target == NuGetPackageTarget.Blazor))
{
return;
}
@@ -171,7 +175,7 @@ namespace Volo.Abp.Cli.ProjectModification
{
await RemoveProjectByTarget(module, moduleSolutionFile, NuGetPackageTarget.EntityFrameworkCore, isProjectTiered);
await RemoveProjectByPostFix(module, moduleSolutionFile, "test", ".EntityFrameworkCore.Tests");
- await ChangeDomainTestReferenceToMongoDB(module, moduleSolutionFile);
+ ChangeDomainTestReferenceToMongoDB(module, moduleSolutionFile);
}
}
@@ -211,7 +215,7 @@ namespace Volo.Abp.Cli.ProjectModification
return;
}
- var projectFolderPath = Directory.GetDirectories(srcPath).FirstOrDefault(d=> d.EndsWith(postFix));
+ var projectFolderPath = Directory.GetDirectories(srcPath).FirstOrDefault(d => d.EndsWith(postFix));
if (projectFolderPath == null)
{
@@ -226,7 +230,7 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
- private async Task ChangeDomainTestReferenceToMongoDB(ModuleWithMastersInfo module, string moduleSolutionFile)
+ private void ChangeDomainTestReferenceToMongoDB(ModuleWithMastersInfo module, string moduleSolutionFile)
{
var testPath = Path.Combine(Path.GetDirectoryName(moduleSolutionFile), "test");
@@ -235,7 +239,7 @@ namespace Volo.Abp.Cli.ProjectModification
return;
}
- var projectFolderPath = Directory.GetDirectories(testPath).FirstOrDefault(d=> d.EndsWith("Domain.Tests"));
+ var projectFolderPath = Directory.GetDirectories(testPath).FirstOrDefault(d => d.EndsWith("Domain.Tests"));
if (projectFolderPath == null)
{
@@ -250,10 +254,10 @@ namespace Volo.Abp.Cli.ProjectModification
return;
}
- File.WriteAllText(csprojFile, File.ReadAllText(csprojFile).Replace("EntityFrameworkCore","MongoDB"));
+ File.WriteAllText(csprojFile, File.ReadAllText(csprojFile).Replace("EntityFrameworkCore", "MongoDB"));
File.WriteAllText(moduleFile, File.ReadAllText(moduleFile)
- .Replace(".EntityFrameworkCore;",".MongoDB;")
- .Replace("EntityFrameworkCoreTestModule","MongoDbTestModule"));
+ .Replace(".EntityFrameworkCore;", ".MongoDB;")
+ .Replace("EntityFrameworkCoreTestModule", "MongoDbTestModule"));
}
private async Task AddAngularPackages(string solutionFilePath, ModuleWithMastersInfo module)
@@ -355,9 +359,9 @@ namespace Volo.Abp.Cli.ProjectModification
);
}
- await DeleteRedundantHostProjects(targetModuleFolder,"app");
- await DeleteRedundantHostProjects(targetModuleFolder,"demo");
- await DeleteRedundantHostProjects(targetModuleFolder,"host");
+ await DeleteRedundantHostProjects(targetModuleFolder, "app");
+ await DeleteRedundantHostProjects(targetModuleFolder, "demo");
+ await DeleteRedundantHostProjects(targetModuleFolder, "host");
if (module.MasterModuleInfos == null)
{
@@ -501,7 +505,7 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
- protected virtual async Task RunMigrator(string[] projectFiles)
+ protected virtual void RunMigrator(string[] projectFiles)
{
var dbMigratorProject = projectFiles.FirstOrDefault(p => p.EndsWith(".DbMigrator.csproj"));
@@ -516,15 +520,14 @@ namespace Volo.Abp.Cli.ProjectModification
{
if (newTemplate || newProTemplate)
{
- return await GetEmptyModuleProjectInfoAsync(moduleName, newProTemplate);
+ return GetEmptyModuleProjectInfo(moduleName, newProTemplate);
}
- using (var client = new CliHttpClient())
- {
- var url = $"{CliUrls.WwwAbpIo}api/app/module/byNameWithDetails/?name=" + moduleName;
-
- var response = await client.GetAsync(url);
+ var url = $"{CliUrls.WwwAbpIo}api/app/module/byNameWithDetails/?name=" + moduleName;
+ var client = _cliHttpClientFactory.CreateClient();
+ using (var response = await client.GetAsync(url, _cliHttpClientFactory.GetCancellationToken()))
+ {
if (!response.IsSuccessStatusCode)
{
if (response.StatusCode == HttpStatusCode.NotFound)
@@ -540,7 +543,7 @@ namespace Volo.Abp.Cli.ProjectModification
}
}
- private async Task GetEmptyModuleProjectInfoAsync(string moduleName,
+ private ModuleWithMastersInfo GetEmptyModuleProjectInfo(string moduleName,
bool newProTemplate = false)
{
var module = new ModuleWithMastersInfo
@@ -625,7 +628,7 @@ namespace Volo.Abp.Cli.ProjectModification
protected virtual async Task IsProjectTiered(string[] projectFiles)
{
return projectFiles.Select(ProjectFileNameHelper.GetAssemblyNameFromProjectPath)
- .Any(p =>p.EndsWith(".HttpApi.Host"))
+ .Any(p => p.EndsWith(".HttpApi.Host"))
&& projectFiles.Select(ProjectFileNameHelper.GetAssemblyNameFromProjectPath)
.Any(p => p.EndsWith(".IdentityServer"));
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs
index 07052a8f48..07b470225a 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs
+++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Utils/CmdHelper.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using System.IO;
using System.Runtime.InteropServices;
namespace Volo.Abp.Cli.Utils
@@ -7,6 +8,23 @@ namespace Volo.Abp.Cli.Utils
{
public static int SuccessfulExitCode = 0;
+ public static void OpenWebPage(string url)
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ url = url.Replace("&", "^&");
+ Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") { CreateNoWindow = true });
+ }
+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ {
+ Process.Start("xdg-open", url);
+ }
+ else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ Process.Start("open", url);
+ }
+ }
+
public static void Run(string file, string arguments)
{
var procStartInfo = new ProcessStartInfo(file, arguments);
@@ -47,7 +65,7 @@ namespace Volo.Abp.Cli.Utils
{
process.StartInfo = new ProcessStartInfo(CmdHelper.GetFileName())
{
- Arguments = CmdHelper.GetArguments(command),
+ Arguments = GetArguments(command),
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardOutput = true,
@@ -86,14 +104,28 @@ namespace Volo.Abp.Cli.Utils
public static string GetFileName()
{
- if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ //Windows
+ return "cmd.exe";
+ }
+
+ //Linux or OSX
+ if (File.Exists("/bin/bash"))
{
- //TODO: Test this. it should work for both operation systems.
return "/bin/bash";
}
- //Windows default.
- return "cmd.exe";
+ if (File.Exists("/bin/sh"))
+ {
+ return "/bin/sh"; //some Linux distributions like Alpine doesn't have bash
+ }
+
+ throw new AbpException($"Cannot determine shell command for this OS! " +
+ $"Running on OS: {System.Runtime.InteropServices.RuntimeInformation.OSDescription} | " +
+ $"OS Architecture: {System.Runtime.InteropServices.RuntimeInformation.OSArchitecture} | " +
+ $"Framework: {System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription} | " +
+ $"Process Architecture{System.Runtime.InteropServices.RuntimeInformation.ProcessArchitecture}");
}
}
}
diff --git a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs
index b0544d0338..eb54a19900 100644
--- a/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs
+++ b/framework/src/Volo.Abp.Core/Volo/Abp/Modularity/PlugIns/FolderPlugInSource.cs
@@ -18,7 +18,7 @@ namespace Volo.Abp.Modularity.PlugIns
public Func Filter { get; set; }
public FolderPlugInSource(
- [NotNull] string folder,
+ [NotNull] string folder,
SearchOption searchOption = SearchOption.TopDirectoryOnly)
{
Check.NotNull(folder, nameof(folder));
@@ -52,7 +52,7 @@ namespace Volo.Abp.Modularity.PlugIns
return modules.ToArray();
}
- private IEnumerable GetAssemblies()
+ private List GetAssemblies()
{
var assemblyFiles = AssemblyHelper.GetAssemblyFiles(Folder, SearchOption);
@@ -61,7 +61,7 @@ namespace Volo.Abp.Modularity.PlugIns
assemblyFiles = assemblyFiles.Where(Filter);
}
- return assemblyFiles.Select(AssemblyLoadContext.Default.LoadFromAssemblyPath);
+ return assemblyFiles.Select(AssemblyLoadContext.Default.LoadFromAssemblyPath).ToList();
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataModule.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataModule.cs
index 8c9643012e..bc3bc8e5dd 100644
--- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataModule.cs
+++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDataModule.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Options;
using Volo.Abp.Modularity;
using Volo.Abp.ObjectExtending;
using Volo.Abp.Uow;
@@ -27,6 +28,14 @@ namespace Volo.Abp.Data
context.Services.AddSingleton(typeof(IDataFilter<>), typeof(DataFilter<>));
}
+ public override void PostConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.Databases.RefreshIndexes();
+ });
+ }
+
private static void AutoAddDataSeedContributors(IServiceCollection services)
{
var contributors = new List();
diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfo.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfo.cs
new file mode 100644
index 0000000000..4f719a862a
--- /dev/null
+++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfo.cs
@@ -0,0 +1,28 @@
+using System.Collections.Generic;
+
+namespace Volo.Abp.Data
+{
+ public class AbpDatabaseInfo
+ {
+ public string DatabaseName { get; set; }
+
+ ///
+ /// List of connection names mapped to this database.
+ ///
+ public HashSet MappedConnections { get; }
+
+ ///
+ /// Is this database used by tenants. Set this to true if this database
+ /// can't owned by tenants.
+ ///
+ /// Default: true.
+ ///
+ public bool IsUsedByTenants { get; set; } = true;
+
+ internal AbpDatabaseInfo(string databaseName)
+ {
+ DatabaseName = databaseName;
+ MappedConnections = new HashSet();
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs
new file mode 100644
index 0000000000..93098d303d
--- /dev/null
+++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDatabaseInfoDictionary.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+using JetBrains.Annotations;
+
+namespace Volo.Abp.Data
+{
+ public class AbpDatabaseInfoDictionary : Dictionary
+ {
+ private Dictionary ConnectionIndex { get; set; }
+
+ public AbpDatabaseInfoDictionary()
+ {
+ ConnectionIndex = new Dictionary();
+ }
+
+ [CanBeNull]
+ public AbpDatabaseInfo GetMappedDatabaseOrNull(string connectionStringName)
+ {
+ return ConnectionIndex.GetOrDefault(connectionStringName);
+ }
+
+ public AbpDatabaseInfoDictionary Configure(string databaseName, Action configureAction)
+ {
+ var databaseInfo = this.GetOrAdd(
+ databaseName,
+ () => new AbpDatabaseInfo(databaseName)
+ );
+
+ configureAction(databaseInfo);
+
+ return this;
+ }
+
+ ///
+ /// This method should be called if this dictionary changes.
+ /// It refreshes indexes for quick access to the connection informations.
+ ///
+ public void RefreshIndexes()
+ {
+ ConnectionIndex = new Dictionary();
+
+ foreach (var databaseInfo in Values)
+ {
+ foreach (var mappedConnection in databaseInfo.MappedConnections)
+ {
+ if (ConnectionIndex.ContainsKey(mappedConnection))
+ {
+ throw new AbpException(
+ $"A connection name can not map to multiple databases: {mappedConnection}."
+ );
+ }
+
+ ConnectionIndex[mappedConnection] = databaseInfo;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs
index 863bffb743..9f6ad78a69 100644
--- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs
+++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/AbpDbConnectionOptions.cs
@@ -1,12 +1,54 @@
-namespace Volo.Abp.Data
+using System;
+using System.Collections.Generic;
+
+namespace Volo.Abp.Data
{
public class AbpDbConnectionOptions
{
public ConnectionStrings ConnectionStrings { get; set; }
+
+ public AbpDatabaseInfoDictionary Databases { get; set; }
public AbpDbConnectionOptions()
{
ConnectionStrings = new ConnectionStrings();
+ Databases = new AbpDatabaseInfoDictionary();
+ }
+
+ public string GetConnectionStringOrNull(
+ string connectionStringName,
+ bool fallbackToDatabaseMappings = true,
+ bool fallbackToDefault = true)
+ {
+ var connectionString = ConnectionStrings.GetOrDefault(connectionStringName);
+ if (!connectionString.IsNullOrEmpty())
+ {
+ return connectionString;
+ }
+
+ if (fallbackToDatabaseMappings)
+ {
+ var database = Databases.GetMappedDatabaseOrNull(connectionStringName);
+ if (database != null)
+ {
+ connectionString = ConnectionStrings.GetOrDefault(database.DatabaseName);
+ if (!connectionString.IsNullOrEmpty())
+ {
+ return connectionString;
+ }
+ }
+ }
+
+ if (fallbackToDefault)
+ {
+ connectionString = ConnectionStrings.Default;
+ if (!connectionString.IsNullOrWhiteSpace())
+ {
+ return connectionString;
+ }
+ }
+
+ return null;
}
}
}
diff --git a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs
index 4d5ce2fb27..f907cb0cb6 100644
--- a/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs
+++ b/framework/src/Volo.Abp.Data/Volo/Abp/Data/DefaultConnectionStringResolver.cs
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
@@ -10,7 +9,8 @@ namespace Volo.Abp.Data
{
protected AbpDbConnectionOptions Options { get; }
- public DefaultConnectionStringResolver(IOptionsSnapshot options)
+ public DefaultConnectionStringResolver(
+ IOptionsSnapshot options)
{
Options = options.Value;
}
@@ -28,18 +28,19 @@ namespace Volo.Abp.Data
private string ResolveInternal(string connectionStringName)
{
- //Get module specific value if provided
- if (!connectionStringName.IsNullOrEmpty())
+ if (connectionStringName == null)
{
- var moduleConnString = Options.ConnectionStrings.GetOrDefault(connectionStringName);
- if (!moduleConnString.IsNullOrEmpty())
- {
- return moduleConnString;
- }
+ return Options.ConnectionStrings.Default;
+ }
+
+ var connectionString = Options.GetConnectionStringOrNull(connectionStringName);
+
+ if (!connectionString.IsNullOrEmpty())
+ {
+ return connectionString;
}
- //Get default value
- return Options.ConnectionStrings.Default;
+ return null;
}
}
-}
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs
index 232afb4280..4ac41663e4 100644
--- a/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs
+++ b/framework/src/Volo.Abp.Ddd.Application/Volo/Abp/Application/Services/ApplicationService.cs
@@ -35,6 +35,7 @@ namespace Volo.Abp.Application.Services
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
public static string[] CommonPostfixes { get; set; } = { "AppService", "ApplicationService", "Service" };
@@ -51,7 +52,7 @@ namespace Volo.Abp.Application.Services
? provider.GetRequiredService()
: (IObjectMapper) provider.GetRequiredService(typeof(IObjectMapper<>).MakeGenericType(ObjectMapperContext)));
- public IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
+ protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService();
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs
index c7f7230710..dbd46811f2 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/DependencyInjection/AbpCommonDbContextRegistrationOptions.cs
@@ -117,25 +117,5 @@ namespace Volo.Abp.DependencyInjection
CustomRepositories[entityType] = repositoryType;
}
-
- public bool ShouldRegisterDefaultRepositoryFor(Type entityType)
- {
- if (!RegisterDefaultRepositories)
- {
- return false;
- }
-
- if (CustomRepositories.ContainsKey(entityType))
- {
- return false;
- }
-
- if (!IncludeAllEntitiesForDefaultRepositories && !typeof(IAggregateRoot).IsAssignableFrom(entityType))
- {
- return false;
- }
-
- return true;
- }
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs
index 5e81e2270d..2f8dd28afc 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/EntityHelper.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using JetBrains.Annotations;
@@ -15,6 +13,17 @@ namespace Volo.Abp.Domain.Entities
///
public static class EntityHelper
{
+ public static bool IsMultiTenant()
+ where TEntity : IEntity
+ {
+ return IsMultiTenant(typeof(TEntity));
+ }
+
+ public static bool IsMultiTenant(Type type)
+ {
+ return typeof(IMultiTenant).IsAssignableFrom(type);
+ }
+
public static bool EntityEquals(IEntity entity1, IEntity entity2)
{
if (entity1 == null || entity2 == null)
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
index 3bda51bd2e..f1136c4ea2 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Repositories/IRepository.cs
@@ -20,8 +20,10 @@ namespace Volo.Abp.Domain.Repositories
{
///
/// Get a single entity by the given .
- /// It returns null if no entity with the given .
+ ///
+ /// It returns null if there is no entity with the given .
/// It throws if there are multiple entities with the given .
+ ///
///
/// A condition to find the entity
/// Set true to include all children of this entity
@@ -34,8 +36,10 @@ namespace Volo.Abp.Domain.Repositories
///
/// Get a single entity by the given .
+ ///
/// It throws if there is no entity with the given .
/// It throws if there are multiple entities with the given .
+ ///
///
/// A condition to filter entities
/// Set true to include all children of this entity
@@ -47,10 +51,11 @@ namespace Volo.Abp.Domain.Repositories
);
///
- /// Deletes many entities by function.
- /// Notice that: All entities fits to given predicate are retrieved and deleted.
- /// This may cause major performance problems if there are too many entities with
- /// given predicate.
+ /// Deletes many entities by the given .
+ ///
+ /// Please note: This may cause major performance problems if there are too many entities returned for a
+ /// given predicate and the database provider doesn't have a way to efficiently delete many entities.
+ ///
///
/// A condition to filter entities
///
@@ -69,4 +74,4 @@ namespace Volo.Abp.Domain.Repositories
where TEntity : class, IEntity
{
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs
index 751b938f1d..39938b081a 100644
--- a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs
+++ b/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Services/DomainService.cs
@@ -13,11 +13,12 @@ namespace Volo.Abp.Domain.Services
{
public IAbpLazyServiceProvider LazyServiceProvider { get; set; }
+ [Obsolete("Use LazyServiceProvider instead.")]
public IServiceProvider ServiceProvider { get; set; }
protected IClock Clock => LazyServiceProvider.LazyGetRequiredService();
- public IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
+ protected IGuidGenerator GuidGenerator => LazyServiceProvider.LazyGetService(SimpleGuidGenerator.Instance);
protected ILoggerFactory LoggerFactory => LazyServiceProvider.LazyGetRequiredService();
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj
index 8616838cc0..e8c90ccf13 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj
+++ b/framework/src/Volo.Abp.EntityFrameworkCore.PostgreSql/Volo.Abp.EntityFrameworkCore.PostgreSql.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpModelBuilderExtensions.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpModelBuilderExtensions.cs
index 7148cb69bd..1ccfee1506 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpModelBuilderExtensions.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Microsoft/EntityFrameworkCore/AbpModelBuilderExtensions.cs
@@ -1,10 +1,72 @@
using Volo.Abp.EntityFrameworkCore;
+using Volo.Abp.MultiTenancy;
namespace Microsoft.EntityFrameworkCore
{
public static class AbpModelBuilderExtensions
{
private const string ModelDatabaseProviderAnnotationKey = "_Abp_DatabaseProvider";
+ private const string ModelMultiTenancySideAnnotationKey = "_Abp_MultiTenancySide";
+
+ #region MultiTenancySide
+
+ public static void SetMultiTenancySide(
+ this ModelBuilder modelBuilder,
+ MultiTenancySides side)
+ {
+ modelBuilder.Model.SetAnnotation(ModelMultiTenancySideAnnotationKey, side);
+ }
+
+ public static MultiTenancySides GetMultiTenancySide(this ModelBuilder modelBuilder)
+ {
+ var value = modelBuilder.Model[ModelMultiTenancySideAnnotationKey];
+ if (value == null)
+ {
+ return MultiTenancySides.Both;
+ }
+
+ return (MultiTenancySides) value;
+ }
+
+ ///
+ /// Returns true if this is a database schema that is used by the host
+ /// but can also be shared with the tenants.
+ ///
+ public static bool IsHostDatabase(this ModelBuilder modelBuilder)
+ {
+ return modelBuilder.GetMultiTenancySide().HasFlag(MultiTenancySides.Host);
+ }
+
+ ///
+ /// Returns true if this is a database schema that is used by the tenants
+ /// but can also be shared with the host.
+ ///
+ public static bool IsTenantDatabase(this ModelBuilder modelBuilder)
+ {
+ return modelBuilder.GetMultiTenancySide().HasFlag(MultiTenancySides.Tenant);
+ }
+
+ ///
+ /// Returns true if this is a database schema that is only used by the host
+ /// and should not contain tenant-only tables.
+ ///
+ public static bool IsHostOnlyDatabase(this ModelBuilder modelBuilder)
+ {
+ return modelBuilder.GetMultiTenancySide() == MultiTenancySides.Host;
+ }
+
+ ///
+ /// Returns true if this is a database schema that is only used by tenants.
+ /// and should not contain host-only tables.
+ ///
+ public static bool IsTenantOnlyDatabase(this ModelBuilder modelBuilder)
+ {
+ return modelBuilder.GetMultiTenancySide() == MultiTenancySides.Tenant;
+ }
+
+ #endregion
+
+ #region DatabaseProvider
public static void SetDatabaseProvider(
this ModelBuilder modelBuilder,
@@ -61,7 +123,7 @@ namespace Microsoft.EntityFrameworkCore
{
modelBuilder.SetDatabaseProvider(EfCoreDatabaseProvider.InMemory);
}
-
+
public static bool IsUsingInMemory(
this ModelBuilder modelBuilder)
{
@@ -73,7 +135,7 @@ namespace Microsoft.EntityFrameworkCore
{
modelBuilder.SetDatabaseProvider(EfCoreDatabaseProvider.Cosmos);
}
-
+
public static bool IsUsingCosmos(
this ModelBuilder modelBuilder)
{
@@ -85,11 +147,13 @@ namespace Microsoft.EntityFrameworkCore
{
modelBuilder.SetDatabaseProvider(EfCoreDatabaseProvider.Firebird);
}
-
+
public static bool IsUsingFirebird(
this ModelBuilder modelBuilder)
{
return modelBuilder.GetDatabaseProvider() == EfCoreDatabaseProvider.Firebird;
}
+
+ #endregion
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
index 4ba5457677..d673ff2c28 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs
@@ -13,6 +13,7 @@ using Volo.Abp.Domain.Entities;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
using Volo.Abp.Guids;
+using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
{
@@ -21,18 +22,42 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
where TEntity : class, IEntity
{
[Obsolete("Use GetDbContextAsync() method.")]
- protected virtual TDbContext DbContext => _dbContextProvider.GetDbContext();
+ protected virtual TDbContext DbContext => GetDbContext();
[Obsolete("Use GetDbContextAsync() method.")]
- DbContext IEfCoreRepository.DbContext => DbContext.As();
+ DbContext IEfCoreRepository.DbContext => GetDbContext() as DbContext;
async Task IEfCoreRepository.GetDbContextAsync()
{
return await GetDbContextAsync() as DbContext;
}
+ [Obsolete("Use GetDbContextAsync() method.")]
+ private TDbContext GetDbContext()
+ {
+ // Multi-tenancy unaware entities should always use the host connection string
+ if (!EntityHelper.IsMultiTenant())
+ {
+ using (CurrentTenant.Change(null))
+ {
+ return _dbContextProvider.GetDbContext();
+ }
+ }
+
+ return _dbContextProvider.GetDbContext();
+ }
+
protected virtual Task GetDbContextAsync()
{
+ // Multi-tenancy unaware entities should always use the host connection string
+ if (!EntityHelper.IsMultiTenant())
+ {
+ using (CurrentTenant.Change(null))
+ {
+ return _dbContextProvider.GetDbContextAsync();
+ }
+ }
+
return _dbContextProvider.GetDbContextAsync();
}
@@ -264,10 +289,7 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore
.Where(predicate)
.ToListAsync(GetCancellationToken(cancellationToken));
- foreach (var entity in entities)
- {
- dbSet.Remove(entity);
- }
+ await DeleteManyAsync(entities, autoSave, cancellationToken);
if (autoSave)
{
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/DbContextOptionsFactory.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/DbContextOptionsFactory.cs
index 0147de12fb..c0603ec6f1 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/DbContextOptionsFactory.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/EntityFrameworkCore/DependencyInjection/DbContextOptionsFactory.cs
@@ -4,6 +4,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Volo.Abp.Data;
+using Volo.Abp.MultiTenancy;
namespace Volo.Abp.EntityFrameworkCore.DependencyInjection
{
@@ -86,16 +87,34 @@ namespace Volo.Abp.EntityFrameworkCore.DependencyInjection
}
var connectionStringName = ConnectionStringNameAttribute.GetConnStringName();
-
- //Use DefaultConnectionStringResolver.Resolve when we remove IConnectionStringResolver.Resolve
-#pragma warning disable 618
- var connectionString = serviceProvider.GetRequiredService().Resolve(connectionStringName);
-#pragma warning restore 618
+ var connectionString = ResolveConnectionString(serviceProvider, connectionStringName);
return new DbContextCreationContext(
connectionStringName,
connectionString
);
}
+
+ private static string ResolveConnectionString(
+ IServiceProvider serviceProvider,
+ string connectionStringName)
+ {
+ // Use DefaultConnectionStringResolver.Resolve when we remove IConnectionStringResolver.Resolve
+#pragma warning disable 618
+ var connectionStringResolver = serviceProvider.GetRequiredService();
+ var currentTenant = serviceProvider.GetRequiredService();
+
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (currentTenant.Change(null))
+ {
+ return connectionStringResolver.Resolve(connectionStringName);
+ }
+ }
+
+ return connectionStringResolver.Resolve(connectionStringName);
+#pragma warning restore 618
+ }
}
}
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs
index 99622dda96..ce9afacef1 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/EfCoreTransactionApi.cs
@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage;
using Volo.Abp.EntityFrameworkCore;
+using Volo.Abp.Threading;
namespace Volo.Abp.Uow.EntityFrameworkCore
{
@@ -14,22 +15,22 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
public IEfCoreDbContext StarterDbContext { get; }
public List AttendedDbContexts { get; }
- public EfCoreTransactionApi(IDbContextTransaction dbContextTransaction, IEfCoreDbContext starterDbContext)
+ protected ICancellationTokenProvider CancellationTokenProvider { get; }
+
+ public EfCoreTransactionApi(
+ IDbContextTransaction dbContextTransaction,
+ IEfCoreDbContext starterDbContext,
+ ICancellationTokenProvider cancellationTokenProvider)
{
DbContextTransaction = dbContextTransaction;
StarterDbContext = starterDbContext;
+ CancellationTokenProvider = cancellationTokenProvider;
AttendedDbContexts = new List();
}
- public Task CommitAsync()
- {
- Commit();
- return Task.CompletedTask;
- }
-
- protected void Commit()
+ public async Task CommitAsync()
{
- DbContextTransaction.Commit();
+ await DbContextTransaction.CommitAsync(CancellationTokenProvider.Token);
foreach (var dbContext in AttendedDbContexts)
{
@@ -38,7 +39,7 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
continue; //Relational databases use the shared transaction
}
- dbContext.Database.CommitTransaction();
+ await dbContext.Database.CommitTransactionAsync(CancellationTokenProvider.Token);
}
}
@@ -47,15 +48,19 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
DbContextTransaction.Dispose();
}
- public void Rollback()
+ public async Task RollbackAsync(CancellationToken cancellationToken)
{
- DbContextTransaction.Rollback();
- }
+ await DbContextTransaction.RollbackAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
- public Task RollbackAsync(CancellationToken cancellationToken)
- {
- DbContextTransaction.Rollback();
- return Task.CompletedTask;
+ foreach (var dbContext in AttendedDbContexts)
+ {
+ if (dbContext.As().HasRelationalTransactionManager())
+ {
+ continue; //Relational databases use the shared transaction
+ }
+
+ await dbContext.Database.RollbackTransactionAsync(CancellationTokenProvider.FallbackToProvider(cancellationToken));
+ }
}
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs
index 564a3ef8ad..89cc69fb74 100644
--- a/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs
+++ b/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Uow/EntityFrameworkCore/UnitOfWorkDbContextProvider.cs
@@ -9,6 +9,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.DependencyInjection;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
namespace Volo.Abp.Uow.EntityFrameworkCore
@@ -23,15 +24,18 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IConnectionStringResolver _connectionStringResolver;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
+ private readonly ICurrentTenant _currentTenant;
public UnitOfWorkDbContextProvider(
IUnitOfWorkManager unitOfWorkManager,
IConnectionStringResolver connectionStringResolver,
- ICancellationTokenProvider cancellationTokenProvider)
+ ICancellationTokenProvider cancellationTokenProvider,
+ ICurrentTenant currentTenant)
{
_unitOfWorkManager = unitOfWorkManager;
_connectionStringResolver = connectionStringResolver;
_cancellationTokenProvider = cancellationTokenProvider;
+ _currentTenant = currentTenant;
Logger = NullLogger>.Instance;
}
@@ -57,7 +61,7 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
}
var connectionStringName = ConnectionStringNameAttribute.GetConnStringName();
- var connectionString = _connectionStringResolver.Resolve(connectionStringName);
+ var connectionString = ResolveConnectionString(connectionStringName);
var dbContextKey = $"{typeof(TDbContext).FullName}_{connectionString}";
@@ -79,7 +83,7 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
}
var connectionStringName = ConnectionStringNameAttribute.GetConnStringName();
- var connectionString = await _connectionStringResolver.ResolveAsync(connectionStringName);
+ var connectionString = await ResolveConnectionStringAsync(connectionStringName);
var dbContextKey = $"{typeof(TDbContext).FullName}_{connectionString}";
@@ -168,7 +172,8 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
transactionApiKey,
new EfCoreTransactionApi(
dbtransaction,
- dbContext
+ dbContext,
+ _cancellationTokenProvider
)
);
@@ -186,7 +191,10 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
}
else
{
- dbContext.Database.BeginTransaction(); //TODO: Why not using the new created transaction?
+ /* No need to store the returning IDbContextTransaction for non-relational databases
+ * since EfCoreTransactionApi will handle the commit/rollback over the DbContext instance.
+ */
+ dbContext.Database.BeginTransaction();
}
activeTransaction.AttendedDbContexts.Add(dbContext);
@@ -212,7 +220,8 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
transactionApiKey,
new EfCoreTransactionApi(
dbTransaction,
- dbContext
+ dbContext,
+ _cancellationTokenProvider
)
);
@@ -230,7 +239,10 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
}
else
{
- await dbContext.Database.BeginTransactionAsync(GetCancellationToken()); //TODO: Why not using the new created transaction?
+ /* No need to store the returning IDbContextTransaction for non-relational databases
+ * since EfCoreTransactionApi will handle the commit/rollback over the DbContext instance.
+ */
+ await dbContext.Database.BeginTransactionAsync(GetCancellationToken());
}
activeTransaction.AttendedDbContexts.Add(dbContext);
@@ -239,6 +251,35 @@ namespace Volo.Abp.Uow.EntityFrameworkCore
}
}
+ private async Task ResolveConnectionStringAsync(string connectionStringName)
+ {
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (_currentTenant.Change(null))
+ {
+ return await _connectionStringResolver.ResolveAsync(connectionStringName);
+ }
+ }
+
+ return await _connectionStringResolver.ResolveAsync(connectionStringName);
+ }
+
+ [Obsolete("Use ResolveConnectionStringAsync method.")]
+ private string ResolveConnectionString(string connectionStringName)
+ {
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (_currentTenant.Change(null))
+ {
+ return _connectionStringResolver.Resolve(connectionStringName);
+ }
+ }
+
+ return _connectionStringResolver.Resolve(connectionStringName);
+ }
+
protected virtual CancellationToken GetCancellationToken(CancellationToken preferredValue = default)
{
return _cancellationTokenProvider.FallbackToProvider(preferredValue);
diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml
new file mode 100644
index 0000000000..bc5a74a236
--- /dev/null
+++ b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd
new file mode 100644
index 0000000000..3f3946e282
--- /dev/null
+++ b/framework/src/Volo.Abp.EventBus.Abstractions/FodyWeavers.xsd
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
+
+
+
+
+ A comma-separated list of error codes that can be safely ignored in assembly verification.
+
+
+
+
+ 'false' to turn off automatic generation of the XML Schema file.
+
+
+
+
+
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj b/framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj
new file mode 100644
index 0000000000..ae0cef7f59
--- /dev/null
+++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo.Abp.EventBus.Abstractions.csproj
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ netstandard2.0
+
+
+
+
+
+
+
+
diff --git a/framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs
similarity index 100%
rename from framework/src/Volo.Abp.Ddd.Domain/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs
rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/Domain/Entities/Events/Distributed/EtoBase.cs
diff --git a/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs
new file mode 100644
index 0000000000..bb9d4585b9
--- /dev/null
+++ b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/Abstractions/AbpEventBusAbstractionsModule.cs
@@ -0,0 +1,9 @@
+using Volo.Abp.Modularity;
+
+namespace Volo.Abp.EventBus.Abstractions
+{
+ public class AbpEventBusAbstractionsModule : AbpModule
+ {
+
+ }
+}
diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventNameAttribute.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/EventNameAttribute.cs
similarity index 100%
rename from framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/EventNameAttribute.cs
rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/EventNameAttribute.cs
diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/GenericEventNameAttribute.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/GenericEventNameAttribute.cs
similarity index 100%
rename from framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/GenericEventNameAttribute.cs
rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/GenericEventNameAttribute.cs
diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventNameProvider.cs b/framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/IEventNameProvider.cs
similarity index 100%
rename from framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/IEventNameProvider.cs
rename to framework/src/Volo.Abp.EventBus.Abstractions/Volo/Abp/EventBus/IEventNameProvider.cs
diff --git a/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj b/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj
index a1799c6673..221454bed3 100644
--- a/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj
+++ b/framework/src/Volo.Abp.EventBus/Volo.Abp.EventBus.csproj
@@ -15,7 +15,7 @@
-
+
diff --git a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs
index 81c3393a50..eb9c17b129 100644
--- a/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs
+++ b/framework/src/Volo.Abp.EventBus/Volo/Abp/EventBus/AbpEventBusModule.cs
@@ -1,6 +1,7 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
+using Volo.Abp.EventBus.Abstractions;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.EventBus.Local;
using Volo.Abp.Modularity;
@@ -9,7 +10,9 @@ using Volo.Abp.Reflection;
namespace Volo.Abp.EventBus
{
- [DependsOn(typeof(AbpMultiTenancyModule))]
+ [DependsOn(
+ typeof(AbpEventBusAbstractionsModule),
+ typeof(AbpMultiTenancyModule))]
public class AbpEventBusModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
diff --git a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs
index eb8c4eb804..6c0c8ef193 100644
--- a/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs
+++ b/framework/src/Volo.Abp.ExceptionHandling/Volo/Abp/AspNetCore/ExceptionHandling/DefaultExceptionToErrorInfoConverter.cs
@@ -141,7 +141,7 @@ namespace Volo.Abp.AspNetCore.ExceptionHandling
{
foreach (var key in exception.Data.Keys)
{
- localizedValue = localizedValue.Replace("{" + key + "}", exception.Data[key].ToString());
+ localizedValue = localizedValue.Replace("{" + key + "}", exception.Data[key]?.ToString());
}
}
diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Content/ReferencedRemoteStreamContent.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Content/ReferencedRemoteStreamContent.cs
deleted file mode 100644
index b99cec8a51..0000000000
--- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/Content/ReferencedRemoteStreamContent.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using System.IO;
-using Volo.Abp.Content;
-
-namespace Volo.Abp.Http.Client.Content
-{
- internal class ReferencedRemoteStreamContent : RemoteStreamContent
- {
- private readonly object[] _references;
-
- public ReferencedRemoteStreamContent(Stream stream, params object[] references)
- : base(stream)
- {
- this._references = references;
- }
- }
-}
diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs
index 9142118b97..7e90bd4fe7 100644
--- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs
+++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/ApiDescriptionFinder.cs
@@ -1,24 +1,38 @@
using System;
+using System.Globalization;
using System.Linq;
using System.Net.Http;
+using System.Net.Http.Headers;
using System.Reflection;
using System.Text.Json;
using System.Threading.Tasks;
+using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Modeling;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
+using Volo.Abp.Tracing;
namespace Volo.Abp.Http.Client.DynamicProxying
{
public class ApiDescriptionFinder : IApiDescriptionFinder, ITransientDependency
{
public ICancellationTokenProvider CancellationTokenProvider { get; set; }
-
protected IApiDescriptionCache Cache { get; }
-
- public ApiDescriptionFinder(IApiDescriptionCache cache)
+ protected AbpCorrelationIdOptions AbpCorrelationIdOptions { get; }
+ protected ICorrelationIdProvider CorrelationIdProvider { get; }
+ protected ICurrentTenant CurrentTenant { get; }
+
+ public ApiDescriptionFinder(
+ IApiDescriptionCache cache,
+ IOptions abpCorrelationIdOptions,
+ ICorrelationIdProvider correlationIdProvider,
+ ICurrentTenant currentTenant)
{
Cache = cache;
+ AbpCorrelationIdOptions = abpCorrelationIdOptions.Value;
+ CorrelationIdProvider = correlationIdProvider;
+ CurrentTenant = currentTenant;
CancellationTokenProvider = NullCancellationTokenProvider.Instance;
}
@@ -71,10 +85,19 @@ namespace Volo.Abp.Http.Client.DynamicProxying
return await Cache.GetAsync(baseUrl, () => GetApiDescriptionFromServerAsync(client, baseUrl));
}
- protected virtual async Task GetApiDescriptionFromServerAsync(HttpClient client, string baseUrl)
+ protected virtual async Task GetApiDescriptionFromServerAsync(
+ HttpClient client,
+ string baseUrl)
{
- var response = await client.GetAsync(
- baseUrl.EnsureEndsWith('/') + "api/abp/api-definition",
+ var requestMessage = new HttpRequestMessage(
+ HttpMethod.Get,
+ baseUrl.EnsureEndsWith('/') + "api/abp/api-definition"
+ );
+
+ AddHeaders(requestMessage);
+
+ var response = await client.SendAsync(
+ requestMessage,
CancellationTokenProvider.Token
);
@@ -93,6 +116,30 @@ namespace Volo.Abp.Http.Client.DynamicProxying
return (ApplicationApiDescriptionModel)result;
}
+ protected virtual void AddHeaders(HttpRequestMessage requestMessage)
+ {
+ //CorrelationId
+ requestMessage.Headers.Add(AbpCorrelationIdOptions.HttpHeaderName, CorrelationIdProvider.Get());
+
+ //TenantId
+ if (CurrentTenant.Id.HasValue)
+ {
+ //TODO: Use AbpAspNetCoreMultiTenancyOptions to get the key
+ requestMessage.Headers.Add(TenantResolverConsts.DefaultTenantKey, CurrentTenant.Id.Value.ToString());
+ }
+
+ //Culture
+ //TODO: Is that the way we want? Couldn't send the culture (not ui culture)
+ var currentCulture = CultureInfo.CurrentUICulture.Name ?? CultureInfo.CurrentCulture.Name;
+ if (!currentCulture.IsNullOrEmpty())
+ {
+ requestMessage.Headers.AcceptLanguage.Add(new StringWithQualityHeaderValue(currentCulture));
+ }
+
+ //X-Requested-With
+ requestMessage.Headers.Add("X-Requested-With", "XMLHttpRequest");
+ }
+
protected virtual bool TypeMatches(MethodParameterApiDescriptionModel actionParameter, ParameterInfo methodParameter)
{
return NormalizeTypeName(actionParameter.TypeAsString) ==
diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
index 7eb4e5ad78..136c9e42ef 100644
--- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
+++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/DynamicHttpProxyInterceptor.cs
@@ -14,7 +14,6 @@ using Volo.Abp.Content;
using Volo.Abp.DependencyInjection;
using Volo.Abp.DynamicProxy;
using Volo.Abp.Http.Client.Authentication;
-using Volo.Abp.Http.Client.Content;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Http.ProxyScripting.Generators;
using Volo.Abp.Json;
@@ -112,7 +111,10 @@ namespace Volo.Abp.Http.Client.DynamicProxying
/* returning a class that holds a reference to response
* content just to be sure that GC does not dispose of
* it before we finish doing our work with the stream */
- return (T)((object)new ReferencedRemoteStreamContent(await responseContent.ReadAsStreamAsync(), responseContent));
+ return (T)(object)new RemoteStreamContent(await responseContent.ReadAsStreamAsync())
+ {
+ ContentType = responseContent.Headers.ContentType?.ToString()
+ };
}
var stringContent = await responseContent.ReadAsStringAsync();
@@ -136,7 +138,13 @@ namespace Volo.Abp.Http.Client.DynamicProxying
var client = HttpClientFactory.Create(clientConfig.RemoteServiceName);
- var action = await ApiDescriptionFinder.FindActionAsync(client, remoteServiceConfig.BaseUrl, typeof(TService), invocation.Method);
+ var action = await ApiDescriptionFinder.FindActionAsync(
+ client,
+ remoteServiceConfig.BaseUrl,
+ typeof(TService),
+ invocation.Method
+ );
+
var apiVersion = GetApiVersionInfo(action);
var url = remoteServiceConfig.BaseUrl.EnsureEndsWith('/') + UrlBuilder.GenerateUrlWithParameters(action, invocation.ArgumentsDictionary, apiVersion);
@@ -156,9 +164,11 @@ namespace Volo.Abp.Http.Client.DynamicProxying
)
);
- var response = await client.SendAsync(requestMessage,
+ var response = await client.SendAsync(
+ requestMessage,
HttpCompletionOption.ResponseHeadersRead /*this will buffer only the headers, the content will be used as a stream*/,
- GetCancellationToken());
+ GetCancellationToken()
+ );
if (!response.IsSuccessStatusCode)
{
@@ -196,7 +206,11 @@ namespace Volo.Abp.Http.Client.DynamicProxying
return action.SupportedVersions.Last(); //TODO: Ensure to get the latest version!
}
- protected virtual void AddHeaders(IAbpMethodInvocation invocation, ActionApiDescriptionModel action, HttpRequestMessage requestMessage, ApiVersionInfo apiVersion)
+ protected virtual void AddHeaders(
+ IAbpMethodInvocation invocation,
+ ActionApiDescriptionModel action,
+ HttpRequestMessage requestMessage,
+ ApiVersionInfo apiVersion)
{
//API Version
if (!apiVersion.Version.IsNullOrEmpty())
diff --git a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/UrlBuilder.cs b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/UrlBuilder.cs
index e4b82b21e1..5bee246bd0 100644
--- a/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/UrlBuilder.cs
+++ b/framework/src/Volo.Abp.Http.Client/Volo/Abp/Http/Client/DynamicProxying/UrlBuilder.cs
@@ -8,7 +8,6 @@ using JetBrains.Annotations;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Http.ProxyScripting.Generators;
using Volo.Abp.Localization;
-using Volo.Abp.Reflection;
namespace Volo.Abp.Http.Client.DynamicProxying
{
@@ -82,9 +81,10 @@ namespace Volo.Abp.Http.Client.DynamicProxying
continue;
}
- AddQueryStringParameter(urlBuilder, isFirstParam, queryStringParameter.Name, value);
-
- isFirstParam = false;
+ if (AddQueryStringParameter(urlBuilder, isFirstParam, queryStringParameter.Name, value))
+ {
+ isFirstParam = false;
+ }
}
if (apiVersion.ShouldSendInQueryString())
@@ -93,28 +93,37 @@ namespace Volo.Abp.Http.Client.DynamicProxying
}
}
- private static void AddQueryStringParameter(
+ private static bool AddQueryStringParameter(
StringBuilder urlBuilder,
bool isFirstParam,
string name,
[NotNull] object value)
{
- urlBuilder.Append(isFirstParam ? "?" : "&");
-
if (value.GetType().IsArray || (value.GetType().IsGenericType && value is IEnumerable))
{
var index = 0;
foreach (var item in (IEnumerable) value)
{
+ if (index == 0)
+ {
+ urlBuilder.Append(isFirstParam ? "?" : "&");
+ }
urlBuilder.Append(name + $"[{index++}]=" + System.Net.WebUtility.UrlEncode(ConvertValueToString(item)) + "&");
}
- //remove & at the end of the urlBuilder.
- urlBuilder.Remove(urlBuilder.Length - 1, 1);
- }
- else
- {
- urlBuilder.Append(name + "=" + System.Net.WebUtility.UrlEncode(ConvertValueToString(value)));
+
+ if (index > 0)
+ {
+ //remove & at the end of the urlBuilder.
+ urlBuilder.Remove(urlBuilder.Length - 1, 1);
+ return true;
+ }
+
+ return false;
}
+
+ urlBuilder.Append(isFirstParam ? "?" : "&");
+ urlBuilder.Append(name + "=" + System.Net.WebUtility.UrlEncode(ConvertValueToString(value)));
+ return true;
}
private static string ConvertValueToString([NotNull] object value)
diff --git a/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/AbpKafkaOptions.cs b/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/AbpKafkaOptions.cs
index 1769d8a076..26d15ce818 100644
--- a/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/AbpKafkaOptions.cs
+++ b/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/AbpKafkaOptions.cs
@@ -9,11 +9,13 @@ namespace Volo.Abp.Kafka
public KafkaConnections Connections { get; }
public Action ConfigureProducer { get; set; }
-
+
public Action ConfigureConsumer { get; set; }
public Action ConfigureTopic { get; set; }
+ public bool ReQueue { get; set; } = true;
+
public AbpKafkaOptions()
{
Connections = new KafkaConnections();
diff --git a/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/KafkaMessageConsumer.cs b/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/KafkaMessageConsumer.cs
index 8ae81a2a26..3b8f022012 100644
--- a/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/KafkaMessageConsumer.cs
+++ b/framework/src/Volo.Abp.Kafka/Volo/Abp/Kafka/KafkaMessageConsumer.cs
@@ -20,6 +20,8 @@ namespace Volo.Abp.Kafka
protected IConsumerPool ConsumerPool { get; }
+ protected IProducerPool ProducerPool { get; }
+
protected IExceptionNotifier ExceptionNotifier { get; }
protected AbpKafkaOptions Options { get; }
@@ -37,10 +39,12 @@ namespace Volo.Abp.Kafka
public KafkaMessageConsumer(
IConsumerPool consumerPool,
IExceptionNotifier exceptionNotifier,
- IOptions options)
+ IOptions options,
+ IProducerPool producerPool)
{
ConsumerPool = consumerPool;
ExceptionNotifier = exceptionNotifier;
+ ProducerPool = producerPool;
Options = options.Value;
Logger = NullLogger.Instance;
@@ -86,7 +90,7 @@ namespace Volo.Abp.Kafka
}
catch (CreateTopicsException e)
{
- if (!e.Error.Reason.Contains($"Topic '{TopicName}' already exists"))
+ if(e.Results.First().Error.Code != ErrorCode.TopicAlreadyExists)
{
throw;
}
@@ -132,14 +136,29 @@ namespace Volo.Abp.Kafka
{
await callback(consumeResult.Message);
}
-
- Consumer.Commit(consumeResult);
}
catch (Exception ex)
{
+ await RequeueAsync(consumeResult);
+
Logger.LogException(ex);
await ExceptionNotifier.NotifyAsync(ex);
}
+ finally
+ {
+ Consumer.Commit(consumeResult);
+ }
+ }
+
+ protected virtual async Task RequeueAsync(ConsumeResult consumeResult)
+ {
+ if (!Options.ReQueue)
+ {
+ return;
+ }
+
+ var producer = ProducerPool.Get(ConnectionName);
+ await producer.ProduceAsync(consumeResult.Topic, consumeResult.Message);
}
public virtual void Dispose()
diff --git a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs
index 8ab6753de3..fd8c5afd16 100644
--- a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs
+++ b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Domain/Repositories/MemoryDb/MemoryDbRepository.cs
@@ -191,10 +191,7 @@ namespace Volo.Abp.Domain.Repositories.MemoryDb
{
var entities = (await GetQueryableAsync()).Where(predicate).ToList();
- foreach (var entity in entities)
- {
- await DeleteAsync(entity, autoSave, cancellationToken);
- }
+ await DeleteManyAsync(entities, autoSave, cancellationToken);
}
public override async Task InsertAsync(
diff --git a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Uow/MemoryDb/UnitOfWorkMemoryDatabaseProvider.cs b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Uow/MemoryDb/UnitOfWorkMemoryDatabaseProvider.cs
index c2c5a1df71..9772bac8a0 100644
--- a/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Uow/MemoryDb/UnitOfWorkMemoryDatabaseProvider.cs
+++ b/framework/src/Volo.Abp.MemoryDb/Volo/Abp/Uow/MemoryDb/UnitOfWorkMemoryDatabaseProvider.cs
@@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.Domain.Repositories.MemoryDb;
using Volo.Abp.MemoryDb;
+using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Uow.MemoryDb
{
@@ -14,17 +15,20 @@ namespace Volo.Abp.Uow.MemoryDb
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IConnectionStringResolver _connectionStringResolver;
private readonly MemoryDatabaseManager _memoryDatabaseManager;
+ private readonly ICurrentTenant _currentTenant;
public UnitOfWorkMemoryDatabaseProvider(
IUnitOfWorkManager unitOfWorkManager,
IConnectionStringResolver connectionStringResolver,
TMemoryDbContext dbContext,
- MemoryDatabaseManager memoryDatabaseManager)
+ MemoryDatabaseManager memoryDatabaseManager,
+ ICurrentTenant currentTenant)
{
_unitOfWorkManager = unitOfWorkManager;
_connectionStringResolver = connectionStringResolver;
DbContext = dbContext;
_memoryDatabaseManager = memoryDatabaseManager;
+ _currentTenant = currentTenant;
}
public Task GetDbContextAsync()
@@ -72,5 +76,34 @@ namespace Volo.Abp.Uow.MemoryDb
return ((MemoryDbDatabaseApi)databaseApi).Database;
}
+
+ private async Task ResolveConnectionStringAsync()
+ {
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TMemoryDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (_currentTenant.Change(null))
+ {
+ return await _connectionStringResolver.ResolveAsync();
+ }
+ }
+
+ return await _connectionStringResolver.ResolveAsync();
+ }
+
+ [Obsolete("Use ResolveConnectionStringAsync method.")]
+ private string ResolveConnectionString()
+ {
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TMemoryDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (_currentTenant.Change(null))
+ {
+ return _connectionStringResolver.Resolve();
+ }
+ }
+
+ return _connectionStringResolver.Resolve();
+ }
}
}
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
index 960222679f..12e5987777 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
@@ -24,6 +24,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
IMongoQueryable GetMongoQueryable();
Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default);
+
+ Task> GetAggregateAsync(CancellationToken cancellationToken = default);
}
public interface IMongoDbRepository : IMongoDbRepository, IRepository
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
index b252c48999..e6030246aa 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
@@ -16,6 +16,7 @@ using Volo.Abp.EventBus.Distributed;
using Volo.Abp.EventBus.Local;
using Volo.Abp.Guids;
using Volo.Abp.MongoDB;
+using Volo.Abp.MultiTenancy;
namespace Volo.Abp.Domain.Repositories.MongoDB
{
@@ -51,11 +52,37 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
}
[Obsolete("Use GetDbContextAsync method.")]
- protected virtual TMongoDbContext DbContext => DbContextProvider.GetDbContext();
+ protected virtual TMongoDbContext DbContext => GetDbContext();
+
+ [Obsolete("Use GetDbContextAsync method.")]
+ private TMongoDbContext GetDbContext()
+ {
+ // Multi-tenancy unaware entities should always use the host connection string
+ if (!EntityHelper.IsMultiTenant())
+ {
+ using (CurrentTenant.Change(null))
+ {
+ return DbContextProvider.GetDbContext();
+ }
+ }
+
+ return DbContextProvider.GetDbContext();
+ }
protected Task GetDbContextAsync(CancellationToken cancellationToken = default)
{
- return DbContextProvider.GetDbContextAsync(GetCancellationToken(cancellationToken));
+ cancellationToken = GetCancellationToken(cancellationToken);
+
+ // Multi-tenancy unaware entities should always use the host connection string
+ if (!EntityHelper.IsMultiTenant())
+ {
+ using (CurrentTenant.Change(null))
+ {
+ return DbContextProvider.GetDbContextAsync(cancellationToken);
+ }
+ }
+
+ return DbContextProvider.GetDbContextAsync(cancellationToken);
}
protected IMongoDbContextProvider DbContextProvider { get; }
@@ -82,9 +109,11 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
bool autoSave = false,
CancellationToken cancellationToken = default)
{
+ cancellationToken = GetCancellationToken(cancellationToken);
+
await ApplyAbpConceptsForAddedEntityAsync(entity);
- var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken));
+ var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
if (dbContext.SessionHandle != null)
@@ -92,14 +121,14 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
await collection.InsertOneAsync(
dbContext.SessionHandle,
entity,
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
else
{
await collection.InsertOneAsync(
entity,
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
@@ -108,6 +137,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
public override async Task InsertManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default)
{
+ cancellationToken = GetCancellationToken(cancellationToken);
+
var entityArray = entities.ToArray();
foreach (var entity in entityArray)
@@ -115,7 +146,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
await ApplyAbpConceptsForAddedEntityAsync(entity);
}
- var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken));
+ var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
if (BulkOperationProvider != null)
@@ -144,6 +175,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
bool autoSave = false,
CancellationToken cancellationToken = default)
{
+ cancellationToken = GetCancellationToken(cancellationToken);
+
SetModificationAuditProperties(entity);
if (entity is ISoftDelete softDeleteEntity && softDeleteEntity.IsDeleted)
@@ -161,7 +194,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
var oldConcurrencyStamp = SetNewConcurrencyStamp(entity);
ReplaceOneResult result;
- var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken));
+ var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
if (dbContext.SessionHandle != null)
@@ -170,7 +203,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
dbContext.SessionHandle,
CreateEntityFilter(entity, true, oldConcurrencyStamp),
entity,
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
else
@@ -178,7 +211,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
result = await collection.ReplaceOneAsync(
CreateEntityFilter(entity, true, oldConcurrencyStamp),
entity,
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
@@ -252,15 +285,18 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
bool autoSave = false,
CancellationToken cancellationToken = default)
{
- await ApplyAbpConceptsForDeletedEntityAsync(entity);
- var oldConcurrencyStamp = SetNewConcurrencyStamp(entity);
+ cancellationToken = GetCancellationToken(cancellationToken);
- var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken));
+ var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
- if (entity is ISoftDelete softDeleteEntity && !IsHardDeleted(entity))
+ var oldConcurrencyStamp = SetNewConcurrencyStamp(entity);
+
+ if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && !IsHardDeleted(entity))
{
- softDeleteEntity.IsDeleted = true;
+ ((ISoftDelete)entity).IsDeleted = true;
+ await ApplyAbpConceptsForDeletedEntityAsync(entity);
+
ReplaceOneResult result;
if (dbContext.SessionHandle != null)
@@ -269,7 +305,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
dbContext.SessionHandle,
CreateEntityFilter(entity, true, oldConcurrencyStamp),
entity,
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
else
@@ -277,7 +313,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
result = await collection.ReplaceOneAsync(
CreateEntityFilter(entity, true, oldConcurrencyStamp),
entity,
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
@@ -288,6 +324,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
}
else
{
+ await ApplyAbpConceptsForDeletedEntityAsync(entity);
+
DeleteResult result;
if (dbContext.SessionHandle != null)
@@ -295,14 +333,14 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
result = await collection.DeleteOneAsync(
dbContext.SessionHandle,
CreateEntityFilter(entity, true, oldConcurrencyStamp),
- cancellationToken: GetCancellationToken(cancellationToken)
+ cancellationToken: cancellationToken
);
}
else
{
result = await collection.DeleteOneAsync(
CreateEntityFilter(entity, true, oldConcurrencyStamp),
- GetCancellationToken(cancellationToken)
+ cancellationToken
);
}
@@ -314,71 +352,84 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
}
public override async Task DeleteManyAsync(
- IEnumerable entities,
- bool autoSave = false,
- CancellationToken cancellationToken = default)
+ IEnumerable entities,
+ bool autoSave = false,
+ CancellationToken cancellationToken = default)
{
- var entityArray = entities.ToArray();
+ cancellationToken = GetCancellationToken(cancellationToken);
- foreach (var entity in entityArray)
+ var softDeletedEntities = new Dictionary();
+ var hardDeletedEntities = new List();
+
+ foreach (var entity in entities)
{
+ if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && !IsHardDeleted(entity))
+ {
+ ((ISoftDelete)entity).IsDeleted = true;
+
+ softDeletedEntities.Add(entity, SetNewConcurrencyStamp(entity));
+ }
+ else
+ {
+ hardDeletedEntities.Add(entity);
+ }
+
await ApplyAbpConceptsForDeletedEntityAsync(entity);
- SetNewConcurrencyStamp(entity);
}
- var dbContext = await GetDbContextAsync(GetCancellationToken(cancellationToken));
+ var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
if (BulkOperationProvider != null)
{
- await BulkOperationProvider.DeleteManyAsync(this, entityArray, dbContext.SessionHandle, autoSave, cancellationToken);
+ await BulkOperationProvider.DeleteManyAsync(this, entities, dbContext.SessionHandle, autoSave, cancellationToken);
return;
}
- var entitiesCount = entityArray.Count();
-
- if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)))
+ if (softDeletedEntities.Count > 0)
{
- UpdateResult updateResult;
+ BulkWriteResult updateResult;
+
+ var replaceRequests = new List>(
+ softDeletedEntities.Select(entity => new ReplaceOneModel(
+ CreateEntityFilter(entity.Key, true, entity.Value), entity.Key))
+ );
+
if (dbContext.SessionHandle != null)
{
- updateResult = await collection.UpdateManyAsync(
- dbContext.SessionHandle,
- CreateEntitiesFilter(entityArray),
- Builders.Update.Set(x => ((ISoftDelete)x).IsDeleted, true)
- );
+ updateResult = await collection.BulkWriteAsync(dbContext.SessionHandle, replaceRequests, cancellationToken: cancellationToken);
}
else
{
- updateResult = await collection.UpdateManyAsync(
- CreateEntitiesFilter(entityArray),
- Builders.Update.Set(x => ((ISoftDelete)x).IsDeleted, true)
- );
+ updateResult = await collection.BulkWriteAsync(replaceRequests, cancellationToken: cancellationToken);
}
- if (updateResult.MatchedCount < entitiesCount)
+ if (updateResult.MatchedCount < softDeletedEntities.Count)
{
ThrowOptimisticConcurrencyException();
}
}
- else
+
+ if (hardDeletedEntities.Count > 0)
{
DeleteResult deleteResult;
+ var hardDeletedEntitiesCount = hardDeletedEntities.Count;
+
if (dbContext.SessionHandle != null)
{
deleteResult = await collection.DeleteManyAsync(
dbContext.SessionHandle,
- CreateEntitiesFilter(entityArray)
- );
+ CreateEntitiesFilter(hardDeletedEntities),
+ cancellationToken: cancellationToken);
}
else
{
deleteResult = await collection.DeleteManyAsync(
- CreateEntitiesFilter(entityArray)
- );
+ CreateEntitiesFilter(hardDeletedEntities),
+ cancellationToken: cancellationToken);
}
- if (deleteResult.DeletedCount < entitiesCount)
+ if (deleteResult.DeletedCount < hardDeletedEntitiesCount)
{
ThrowOptimisticConcurrencyException();
}
@@ -424,10 +475,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
.Where(predicate)
.ToListAsync(cancellationToken);
- foreach (var entity in entities)
- {
- await DeleteAsync(entity, autoSave, cancellationToken);
- }
+ await DeleteManyAsync(entities, autoSave, cancellationToken);
}
[Obsolete("Use GetQueryableAsync method.")]
@@ -446,9 +494,11 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
+ cancellationToken = GetCancellationToken(cancellationToken);
+
return await (await GetMongoQueryableAsync(cancellationToken))
.Where(predicate)
- .SingleOrDefaultAsync(GetCancellationToken(cancellationToken));
+ .SingleOrDefaultAsync(cancellationToken);
}
[Obsolete("Use GetMongoQueryableAsync method.")]
@@ -463,6 +513,8 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
public async Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default)
{
+ cancellationToken = GetCancellationToken(cancellationToken);
+
var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
@@ -473,6 +525,19 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
);
}
+ public async Task> GetAggregateAsync(CancellationToken cancellationToken = default)
+ {
+ cancellationToken = GetCancellationToken(cancellationToken);
+
+ var dbContext = await GetDbContextAsync(cancellationToken);
+ var collection = await GetCollectionAsync(cancellationToken);
+
+ return ApplyDataFilters(
+ dbContext.SessionHandle != null
+ ? collection.Aggregate(dbContext.SessionHandle)
+ : collection.Aggregate());
+ }
+
protected virtual bool IsHardDeleted(TEntity entity)
{
var hardDeletedEntities = UnitOfWorkManager?.Current?.Items.GetOrDefault(UnitOfWorkItemNames.HardDeletedEntities) as HashSet;
@@ -621,6 +686,22 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
throw new AbpDbConcurrencyException("Database operation expected to affect 1 row but actually affected 0 row. Data may have been modified or deleted since entities were loaded. This exception has been thrown on optimistic concurrency check.");
}
+ protected virtual IAggregateFluent ApplyDataFilters(IAggregateFluent aggregate)
+ {
+ if (typeof(ISoftDelete).IsAssignableFrom(typeof(TEntity)) && DataFilter.IsEnabled())
+ {
+ aggregate = aggregate.Match(e => ((ISoftDelete)e).IsDeleted == false);
+ }
+
+ if (typeof(IMultiTenant).IsAssignableFrom(typeof(TEntity)) && DataFilter.IsEnabled())
+ {
+ var tenantId = CurrentTenant.Id;
+ aggregate = aggregate.Match(e => ((IMultiTenant)e).TenantId == tenantId);
+ }
+
+ return aggregate;
+ }
+
[Obsolete("This method will be removed in future versions.")]
public QueryableExecutionModel GetExecutionModel()
{
@@ -630,13 +711,13 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
[Obsolete("This method will be removed in future versions.")]
public IAsyncCursor ToCursor(CancellationToken cancellationToken = new CancellationToken())
{
- return GetMongoQueryable().ToCursor(cancellationToken);
+ return GetMongoQueryable().ToCursor(GetCancellationToken(cancellationToken));
}
[Obsolete("This method will be removed in future versions.")]
public Task> ToCursorAsync(CancellationToken cancellationToken = new CancellationToken())
{
- return GetMongoQueryable().ToCursorAsync(cancellationToken);
+ return GetMongoQueryable().ToCursorAsync(GetCancellationToken(cancellationToken));
}
}
@@ -659,7 +740,7 @@ namespace Volo.Abp.Domain.Repositories.MongoDB
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
- var entity = await FindAsync(id, includeDetails, cancellationToken);
+ var entity = await FindAsync(id, includeDetails, GetCancellationToken(cancellationToken));
if (entity == null)
{
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
index 90605f416e..bcbdc00d9e 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
@@ -1,4 +1,5 @@
using System;
+using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDB.Driver.Linq;
@@ -16,10 +17,10 @@ namespace Volo.Abp.Domain.Repositories
return repository.ToMongoDbRepository().Database;
}
- public static Task GetDatabaseAsync(this IBasicRepository repository)
+ public static Task GetDatabaseAsync(this IBasicRepository repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity
{
- return repository.ToMongoDbRepository().GetDatabaseAsync();
+ return repository.ToMongoDbRepository().GetDatabaseAsync(cancellationToken);
}
[Obsolete("Use GetCollectionAsync method.")]
@@ -29,10 +30,10 @@ namespace Volo.Abp.Domain.Repositories
return repository.ToMongoDbRepository().Collection;
}
- public static Task> GetCollectionAsync(this IBasicRepository repository)
+ public static Task> GetCollectionAsync(this IBasicRepository repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity
{
- return repository.ToMongoDbRepository().GetCollectionAsync();
+ return repository.ToMongoDbRepository().GetCollectionAsync(cancellationToken);
}
[Obsolete("Use GetMongoQueryableAsync method.")]
@@ -42,10 +43,16 @@ namespace Volo.Abp.Domain.Repositories
return repository.ToMongoDbRepository().GetMongoQueryable();
}
- public static Task> GetMongoQueryableAsync(this IBasicRepository repository)
+ public static Task> GetMongoQueryableAsync(this IBasicRepository repository, CancellationToken cancellationToken = default)
where TEntity : class, IEntity
{
- return repository.ToMongoDbRepository().GetMongoQueryableAsync();
+ return repository.ToMongoDbRepository().GetMongoQueryableAsync(cancellationToken);
+ }
+
+ public static Task> GetAggregateAsync(this IBasicRepository repository, CancellationToken cancellationToken = default)
+ where TEntity : class, IEntity
+ {
+ return repository.ToMongoDbRepository().GetAggregateAsync(cancellationToken);
}
public static IMongoDbRepository ToMongoDbRepository(this IBasicRepository repository)
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/MongoDbTransactionApi.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/MongoDbTransactionApi.cs
index 6c3ab76ee5..f376c2f804 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/MongoDbTransactionApi.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/MongoDbTransactionApi.cs
@@ -1,7 +1,7 @@
-using System.Collections.Generic;
-using System.Threading;
+using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
+using Volo.Abp.Threading;
namespace Volo.Abp.Uow.MongoDB
{
@@ -9,19 +9,19 @@ namespace Volo.Abp.Uow.MongoDB
{
public IClientSessionHandle SessionHandle { get; }
- public MongoDbTransactionApi(IClientSessionHandle sessionHandle)
+ protected ICancellationTokenProvider CancellationTokenProvider { get; }
+
+ public MongoDbTransactionApi(
+ IClientSessionHandle sessionHandle,
+ ICancellationTokenProvider cancellationTokenProvider)
{
SessionHandle = sessionHandle;
+ CancellationTokenProvider = cancellationTokenProvider;
}
public async Task CommitAsync()
{
- await SessionHandle.CommitTransactionAsync();
- }
-
- protected void Commit()
- {
- SessionHandle.CommitTransaction();
+ await SessionHandle.CommitTransactionAsync(CancellationTokenProvider.Token);
}
public void Dispose()
@@ -29,14 +29,11 @@ namespace Volo.Abp.Uow.MongoDB
SessionHandle.Dispose();
}
- public void Rollback()
- {
- SessionHandle.AbortTransaction();
- }
-
public async Task RollbackAsync(CancellationToken cancellationToken)
{
- await SessionHandle.AbortTransactionAsync(cancellationToken);
+ await SessionHandle.AbortTransactionAsync(
+ CancellationTokenProvider.FallbackToProvider(cancellationToken)
+ );
}
}
}
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs
index 2b279f9c37..684593fb7f 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Uow/MongoDB/UnitOfWorkMongoDbContextProvider.cs
@@ -8,6 +8,7 @@ using MongoDB.Bson;
using MongoDB.Driver;
using Volo.Abp.Data;
using Volo.Abp.MongoDB;
+using Volo.Abp.MultiTenancy;
using Volo.Abp.Threading;
namespace Volo.Abp.Uow.MongoDB
@@ -20,15 +21,18 @@ namespace Volo.Abp.Uow.MongoDB
private readonly IUnitOfWorkManager _unitOfWorkManager;
private readonly IConnectionStringResolver _connectionStringResolver;
private readonly ICancellationTokenProvider _cancellationTokenProvider;
+ private readonly ICurrentTenant _currentTenant;
public UnitOfWorkMongoDbContextProvider(
IUnitOfWorkManager unitOfWorkManager,
IConnectionStringResolver connectionStringResolver,
- ICancellationTokenProvider cancellationTokenProvider)
+ ICancellationTokenProvider cancellationTokenProvider,
+ ICurrentTenant currentTenant)
{
_unitOfWorkManager = unitOfWorkManager;
_connectionStringResolver = connectionStringResolver;
_cancellationTokenProvider = cancellationTokenProvider;
+ _currentTenant = currentTenant;
Logger = NullLogger>.Instance;
}
@@ -54,7 +58,7 @@ namespace Volo.Abp.Uow.MongoDB
$"A {nameof(IMongoDatabase)} instance can only be created inside a unit of work!");
}
- var connectionString = _connectionStringResolver.Resolve();
+ var connectionString = ResolveConnectionString();
var dbContextKey = $"{typeof(TMongoDbContext).FullName}_{connectionString}";
var mongoUrl = new MongoUrl(connectionString);
@@ -81,7 +85,7 @@ namespace Volo.Abp.Uow.MongoDB
$"A {nameof(IMongoDatabase)} instance can only be created inside a unit of work!");
}
- var connectionString = await _connectionStringResolver.ResolveAsync();
+ var connectionString = await ResolveConnectionStringAsync();
var dbContextKey = $"{typeof(TMongoDbContext).FullName}_{connectionString}";
var mongoUrl = new MongoUrl(connectionString);
@@ -178,7 +182,10 @@ namespace Volo.Abp.Uow.MongoDB
unitOfWork.AddTransactionApi(
transactionApiKey,
- new MongoDbTransactionApi(session)
+ new MongoDbTransactionApi(
+ session,
+ _cancellationTokenProvider
+ )
);
dbContext.ToAbpMongoDbContext().InitializeDatabase(database, client, session);
@@ -215,7 +222,10 @@ namespace Volo.Abp.Uow.MongoDB
unitOfWork.AddTransactionApi(
transactionApiKey,
- new MongoDbTransactionApi(session)
+ new MongoDbTransactionApi(
+ session,
+ _cancellationTokenProvider
+ )
);
dbContext.ToAbpMongoDbContext().InitializeDatabase(database, client, session);
@@ -228,6 +238,35 @@ namespace Volo.Abp.Uow.MongoDB
return dbContext;
}
+ private async Task ResolveConnectionStringAsync()
+ {
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TMongoDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (_currentTenant.Change(null))
+ {
+ return await _connectionStringResolver.ResolveAsync();
+ }
+ }
+
+ return await _connectionStringResolver.ResolveAsync();
+ }
+
+ [Obsolete("Use ResolveConnectionStringAsync method.")]
+ private string ResolveConnectionString()
+ {
+ // Multi-tenancy unaware contexts should always use the host connection string
+ if (typeof(TMongoDbContext).IsDefined(typeof(IgnoreMultiTenancyAttribute), false))
+ {
+ using (_currentTenant.Change(null))
+ {
+ return _connectionStringResolver.Resolve();
+ }
+ }
+
+ return _connectionStringResolver.Resolve();
+ }
+
protected virtual CancellationToken GetCancellationToken(CancellationToken preferredValue = default)
{
return _cancellationTokenProvider.FallbackToProvider(preferredValue);
diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj b/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj
index 951712c7f0..344dbfdec0 100644
--- a/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj
+++ b/framework/src/Volo.Abp.MultiTenancy/Volo.Abp.MultiTenancy.csproj
@@ -16,6 +16,7 @@
+
diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs
index 9dc64ef7f8..c51daf99aa 100644
--- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs
+++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/AbpMultiTenancyModule.cs
@@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Data;
+using Volo.Abp.EventBus.Abstractions;
using Volo.Abp.Modularity;
using Volo.Abp.MultiTenancy.ConfigurationStore;
using Volo.Abp.Security;
@@ -10,7 +11,8 @@ namespace Volo.Abp.MultiTenancy
[DependsOn(
typeof(AbpDataModule),
- typeof(AbpSecurityModule)
+ typeof(AbpSecurityModule),
+ typeof(AbpEventBusAbstractionsModule)
)]
public class AbpMultiTenancyModule : AbpModule
{
diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs
index 0d82419013..41ba7873ac 100644
--- a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs
+++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs
@@ -26,105 +26,144 @@ namespace Volo.Abp.MultiTenancy
public override async Task ResolveAsync(string connectionStringName = null)
{
- //No current tenant, fallback to default logic
if (_currentTenant.Id == null)
{
+ //No current tenant, fallback to default logic
return await base.ResolveAsync(connectionStringName);
}
- using (var serviceScope = _serviceProvider.CreateScope())
- {
- var tenantStore = serviceScope
- .ServiceProvider
- .GetRequiredService();
+ var tenant = await FindTenantConfigurationAsync(_currentTenant.Id.Value);
- var tenant = await tenantStore.FindAsync(_currentTenant.Id.Value);
-
- if (tenant?.ConnectionStrings == null)
- {
- return await base.ResolveAsync(connectionStringName);
- }
+ if (tenant == null || tenant.ConnectionStrings.IsNullOrEmpty())
+ {
+ //Tenant has not defined any connection string, fallback to default logic
+ return await base.ResolveAsync(connectionStringName);
+ }
- //Requesting default connection string
- if (connectionStringName == null)
- {
- return tenant.ConnectionStrings.Default ??
- Options.ConnectionStrings.Default;
- }
+ var tenantDefaultConnectionString = tenant.ConnectionStrings.Default;
+
+ //Requesting default connection string...
+ if (connectionStringName == null ||
+ connectionStringName == ConnectionStrings.DefaultConnectionStringName)
+ {
+ //Return tenant's default or global default
+ return !tenantDefaultConnectionString.IsNullOrWhiteSpace()
+ ? tenantDefaultConnectionString
+ : Options.ConnectionStrings.Default;
+ }
- //Requesting specific connection string
- var connString = tenant.ConnectionStrings.GetOrDefault(connectionStringName);
- if (connString != null)
+ //Requesting specific connection string...
+ var connString = tenant.ConnectionStrings.GetOrDefault(connectionStringName);
+ if (!connString.IsNullOrWhiteSpace())
+ {
+ //Found for the tenant
+ return connString;
+ }
+
+ //Fallback to the mapped database for the specific connection string
+ var database = Options.Databases.GetMappedDatabaseOrNull(connectionStringName);
+ if (database != null)
+ {
+ connString = tenant.ConnectionStrings.GetOrDefault(database.DatabaseName);
+ if (!connString.IsNullOrWhiteSpace())
{
+ //Found for the tenant
return connString;
}
+ }
- /* Requested a specific connection string, but it's not specified for the tenant.
- * - If it's specified in options, use it.
- * - If not, use tenant's default conn string.
- */
-
- var connStringInOptions = Options.ConnectionStrings.GetOrDefault(connectionStringName);
- if (connStringInOptions != null)
- {
- return connStringInOptions;
- }
-
- return tenant.ConnectionStrings.Default ??
- Options.ConnectionStrings.Default;
+ //Fallback to tenant's default connection string if available
+ if (!tenantDefaultConnectionString.IsNullOrWhiteSpace())
+ {
+ return tenantDefaultConnectionString;
}
+
+ return await base.ResolveAsync(connectionStringName);
}
[Obsolete("Use ResolveAsync method.")]
public override string Resolve(string connectionStringName = null)
{
- //No current tenant, fallback to default logic
if (_currentTenant.Id == null)
{
+ //No current tenant, fallback to default logic
return base.Resolve(connectionStringName);
}
- using (var serviceScope = _serviceProvider.CreateScope())
+ var tenant = FindTenantConfiguration(_currentTenant.Id.Value);
+
+ if (tenant == null || tenant.ConnectionStrings.IsNullOrEmpty())
{
- var tenantStore = serviceScope
- .ServiceProvider
- .GetRequiredService();
+ //Tenant has not defined any connection string, fallback to default logic
+ return base.Resolve(connectionStringName);
+ }
- var tenant = tenantStore.Find(_currentTenant.Id.Value);
+ var tenantDefaultConnectionString = tenant.ConnectionStrings.Default;
- if (tenant?.ConnectionStrings == null)
- {
- return base.Resolve(connectionStringName);
- }
+ //Requesting default connection string...
+ if (connectionStringName == null ||
+ connectionStringName == ConnectionStrings.DefaultConnectionStringName)
+ {
+ //Return tenant's default or global default
+ return !tenantDefaultConnectionString.IsNullOrWhiteSpace()
+ ? tenantDefaultConnectionString
+ : Options.ConnectionStrings.Default;
+ }
- //Requesting default connection string
- if (connectionStringName == null)
- {
- return tenant.ConnectionStrings.Default ??
- Options.ConnectionStrings.Default;
- }
+ //Requesting specific connection string...
+ var connString = tenant.ConnectionStrings.GetOrDefault(connectionStringName);
+ if (!connString.IsNullOrWhiteSpace())
+ {
+ //Found for the tenant
+ return connString;
+ }
- //Requesting specific connection string
- var connString = tenant.ConnectionStrings.GetOrDefault(connectionStringName);
- if (connString != null)
- {
- return connString;
- }
+ //Fallback to tenant's default connection string if available
+ if (!tenantDefaultConnectionString.IsNullOrWhiteSpace())
+ {
+ return tenantDefaultConnectionString;
+ }
- /* Requested a specific connection string, but it's not specified for the tenant.
- * - If it's specified in options, use it.
- * - If not, use tenant's default conn string.
- */
+ //Try to find the specific connection string for given name
+ var connStringInOptions = Options.ConnectionStrings.GetOrDefault(connectionStringName);
+ if (!connStringInOptions.IsNullOrWhiteSpace())
+ {
+ return connStringInOptions;
+ }
- var connStringInOptions = Options.ConnectionStrings.GetOrDefault(connectionStringName);
- if (connStringInOptions != null)
- {
- return connStringInOptions;
- }
+ //Fallback to the global default connection string
+ var defaultConnectionString = Options.ConnectionStrings.Default;
+ if (!defaultConnectionString.IsNullOrWhiteSpace())
+ {
+ return defaultConnectionString;
+ }
+
+ throw new AbpException("No connection string defined!");
+ }
+
+ protected virtual async Task FindTenantConfigurationAsync(Guid tenantId)
+ {
+ using (var serviceScope = _serviceProvider.CreateScope())
+ {
+ var tenantStore = serviceScope
+ .ServiceProvider
+ .GetRequiredService();
+
+ return await tenantStore.FindAsync(tenantId);
+ }
+ }
+
+ [Obsolete("Use FindTenantConfigurationAsync method.")]
+ protected virtual TenantConfiguration FindTenantConfiguration(Guid tenantId)
+ {
+ using (var serviceScope = _serviceProvider.CreateScope())
+ {
+ var tenantStore = serviceScope
+ .ServiceProvider
+ .GetRequiredService();
- return tenant.ConnectionStrings.Default ??
- Options.ConnectionStrings.Default;
+ return tenantStore.Find(tenantId);
}
}
}
-}
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs
new file mode 100644
index 0000000000..022343821b
--- /dev/null
+++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantConnectionStringUpdatedEto.cs
@@ -0,0 +1,21 @@
+using System;
+using Volo.Abp.Domain.Entities.Events.Distributed;
+using Volo.Abp.EventBus;
+
+namespace Volo.Abp.MultiTenancy
+{
+ [Serializable]
+ [EventName("abp.multi_tenancy.tenant.connection_string.updated")]
+ public class TenantConnectionStringUpdatedEto : EtoBase
+ {
+ public Guid Id { get; set; }
+
+ public string Name { get; set; }
+
+ public string ConnectionStringName { get; set; }
+
+ public string OldValue { get; set; }
+
+ public string NewValue { get; set; }
+ }
+}
diff --git a/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs
new file mode 100644
index 0000000000..317995c971
--- /dev/null
+++ b/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/TenantCreatedEto.cs
@@ -0,0 +1,15 @@
+using System;
+using Volo.Abp.Domain.Entities.Events.Distributed;
+using Volo.Abp.EventBus;
+
+namespace Volo.Abp.MultiTenancy
+{
+ [Serializable]
+ [EventName("abp.multi_tenancy.tenant.created")]
+ public class TenantCreatedEto : EtoBase
+ {
+ public Guid Id { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs
index b94663d886..f757efab64 100644
--- a/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs
+++ b/framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/RabbitMqMessageConsumer.cs
@@ -191,6 +191,16 @@ namespace Volo.Abp.RabbitMQ
}
catch (Exception ex)
{
+ try
+ {
+ Channel.BasicNack(
+ basicDeliverEventArgs.DeliveryTag,
+ multiple: false,
+ requeue: true
+ );
+ }
+ catch { }
+
Logger.LogException(ex);
await ExceptionNotifier.NotifyAsync(ex);
}
diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsRollback.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsRollback.cs
index 4c211d652d..2286a386b8 100644
--- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsRollback.cs
+++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/ISupportsRollback.cs
@@ -5,8 +5,6 @@ namespace Volo.Abp.Uow
{
public interface ISupportsRollback
{
- void Rollback();
-
Task RollbackAsync(CancellationToken cancellationToken);
}
-}
\ No newline at end of file
+}
diff --git a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs
index 955fa6b449..878c03d629 100644
--- a/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs
+++ b/framework/src/Volo.Abp.Uow/Volo/Abp/Uow/UnitOfWork.cs
@@ -262,27 +262,6 @@ namespace Volo.Abp.Uow
}
}
- protected virtual void RollbackAll()
- {
- foreach (var databaseApi in GetAllActiveDatabaseApis())
- {
- try
- {
- (databaseApi as ISupportsRollback)?.Rollback();
- }
- catch { }
- }
-
- foreach (var transactionApi in GetAllActiveTransactionApis())
- {
- try
- {
- (transactionApi as ISupportsRollback)?.Rollback();
- }
- catch { }
- }
- }
-
protected virtual async Task RollbackAllAsync(CancellationToken cancellationToken)
{
foreach (var databaseApi in GetAllActiveDatabaseApis())
diff --git a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationHelper.cs b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationHelper.cs
index d46281d2e9..9f6cec23e5 100644
--- a/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationHelper.cs
+++ b/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationHelper.cs
@@ -4,7 +4,9 @@ namespace Volo.Abp.Validation
{
public class ValidationHelper
{
- private const string EmailRegEx = @"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?";
+ // Taken from W3C as an alternative to the RFC5322 specification: https://html.spec.whatwg.org/#valid-e-mail-address
+ // The RFC5322 regex can be found here: https://emailregex.com/
+ public static string EmailRegEx { get; set; } = @"^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$";
public static bool IsValidEmailAddress(string email)
{
@@ -13,7 +15,6 @@ namespace Volo.Abp.Validation
return false;
}
- /*RFC 2822 (simplified)*/
return Regex.IsMatch(email, EmailRegEx, RegexOptions.Compiled | RegexOptions.IgnoreCase);
}
}
diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs
new file mode 100644
index 0000000000..15491f9b21
--- /dev/null
+++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController.cs
@@ -0,0 +1,36 @@
+using System.IO;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Shouldly;
+using Volo.Abp.Content;
+
+namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters
+{
+ [Route("api/remote-stream-content-test")]
+ public class RemoteStreamContentTestController : AbpController
+ {
+ [HttpGet]
+ [Route("Download")]
+ public async Task DownloadAsync()
+ {
+ var memoryStream = new MemoryStream();
+ await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("DownloadAsync"));
+
+ return new RemoteStreamContent(memoryStream)
+ {
+ ContentType = "application/rtf"
+ };
+ }
+
+ [HttpPost]
+ [Route("Upload")]
+ public async Task UploadAsync([FromBody]IRemoteStreamContent streamContent)
+ {
+ using (var reader = new StreamReader(streamContent.GetStream()))
+ {
+ return await reader.ReadToEndAsync() + ":" + streamContent.ContentType;
+ }
+ }
+ }
+}
diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.cs b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.cs
new file mode 100644
index 0000000000..3d49a5b3ff
--- /dev/null
+++ b/framework/test/Volo.Abp.AspNetCore.Mvc.Tests/Volo/Abp/AspNetCore/Mvc/ContentFormatters/RemoteStreamContentTestController_Tests.cs
@@ -0,0 +1,37 @@
+using System.IO;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using Shouldly;
+using Xunit;
+
+namespace Volo.Abp.AspNetCore.Mvc.ContentFormatters
+{
+ public class RemoteStreamContentTestController_Tests : AspNetCoreMvcTestBase
+ {
+ [Fact]
+ public async Task DownloadAsync()
+ {
+ var result = await GetResponseAsync("/api/remote-stream-content-test/download");
+ result.Content.Headers.ContentType?.ToString().ShouldBe("application/rtf");
+ (await result.Content.ReadAsStringAsync()).ShouldBe("DownloadAsync");
+ }
+
+ [Fact]
+ public async Task UploadAsync()
+ {
+ using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/api/remote-stream-content-test/upload"))
+ {
+ var memoryStream = new MemoryStream();
+ await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("UploadAsync"));
+ memoryStream.Position = 0;
+ requestMessage.Content = new StreamContent(memoryStream);
+ requestMessage.Content.Headers.Add("Content-Type", "application/rtf");
+
+ var response = await Client.SendAsync(requestMessage);
+
+ (await response.Content.ReadAsStringAsync()).ShouldBe("UploadAsync:application/rtf");
+ }
+ }
+ }
+}
diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/package.json b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/package.json
index adf881d848..994844bec9 100644
--- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/package.json
+++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/package.json
@@ -3,7 +3,7 @@
"name": "asp.net",
"private": true,
"dependencies": {
- "@abp/aspnetcore.mvc.ui.theme.shared": "^4.1.1",
+ "@abp/aspnetcore.mvc.ui.theme.shared": "^4.2.0",
"highlight.js": "^9.13.1"
},
"devDependencies": {}
diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/yarn.lock b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/yarn.lock
index 26b95fd56b..a50932965e 100644
--- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/yarn.lock
+++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo/yarn.lock
@@ -2,30 +2,30 @@
# yarn lockfile v1
-"@abp/aspnetcore.mvc.ui.theme.shared@^4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui.theme.shared/-/aspnetcore.mvc.ui.theme.shared-4.1.1.tgz#dbf6ae11b1e99b2cfe9e4d2175341c6fba2168d0"
- integrity sha512-HECMBY5ETtaqFxoO/7teYQmdWyFaQNeWuzMyeclMBOvR+pjAttnZiGRZGeB75OuQsfE3m6dIQ64n5chBnoBPdg==
- dependencies:
- "@abp/aspnetcore.mvc.ui" "~4.1.1"
- "@abp/bootstrap" "~4.1.1"
- "@abp/bootstrap-datepicker" "~4.1.1"
- "@abp/datatables.net-bs4" "~4.1.1"
- "@abp/font-awesome" "~4.1.1"
- "@abp/jquery-form" "~4.1.1"
- "@abp/jquery-validation-unobtrusive" "~4.1.1"
- "@abp/lodash" "~4.1.1"
- "@abp/luxon" "~4.1.1"
- "@abp/malihu-custom-scrollbar-plugin" "~4.1.1"
- "@abp/select2" "~4.1.1"
- "@abp/sweetalert" "~4.1.1"
- "@abp/timeago" "~4.1.1"
- "@abp/toastr" "~4.1.1"
-
-"@abp/aspnetcore.mvc.ui@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui/-/aspnetcore.mvc.ui-4.1.1.tgz#74facb7722834e781f2801f56dba729c575463f3"
- integrity sha512-WmRMWIeb2tYL+VhaLNvbcMKSbWNNi6cKflbIVPQQeY8WmI1ac5wWGLw7XsiniAEXP4WYrOGScXC7WNkgXGtrZw==
+"@abp/aspnetcore.mvc.ui.theme.shared@^4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui.theme.shared/-/aspnetcore.mvc.ui.theme.shared-4.2.0.tgz#a72b5e1cefa27e658b7f072a8c2c1b4ee12baef8"
+ integrity sha512-bgWwBBJA/74kFGWh7O+lzb+inV5LOlYOpDoCNAL0XgQTrutrPNHwsk5ZnGVfhSYrBgk47HGVZDwsqKMCTRn1ig==
+ dependencies:
+ "@abp/aspnetcore.mvc.ui" "~4.2.0"
+ "@abp/bootstrap" "~4.2.0"
+ "@abp/bootstrap-datepicker" "~4.2.0"
+ "@abp/datatables.net-bs4" "~4.2.0"
+ "@abp/font-awesome" "~4.2.0"
+ "@abp/jquery-form" "~4.2.0"
+ "@abp/jquery-validation-unobtrusive" "~4.2.0"
+ "@abp/lodash" "~4.2.0"
+ "@abp/luxon" "~4.2.0"
+ "@abp/malihu-custom-scrollbar-plugin" "~4.2.0"
+ "@abp/select2" "~4.2.0"
+ "@abp/sweetalert" "~4.2.0"
+ "@abp/timeago" "~4.2.0"
+ "@abp/toastr" "~4.2.0"
+
+"@abp/aspnetcore.mvc.ui@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui/-/aspnetcore.mvc.ui-4.2.0.tgz#9c090f64a33d31962936d8d53b345afeaa9f2ba3"
+ integrity sha512-Qt3MUZ41vuvnIVEAYxyOm1mflvFwwvKYsEjFBbePBnwaYL7udooiIFxTEm4FBh3EQJOi+8T84rnXqiIXj4Pi8A==
dependencies:
ansi-colors "^4.1.1"
extend-object "^1.0.0"
@@ -36,145 +36,145 @@
micromatch "^4.0.2"
path "^0.12.7"
-"@abp/bootstrap-datepicker@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/bootstrap-datepicker/-/bootstrap-datepicker-4.1.1.tgz#c7368837b3881bf871b286c754fac62597e0c150"
- integrity sha512-reOGgNZo0nDihX5niUcf9g2eg5OGLzeKbfDyrsn8dWyFEUPSS5JGCgHFwi943ULOR2untI0TK3J+KGqPk+5y0A==
+"@abp/bootstrap-datepicker@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/bootstrap-datepicker/-/bootstrap-datepicker-4.2.0.tgz#92abebe044a91b94b8a3b85560b501120a0fa500"
+ integrity sha512-bhEa/+zGVX00vkXGrbKI/hcl9o5Xgqwb27by9ZQqxk9Go4lwsEP/7lrXM49Cg8XZTT3L0/lYclneEMDrqGafaQ==
dependencies:
bootstrap-datepicker "^1.9.0"
-"@abp/bootstrap@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/bootstrap/-/bootstrap-4.1.1.tgz#3df31b416331241afac6e0d20e4e8a723d91a86f"
- integrity sha512-9V07JRsIdFpRqw1e4r2sGNJs6egyQjCpUfoa72e2/Bh8Qajp1bXTUvVBKxY+6XBpa3M5WmXpO/h7J8TYFGpYSQ==
+"@abp/bootstrap@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/bootstrap/-/bootstrap-4.2.0.tgz#c7ce82ead40bf0d62a318f67f180663ec76aa53c"
+ integrity sha512-E1gEX0ct67KFjKiZB6eQcIYJ3TS/pF1S4CxknBVCd77Zs03bHI+eEgBNlwcYriVBbQo+vheUQAaACbi+e2mm3Q==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
bootstrap "^4.5.0"
bootstrap-v4-rtl "4.4.1-2"
-"@abp/core@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/core/-/core-4.1.1.tgz#6f2600b5ab81033efb7441a719ef2d86f97f2edc"
- integrity sha512-mbvtqFRMSrjM8m2jpfUU5G4ZB+g2xqEyXEgn8yaFMw8Rg63Vxn3C/fGh2oa7O9z45oEuxshS4sm20ahg7xa0Iw==
+"@abp/core@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/core/-/core-4.2.0.tgz#20da3d1bab30e80d8864915fdd67e99db729be71"
+ integrity sha512-Cfa6Ck+Tr7isVpNxo9qT9eKByLadDErA+QVjeps7qYq9ztIpIz/7Yl85tHYEH0YPO9y2zcSOvxjy5SCBXlph5Q==
dependencies:
- "@abp/utils" "^4.1.1"
+ "@abp/utils" "^4.2.0"
-"@abp/datatables.net-bs4@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/datatables.net-bs4/-/datatables.net-bs4-4.1.1.tgz#70f621490423f98d6c5491bb6efa9f406504a4ad"
- integrity sha512-I8yTKHXlVolXbgk3jBFB7FFEamChTezOT2le41GW5aDJvRkeCeghsSX7qxkfwoQWVKF4j6qie2nb/RU0cTHLqQ==
+"@abp/datatables.net-bs4@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/datatables.net-bs4/-/datatables.net-bs4-4.2.0.tgz#b5cb47235079a4063c5ff8ce78e65596fa587709"
+ integrity sha512-N4hp2xCst1qavt07Nf+zXlvbZfeSah64VuMjsZgaimHMlDjxg6zVsTHLgLfzwfPV/eOBrGiecPEuvfEeaqcw4A==
dependencies:
- "@abp/datatables.net" "~4.1.1"
+ "@abp/datatables.net" "~4.2.0"
datatables.net-bs4 "^1.10.21"
-"@abp/datatables.net@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/datatables.net/-/datatables.net-4.1.1.tgz#d2d2d46be91c005a04e88cbbb81fccf647106cda"
- integrity sha512-vyc0tvAXHubdTNwTaheanGQ/PnnxOG829a/+vODqsxmCF75Xn/wVPKF3TphUOsoAx/Ues/srb3OzobSn3TnUeA==
+"@abp/datatables.net@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/datatables.net/-/datatables.net-4.2.0.tgz#2e0273c3212e5a62fc8b4138e4570fb27143f701"
+ integrity sha512-33ZkaorkVkPQ7HNtDjyIvcVbvAdFm8V+gFN+xMQZhA10wMlMGrKzVJjriv4NhNpPjtB4/owhOv6wobiuWBrGiA==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
datatables.net "^1.10.21"
-"@abp/font-awesome@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/font-awesome/-/font-awesome-4.1.1.tgz#329a45ee382ba50de29d7aa7e4e2c88cd3f894ff"
- integrity sha512-vWfD0OMEtHqbemX2yWCB3p7Tu3IxzxKob6Cle/kqK3DJG9x3D7fmg3RjTDK+VB8aEFYpGiaEPQ/bxnsQVU8cSA==
+"@abp/font-awesome@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/font-awesome/-/font-awesome-4.2.0.tgz#a637d164634b0df862e4ea620736afae282c71c9"
+ integrity sha512-P8OXp+XIZj6l7cNJ5+7Lpl8iixI/bHGSPkATggaOYZ2EWoNR3B/8pj7p44weP2bCAvUEvaxk214BKlpAslo8eQ==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
"@fortawesome/fontawesome-free" "^5.13.0"
-"@abp/jquery-form@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery-form/-/jquery-form-4.1.1.tgz#0a7ba7c959f9e0a33e5316af528c698d3698c8e5"
- integrity sha512-eTSUBAm/SD+u/FV5qZ5mgBqxmUgjcHxK243r9a5M5zVXwMi+54XsY8pGkEFtpATail/oja4AZBGXB0pbSdAQ7Q==
+"@abp/jquery-form@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery-form/-/jquery-form-4.2.0.tgz#12b88a79a69f7d3b15aed8c7ca3ff5bc9f526f22"
+ integrity sha512-lxvXhA4kg002gmDTWgoE6TcQWDe6kBcpV4KBB7aK/6LjK3noeT29SPX0kvKxjoUKyM5TqT2Hx7rg4jgtICjFFA==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
jquery-form "^4.3.0"
-"@abp/jquery-validation-unobtrusive@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery-validation-unobtrusive/-/jquery-validation-unobtrusive-4.1.1.tgz#063bad034aed1313efb61522ec7fb370ce5bea12"
- integrity sha512-xgb2qu9nlD/5h5obIj9kWnXRPucno0D3KNnPmVhN5LIeUEdme/sBxSugxG7xSzHh5b8xgnO87OA/bzy5z+Biig==
+"@abp/jquery-validation-unobtrusive@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery-validation-unobtrusive/-/jquery-validation-unobtrusive-4.2.0.tgz#05bcd303ec1e22b85389d03a8941eb898bac354f"
+ integrity sha512-mtvUcoTD5XSurMFI5cybgWzFI9bn35vU1PvH5NJxJitjJ7sg9gjtLf9WOIddIy4FdqmprhbG2YnR32GITOwFhg==
dependencies:
- "@abp/jquery-validation" "~4.1.1"
+ "@abp/jquery-validation" "~4.2.0"
jquery-validation-unobtrusive "^3.2.11"
-"@abp/jquery-validation@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery-validation/-/jquery-validation-4.1.1.tgz#94c15a55c958f9203ac48971ed257f41974e9648"
- integrity sha512-L3Bp9DLdu5VFPFA1qyNobnGMaBfYAhZaJkcNpOeUKSf8b1oTc93lPb0jlUfWcXPAVsrg1WkV4QgIC4Ep/JonYQ==
+"@abp/jquery-validation@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery-validation/-/jquery-validation-4.2.0.tgz#a09d7cf2abf8ccf0c59f27eadacb030fb2067bbe"
+ integrity sha512-/nvJrs1pt3LJX+SgH3FtDPfCDrcl4M0LDxjV7hf0Y1jtyhvWOQiyJMb8FKzMweTTEOd0pHG/GvOKd90STabSiw==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
jquery-validation "^1.19.2"
-"@abp/jquery@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery/-/jquery-4.1.1.tgz#37169b37c97ff866bf7b9b2af77b47be831ce786"
- integrity sha512-DbwqdkVctwx2q+ngzjYKWh9YRUBl+hEt1X3nxAN9XVACtF76ZqiuRkV73Rrbugggw5WZdSJoD9WW5FbGKRFQ2A==
+"@abp/jquery@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery/-/jquery-4.2.0.tgz#0a24488198ca6c9b84273fa028b853ee9f94f3a7"
+ integrity sha512-6a42Iy7knhgzvQUvCHenrVnPDKhsOyqgZkPxs9pa9x/wNapSch+jLM7u1ezKAFj/Ai4w9yG/yqP+4YE8seZDZw==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
jquery "~3.5.1"
-"@abp/lodash@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/lodash/-/lodash-4.1.1.tgz#7a643603677f72001e5a636b5df1a0eee7cd6b53"
- integrity sha512-d+pSvprxzniqqT97aIN24bpS7zHM7a6Pa/17ZK64OGC3uUZ/RrwMH3nyYxnUhVM27PgGSZigebgrhRVBcBK5Yw==
+"@abp/lodash@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/lodash/-/lodash-4.2.0.tgz#74dfac7d70f1563df2b78c5ebd0b2450e11c4c42"
+ integrity sha512-5hpjxWZJPvjMIY7FCCw/v/B+JzJbB/yuoioRzcU4vrisY9uRq54vVYcX7hH1DldsJFPTuXY3Id1WBflHA5I9Aw==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
lodash "^4.17.15"
-"@abp/luxon@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/luxon/-/luxon-4.1.1.tgz#06678bc17299453a2d9162eb3cef7d32cf1067db"
- integrity sha512-6P4+BLl6s07QBPi0Bskqcym9bOVtqB30XQRWz1I7d/ttqHg89nRvPoHhshrBQiaVq6wkVq8o+teTD2P93hFAmw==
+"@abp/luxon@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/luxon/-/luxon-4.2.0.tgz#9cd02faa02cda1315f3e23ae204991ef47d6ae7c"
+ integrity sha512-dwtv2kqWCDyQADA1Os0aIy6Au2PhBtN6q9kukLWCvYmQZI23OKuEBMSngbJVTqEPfz0LV6CWbsWCUC3okAs46A==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
luxon "^1.24.1"
-"@abp/malihu-custom-scrollbar-plugin@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/malihu-custom-scrollbar-plugin/-/malihu-custom-scrollbar-plugin-4.1.1.tgz#b630f623b1395a28db7be80e1cfb11f9805f1684"
- integrity sha512-X4mzfhEHHrC1tGutVNc2BK1Jn1x1dM/zYmUHXKbPig3xza0yBUkPeGau1y9KLtg7CheNSpQo7wlJvvrVQJsRfg==
+"@abp/malihu-custom-scrollbar-plugin@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/malihu-custom-scrollbar-plugin/-/malihu-custom-scrollbar-plugin-4.2.0.tgz#2f8538df5567a2cf227998e4e2fb9a44b6e814eb"
+ integrity sha512-3D5REdR7yw2sRRfm3Oi+qlhDABLrKvfU/l7JcCJy+vrBvadx3e3pTdTLXsGptypPN3x/Qr400LgwIrrgyefN8g==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
malihu-custom-scrollbar-plugin "^3.1.5"
-"@abp/select2@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/select2/-/select2-4.1.1.tgz#c424b87b438c681188047c00338e46e02c5926b1"
- integrity sha512-pKcrAI35eazScdDwL/qrshJoQgWzSTjBvEC2gq8VPxLxGqsUcWLv4DgMDjpIDLE6NYn7Tkvj9rgfof1Yon/JZQ==
+"@abp/select2@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/select2/-/select2-4.2.0.tgz#eb05d22b1390c037911ba25e5ca0f2ed508a93b1"
+ integrity sha512-VlNoa9+F1/kGmaEI2wbL/cRNeAEpp0UdLpbadAnsmpUIODxCULCWS556Q4Y6Ff4CzYtzkYz2qaJ8T8pn+3EOcA==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
select2 "^4.0.13"
-"@abp/sweetalert@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/sweetalert/-/sweetalert-4.1.1.tgz#05ccb26be45a127148faf4eccdc4f5cc65b87d73"
- integrity sha512-lOghwt4YHqk5CPB996YYBxDJyVS3cS1piWzIlD/HYkZfE+Zt5m2zSkaU5cd4sSFv4dhdD31MfUkTYxq8jMN4Hw==
+"@abp/sweetalert@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/sweetalert/-/sweetalert-4.2.0.tgz#b1daf641f27f0c8c2e246d364d6285c133faf773"
+ integrity sha512-AarV/L031xNB1gk/OYEUxkKZmls7zTwovS2t3ZrmwXXoav7nBCSPjEf1ByR2yhZRU/Yo1SNY/CNQQ4dgyf7Xng==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
sweetalert "^2.1.2"
-"@abp/timeago@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/timeago/-/timeago-4.1.1.tgz#9fa924e003f7955a8ee0f3b9dfe15610339849e7"
- integrity sha512-S7sxQo1q70s0V2BruVKu3BTH/XC+0/AkGuIBGKQODA+1LCOpjRGMZFoTRFx0fqNlV7qniYoQiNaXDs0anKhO+w==
+"@abp/timeago@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/timeago/-/timeago-4.2.0.tgz#9b15c496b7e63df93921d41de9e9eaf35a8dccbe"
+ integrity sha512-hyuLVGluHxtWEhR0VakPx5UCbyPcfq4lECEgHhI62PvH0xcSNNZ3bp1QnBTd3se/HAYvwA5sCwJY0YXQgUF2UQ==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
timeago "^1.6.7"
-"@abp/toastr@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/toastr/-/toastr-4.1.1.tgz#06af91ded4f03975c8ae0ff948646653b9017a88"
- integrity sha512-RR8o7S7P31SCuJD50nTQ5kc8wdAMySfMsrPEkLdWw1aGCf84e7gRlT2Tc3BWGRdXcAfjU9HioT95t8DzWc+x8w==
+"@abp/toastr@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/toastr/-/toastr-4.2.0.tgz#400e2f28b19c72b131ca32aa188ff5151d035752"
+ integrity sha512-tuGZd3kXqj1t/Y1xN8sOUH1KxiArYKD7xkhuajoOS65Ex5ad8mHPuzCtu8Pv+KL8TVFys9x3U3Tg24DQ6ASjhQ==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
toastr "^2.1.4"
-"@abp/utils@^4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.1.1.tgz#87f453602d8d8381f730f720eff206f08f218de9"
- integrity sha512-WtVKkXAW5bC6XtG/yjkChUM9Z8j+f4idc92CVQxUDOzXhQKGqNsi/3N+qacmD0o+dQVIokDgNmS10R1OaYKtcA==
+"@abp/utils@^4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.2.0.tgz#073330e3e3f6ee61892f50260e48dbe1b05df35e"
+ integrity sha512-75qR3SdiAa75wqleAx9sUMXLj4m9duuBo5+2sVv7Y29GcEyKUPvm8B1s6tksvSGA0e3vnFTHeVEc10eD1xKHSQ==
dependencies:
just-compare "^1.3.0"
diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/package.json b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/package.json
index d0ca5464b0..f0f6e96574 100644
--- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/package.json
+++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/package.json
@@ -3,8 +3,8 @@
"name": "asp.net",
"private": true,
"dependencies": {
- "@abp/aspnetcore.mvc.ui.theme.basic": "^4.1.1",
- "@abp/prismjs": "^4.1.1"
+ "@abp/aspnetcore.mvc.ui.theme.basic": "^4.2.0",
+ "@abp/prismjs": "^4.2.0"
},
"devDependencies": {}
-}
\ No newline at end of file
+}
diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/yarn.lock b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/yarn.lock
index ae59906117..c3d415ce3b 100644
--- a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/yarn.lock
+++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/yarn.lock
@@ -2,37 +2,37 @@
# yarn lockfile v1
-"@abp/aspnetcore.mvc.ui.theme.basic@^4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui.theme.basic/-/aspnetcore.mvc.ui.theme.basic-4.1.1.tgz#c1181517794fad8569f4afd1a112803e7f3e32e0"
- integrity sha512-JheNV5UVkkJZ4IdQsVmqB3lKYOQsa1NI1JfbDku9v/r/xEEhg8Ch/q39j5TPtKAmF0KES6XW6zWXzaKWYhdhVw==
- dependencies:
- "@abp/aspnetcore.mvc.ui.theme.shared" "~4.1.1"
-
-"@abp/aspnetcore.mvc.ui.theme.shared@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui.theme.shared/-/aspnetcore.mvc.ui.theme.shared-4.1.1.tgz#dbf6ae11b1e99b2cfe9e4d2175341c6fba2168d0"
- integrity sha512-HECMBY5ETtaqFxoO/7teYQmdWyFaQNeWuzMyeclMBOvR+pjAttnZiGRZGeB75OuQsfE3m6dIQ64n5chBnoBPdg==
- dependencies:
- "@abp/aspnetcore.mvc.ui" "~4.1.1"
- "@abp/bootstrap" "~4.1.1"
- "@abp/bootstrap-datepicker" "~4.1.1"
- "@abp/datatables.net-bs4" "~4.1.1"
- "@abp/font-awesome" "~4.1.1"
- "@abp/jquery-form" "~4.1.1"
- "@abp/jquery-validation-unobtrusive" "~4.1.1"
- "@abp/lodash" "~4.1.1"
- "@abp/luxon" "~4.1.1"
- "@abp/malihu-custom-scrollbar-plugin" "~4.1.1"
- "@abp/select2" "~4.1.1"
- "@abp/sweetalert" "~4.1.1"
- "@abp/timeago" "~4.1.1"
- "@abp/toastr" "~4.1.1"
-
-"@abp/aspnetcore.mvc.ui@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui/-/aspnetcore.mvc.ui-4.1.1.tgz#74facb7722834e781f2801f56dba729c575463f3"
- integrity sha512-WmRMWIeb2tYL+VhaLNvbcMKSbWNNi6cKflbIVPQQeY8WmI1ac5wWGLw7XsiniAEXP4WYrOGScXC7WNkgXGtrZw==
+"@abp/aspnetcore.mvc.ui.theme.basic@^4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui.theme.basic/-/aspnetcore.mvc.ui.theme.basic-4.2.0.tgz#01d6aab8a31fd6ea828b753805f1ba9a9165975f"
+ integrity sha512-d+7YubPbuBRY8tjqBxS4I1gyxekjg8Z0X9QaDrf/SGQBoWpIdbG09AekNdddKNkimWcPg4UgUytahPuX9f17ZA==
+ dependencies:
+ "@abp/aspnetcore.mvc.ui.theme.shared" "~4.2.0"
+
+"@abp/aspnetcore.mvc.ui.theme.shared@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui.theme.shared/-/aspnetcore.mvc.ui.theme.shared-4.2.0.tgz#a72b5e1cefa27e658b7f072a8c2c1b4ee12baef8"
+ integrity sha512-bgWwBBJA/74kFGWh7O+lzb+inV5LOlYOpDoCNAL0XgQTrutrPNHwsk5ZnGVfhSYrBgk47HGVZDwsqKMCTRn1ig==
+ dependencies:
+ "@abp/aspnetcore.mvc.ui" "~4.2.0"
+ "@abp/bootstrap" "~4.2.0"
+ "@abp/bootstrap-datepicker" "~4.2.0"
+ "@abp/datatables.net-bs4" "~4.2.0"
+ "@abp/font-awesome" "~4.2.0"
+ "@abp/jquery-form" "~4.2.0"
+ "@abp/jquery-validation-unobtrusive" "~4.2.0"
+ "@abp/lodash" "~4.2.0"
+ "@abp/luxon" "~4.2.0"
+ "@abp/malihu-custom-scrollbar-plugin" "~4.2.0"
+ "@abp/select2" "~4.2.0"
+ "@abp/sweetalert" "~4.2.0"
+ "@abp/timeago" "~4.2.0"
+ "@abp/toastr" "~4.2.0"
+
+"@abp/aspnetcore.mvc.ui@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/aspnetcore.mvc.ui/-/aspnetcore.mvc.ui-4.2.0.tgz#9c090f64a33d31962936d8d53b345afeaa9f2ba3"
+ integrity sha512-Qt3MUZ41vuvnIVEAYxyOm1mflvFwwvKYsEjFBbePBnwaYL7udooiIFxTEm4FBh3EQJOi+8T84rnXqiIXj4Pi8A==
dependencies:
ansi-colors "^4.1.1"
extend-object "^1.0.0"
@@ -43,162 +43,162 @@
micromatch "^4.0.2"
path "^0.12.7"
-"@abp/bootstrap-datepicker@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/bootstrap-datepicker/-/bootstrap-datepicker-4.1.1.tgz#c7368837b3881bf871b286c754fac62597e0c150"
- integrity sha512-reOGgNZo0nDihX5niUcf9g2eg5OGLzeKbfDyrsn8dWyFEUPSS5JGCgHFwi943ULOR2untI0TK3J+KGqPk+5y0A==
+"@abp/bootstrap-datepicker@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/bootstrap-datepicker/-/bootstrap-datepicker-4.2.0.tgz#92abebe044a91b94b8a3b85560b501120a0fa500"
+ integrity sha512-bhEa/+zGVX00vkXGrbKI/hcl9o5Xgqwb27by9ZQqxk9Go4lwsEP/7lrXM49Cg8XZTT3L0/lYclneEMDrqGafaQ==
dependencies:
bootstrap-datepicker "^1.9.0"
-"@abp/bootstrap@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/bootstrap/-/bootstrap-4.1.1.tgz#3df31b416331241afac6e0d20e4e8a723d91a86f"
- integrity sha512-9V07JRsIdFpRqw1e4r2sGNJs6egyQjCpUfoa72e2/Bh8Qajp1bXTUvVBKxY+6XBpa3M5WmXpO/h7J8TYFGpYSQ==
+"@abp/bootstrap@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/bootstrap/-/bootstrap-4.2.0.tgz#c7ce82ead40bf0d62a318f67f180663ec76aa53c"
+ integrity sha512-E1gEX0ct67KFjKiZB6eQcIYJ3TS/pF1S4CxknBVCd77Zs03bHI+eEgBNlwcYriVBbQo+vheUQAaACbi+e2mm3Q==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
bootstrap "^4.5.0"
bootstrap-v4-rtl "4.4.1-2"
-"@abp/clipboard@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/clipboard/-/clipboard-4.1.1.tgz#65d3c8ec430029e292f79549e4f8245d08fdc85c"
- integrity sha512-dy6Ewb0NHoYqXP/uInaRV9d22uzpJR+XjNrEe+g+i9JXWPwtQ/+ch439E607Z1oV3AkpjSCYCmlTuy641A2klQ==
+"@abp/clipboard@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/clipboard/-/clipboard-4.2.0.tgz#860220df1d57ef64e864401d56cb5cf7068d5861"
+ integrity sha512-yBgMDhpqPEHp9N9//Ur1BEIOicFIoKBut75PMz9XPOttLyqCmqHYEPj/jgAkUzLd5O+fJM9TE3yGNM7YdRbRPg==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
clipboard "^2.0.6"
-"@abp/core@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/core/-/core-4.1.1.tgz#6f2600b5ab81033efb7441a719ef2d86f97f2edc"
- integrity sha512-mbvtqFRMSrjM8m2jpfUU5G4ZB+g2xqEyXEgn8yaFMw8Rg63Vxn3C/fGh2oa7O9z45oEuxshS4sm20ahg7xa0Iw==
+"@abp/core@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/core/-/core-4.2.0.tgz#20da3d1bab30e80d8864915fdd67e99db729be71"
+ integrity sha512-Cfa6Ck+Tr7isVpNxo9qT9eKByLadDErA+QVjeps7qYq9ztIpIz/7Yl85tHYEH0YPO9y2zcSOvxjy5SCBXlph5Q==
dependencies:
- "@abp/utils" "^4.1.1"
+ "@abp/utils" "^4.2.0"
-"@abp/datatables.net-bs4@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/datatables.net-bs4/-/datatables.net-bs4-4.1.1.tgz#70f621490423f98d6c5491bb6efa9f406504a4ad"
- integrity sha512-I8yTKHXlVolXbgk3jBFB7FFEamChTezOT2le41GW5aDJvRkeCeghsSX7qxkfwoQWVKF4j6qie2nb/RU0cTHLqQ==
+"@abp/datatables.net-bs4@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/datatables.net-bs4/-/datatables.net-bs4-4.2.0.tgz#b5cb47235079a4063c5ff8ce78e65596fa587709"
+ integrity sha512-N4hp2xCst1qavt07Nf+zXlvbZfeSah64VuMjsZgaimHMlDjxg6zVsTHLgLfzwfPV/eOBrGiecPEuvfEeaqcw4A==
dependencies:
- "@abp/datatables.net" "~4.1.1"
+ "@abp/datatables.net" "~4.2.0"
datatables.net-bs4 "^1.10.21"
-"@abp/datatables.net@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/datatables.net/-/datatables.net-4.1.1.tgz#d2d2d46be91c005a04e88cbbb81fccf647106cda"
- integrity sha512-vyc0tvAXHubdTNwTaheanGQ/PnnxOG829a/+vODqsxmCF75Xn/wVPKF3TphUOsoAx/Ues/srb3OzobSn3TnUeA==
+"@abp/datatables.net@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/datatables.net/-/datatables.net-4.2.0.tgz#2e0273c3212e5a62fc8b4138e4570fb27143f701"
+ integrity sha512-33ZkaorkVkPQ7HNtDjyIvcVbvAdFm8V+gFN+xMQZhA10wMlMGrKzVJjriv4NhNpPjtB4/owhOv6wobiuWBrGiA==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
datatables.net "^1.10.21"
-"@abp/font-awesome@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/font-awesome/-/font-awesome-4.1.1.tgz#329a45ee382ba50de29d7aa7e4e2c88cd3f894ff"
- integrity sha512-vWfD0OMEtHqbemX2yWCB3p7Tu3IxzxKob6Cle/kqK3DJG9x3D7fmg3RjTDK+VB8aEFYpGiaEPQ/bxnsQVU8cSA==
+"@abp/font-awesome@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/font-awesome/-/font-awesome-4.2.0.tgz#a637d164634b0df862e4ea620736afae282c71c9"
+ integrity sha512-P8OXp+XIZj6l7cNJ5+7Lpl8iixI/bHGSPkATggaOYZ2EWoNR3B/8pj7p44weP2bCAvUEvaxk214BKlpAslo8eQ==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
"@fortawesome/fontawesome-free" "^5.13.0"
-"@abp/jquery-form@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery-form/-/jquery-form-4.1.1.tgz#0a7ba7c959f9e0a33e5316af528c698d3698c8e5"
- integrity sha512-eTSUBAm/SD+u/FV5qZ5mgBqxmUgjcHxK243r9a5M5zVXwMi+54XsY8pGkEFtpATail/oja4AZBGXB0pbSdAQ7Q==
+"@abp/jquery-form@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery-form/-/jquery-form-4.2.0.tgz#12b88a79a69f7d3b15aed8c7ca3ff5bc9f526f22"
+ integrity sha512-lxvXhA4kg002gmDTWgoE6TcQWDe6kBcpV4KBB7aK/6LjK3noeT29SPX0kvKxjoUKyM5TqT2Hx7rg4jgtICjFFA==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
jquery-form "^4.3.0"
-"@abp/jquery-validation-unobtrusive@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery-validation-unobtrusive/-/jquery-validation-unobtrusive-4.1.1.tgz#063bad034aed1313efb61522ec7fb370ce5bea12"
- integrity sha512-xgb2qu9nlD/5h5obIj9kWnXRPucno0D3KNnPmVhN5LIeUEdme/sBxSugxG7xSzHh5b8xgnO87OA/bzy5z+Biig==
+"@abp/jquery-validation-unobtrusive@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery-validation-unobtrusive/-/jquery-validation-unobtrusive-4.2.0.tgz#05bcd303ec1e22b85389d03a8941eb898bac354f"
+ integrity sha512-mtvUcoTD5XSurMFI5cybgWzFI9bn35vU1PvH5NJxJitjJ7sg9gjtLf9WOIddIy4FdqmprhbG2YnR32GITOwFhg==
dependencies:
- "@abp/jquery-validation" "~4.1.1"
+ "@abp/jquery-validation" "~4.2.0"
jquery-validation-unobtrusive "^3.2.11"
-"@abp/jquery-validation@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery-validation/-/jquery-validation-4.1.1.tgz#94c15a55c958f9203ac48971ed257f41974e9648"
- integrity sha512-L3Bp9DLdu5VFPFA1qyNobnGMaBfYAhZaJkcNpOeUKSf8b1oTc93lPb0jlUfWcXPAVsrg1WkV4QgIC4Ep/JonYQ==
+"@abp/jquery-validation@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery-validation/-/jquery-validation-4.2.0.tgz#a09d7cf2abf8ccf0c59f27eadacb030fb2067bbe"
+ integrity sha512-/nvJrs1pt3LJX+SgH3FtDPfCDrcl4M0LDxjV7hf0Y1jtyhvWOQiyJMb8FKzMweTTEOd0pHG/GvOKd90STabSiw==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
jquery-validation "^1.19.2"
-"@abp/jquery@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/jquery/-/jquery-4.1.1.tgz#37169b37c97ff866bf7b9b2af77b47be831ce786"
- integrity sha512-DbwqdkVctwx2q+ngzjYKWh9YRUBl+hEt1X3nxAN9XVACtF76ZqiuRkV73Rrbugggw5WZdSJoD9WW5FbGKRFQ2A==
+"@abp/jquery@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/jquery/-/jquery-4.2.0.tgz#0a24488198ca6c9b84273fa028b853ee9f94f3a7"
+ integrity sha512-6a42Iy7knhgzvQUvCHenrVnPDKhsOyqgZkPxs9pa9x/wNapSch+jLM7u1ezKAFj/Ai4w9yG/yqP+4YE8seZDZw==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
jquery "~3.5.1"
-"@abp/lodash@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/lodash/-/lodash-4.1.1.tgz#7a643603677f72001e5a636b5df1a0eee7cd6b53"
- integrity sha512-d+pSvprxzniqqT97aIN24bpS7zHM7a6Pa/17ZK64OGC3uUZ/RrwMH3nyYxnUhVM27PgGSZigebgrhRVBcBK5Yw==
+"@abp/lodash@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/lodash/-/lodash-4.2.0.tgz#74dfac7d70f1563df2b78c5ebd0b2450e11c4c42"
+ integrity sha512-5hpjxWZJPvjMIY7FCCw/v/B+JzJbB/yuoioRzcU4vrisY9uRq54vVYcX7hH1DldsJFPTuXY3Id1WBflHA5I9Aw==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
lodash "^4.17.15"
-"@abp/luxon@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/luxon/-/luxon-4.1.1.tgz#06678bc17299453a2d9162eb3cef7d32cf1067db"
- integrity sha512-6P4+BLl6s07QBPi0Bskqcym9bOVtqB30XQRWz1I7d/ttqHg89nRvPoHhshrBQiaVq6wkVq8o+teTD2P93hFAmw==
+"@abp/luxon@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/luxon/-/luxon-4.2.0.tgz#9cd02faa02cda1315f3e23ae204991ef47d6ae7c"
+ integrity sha512-dwtv2kqWCDyQADA1Os0aIy6Au2PhBtN6q9kukLWCvYmQZI23OKuEBMSngbJVTqEPfz0LV6CWbsWCUC3okAs46A==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
luxon "^1.24.1"
-"@abp/malihu-custom-scrollbar-plugin@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/malihu-custom-scrollbar-plugin/-/malihu-custom-scrollbar-plugin-4.1.1.tgz#b630f623b1395a28db7be80e1cfb11f9805f1684"
- integrity sha512-X4mzfhEHHrC1tGutVNc2BK1Jn1x1dM/zYmUHXKbPig3xza0yBUkPeGau1y9KLtg7CheNSpQo7wlJvvrVQJsRfg==
+"@abp/malihu-custom-scrollbar-plugin@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/malihu-custom-scrollbar-plugin/-/malihu-custom-scrollbar-plugin-4.2.0.tgz#2f8538df5567a2cf227998e4e2fb9a44b6e814eb"
+ integrity sha512-3D5REdR7yw2sRRfm3Oi+qlhDABLrKvfU/l7JcCJy+vrBvadx3e3pTdTLXsGptypPN3x/Qr400LgwIrrgyefN8g==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
malihu-custom-scrollbar-plugin "^3.1.5"
-"@abp/prismjs@^4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/prismjs/-/prismjs-4.1.1.tgz#ebdbea3a09e1c1bb5c7ebe2c53b12b48c7634313"
- integrity sha512-11cKcdXlf99FEbxmpOcCOj5WR/gPrIJxJfGbgvIKoYvovivleyejGmCx7yzrD39gnKf+ukKp0f2aojnj/fykEw==
+"@abp/prismjs@^4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/prismjs/-/prismjs-4.2.0.tgz#8cedfac538d225930c3654f0d94cad0102faa2f4"
+ integrity sha512-f4duxGD47p2TDMNiiBcvvjOG1hjhSbAoXyq306RrbP0CBUVTdjzzVhCPPnr5+nMoG55VlRBqh92zkax5kdgwQg==
dependencies:
- "@abp/clipboard" "~4.1.1"
- "@abp/core" "~4.1.1"
+ "@abp/clipboard" "~4.2.0"
+ "@abp/core" "~4.2.0"
prismjs "^1.20.0"
-"@abp/select2@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/select2/-/select2-4.1.1.tgz#c424b87b438c681188047c00338e46e02c5926b1"
- integrity sha512-pKcrAI35eazScdDwL/qrshJoQgWzSTjBvEC2gq8VPxLxGqsUcWLv4DgMDjpIDLE6NYn7Tkvj9rgfof1Yon/JZQ==
+"@abp/select2@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/select2/-/select2-4.2.0.tgz#eb05d22b1390c037911ba25e5ca0f2ed508a93b1"
+ integrity sha512-VlNoa9+F1/kGmaEI2wbL/cRNeAEpp0UdLpbadAnsmpUIODxCULCWS556Q4Y6Ff4CzYtzkYz2qaJ8T8pn+3EOcA==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
select2 "^4.0.13"
-"@abp/sweetalert@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/sweetalert/-/sweetalert-4.1.1.tgz#05ccb26be45a127148faf4eccdc4f5cc65b87d73"
- integrity sha512-lOghwt4YHqk5CPB996YYBxDJyVS3cS1piWzIlD/HYkZfE+Zt5m2zSkaU5cd4sSFv4dhdD31MfUkTYxq8jMN4Hw==
+"@abp/sweetalert@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/sweetalert/-/sweetalert-4.2.0.tgz#b1daf641f27f0c8c2e246d364d6285c133faf773"
+ integrity sha512-AarV/L031xNB1gk/OYEUxkKZmls7zTwovS2t3ZrmwXXoav7nBCSPjEf1ByR2yhZRU/Yo1SNY/CNQQ4dgyf7Xng==
dependencies:
- "@abp/core" "~4.1.1"
+ "@abp/core" "~4.2.0"
sweetalert "^2.1.2"
-"@abp/timeago@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/timeago/-/timeago-4.1.1.tgz#9fa924e003f7955a8ee0f3b9dfe15610339849e7"
- integrity sha512-S7sxQo1q70s0V2BruVKu3BTH/XC+0/AkGuIBGKQODA+1LCOpjRGMZFoTRFx0fqNlV7qniYoQiNaXDs0anKhO+w==
+"@abp/timeago@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/timeago/-/timeago-4.2.0.tgz#9b15c496b7e63df93921d41de9e9eaf35a8dccbe"
+ integrity sha512-hyuLVGluHxtWEhR0VakPx5UCbyPcfq4lECEgHhI62PvH0xcSNNZ3bp1QnBTd3se/HAYvwA5sCwJY0YXQgUF2UQ==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
timeago "^1.6.7"
-"@abp/toastr@~4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/toastr/-/toastr-4.1.1.tgz#06af91ded4f03975c8ae0ff948646653b9017a88"
- integrity sha512-RR8o7S7P31SCuJD50nTQ5kc8wdAMySfMsrPEkLdWw1aGCf84e7gRlT2Tc3BWGRdXcAfjU9HioT95t8DzWc+x8w==
+"@abp/toastr@~4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/toastr/-/toastr-4.2.0.tgz#400e2f28b19c72b131ca32aa188ff5151d035752"
+ integrity sha512-tuGZd3kXqj1t/Y1xN8sOUH1KxiArYKD7xkhuajoOS65Ex5ad8mHPuzCtu8Pv+KL8TVFys9x3U3Tg24DQ6ASjhQ==
dependencies:
- "@abp/jquery" "~4.1.1"
+ "@abp/jquery" "~4.2.0"
toastr "^2.1.4"
-"@abp/utils@^4.1.1":
- version "4.1.1"
- resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.1.1.tgz#87f453602d8d8381f730f720eff206f08f218de9"
- integrity sha512-WtVKkXAW5bC6XtG/yjkChUM9Z8j+f4idc92CVQxUDOzXhQKGqNsi/3N+qacmD0o+dQVIokDgNmS10R1OaYKtcA==
+"@abp/utils@^4.2.0":
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.2.0.tgz#073330e3e3f6ee61892f50260e48dbe1b05df35e"
+ integrity sha512-75qR3SdiAa75wqleAx9sUMXLj4m9duuBo5+2sVv7Y29GcEyKUPvm8B1s6tksvSGA0e3vnFTHeVEc10eD1xKHSQ==
dependencies:
just-compare "^1.3.0"
diff --git a/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_CustomServiceConstruction_Tests.cs b/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_CustomServiceConstruction_Tests.cs
new file mode 100644
index 0000000000..c1995970b5
--- /dev/null
+++ b/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_CustomServiceConstruction_Tests.cs
@@ -0,0 +1,83 @@
+using System;
+using AutoMapper;
+using Microsoft.Extensions.DependencyInjection;
+using Shouldly;
+using Volo.Abp.Modularity;
+using Volo.Abp.Testing;
+using Xunit;
+using IObjectMapper = Volo.Abp.ObjectMapping.IObjectMapper;
+
+namespace Volo.Abp.AutoMapper
+{
+ public class AutoMapper_CustomServiceConstruction_Tests : AbpIntegratedTest
+ {
+ private readonly IObjectMapper _objectMapper;
+
+ public AutoMapper_CustomServiceConstruction_Tests()
+ {
+ _objectMapper = ServiceProvider.GetRequiredService();
+ }
+
+ [Fact]
+ public void Should_Custom_Service_Construction()
+ {
+ var source = new SourceModel
+ {
+ Name = nameof(SourceModel)
+ };
+ _objectMapper.Map(source).Name.ShouldBe(nameof(CustomMappingAction));
+ }
+
+ [DependsOn(typeof(AbpAutoMapperModule))]
+ public class TestModule : AbpModule
+ {
+ public override void ConfigureServices(ServiceConfigurationContext context)
+ {
+ Configure(options =>
+ {
+ options.AddMaps();
+ options.Configurators.Add(configurationContext =>
+ {
+ configurationContext.MapperConfiguration.ConstructServicesUsing(type =>
+ type.Name.Contains(nameof(CustomMappingAction))
+ ? new CustomMappingAction(nameof(CustomMappingAction))
+ : Activator.CreateInstance(type));
+ });
+ });
+ }
+ }
+
+ public class SourceModel
+ {
+ public string Name { get; set; }
+ }
+
+ public class DestModel
+ {
+ public string Name { get; set; }
+ }
+
+ public class MapperActionProfile : Profile
+ {
+ public MapperActionProfile()
+ {
+ CreateMap().AfterMap();
+ }
+ }
+
+ public class CustomMappingAction : IMappingAction
+ {
+ private readonly string _name;
+
+ public CustomMappingAction(string name)
+ {
+ _name = name;
+ }
+
+ public void Process(SourceModel source, DestModel destination, ResolutionContext context)
+ {
+ destination.Name = _name;
+ }
+ }
+ }
+}
diff --git a/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_Dependency_Injection_Tests.cs b/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_Dependency_Injection_Tests.cs
index 56c5e6f061..7edf32eb23 100644
--- a/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_Dependency_Injection_Tests.cs
+++ b/framework/test/Volo.Abp.AutoMapper.Tests/Volo/Abp/AutoMapper/AutoMapper_Dependency_Injection_Tests.cs
@@ -19,7 +19,7 @@ namespace Volo.Abp.AutoMapper
[Fact]
public void Should_Registered_AutoMapper_Service()
{
- GetService().ShouldNotBeNull();
+ GetService().ShouldNotBeNull();
}
[Fact]
@@ -47,15 +47,30 @@ namespace Volo.Abp.AutoMapper
{
public MapperActionProfile()
{
- CreateMap().AfterMap();
+ CreateMap().AfterMap();
}
}
- public class CustomMappingActionService : IMappingAction
+ public class CustomMappingAction : IMappingAction
{
+ private readonly CustomMappingActionService _customMappingActionService;
+
+ public CustomMappingAction(CustomMappingActionService customMappingActionService)
+ {
+ _customMappingActionService = customMappingActionService;
+ }
+
public void Process(SourceModel source, DestModel destination, ResolutionContext context)
{
- destination.Name = nameof(CustomMappingActionService);
+ destination.Name = _customMappingActionService.GetName();
+ }
+ }
+
+ public class CustomMappingActionService : ITransientDependency
+ {
+ public string GetName()
+ {
+ return nameof(CustomMappingActionService);
}
}
}
diff --git a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs
index 32876c08fe..c1d5af64ef 100644
--- a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs
+++ b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/DistributedCache_Tests.cs
@@ -712,5 +712,240 @@ namespace Volo.Abp.Caching
(await personCache.GetAsync("john")).Name.ShouldBe("John Nash");
(await personCache.GetAsync("baris")).ShouldBeNull();
}
+
+ [Fact]
+ public async Task Should_Get_And_Add_Multiple_Items_Async()
+ {
+ var testkey = "testkey";
+ var testkey2 = "testkey2";
+
+ var testkey3 = new[] {testkey, testkey2};
+ var personCache = GetRequiredService>();
+
+ await personCache.SetAsync(testkey, new PersonCacheItem("john"));
+
+ var cacheValue = await personCache.GetManyAsync(testkey3);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.ShouldBeNull();
+
+ cacheValue = await personCache.GetOrAddManyAsync(testkey3, (missingKeys) =>
+ {
+ var missingKeyArray = missingKeys.ToArray();
+ missingKeyArray.Length.ShouldBe(1);
+ missingKeyArray[0].ShouldBe(testkey2);
+
+ return Task.FromResult(new List>
+ {
+ new(testkey2, new PersonCacheItem("jack"))
+ });
+ });
+
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ cacheValue = await personCache.GetManyAsync(testkey3);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+ }
+
+ [Fact]
+ public async Task Cache_Should_Only_Available_In_Uow_For_GetOrAddManyAsync()
+ {
+ var testkey = "testkey";
+ var testkey2 = "testkey2";
+
+ var testkey3 = new[] {testkey, testkey2};
+
+ using (var uow = GetRequiredService().Begin())
+ {
+ var personCache = GetRequiredService>();
+
+ var cacheValue = await personCache.GetOrAddManyAsync(testkey3, (missingKeys) => Task.FromResult(new List>
+ {
+ new(testkey, new PersonCacheItem("john")),
+ new(testkey2, new PersonCacheItem("jack")),
+ }), considerUow: true);
+
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: true);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+
+ uow.OnCompleted(async () =>
+ {
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.ShouldNotBeNull();
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+ });
+
+ await uow.CompleteAsync();
+ }
+ }
+
+ [Fact]
+ public async Task Cache_Should_Rollback_With_Uow_For_GetOrAddManyAsync()
+ {
+ var testkey = "testkey";
+ var testkey2 = "testkey2";
+
+ var testkey3 = new[] {testkey, testkey2};
+
+ var personCache = GetRequiredService>();
+
+ var cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+
+ using (var uow = GetRequiredService().Begin())
+ {
+ cacheValue = await personCache.GetOrAddManyAsync(testkey3, (missingKeys) => Task.FromResult(new List>
+ {
+ new(testkey, new PersonCacheItem("john")),
+ new(testkey2, new PersonCacheItem("jack")),
+ }), considerUow: true);
+
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: true);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+ }
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+ }
+
+ [Fact]
+ public async Task Should_Remove_Multiple_Items_Async()
+ {
+ var testkey = "testkey";
+ var testkey2 = "testkey2";
+ var testkey3 = new[] {testkey, testkey2};
+
+ var personCache = GetRequiredService>();
+
+ await personCache.SetManyAsync(new List>
+ {
+ new(testkey, new PersonCacheItem("john")),
+ new(testkey2, new PersonCacheItem("jack"))
+ });
+
+ await personCache.RemoveManyAsync(testkey3);
+
+ var cacheValue = await personCache.GetManyAsync(testkey3);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+ }
+
+ [Fact]
+ public async Task Cache_Should_Only_Available_In_Uow_For_RemoveManyAsync()
+ {
+ var testkey = "testkey";
+ var testkey2 = "testkey2";
+ var testkey3 = new[] {testkey, testkey2};
+ var personCache = GetRequiredService>();
+
+ var cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+
+ using (var uow = GetRequiredService().Begin())
+ {
+ await personCache.SetManyAsync(new List>
+ {
+ new(testkey, new PersonCacheItem("john")),
+ new(testkey2, new PersonCacheItem("jack"))
+ });
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: true);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ await personCache.RemoveManyAsync(testkey3, considerUow: true);
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ uow.OnCompleted(async () =>
+ {
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.ShouldNotBeNull();
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+ });
+
+ await uow.CompleteAsync();
+ }
+
+ }
+
+ [Fact]
+ public async Task Cache_Should_Rollback_With_Uow_For_RemoveManyAsync()
+ {
+ var testkey = "testkey";
+ var testkey2 = "testkey2";
+ var testkey3 = new[] {testkey, testkey2};
+ var personCache = GetRequiredService>();
+
+ var cacheValue = await personCache.GetManyAsync(testkey3, considerUow: false);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+
+ using (var uow = GetRequiredService().Begin())
+ {
+ await personCache.SetManyAsync(new List>
+ {
+ new(testkey, new PersonCacheItem("john")),
+ new(testkey2, new PersonCacheItem("jack"))
+ }, considerUow: true);
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: true);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.Name.ShouldBe("john");
+ cacheValue[1].Value.Name.ShouldBe("jack");
+
+ await personCache.RemoveManyAsync(testkey3, considerUow: true);
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: true);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+ }
+
+ cacheValue = await personCache.GetManyAsync(testkey3, considerUow: true);
+ cacheValue.Length.ShouldBe(2);
+ cacheValue[0].Value.ShouldBeNull();
+ cacheValue[1].Value.ShouldBeNull();
+ }
}
}
diff --git a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/TestMemoryDistributedCache.cs b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/TestMemoryDistributedCache.cs
index 69589d97cd..5df5b488d9 100644
--- a/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/TestMemoryDistributedCache.cs
+++ b/framework/test/Volo.Abp.Caching.Tests/Volo/Abp/Caching/TestMemoryDistributedCache.cs
@@ -57,5 +57,37 @@ namespace Volo.Abp.Caching
await SetAsync(item.Key, item.Value, options, token);
}
}
+
+ public void RefreshMany(IEnumerable keys)
+ {
+ foreach (var key in keys)
+ {
+ Refresh(key);
+ }
+ }
+
+ public async Task RefreshManyAsync(IEnumerable keys, CancellationToken token = default)
+ {
+ foreach (var key in keys)
+ {
+ await RefreshAsync(key, token);
+ }
+ }
+
+ public void RemoveMany(IEnumerable keys)
+ {
+ foreach (var key in keys)
+ {
+ Remove(key);
+ }
+ }
+
+ public async Task RemoveManyAsync(IEnumerable keys, CancellationToken token = default)
+ {
+ foreach (var key in keys)
+ {
+ await RemoveAsync(key, token);
+ }
+ }
}
}
diff --git a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs
index d3371f383a..7022f41b21 100644
--- a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs
+++ b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/LocalDistributedEventBus_Test.cs
@@ -44,5 +44,23 @@ namespace Volo.Abp.EventBus.Distributed
Assert.Equal(tenantId, MySimpleDistributedSingleInstanceEventHandler.TenantId);
}
+
+ [Fact]
+ public async Task Should_Get_TenantId_From_EventEto_Extra_Property()
+ {
+ var tenantId = Guid.NewGuid();
+
+ DistributedEventBus.Subscribe(GetRequiredService());
+
+ await DistributedEventBus.PublishAsync(new MySimpleEto
+ {
+ Properties =
+ {
+ {"TenantId", tenantId}
+ }
+ });
+
+ Assert.Equal(tenantId, MySimpleDistributedSingleInstanceEventHandler.TenantId);
+ }
}
}
diff --git a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/MySimpleDistributedSingleInstanceEventHandler.cs b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/MySimpleDistributedSingleInstanceEventHandler.cs
index 53fe8e347b..9141a28024 100644
--- a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/MySimpleDistributedSingleInstanceEventHandler.cs
+++ b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/Distributed/MySimpleDistributedSingleInstanceEventHandler.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Entities.Events.Distributed;
@@ -6,7 +7,7 @@ using Volo.Abp.MultiTenancy;
namespace Volo.Abp.EventBus.Distributed
{
- public class MySimpleDistributedSingleInstanceEventHandler : IDistributedEventHandler, IDistributedEventHandler>, ITransientDependency
+ public class MySimpleDistributedSingleInstanceEventHandler : IDistributedEventHandler, IDistributedEventHandler>, IDistributedEventHandler, ITransientDependency
{
private readonly ICurrentTenant _currentTenant;
@@ -28,5 +29,12 @@ namespace Volo.Abp.EventBus.Distributed
TenantId = _currentTenant.Id;
return Task.CompletedTask;
}
+
+ public Task HandleEventAsync(MySimpleEto eventData)
+ {
+ var tenantIdString = eventData.Properties.GetOrDefault("TenantId").ToString();
+ TenantId = tenantIdString != null ? new Guid(tenantIdString) : _currentTenant.Id;
+ return Task.CompletedTask;
+ }
}
}
diff --git a/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEto.cs b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEto.cs
new file mode 100644
index 0000000000..55d176c392
--- /dev/null
+++ b/framework/test/Volo.Abp.EventBus.Tests/Volo/Abp/EventBus/MySimpleEto.cs
@@ -0,0 +1,8 @@
+using Volo.Abp.Domain.Entities.Events.Distributed;
+
+namespace Volo.Abp.EventBus
+{
+ public class MySimpleEto : EtoBase
+ {
+ }
+}
\ No newline at end of file
diff --git a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs
index e53e3cabbf..c2fc5ea4b3 100644
--- a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs
+++ b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/PersonAppServiceClientProxy_Tests.cs
@@ -1,11 +1,14 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute.Extensions;
using Shouldly;
using Volo.Abp.Application.Dtos;
+using Volo.Abp.Content;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Http.Client;
using Volo.Abp.TestApp.Application;
@@ -168,5 +171,31 @@ namespace Volo.Abp.Http.DynamicProxying
result.Inner1.Value2.ShouldBe("value two");
result.Inner1.Inner2.Value3.ShouldBe("value three");
}
+
+ [Fact]
+ public async Task DownloadAsync()
+ {
+ var result = await _peopleAppService.DownloadAsync();
+
+ result.ContentType.ShouldBe("application/rtf");
+ using (var reader = new StreamReader(result.GetStream()))
+ {
+ var str = await reader.ReadToEndAsync();
+ str.ShouldBe("DownloadAsync");
+ }
+ }
+
+ [Fact]
+ public async Task UploadAsync()
+ {
+ var memoryStream = new MemoryStream();
+ await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("UploadAsync"));
+ memoryStream.Position = 0;
+ var result = await _peopleAppService.UploadAsync(new RemoteStreamContent(memoryStream)
+ {
+ ContentType = "application/rtf"
+ });
+ result.ShouldBe("UploadAsync:application/rtf");
+ }
}
}
diff --git a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/RegularTestController.cs b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/RegularTestController.cs
index da61333d4e..e18c2f8f4a 100644
--- a/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/RegularTestController.cs
+++ b/framework/test/Volo.Abp.Http.Client.Tests/Volo/Abp/Http/DynamicProxying/RegularTestController.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Globalization;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
@@ -140,5 +141,13 @@ namespace Volo.Abp.Http.DynamicProxying
[FromQuery]
public DateTime FirstReleaseDate { get; set; }
+
+ [FromQuery]
+ public List Colors { get; set; }
+
+ public Car()
+ {
+ Colors = new List();
+ }
}
}
diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs
index a34cd19ebb..2344cb7c9b 100644
--- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs
+++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/IPeopleAppService.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
+using Volo.Abp.Content;
using Volo.Abp.TestApp.Application.Dto;
namespace Volo.Abp.TestApp.Application
@@ -20,5 +21,9 @@ namespace Volo.Abp.TestApp.Application
Task GetWithAuthorized();
Task GetWithComplexType(GetWithComplexTypeInput input);
+
+ Task DownloadAsync();
+
+ Task UploadAsync(IRemoteStreamContent streamContent);
}
}
diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs
index cff72c7869..788304900d 100644
--- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs
+++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Application/PeopleAppService.cs
@@ -1,12 +1,15 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos;
using Volo.Abp.TestApp.Domain;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Application.Services;
+using Volo.Abp.Content;
using Volo.Abp.TestApp.Application.Dto;
namespace Volo.Abp.TestApp.Application
@@ -64,5 +67,24 @@ namespace Volo.Abp.TestApp.Application
{
return Task.FromResult(input);
}
+
+ public async Task DownloadAsync()
+ {
+ var memoryStream = new MemoryStream();
+ await memoryStream.WriteAsync(Encoding.UTF8.GetBytes("DownloadAsync"));
+
+ return new RemoteStreamContent(memoryStream)
+ {
+ ContentType = "application/rtf"
+ };
+ }
+
+ public async Task UploadAsync(IRemoteStreamContent streamContent)
+ {
+ using (var reader = new StreamReader(streamContent.GetStream()))
+ {
+ return await reader.ReadToEndAsync() + ":" + streamContent.ContentType;
+ }
+ }
}
}
diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/HardDelete_Tests.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/HardDelete_Tests.cs
index 3d9b324da8..e31b64f6e4 100644
--- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/HardDelete_Tests.cs
+++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/HardDelete_Tests.cs
@@ -1,7 +1,9 @@
using Shouldly;
using System;
+using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Data;
+using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Modularity;
using Volo.Abp.TestApp.Domain;
@@ -119,5 +121,40 @@ namespace Volo.Abp.TestApp.Testing
john.ShouldBeNull();
}
}
+
+ [Fact]
+ public async Task Should_HardDelete_WithDeleteMany()
+ {
+ var persons = await PersonRepository.GetListAsync();
+
+ await WithUnitOfWorkAsync(async () =>
+ {
+ var hardDeleteEntities = (HashSet)UnitOfWorkManager.Current.Items.GetOrAdd(
+ UnitOfWorkItemNames.HardDeletedEntities,
+ () => new HashSet()
+ );
+ hardDeleteEntities.UnionWith(persons);
+ await PersonRepository.DeleteManyAsync(persons);
+ });
+
+ var personsCount = await PersonRepository.GetCountAsync();
+
+ personsCount.ShouldBe(0);
+ }
+
+ [Fact]
+ public async Task Should_HardDelete_WithDeleteMany_WithPredicate()
+ {
+ await WithUnitOfWorkAsync(async () =>
+ {
+ await PersonRepository.HardDeleteAsync(x => x.Id == TestDataBuilder.UserDouglasId);
+
+ await PersonRepository.DeleteManyAsync(new[] { TestDataBuilder.UserDouglasId });
+ });
+
+ var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId);
+
+ douglas.ShouldBeNull();
+ }
}
}
diff --git a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs
index b8618fd6a3..4b313d2127 100644
--- a/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs
+++ b/framework/test/Volo.Abp.TestApp/Volo/Abp/TestApp/Testing/SoftDelete_Tests.cs
@@ -56,6 +56,23 @@ namespace Volo.Abp.TestApp.Testing
douglas.DeletionTime.ShouldNotBeNull();
}
}
+
+ [Fact]
+ public async Task Should_Cancel_Deletion_For_Soft_Delete_Many_Entities_ById()
+ {
+ await PersonRepository.DeleteManyAsync(new []{ TestDataBuilder.UserDouglasId });
+
+ var douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId);
+ douglas.ShouldBeNull();
+
+ using (DataFilter.Disable())
+ {
+ douglas = await PersonRepository.FindAsync(TestDataBuilder.UserDouglasId);
+ douglas.ShouldNotBeNull();
+ douglas.IsDeleted.ShouldBeTrue();
+ douglas.DeletionTime.ShouldNotBeNull();
+ }
+ }
[Fact]
public async Task Should_Handle_Deletion_On_Update_For_Soft_Delete_Entities()
diff --git a/framework/test/Volo.Abp.Validation.Tests/Volo/Abp/Validation/ApplicationService_Validation_Tests.cs b/framework/test/Volo.Abp.Validation.Tests/Volo/Abp/Validation/ApplicationService_Validation_Tests.cs
index de9067e2f7..cd602c07af 100644
--- a/framework/test/Volo.Abp.Validation.Tests/Volo/Abp/Validation/ApplicationService_Validation_Tests.cs
+++ b/framework/test/Volo.Abp.Validation.Tests/Volo/Abp/Validation/ApplicationService_Validation_Tests.cs
@@ -180,15 +180,19 @@ namespace Volo.Abp.Validation
{
//Valid
ValidationHelper.IsValidEmailAddress("john.doe@domain.com").ShouldBe(true);
+ ValidationHelper.IsValidEmailAddress("john-doe1@domain.co").ShouldBe(true);
ValidationHelper.IsValidEmailAddress("ip@1.2.3.123").ShouldBe(true);
ValidationHelper.IsValidEmailAddress("pharaoh@egyptian.museum").ShouldBe(true);
ValidationHelper.IsValidEmailAddress("john.doe+regexbuddy@gmail.com").ShouldBe(true);
ValidationHelper.IsValidEmailAddress("Mike.O'Dell@ireland.com").ShouldBe(true);
+ ValidationHelper.IsValidEmailAddress("admin@localhost").ShouldBe(true);
+ ValidationHelper.IsValidEmailAddress("j@h.c").ShouldBe(true);
//Invalid
- ValidationHelper.IsValidEmailAddress("1024x768@60Hz").ShouldBe(false);
ValidationHelper.IsValidEmailAddress("not.a.valid.email").ShouldBe(false);
ValidationHelper.IsValidEmailAddress("john@aol...com").ShouldBe(false);
+ ValidationHelper.IsValidEmailAddress("john@aol@domain.com").ShouldBe(false);
+ ValidationHelper.IsValidEmailAddress("jack@domain.").ShouldBe(false);
}
[DependsOn(typeof(AbpAutofacModule))]
diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
index 755cd5674b..459d115398 100644
--- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
+++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json
@@ -60,6 +60,8 @@
"Volo.Account:InvalidEmailAddress": "Can not find the given email address: {0}",
"PasswordReset": "Password reset",
"PasswordResetInfoInEmail": "We received an account recovery request! If you initiated this request, click the following link to reset your password.",
- "ResetMyPassword": "Reset my password"
+ "ResetMyPassword": "Reset my password",
+ "AccessDenied": "Access denied!",
+ "AccessDeniedMessage": "You do not have access to this resource."
}
}
diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json
index d8cf5dd74f..a1c899357b 100644
--- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json
+++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/tr.json
@@ -60,6 +60,8 @@
"Volo.Account:InvalidEmailAddress": "Email adresi bulunamadı: {0}",
"PasswordReset": "Şifre Sıfırlama",
"PasswordResetInfoInEmail": "Şifrenizi sıfırlamanız için bir talep aldık! Eğer bu talebi siz gerçekleştirmişseniz, şifrenizi sıfırlamak için bağlantıya tıklayın.",
- "ResetMyPassword": "Şifremi sıfırla"
+ "ResetMyPassword": "Şifremi sıfırla",
+ "AccessDenied": "Erişim reddedildi!",
+ "AccessDeniedMessage": "Bu kaynağa erişiminiz yok."
}
}
diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json
index 53fe6135f2..26c6fc3337 100644
--- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json
+++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json
@@ -60,6 +60,8 @@
"Volo.Account:InvalidEmailAddress": "找不到给定的电子邮件地址:{0}",
"PasswordReset": "重设密码",
"PasswordResetInfoInEmail": "我们收到了帐户恢复请求!如果你发起了此请求,请单击以下链接以重置密码.",
- "ResetMyPassword": "重置我的密码"
+ "ResetMyPassword": "重置我的密码",
+ "AccessDenied": "拒绝访问!",
+ "AccessDeniedMessage": "你无权访问此资源."
}
}
diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hant.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hant.json
index a67ea8d63f..8a57429344 100644
--- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hant.json
+++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hant.json
@@ -58,6 +58,8 @@
"ReturnToApplication": "返回到應用程序",
"PasswordReset": "重設密碼",
"PasswordResetInfoInEmail": "我們收到了帳戶恢復請求!如果你發起了此請求,請單擊以下鏈接以重置密碼.",
- "ResetMyPassword": "重置我的密碼"
+ "ResetMyPassword": "重置我的密碼",
+ "AccessDenied": "拒絕訪問!",
+ "AccessDeniedMessage": "您無權訪問此資源."
}
}
diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs
index 3d7381d2c3..4dab1f9761 100644
--- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs
+++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLoginModel.cs
@@ -103,9 +103,9 @@ namespace Volo.Abp.Account.Web.Pages.Account
public override async Task OnPostAsync(string action)
{
+ var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl);
if (action == "Cancel")
{
- var context = await Interaction.GetAuthorizationContextAsync(ReturnUrl);
if (context == null)
{
return Redirect("~/");
@@ -142,7 +142,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
{
Identity = IdentitySecurityLogIdentityConsts.Identity,
Action = result.ToIdentitySecurityLogAction(),
- UserName = LoginInput.UserNameOrEmailAddress
+ UserName = LoginInput.UserNameOrEmailAddress,
+ ClientId = context?.Client?.ClientId
});
if (result.RequiresTwoFactor)
diff --git a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs
index 26ee0d4c34..94860e80c1 100644
--- a/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs
+++ b/modules/account/src/Volo.Abp.Account.Web.IdentityServer/Pages/Account/IdentityServerSupportedLogoutModel.cs
@@ -20,12 +20,6 @@ namespace Volo.Abp.Account.Web.Pages.Account
public async override Task OnGetAsync()
{
- await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext()
- {
- Identity = IdentitySecurityLogIdentityConsts.Identity,
- Action = IdentitySecurityLogActionConsts.Logout
- });
-
await SignInManager.SignOutAsync();
var logoutId = Request.Query["logoutId"].ToString();
@@ -33,11 +27,14 @@ namespace Volo.Abp.Account.Web.Pages.Account
if (!string.IsNullOrEmpty(logoutId))
{
var logoutContext = await Interaction.GetLogoutContextAsync(logoutId);
+
+ await SaveSecurityLogAsync(logoutContext?.ClientId);
+
await SignInManager.SignOutAsync();
HttpContext.User = new ClaimsPrincipal(new ClaimsIdentity());
- LoggedOutModel vm = new LoggedOutModel()
+ var vm = new LoggedOutModel()
{
PostLogoutRedirectUri = logoutContext?.PostLogoutRedirectUri,
ClientName = logoutContext?.ClientName,
@@ -49,6 +46,8 @@ namespace Volo.Abp.Account.Web.Pages.Account
return RedirectToPage("./LoggedOut", vm);
}
+ await SaveSecurityLogAsync();
+
if (ReturnUrl != null)
{
return LocalRedirect(ReturnUrl);
@@ -58,5 +57,18 @@ namespace Volo.Abp.Account.Web.Pages.Account
$"IdentityServerSupportedLogoutModel couldn't find postLogoutUri... Redirecting to:/Account/Login..");
return RedirectToPage("/Account/Login");
}
+
+ protected virtual async Task SaveSecurityLogAsync(string clientId = null)
+ {
+ if (CurrentUser.IsAuthenticated)
+ {
+ await IdentitySecurityLogManager.SaveAsync(new IdentitySecurityLogContext()
+ {
+ Identity = IdentitySecurityLogIdentityConsts.Identity,
+ Action = IdentitySecurityLogActionConsts.Logout,
+ ClientId = clientId
+ });
+ }
+ }
}
}
diff --git a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
index 303963d24f..4a806b9ae2 100644
--- a/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
+++ b/modules/account/src/Volo.Abp.Account.Web/AbpAccountWebModule.cs
@@ -8,6 +8,7 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars;
using Volo.Abp.AutoMapper;
+using Volo.Abp.ExceptionHandling;
using Volo.Abp.Identity.AspNetCore;
using Volo.Abp.Modularity;
using Volo.Abp.UI.Navigation;
@@ -19,7 +20,8 @@ namespace Volo.Abp.Account.Web
typeof(AbpAccountHttpApiModule),
typeof(AbpIdentityAspNetCoreModule),
typeof(AbpAutoMapperModule),
- typeof(AbpAspNetCoreMvcUiThemeSharedModule)
+ typeof(AbpAspNetCoreMvcUiThemeSharedModule),
+ typeof(AbpExceptionHandlingModule)
)]
public class AbpAccountWebModule : AbpModule
{
diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccessDenied.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccessDenied.cshtml
new file mode 100644
index 0000000000..28608ff883
--- /dev/null
+++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/AccessDenied.cshtml
@@ -0,0 +1,15 @@
+@page
+@model Volo.Abp.Account.Web.Pages.Account.AccessDeniedModel
+@using Microsoft.AspNetCore.Mvc.Localization
+@using Volo.Abp.Account.Localization
+@inject IHtmlLocalizer L
+
+