Browse Source

Merge pull request #11986 from abpframework/auto-merge/rel-5-2/933

Merge branch dev with rel-5.2
pull/12009/head
liangshiwei 5 years ago
committed by GitHub
parent
commit
5048a3c9e7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      docs/en/Background-Workers.md
  2. 71
      docs/en/UI/AspNetCore/AutoComplete-Select.md
  3. 4
      docs/en/docs-nav.json
  4. BIN
      docs/en/images/abp-select2-multiple.png
  5. BIN
      docs/en/images/abp-select2-single.png
  6. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ConnectionStringChangeStep.cs
  7. 14
      framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs

10
docs/en/Background-Workers.md

@ -86,20 +86,20 @@ After creating a background worker class, you should add it to the `IBackgroundW
[DependsOn(typeof(AbpBackgroundWorkersModule))] [DependsOn(typeof(AbpBackgroundWorkersModule))]
public class MyModule : AbpModule public class MyModule : AbpModule
{ {
public override void OnApplicationInitialization( public override Task OnApplicationInitializationAsync(
ApplicationInitializationContext context) ApplicationInitializationContext context)
{ {
context.AddBackgroundWorker<PassiveUserCheckerWorker>(); context.AddBackgroundWorkerAsync<PassiveUserCheckerWorker>();
} }
} }
```` ````
`context.AddBackgroundWorker(...)` is a shortcut extension method for the expression below: `context.AddBackgroundWorkerAsync(...)` is a shortcut extension method for the expression below:
````csharp ````csharp
context.ServiceProvider await context.ServiceProvider
.GetRequiredService<IBackgroundWorkerManager>() .GetRequiredService<IBackgroundWorkerManager>()
.Add( .AddAsync(
context context
.ServiceProvider .ServiceProvider
.GetRequiredService<PassiveUserCheckerWorker>() .GetRequiredService<PassiveUserCheckerWorker>()

71
docs/en/UI/AspNetCore/AutoComplete-Select.md

@ -0,0 +1,71 @@
# ASP.NET Core MVC / Razor Pages: Auto-Complete Select
A simple select component sometimes isn't useful with a huge amount of data. ABP Provides a select implementation that works with pagination and server-side search via using [Select2](https://select2.org/). It works with single or multiple choices well.
A screenshot can be shown below.
| Single | Multiple |
| --- | --- |
| ![autocomplete-select-example](../../images/abp-select2-single.png) |![autocomplete-select-example](../../images/abp-select2-multiple.png) |
## Getting Started
This is a core feature and it's used by the ABP Framework. There is no custom installation or additional packages required.
## Usage
A simple usage is presented below.
```html
<select asp-for="Book.AuthorId"
class="auto-complete-select"
data-autocomplete-api-url="/api/app/author"
data-autocomplete-display-property="name"
data-autocomplete-value-property="id"
data-autocomplete-items-property="items"
data-autocomplete-filter-param-name="filter">
<!-- You can define selected option(s) here -->
<option selected value="@SelectedAuthor.Id">@SelectedAuthor.Name</option>
</select>
```
The select must have the `auto-complete-select` class and the following attributes:
- `data-autocomplete-api-url`: * API Endpoint url to get select items. **GET** request will be sent to this url.
- `data-autocomplete-display-property`: * Property name to display. _(For example: `name` or `title`. Property name of entity/dto.)_.
- `data-autocomplete-value-property`: * Identifier property name. _(For example: `id`)_.
- `data-autocomplete-items-property`: * Property name of collection in response object. _(For example: `items`)_
- `data-autocomplete-filter-param-name`: * Filter text property name. _(For example: `filter`)_.
- `data-autocomplete-selected-item-name`: Text to display as selected item.
- `data-autocomplete-parent-selector`: jQuery selector expression for parent DOM. _(If it's in a modal, it's suggested to send the modal selector as this parameter)_.
Also, selected value(s) should be defined with the `<option>` tags inside select, since pagination is applied and the selected options might haven't loaded yet.
### Multiple Choices
AutoComplete Select supports multiple choices. If the select tag has a `multiple` attribute, it'll allow to choose multiple options.
```html
<select asp-for="Book.TagIds"
class="auto-complete-select"
multiple="multiple"
data-autocomplete-api-url="/api/app/tags"
data-autocomplete-display-property="name"
data-autocomplete-value-property="id"
data-autocomplete-items-property="items"
data-autocomplete-filter-param-name="filter">
@foreach(var tag in SelectedTags)
{
<option selected value="@tag.Id">@tag.Name</option>
}
</select>
```
It'll be automatically bound to a collection of defined value type.
```csharp
public List<Guid> TagIds { get; set; }
```
## Notices
If the authenticated user doesn't have permission on the given URL, the user will get an authorization error. Be careful while designing this kind of UIs.
You can create a specific, [unauthorized](../../Authorization.md) endpoint/method to get the list of items, so the page can retrieve lookup data of dependent entity without giving the entire read permission to users.

4
docs/en/docs-nav.json

@ -627,6 +627,10 @@
"text": "Data Tables", "text": "Data Tables",
"path": "UI/AspNetCore/Data-Tables.md" "path": "UI/AspNetCore/Data-Tables.md"
}, },
{
"text": "Auto-Complete Select",
"path": "UI/AspNetCore/AutoComplete-Select.md"
},
{ {
"text": "Page Alerts", "text": "Page Alerts",
"path": "UI/AspNetCore/Page-Alerts.md" "path": "UI/AspNetCore/Page-Alerts.md"

BIN
docs/en/images/abp-select2-multiple.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
docs/en/images/abp-select2-single.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/ConnectionStringChangeStep.cs

@ -26,7 +26,7 @@ public class ConnectionStringChangeStep : ProjectBuildPipelineStep
return; return;
} }
var newConnectionString = $"\"{DefaultConnectionStringKey}\": \"{context.BuildArgs.ConnectionString}\""; var newConnectionString = $"\"{DefaultConnectionStringKey}\": \"{context.BuildArgs.ConnectionString.Replace(@"\\", @"\").Replace(@"\", @"\\")}\"";
foreach (var appSettingsJson in appSettingsJsonFiles) foreach (var appSettingsJson in appSettingsJsonFiles)
{ {

14
framework/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingEncryptionService.cs

@ -1,4 +1,6 @@
using System; using System;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Security.Encryption; using Volo.Abp.Security.Encryption;
@ -7,10 +9,12 @@ namespace Volo.Abp.Settings;
public class SettingEncryptionService : ISettingEncryptionService, ITransientDependency public class SettingEncryptionService : ISettingEncryptionService, ITransientDependency
{ {
protected IStringEncryptionService StringEncryptionService { get; } protected IStringEncryptionService StringEncryptionService { get; }
public ILogger<SettingEncryptionService> Logger { get; set; }
public SettingEncryptionService(IStringEncryptionService stringEncryptionService) public SettingEncryptionService(IStringEncryptionService stringEncryptionService)
{ {
StringEncryptionService = stringEncryptionService; StringEncryptionService = stringEncryptionService;
Logger = NullLogger<SettingEncryptionService>.Instance;
} }
public virtual string Encrypt(SettingDefinition settingDefinition, string plainValue) public virtual string Encrypt(SettingDefinition settingDefinition, string plainValue)
@ -30,6 +34,14 @@ public class SettingEncryptionService : ISettingEncryptionService, ITransientDep
return encryptedValue; return encryptedValue;
} }
return StringEncryptionService.Decrypt(encryptedValue); try
{
return StringEncryptionService.Decrypt(encryptedValue);
}
catch (Exception e)
{
Logger.LogException(e);
return string.Empty;
}
} }
} }

Loading…
Cancel
Save