Browse Source

Merge pull request #8 from abpframework/dev

merge
pull/2312/head
Marcelo M. M 7 years ago
committed by GitHub
parent
commit
ed28bc806d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      .github/labeler.yml
  2. 24
      .github/workflows/angular.yml
  3. 17
      .github/workflows/labeler.yml
  4. 1
      .gitignore
  5. 60
      .travis.yml
  6. 4
      README.md
  7. 7
      abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json
  8. 6
      abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/pt-BR.json
  9. 7
      abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/zh-Hans.json
  10. 40
      build-all-release.ps1
  11. 8
      docs/cs/Getting-Started-Angular-Template.md
  12. 6
      docs/cs/Getting-Started-AspNetCore-MVC-Template.md
  13. 16
      docs/en/Application-Services.md
  14. 8
      docs/en/AspNetCore/Bundling-Minification.md
  15. 2
      docs/en/Background-Jobs.md
  16. 4
      docs/en/Best-Practices/Module-Architecture.md
  17. 48
      docs/en/Best-Practices/PostgreSQL-Integration.md
  18. 2
      docs/en/CLI.md
  19. 3
      docs/en/Configuration.md
  20. 3
      docs/en/CurrentUser.md
  21. 11
      docs/en/Data-Access.md
  22. 221
      docs/en/Data-Filtering.md
  23. 3
      docs/en/Entities.md
  24. 8
      docs/en/Getting-Started-Angular-Template.md
  25. 2
      docs/en/Getting-Started-AspNetCore-Application.md
  26. 6
      docs/en/Getting-Started-AspNetCore-MVC-Template.md
  27. 3
      docs/en/Localization.md
  28. 2
      docs/en/Modules/Index.md
  29. 84
      docs/en/Modules/Setting-Management.md
  30. 4
      docs/en/Multi-Tenancy.md
  31. 4
      docs/en/Object-To-Object-Mapping.md
  32. 4
      docs/en/Options.md
  33. 179
      docs/en/Settings.md
  34. 4
      docs/en/String-Encryption.md
  35. 48
      docs/en/Tutorials/Angular/Part-II.md
  36. 2
      docs/en/Tutorials/Angular/Part-III.md
  37. BIN
      docs/en/Tutorials/Angular/images/bookstore-confirmation-popup.png
  38. 13
      docs/en/Virtual-File-System.md
  39. 12
      docs/en/docs-nav.json
  40. 8
      docs/pt-BR/Getting-Started-Angular-Template.md
  41. 6
      docs/pt-BR/Getting-Started-AspNetCore-MVC-Template.md
  42. 16
      docs/zh-Hans/Application-Services.md
  43. 2
      docs/zh-Hans/Background-Jobs.md
  44. 2
      docs/zh-Hans/Best-Practices/Application-Services.md
  45. 2
      docs/zh-Hans/Best-Practices/Entity-Framework-Core-Integration.md
  46. 16
      docs/zh-Hans/Best-Practices/Module-Architecture.md
  47. 20
      docs/zh-Hans/CLI.md
  48. 3
      docs/zh-Hans/Configuration.md
  49. 3
      docs/zh-Hans/CurrentUser.md
  50. 222
      docs/zh-Hans/Data-Filtering.md
  51. 6
      docs/zh-Hans/Getting-Started-AspNetCore-MVC-Template.md
  52. 6
      docs/zh-Hans/Index.md
  53. 3
      docs/zh-Hans/Localization.md
  54. 3
      docs/zh-Hans/Modules/Setting-Management.md
  55. 4
      docs/zh-Hans/Multi-Tenancy.md
  56. 256
      docs/zh-Hans/Object-To-Object-Mapping.md
  57. 3
      docs/zh-Hans/Options.md
  58. 180
      docs/zh-Hans/Settings.md
  59. 12
      docs/zh-Hans/Virtual-File-System.md
  60. 17
      docs/zh-Hans/docs-nav.json
  61. 16
      framework/Volo.Abp.sln
  62. 1
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj
  63. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs
  64. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleConfigurationExtensions.cs
  65. 32
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributor.cs
  66. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollection.cs
  67. 47
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleManager.cs
  68. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundlerBase.cs
  69. 15
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/IBundleContributor.cs
  70. 5
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/IBundleManager.cs
  71. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Scripts/ScriptBundler.cs
  72. 2
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Styles/StyleBundler.cs
  73. 9
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperResourceService.cs
  74. 5
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperScriptService.cs
  75. 5
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/TagHelpers/AbpTagHelperStyleService.cs
  76. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/IMinifier.cs
  77. 13
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyCssMinifier.cs
  78. 26
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyException.cs
  79. 15
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyJavascriptMinifier.cs
  80. 31
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyMinifierBase.cs
  81. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/Scripts/IJavascriptMinifier.cs
  82. 7
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/Styles/ICssMinifier.cs
  83. 3
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hans.json
  84. 28
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml
  85. 16
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml
  86. 14
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml
  87. 4
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml
  88. 14
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpErrorPageOptions.cs
  89. 70
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Controllers/ErrorController.cs
  90. 41
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml
  91. 69
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml.cs
  92. 11
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs
  93. 40
      framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml
  94. 3
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpMvcOptionsExtensions.cs
  95. 12
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ApplicationConfigurations/AbpApplicationConfigurationScriptController.cs
  96. 49
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinder.cs
  97. 47
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs
  98. 7
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/AbpServiceProxyScriptController.cs
  99. 4
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs
  100. 4
      framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/VirtualFileSystemApplicationBuilderExtensions.cs

4
.github/labeler.yml

@ -0,0 +1,4 @@
ui-angular:
- npm/ng-packs/**/*
- templates/app/angular/**/*
- templates/module/angular/**/*

24
.github/workflows/angular.yml

@ -0,0 +1,24 @@
name: 'Angular'
on:
pull_request:
paths:
- 'npm/ng-packs/**'
branches:
#- master
- dev
push:
paths:
- 'npm/ng-packs/**'
branches:
#- master
- dev
jobs:
build-test-lint:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: '10.x'
- run: yarn && yarn ci
working-directory: npm/ng-packs

17
.github/workflows/labeler.yml

@ -0,0 +1,17 @@
name: "Pull Request Labeler"
on:
pull_request:
paths:
- npm/ng-packs/**/*
- templates/app/angular/**/*
- templates/module/angular/**/*
branches:
- master
- dev
jobs:
labeler:
runs-on: ubuntu-18.04
steps:
- uses: actions/labeler@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

1
.gitignore

@ -289,4 +289,5 @@ samples/MicroserviceDemo/gateways/BackendAdminAppGateway.Host/Logs/logs.txt
samples/MicroserviceDemo/applications/PublicWebSite.Host/Logs/logs.txt
samples/MicroserviceDemo/gateways/PublicWebSiteGateway.Host/Logs/logs.txt
samples/MicroserviceDemo/microservices/BloggingService.Host/Logs/logs.txt
samples/MicroserviceDemo/applications/ConsoleClientDemo/Logs/logs.txt
modules/docs/app/Volo.DocsTestApp/Logs/logs.txt

60
.travis.yml

@ -1,60 +0,0 @@
language: csharp
mono: none
dotnet: 2.1.300
script:
- dotnet build framework
- dotnet build modules/users
- dotnet build modules/permission-management
- dotnet build modules/setting-management
- dotnet build modules/identity
- dotnet build modules/tenant-management
- dotnet build modules/account
- dotnet build modules/docs
- dotnet build modules/blogging
- dotnet test framework/test/Volo.Abp.AspNetCore.Authentication.OAuth.Tests
- dotnet test framework/test/Volo.Abp.AspNetCore.MultiTenancy.Tests
- dotnet test framework/test/Volo.Abp.AspNetCore.Mvc.Tests
- dotnet test framework/test/Volo.Abp.AspNetCore.Mvc.UI.Tests
- dotnet test framework/test/Volo.Abp.AspNetCore.Mvc.Versioning.Tests
- dotnet test framework/test/Volo.Abp.AspNetCore.Tests
- dotnet test framework/test/Volo.Abp.Auditing.Tests
- dotnet test framework/test/Volo.Abp.Authorization.Tests
- dotnet test framework/test/Volo.Abp.Autofac.Tests
- dotnet test framework/test/Volo.Abp.AutoMapper.Tests
- dotnet test framework/test/Volo.Abp.Caching.Tests
- dotnet test framework/test/Volo.Abp.Castle.Core.Tests
- dotnet test framework/test/Volo.Abp.Core.Tests
- dotnet test framework/test/Volo.Abp.Data.Tests
- dotnet test framework/test/Volo.Abp.Ddd.Tests
- dotnet test framework/test/Volo.Abp.EntityFrameworkCore.Tests
- dotnet test framework/test/Volo.Abp.EventBus.Distributed.Tests
- dotnet test framework/test/Volo.Abp.EventBus.Tests
- dotnet test framework/test/Volo.Abp.Http.Client.Tests
- dotnet test framework/test/Volo.Abp.Localization.Tests
- dotnet test framework/test/Volo.Abp.MemoryDb.Tests
- dotnet test framework/test/Volo.Abp.MongoDB.Tests
- dotnet test framework/test/Volo.Abp.MultiTenancy.Tests
- dotnet test framework/test/Volo.Abp.Serialization.Tests
- dotnet test framework/test/Volo.Abp.TestApp.Tests
- dotnet test framework/test/Volo.Abp.UI.Navigation.Tests
- dotnet test framework/test/Volo.Abp.Uow.Tests
- dotnet test framework/test/Volo.Abp.Validation.Tests
- dotnet test framework/test/Volo.Abp.VirtualFileSystem.Tests
- dotnet test modules/blogging/test/Volo.Blogging.Application.Tests
- dotnet test modules/blogging/test/Volo.Blogging.EntityFrameworkCore.Tests
- dotnet test modules/identity/test/Volo.Abp.Identity.Domain.Tests
- dotnet test modules/identity/test/Volo.Abp.Identity.EntityFrameworkCore.Tests
- dotnet test modules/identity/test/Volo.Abp.Identity.MongoDB.Tests
- dotnet test modules/identity/test/Volo.Abp.Identity.Application.Tests
- dotnet test modules/permission-management/test/Volo.Abp.PermissionManagement.Tests
- dotnet test modules/permission-management/test/Volo.Abp.PermissionManagement.MongoDB.Tests
- dotnet test modules/permission-management/test/Volo.Abp.PermissionManagement.EntityFrameworkCore.Tests
- dotnet test modules/setting-management/test/Volo.Abp.SettingManagement.EntityFrameworkCore.Tests
- dotnet test modules/setting-management/test/Volo.Abp.SettingManagement.MongoDB.Tests
- dotnet test modules/setting-management/test/Volo.Abp.SettingManagement.Tests
- dotnet test modules/tenant-management/test/Volo.Abp.TenantManagement.EntityFrameworkCore.Tests
- dotnet test modules/tenant-management/test/Volo.Abp.TenantManagement.MongoDB.Tests
- dotnet test modules/tenant-management/test/Volo.Abp.TenantManagement.Application.Tests
- dotnet test modules/users/test/Volo.Abp.Users.MongoDB.Tests
- dotnet test modules/users/test/Volo.Abp.Users.EntityFrameworkCore.Tests

4
README.md

@ -9,10 +9,6 @@ This project is the next generation of the [ASP.NET Boilerplate](https://aspnetb
See the official [web site (abp.io)](https://abp.io/) for more information.
### Status
This project is in **preview** stage and it's not suggested to use it in production yet.
### Documentation
See the <a href="https://docs.abp.io/" target="_blank">documentation</a>.

7
abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/en.json

@ -29,15 +29,15 @@
"Authorization": "Authorization",
"AuthorizationExplanation": "Advanced authorization with user, role and fine-grained permission system. Built on the Microsoft Identity library.",
"MultiTenancy": "Multi-Tenancy",
"MultiTenancyExplanation": "SaaS applications made easy! Integrated multi-tenancy from database to UI.",
"MultiTenancyExplanationShort": "SaaS applications made easy! Integrated multi-tenancy from database to UI.",
"CrossCuttingConcerns": "Cross Cutting Concerns",
"CrossCuttingConcernsExplanation": "Complete infrastructure for authorization, validation, exception handling, caching, audit logging, transaction management and so on.",
"CrossCuttingConcernsExplanationShort": "Complete infrastructure for authorization, validation, exception handling, caching, audit logging, transaction management and so on.",
"BuiltInBundlingMinification": "Built-In Bundling & Minification",
"BuiltInBundlingMinificationExplanation": "Stop to use external tools for bundling & minification. ABP offers a simpler, dynamic, powerful, modular and built-in way!",
"VirtualFileSystem": "Virtual File System",
"VirtualFileSystemExplanation": "Embed views, scripts, styles, images... into packages/libraries and reuse in different applications.",
"Theming": "Theming",
"ThemingExplanation": "Use and customize the bootstrap-based standard UI theme or create your own one.",
"ThemingExplanationShort": "Use and customize the bootstrap-based standard UI theme or create your own one.",
"BootstrapTagHelpersDynamicForms": "Bootstrap Tag Helpers & Dynamic Forms",
"BootstrapTagHelpersDynamicFormsExplanation": "Built-in background job system that can be integrated to Hangfire, RabbitMQ or any tool you like.", //TODO explanation doesn't match.
"HTTPAPIsDynamicProxies": "HTTP APIs & Dynamic Proxies",
@ -100,7 +100,6 @@
"DistributedEventBus": "Distributed Event Bus",
"DistributedEventBusWithRabbitMQIntegration": "Distributed Event Bus with RabbitMQ Integration",
"TestInfrastructure": "Test Infrastructure",
"AuditLogging": "Audit Logging",
"AuditLoggingEntityHistories": "Audit Logging & Entity Histories",
"ObjectToObjectMapping": "Object to Object Mapping",
"EmailSMSAbstractions": "Email & SMS Abstractions",

6
abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/pt-BR.json

@ -18,10 +18,10 @@
"AbpShortDescription": "ABP é uma arquitetura completa e uma forte infraestrutura para criar aplicativos da web modernos! Segue as melhores práticas e convenções para fornecer uma sólida experiência de desenvolvimento.",
"SourceCodeUpper": "CÓDIGO FONTE",
"LatestReleaseLogs": "Últimos registros de lançamento",
"Infrastructure": "Infra-estrutura",
"Infrastructure": "Infraestrutura",
"Architecture": "Arquitetura",
"Modular": "Modular",
"DontRepeatYourself": "Não se repita",
"DontRepeatYourself": "Não repita a si mesmo",
"DeveloperFocused": "Desenvolvedor focado",
"FullStackApplicationInfrastructure": "Infraestrutura de aplicativos full stack.",
"DomainDrivenDesign": "Design Orientado a Domínio",
@ -30,7 +30,7 @@
"AuthorizationExplanation": "Autorização avançada com usuário, função e sistema de permissão refinado. Criada na biblioteca Microsoft Identity.",
"MultiTenancy": "Múltiplos inquilinos",
"MultiTenancyExplanation": "Aplicativos SaaS facilitados! Multilocação integrada do banco de dados à interface do usuário.",
"CrossCuttingConcerns": "Preocupações transversais",
"CrossCuttingConcerns": "Características transversais",
"CrossCuttingConcernsExplanation": "Infraestrutura completa para autorização, validação, tratamento de exceções, armazenamento em cache, log de auditoria, gerenciamento de transações e assim por diante.",
"BuiltInBundlingMinification": "Pacote & Minificação Integrados",
"BuiltInBundlingMinificationExplanation": "Pare de usar ferramentas externas para empacotamento e minificação. O ABP oferece uma maneira mais simples, dinâmica, poderosa, modular e integrada!",

7
abp_io/AbpIoLocalization/AbpIoLocalization/Www/Localization/Resources/zh-Hans.json

@ -29,15 +29,15 @@
"Authorization": "授权",
"AuthorizationExplanation": "具有用户,角色和细粒度权限系统的高级授权. 建立在Microsoft Identity库上.",
"MultiTenancy": "多租户",
"MultiTenancyExplanation": "SaaS应用程序变得简单! 从数据库到UI的多租户集成.",
"MultiTenancyExplanationShort": "SaaS应用程序变得简单! 从数据库到UI的多租户集成.",
"CrossCuttingConcerns": "横切关注点",
"CrossCuttingConcernsExplanation": "完整的基础架构,用于授权,验证,异常处理,缓存,审计日志记录,事务管理等.",
"CrossCuttingConcernsExplanationShort": "完整的基础架构,用于授权,验证,异常处理,缓存,审计日志记录,事务管理等.",
"BuiltInBundlingMinification": "内置Bundling & Minification",
"BuiltInBundlingMinificationExplanation": "无需使用外部工具进行Bundling & Minification. ABP提供了一种更简单,动态,功能强大,模块化和内置的方式!",
"VirtualFileSystem": "虚拟文件系统",
"VirtualFileSystemExplanation": "将视图,脚本,样式,图像...嵌入到包/库中,并在不同的应用程序中重复使用.",
"Theming": "主题",
"ThemingExplanation": "使用和定制基于bootstrap的标准UI主题,或创建自己的主题.",
"ThemingExplanationShort": "使用和定制基于bootstrap的标准UI主题,或创建自己的主题.",
"BootstrapTagHelpersDynamicForms": "Bootstrap Tag Helpers和动态表单",
"BootstrapTagHelpersDynamicFormsExplanation": "内置的后台作业系统可以集成到Hangfire,RabbitMQ或您喜欢的任何工具中.", //TODO explanation doesn't match.
"HTTPAPIsDynamicProxies": "HTTP APIs和动态代理",
@ -100,7 +100,6 @@
"DistributedEventBus": "分布式事件总线",
"DistributedEventBusWithRabbitMQIntegration": "具有RabbitMQ集成的分布式事件总线",
"TestInfrastructure": "测试基础设施",
"AuditLogging": "审计日志",
"AuditLoggingEntityHistories": "审计日志和实体历史",
"ObjectToObjectMapping": "对象映射",
"EmailSMSAbstractions": "电子邮件和短信抽象",

40
build-all-release.ps1

@ -0,0 +1,40 @@
# COMMON PATHS
$rootFolder = (Get-Item -Path "./" -Verbose).FullName
# List of solutions
$solutionPaths = (
"framework",
"modules/users",
"modules/permission-management",
"modules/setting-management",
"modules/feature-management",
"modules/identity",
"modules/identityserver",
"modules/tenant-management",
"modules/account",
"modules/docs",
"modules/blogging",
"modules/audit-logging",
"modules/background-jobs",
"modules/client-simulation",
"templates/module/aspnet-core",
"templates/app/aspnet-core",
"abp_io/AbpIoLocalization"
)
# Build all solutions
foreach ($solutionPath in $solutionPaths) {
$solutionAbsPath = (Join-Path $rootFolder $solutionPath)
Set-Location $solutionAbsPath
dotnet build --configuration Release
if (-Not $?) {
Write-Host ("Build failed for the solution: " + $solutionPath)
Set-Location $rootFolder
exit $LASTEXITCODE
}
}
Set-Location $rootFolder

8
docs/cs/Getting-Started-Angular-Template.md

@ -26,10 +26,10 @@ abp new Acme.BookStore -u angular
Vytvořené řešení vyžaduje;
* [Visual Studio 2017 (v15.9.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.2+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v10.16+](https://nodejs.org)
* [Yarn v1.17+](https://yarnpkg.com/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### Struktura řešení

6
docs/cs/Getting-Started-AspNetCore-MVC-Template.md

@ -26,8 +26,10 @@ Příkaz `new` vytvoří **vrstvenou MVC aplikaci** s **Entity Framework Core**
Vytvořené řešení vyžaduje;
* [Visual Studio 2017 (v15.9.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.2+](https://www.microsoft.com/net/download/dotnet-core/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### Struktura řešení

16
docs/en/Application-Services.md

@ -201,15 +201,15 @@ See the [authorization document](Authorization.md) for more.
## CRUD Application Services
If you need to create a simple **CRUD application service** which has Create, Update, Delete and Get methods, you can use ABP's **base classes** to easily build your services. You can either inherit from `CrudAppService` or `AsyncCrudAppService`.
If you need to create a simple **CRUD application service** which has Create, Update, Delete and Get methods, you can use ABP's **base classes** to easily build your services. You can inherit from `CrudAppService`.
### Example
Create an `IBookAppService` interface inheriting from the `IAsyncCrudAppService` interface.
Create an `IBookAppService` interface inheriting from the `ICrudAppService` interface.
````csharp
public interface IBookAppService :
IAsyncCrudAppService< //Defines CRUD methods
ICrudAppService< //Defines CRUD methods
BookDto, //Used to show books
Guid, //Primary key of the book entity
PagedAndSortedResultRequestDto, //Used for paging/sorting on getting a list of books
@ -219,12 +219,12 @@ public interface IBookAppService :
}
````
* `IAsyncCrudAppService` has generic arguments to get the primary key type of the entity and the DTO types for the CRUD operations (it does not get the entity type since the entity type is not exposed to the clients use this interface).
* `ICrudAppService` has generic arguments to get the primary key type of the entity and the DTO types for the CRUD operations (it does not get the entity type since the entity type is not exposed to the clients use this interface).
`IAsyncCrudAppService` declares the following methods:
`ICrudAppService` declares the following methods:
````csharp
public interface IAsyncCrudAppService<
public interface ICrudAppService<
TEntityDto,
in TKey,
in TGetListInput,
@ -279,7 +279,7 @@ And finally, the `BookAppService` implementation is very simple:
````csharp
public class BookAppService :
AsyncCrudAppService<Book, BookDto, Guid, PagedAndSortedResultRequestDto,
CrudAppService<Book, BookDto, Guid, PagedAndSortedResultRequestDto,
CreateUpdateBookDto, CreateUpdateBookDto>,
IBookAppService
{
@ -290,7 +290,7 @@ public class BookAppService :
}
````
`AsyncCrudAppService` implements all methods declared in the `IAsyncCrudAppService` interface. You can then add your own custom methods or override and customize base methods.
`CrudAppService` implements all methods declared in the `ICrudAppService` interface. You can then add your own custom methods or override and customize base methods.
## Lifetime

8
docs/en/AspNetCore/Bundling-Minification.md

@ -114,7 +114,7 @@ public class MyWebModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<BundlingOptions>(options =>
Configure<AbpBundlingOptions>(options =>
{
options
.ScriptBundles
@ -151,7 +151,7 @@ public class MyWebExtensionModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<BundlingOptions>(options =>
Configure<AbpBundlingOptions>(options =>
{
options
.ScriptBundles
@ -189,7 +189,7 @@ public class MyExtensionGlobalStyleContributor : BundleContributor
Then you can use this contributor as like below:
````C#
services.Configure<BundlingOptions>(options =>
services.Configure<AbpBundlingOptions>(options =>
{
options
.ScriptBundles
@ -317,7 +317,7 @@ In some specific cases, it may be needed to create a **new** bundle **inherited*
Example:
````c#
services.Configure<BundlingOptions>(options =>
services.Configure<AbpBundlingOptions>(options =>
{
options
.StyleBundles

2
docs/en/Background-Jobs.md

@ -40,7 +40,7 @@ using Volo.Abp.Emailing;
namespace MyProject
{
public class EmailSendingJob : BackgroundJob<EmailSendingArgs>
public class EmailSendingJob : BackgroundJob<EmailSendingArgs>, ITransientDependency
{
private readonly IEmailSender _emailSender;

4
docs/en/Best-Practices/Module-Architecture.md

@ -57,7 +57,7 @@ Next section describes the packages in more details.
* **Do** divide the domain layer into two projects:
* **Domain.Shared** package, named as *CompanyName.ModuleName.Domain.Shared*, that contains constants, enums and other types those can be safely shared with the all layers of the module. This package can also be shared to 3rd-party clients. It can not contain entities, repositories, domain services or any other business objects.
* **Domain** package, named as *CompanyName.ModuleName.Domain*, that contains entities, repository interfaces, domain service interfaces and their implementations and other domain objects.
* Domain package depends on the **Domain.Share** package.
* Domain package depends on the **Domain.Shared** package.
#### Application Layer
@ -85,5 +85,5 @@ Next section describes the packages in more details.
#### Web Layer
* Do create a **Web** package, named as *CompanyName.ModuleName.Web*, that contains pages, views, scripts, styles, images and other UI components.
* **Do** create a **Web** package, named as *CompanyName.ModuleName.Web*, that contains pages, views, scripts, styles, images and other UI components.
* Web package only depends on the **HttpApi** package.

48
docs/en/Best-Practices/PostgreSQL-Integration.md

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

2
docs/en/CLI.md

@ -46,6 +46,8 @@ abp new Acme.BookStore
* `--tiered`: Creates a tiered solution where Web and Http API layers are physically separated. If not specified, it creates a layered solution which is less complex and suitable for most scenarios.
* `angular`: Angular. There are some additional options for this template:
* `--separate-identity-server`: Separates the identity server application from the API host application. If not specified, you will have a single endpoint in the server side.
* `none`: Without UI. There are some additional options for this template:
* `--separate-identity-server`: Separates the identity server application from the API host application. If not specified, you will have a single endpoint in the server side.
* `--database-provider` or `-d`: Specifies the database provider. Default provider is `ef`. Available providers:
* `ef`: Entity Framework Core.
* `mongodb`: MongoDB.

3
docs/en/Configuration.md

@ -0,0 +1,3 @@
# Configuration
ASP.NET Core has an flexible and extensible key-value based configuration system. In fact, the configuration system is a part of Microsoft.Extensions libraries and it is independent from ASP.NET Core. That means it can be used in any type of application. See [Microsoft's documentation](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/) to learn the configuration infrastructure. ABP framework is 100% compatible with the configuration system.

3
docs/en/CurrentUser.md

@ -0,0 +1,3 @@
# Current User
TODO!

11
docs/en/Data-Access.md

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

221
docs/en/Data-Filtering.md

@ -1,3 +1,222 @@
# Data Filtering
TODO
[Volo.Abp.Data](https://www.nuget.org/packages/Volo.Abp.Data) package defines services to automatically filter data on querying from a database.
## Pre-Defined Filters
ABP defines some filters out of the box.
### ISoftDelete
Used to mark an [entity](Entities.md) as deleted instead of actually deleting it. Implement the `ISoftDelete` interface to make your entity "soft delete".
Example:
````csharp
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace Acme.BookStore
{
public class Book : AggregateRoot<Guid>, ISoftDelete
{
public string Name { get; set; }
public bool IsDeleted { get; set; } //Defined by ISoftDelete
}
}
````
`ISoftDelete` defines the `IsDeleted` property. When you delete a book using [repositories](Repositories.md), ABP automatically sets `IsDeleted` to true and protects it from actual deletion (you can also manually set the `IsDeleted` property to true if you need). In addition, it **automatically filters deleted entities** when you query the database.
> `ISoftDelete` filter is enabled by default and you can not get deleted entities from database unless you explicitly disable it. See the `IDataFilter` service below.
### IMultiTenant
[Multi-tenancy](Multi-Tenancy.md) is an efficient way of creating SaaS applications. Once you create a multi-tenant application, you typically want to isolate data between tenants. Implement `IMultiTenant` interface to make your entity "multi-tenant aware".
Example:
````csharp
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace Acme.BookStore
{
public class Book : AggregateRoot<Guid>, ISoftDelete, IMultiTenant
{
public string Name { get; set; }
public bool IsDeleted { get; set; } //Defined by ISoftDelete
public Guid? TenantId { get; set; } //Defined by IMultiTenant
}
}
````
`IMultiTenant` interface defines the `TenantId` property which is then used to automatically filter the entities for the current tenant. See the [Multi-tenancy](Multi-Tenancy.md) document for more.
## IDataFilter Service: Enable/Disable Data Filters
You can control the filters using `IDataFilter` service.
Example:
````csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
namespace Acme.BookStore
{
public class MyBookService : ITransientDependency
{
private readonly IDataFilter _dataFilter;
private readonly IRepository<Book, Guid> _bookRepository;
public MyBookService(
IDataFilter dataFilter,
IRepository<Book, Guid> bookRepository)
{
_dataFilter = dataFilter;
_bookRepository = bookRepository;
}
public async Task<List<Book>> GetAllBooksIncludingDeletedAsync()
{
//Temporary disable the ISoftDelete filter
using (_dataFilter.Disable<ISoftDelete>())
{
return await _bookRepository.GetListAsync();
}
}
}
}
````
* [Inject](Dependency-Injection.md) the `IDataFilter` service to your class.
* Use the `Disable` method within a `using` statement to create a code block where the `ISoftDelete` filter is disabled inside it (Always use it inside a `using` block to guarantee that the filter is reset to its previous state).
`IDataFilter.Enable` method can be used to enable a filter. `Enable` and `Disable` methods can be used in a nested way to define inner scopes.
## AbpDataFilterOptions
`AbpDataFilterOptions` can be used to [set options](Options.md) for the data filter system.
The example code below disables the `ISoftDelete` filter by default which will cause to include deleted entities when you query the database unless you explicitly enable the filter:
````csharp
Configure<AbpDataFilterOptions>(options =>
{
options.DefaultStates[typeof(ISoftDelete)] = new DataFilterState(isEnabled: false);
});
````
> Carefully change defaults for global filters, especially if you are using a pre-built module which might be developed assuming the soft delete filter is turned on by default. But you can do it for your own defined filters safely.
## Defining Custom Filters
Defining and implementing a new filter highly depends on the database provider. ABP implements all pre-defined filters for all database providers.
When you need it, start by defining an interface (like `ISoftDelete` and `IMultiTenant`) for your filter and implement it for your entities.
Example:
````csharp
public interface IIsActive
{
bool IsActive { get; }
}
````
Such an `IIsActive` interface can be used to filter active/passive data and can be easily implemented by any [entity](Entities.md):
````csharp
public class Book : AggregateRoot<Guid>, IIsActive
{
public string Name { get; set; }
public bool IsActive { get; set; } //Defined by IIsActive
}
````
### EntityFramework Core
ABP uses [EF Core's Global Query Filters](https://docs.microsoft.com/en-us/ef/core/querying/filters) system for the [EF Core Integration](Entity-Framework-Core.md). So, it is well integrated to EF Core and works as expected even if you directly work with `DbContext`.
Best way to implement a custom filter is to override `CreateFilterExpression` method for your `DbContext`. Example:
````csharp
protected bool IsActiveFilterEnabled => DataFilter?.IsEnabled<IIsActive>() ?? false;
protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
{
var expression = base.CreateFilterExpression<TEntity>();
if (typeof(IIsActive).IsAssignableFrom(typeof(TEntity)))
{
Expression<Func<TEntity, bool>> isActiveFilter =
e => !IsActiveFilterEnabled || EF.Property<bool>(e, "IsActive");
expression = expression == null
? isActiveFilter
: CombineExpressions(expression, isActiveFilter);
}
return expression;
}
````
* Added a `IsActiveFilterEnabled` property to check if `IIsActive` is enabled or not. It internally uses the `IDataFilter` service introduced before.
* Overrided the `CreateFilterExpression` method, checked if given entity implements the `IIsActive` interface and combines the expressions if necessary.
### MongoDB
ABP implements data filters directly in the [repository](Repositories.md) level for the [MongoDB Integration](MongoDB.md). So, it works only if you use the repositories properly. Otherwise, you should manually filter the data.
Currently, the best way to implement a data filter for the MongoDB integration is to override the `AddGlobalFilters` in the repository derived from the `MongoDbRepository` class. Example:
````csharp
public class BookRepository : MongoDbRepository<BookStoreMongoDbContext, Book, Guid>
{
protected override void AddGlobalFilters(List<FilterDefinition<Book>> filters)
{
if (DataFilter.IsEnabled<IIsActive>())
{
filters.Add(Builders<Book>.Filter.Eq(e => ((IIsActive)e).IsActive, true));
}
}
}
````
This example implements it only for the `Book` entity. If you want to implement for all entities (those implement the `IIsActive` interface), create your own custom MongoDB repository base class and override the `AddGlobalFilters` as shown below:
````csharp
public abstract class MyMongoRepository<TMongoDbContext, TEntity, TKey> : MongoDbRepository<TMongoDbContext, TEntity, TKey>
where TMongoDbContext : IAbpMongoDbContext
where TEntity : class, IEntity<TKey>
{
protected MyMongoRepository(IMongoDbContextProvider<TMongoDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
protected override void AddGlobalFilters(List<FilterDefinition<TEntity>> filters)
{
if (typeof(IIsActive).IsAssignableFrom(typeof(TEntity))
&& DataFilter.IsEnabled<IIsActive>())
{
filters.Add(Builders<TEntity>.Filter.Eq(e => ((IIsActive)e).IsActive, true));
}
}
}
````
> See "Set Default Repository Classes" section of the [MongoDb Integration document](MongoDB.md) to learn how to replace default repository base with your custom class.

3
docs/en/Entities.md

@ -59,7 +59,8 @@ Entities with composite keys should implement the `GetKeys()` method as shown ab
Notice that you also need to define keys of the entity in your **object-relational mapping** (ORM) configuration.
> Composite primary keys has a restriction with repositories. Since it has not known Id property, you can not use `IRepository<TEntity, TKey>` for these entities. However, you can always use `IRepository<TEntity>`. See [repositories documentation](Repositories.md) for more.
> Also note that Entities with Composite Primary Keys cannot utilize the `IRepository<TEntity, TKey>` interface since it requires a single unique Id property. However, you can always use `IRepository<TEntity>`. See [repositories documentation](Repositories.md) for more.
### AggregateRoot Class

8
docs/en/Getting-Started-Angular-Template.md

@ -26,10 +26,10 @@ abp new Acme.BookStore -u angular
The created solution requires;
* [Visual Studio 2017 (v15.9.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.2+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v10.16+](https://nodejs.org)
* [Yarn v1.17+](https://yarnpkg.com/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### The Solution Structure

2
docs/en/Getting-Started-AspNetCore-Application.md

@ -14,7 +14,7 @@ This tutorial explains how to start ABP from scratch with minimal dependencies.
3. Press to the create button:
![create-aspnet-core-application](D:\Github\abp\docs\en\images\create-aspnet-core-application.png)
![create-aspnet-core-application](images/create-aspnet-core-application.png)
## Install Volo.Abp.AspNetCore.Mvc Package

6
docs/en/Getting-Started-AspNetCore-MVC-Template.md

@ -26,8 +26,10 @@ abp new Acme.BookStore
The created solution requires;
* [Visual Studio 2017 (v15.9.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.2+](https://www.microsoft.com/net/download/dotnet-core/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### The Solution Structure

3
docs/en/Localization.md

@ -48,7 +48,8 @@ public class MyModule : AbpModule
{
Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyModule>();
// "YourRootNameSpace" is the root namespace of your project. It can be empty if your root namespace is empty.
options.FileSets.AddEmbedded<MyModule>("YourRootNameSpace");
});
Configure<AbpLocalizationOptions>(options =>

2
docs/en/Modules/Index.md

@ -19,7 +19,7 @@ There are some **free and open source** application modules developed and mainta
* **Identity**: Used to manage roles, users and their permissions.
* **Identity Server**: Integrates to IdentityServer4.
* **Permission Management**: Used to persist permissions.
* **Setting Management**: Used to persist settings.
* **[Setting Management](Setting-Management.md)**: Used to persist and manage the [settings](../Settings.md).
* **Tenant Management**: Used to manage tenants for a [multi-tenant](../Multi-Tenancy.md) application.
* **Users**: Used to abstract users, so other modules can depend on this instead of the Identity module.

84
docs/en/Modules/Setting-Management.md

@ -0,0 +1,84 @@
# Setting Management Module
Setting Management Module implements the `ISettingStore` (see [the setting system](../Settings.md)) to store the setting values in a database and provides the `ISettingManager` to manage (change) the setting values in the database.
> Setting Management module is already installed and configured for [the startup templates](../Startup-Templates/Index.md). So, most of the times you don't need to manually add this module to your application.
## ISettingManager
`ISettingManager` is used to get and set the values for the settings. Examples:
````csharp
using System;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.SettingManagement;
namespace Demo
{
public class MyService : ITransientDependency
{
private readonly ISettingManager _settingManager;
//Inject ISettingManager service
public MyService(ISettingManager settingManager)
{
_settingManager = settingManager;
}
public async Task FooAsync()
{
Guid user1Id = ...;
Guid tenant1Id = ...;
//Get/set a setting value for the current user or the specified user
string layoutType1 =
await _settingManager.GetOrNullForCurrentUserAsync("App.UI.LayoutType");
string layoutType2 =
await _settingManager.GetOrNullForUserAsync("App.UI.LayoutType", user1Id);
await _settingManager.SetForCurrentUserAsync("App.UI.LayoutType", "LeftMenu");
await _settingManager.SetForUserAsync(user1Id, "App.UI.LayoutType", "LeftMenu");
//Get/set a setting value for the current tenant or the specified tenant
string layoutType3 =
await _settingManager.GetOrNullForCurrentTenantAsync("App.UI.LayoutType");
string layoutType4 =
await _settingManager.GetOrNullForTenantAsync("App.UI.LayoutType", tenant1Id);
await _settingManager.SetForCurrentTenantAsync("App.UI.LayoutType", "LeftMenu");
await _settingManager.SetForTenantAsync(tenant1Id, "App.UI.LayoutType", "LeftMenu");
//Get/set a global and default setting value
string layoutType5 =
await _settingManager.GetOrNullGlobalAsync("App.UI.LayoutType");
string layoutType6 =
await _settingManager.GetOrNullDefaultAsync("App.UI.LayoutType");
await _settingManager.SetGlobalAsync("App.UI.LayoutType", "TopMenu");
}
}
}
````
So, you can get or set a setting value for different setting value providers (Default, Global, User, Tenant... etc).
### Setting Cache
Setting values are cached using the [distributed cache](../Caching.md) system. Always use the `ISettingManager` to change the setting values which manages the cache for you.
## Setting Management Providers
Setting Management module is extensible, just like the [setting system](../Settings.md). You can extend it by defining setting management providers. There are 5 pre-built setting management providers registered by the order below:
* `DefaultValueSettingManagementProvider`: Gets the value from the default value of the setting definition. It can not set the default value since default values are hard-coded on the setting definition.
* `ConfigurationSettingManagementProvider`: Gets the value from the [IConfiguration service](Configuration.md). It can not set the configuration value because it is not possible to change the configuration values on runtime.
* `GlobalSettingManagementProvider`: Gets or sets the global (system-wide) value for a setting.
* `TenantSettingManagementProvider`: Gets or sets the setting value for a tenant.
* `UserSettingManagementProvider`: Gets the setting value for a user.
`ISettingManager` uses the setting management providers on get/set methods. Typically, every setting management provider defines extension methods on the `ISettingManagement` service (like `SetForUserAsync` defined by the user setting management provider).

4
docs/en/Multi-Tenancy.md

@ -312,10 +312,10 @@ http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers
http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
"__tenant" parameter name can be changed using AspNetCoreMultiTenancyOptions. Example:
"__tenant" parameter name can be changed using AbpAspNetCoreMultiTenancyOptions. Example:
````C#
services.Configure<AspNetCoreMultiTenancyOptions>(options =>
services.Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
{
options.TenantKey = "MyTenantKey";
});

4
docs/en/Object-To-Object-Mapping.md

@ -28,7 +28,7 @@ public class UserAppService : ApplicationService
}
```
`CreateUserInput ` is a simple [DTO](Data-Transfer-Objects.md) class and the `User` is a simple [entity](Entities.md). The code above creates a `User` entity from the given input object. The `User` entity will have more properties in a real-world application and manually creating it will become tedious and error-prone. You also have to change the mapping code when you add new properties to `User` and `CreateUserInput` classes.
`CreateUserInput` is a simple [DTO](Data-Transfer-Objects.md) class and the `User` is a simple [entity](Entities.md). The code above creates a `User` entity from the given input object. The `User` entity will have more properties in a real-world application and manually creating it will become tedious and error-prone. You also have to change the mapping code when you add new properties to `User` and `CreateUserInput` classes.
We can use a library to automatically handle these kind of mappings. ABP provides abstractions for object to object mapping and has an integration package to use [AutoMapper](http://automapper.org/) as the object mapper.
@ -182,7 +182,7 @@ public class UserAppService : ApplicationService
}
````
`UserAppService ` injects the `IObjectMapper<MyModule>`, the specific object mapper for this module. It's usage is exactly same of the `IObjectMapper`.
`UserAppService` injects the `IObjectMapper<MyModule>`, the specific object mapper for this module. It's usage is exactly same of the `IObjectMapper`.
The example code above don't use the `ObjectMapper` property defined in the `ApplicationService`, but injects the `IObjectMapper<MyModule>`. However, it is still possible to use the base property since the `ApplicationService` defines an `ObjectMapperContext` property that can be set in the class constructor. So, the example about can be re-written as like below:

4
docs/en/Options.md

@ -0,0 +1,4 @@
# Options
TODO!

179
docs/en/Settings.md

@ -1,3 +1,180 @@
# Settings
TODO!
[Configuration system](Configuration.md) is a good way to configure the application on startup. In addition to the configurations, ABP provides another way to set and get some application settings.
A setting is a name-value pair stored in a dynamic data source, generally in a database. Setting system is extensible and there are pre-built provides for a user, a tenant, global and default.
## Defining Settings
A setting must be defined before its use. ABP was designed to be [modular](Module-Development-Basics.md), so different modules can have different settings. A module must create a class derived from the `SettingDefinitionProvider` in order to define its settings. An example setting definition provider is shown below:
````csharp
public class EmailSettingProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(
new SettingDefinition("Smtp.Host", "127.0.0.1"),
new SettingDefinition("Smtp.Port", "25"),
new SettingDefinition("Smtp.UserName"),
new SettingDefinition("Smtp.Password", isEncrypted: true),
new SettingDefinition("Smtp.EnableSsl", "false")
);
}
}
````
ABP automatically discovers this class and registers the setting definitions.
### SettingDefinition
`SettingDefinition` class has the following properties:
* **Name**: Unique name of the setting in the application. This is **the only mandatory property**. Used to get/set the value of this setting in the application code (It's a good idea to define a const string for a setting name instead of using a magic string).
* **DefaultValue**: A setting may have a default value.
* **DisplayName**: A localizable string that can be used to show the setting name on the UI.
* **Description**: A localizable string that can be used to show the setting description on the UI.
* **IsVisibleToClients**: A boolean value indicates that whether this setting value is available in the client side or not. Default value is false to prevent accidently publishing an internal critical setting value.
* **IsInherited**: A boolean value indicates that whether this setting value is inherited from other providers or not. Default value is true and fallbacks to the next provider if the setting value was not set for the requested provider (see the setting value providers section for more).
* **IsEncrypted**: A boolean value indicates that whether this setting value should be encrypted on save and decrypted on read. It makes possible to secure the setting value in the database.
* **Providers**: Can be used to restrict providers available for a particular setting (see the setting value providers section for more).
* **Properties**: A name/value collection to set custom properties about this setting those can be used later in the application code.
## Reading Setting Values
### ISettingProvider
`ISettingProvider` is used to get the value of a setting or get the values of all the settings. Example usages:
````csharp
public class MyService
{
private readonly ISettingProvider _settingProvider;
//Inject ISettingProvider in the constructor
public MyService(ISettingProvider settingProvider)
{
_settingProvider = settingProvider;
}
public async Task FooAsync()
{
//Get a value as string.
string userName = await _settingProvider.GetOrNullAsync("Smtp.UserName");
//Get a bool value and fallback to the default value (false) if not set.
bool enableSsl = await _settingProvider.GetAsync<bool>("Smtp.EnableSsl");
//Get a bool value and fallback to the provided default value (true) if not set.
bool enableSsl = await _settingProvider.GetAsync<bool>(
"Smtp.EnableSsl", defaultValue: true);
//Get a bool value with the IsTrueAsync shortcut extension method
bool enableSsl = await _settingProvider.IsTrueAsync("Smtp.EnableSsl");
//Get an int value or the default value (0) if not set
int port = (await _settingProvider.GetAsync<int>("Smtp.Port"));
//Get an int value or null if not provided
int? port = (await _settingProvider.GetOrNullAsync("Smtp.Port"))?.To<int>();
}
}
````
> `ISettingProvider` is a very common service and some base classes (like `IApplicationService`) already property-inject it. You can directly use the `SettingProvider` in such cases.
### Reading Setting Values on the Client Side
If a setting is allowed to be visible on the client side, current value of the setting can also be read from the JavaScript code. Examples:
````js
//Gets a value as string.
var language = abp.setting.get('Abp.Localization.DefaultLanguage');
//Gets an integer value.
var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength');
//Gets a boolean value.
var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit');
````
In addition, use `abp.setting.values` to get a dictionary of all the setting values.
## Setting Value Providers
Setting system is extensible, you can extend it by defining setting value providers to get setting values from any source and based on any condition.
`ISettingProvider` uses the setting value providers to obtain a setting value. It fallbacks to the next value provider if a value provider can not get the setting value.
There are 5 pre-built setting value providers registered by the order below:
* `DefaultValueSettingValueProvider`: Gets the value from the default value of the setting definition, if set (see the SettingDefinition section above).
* `ConfigurationSettingValueProvider`: Gets the value from the [IConfiguration service](Configuration.md).
* `GlobalSettingValueProvider`: Gets the global (system-wide) value for a setting, if set.
* `TenantSettingValueProvider`: Gets the setting value for the current tenant, if set (see the [multi-tenancy](Multi-Tenancy.md) document).
* `UserSettingValueProvider`: Gets the setting value for the current user, if set (see the [current user](CurrentUser.md) document).
> Setting fallback system works from bottom (user) to top (default).
Global, Tenant and User setting value providers use the `ISettingStore` to read the value from the data source (see the section below).
### Custom Setting Value Providers
If you need to extend the setting system, you can define a class derived from the `SettingValueProvider` class. Example:
````csharp
public class CustomSettingValueProvider : SettingValueProvider
{
public override string Name => "Custom";
public CustomSettingValueProvider(ISettingStore settingStore)
: base(settingStore)
{
}
public override Task<string> GetOrNullAsync(SettingDefinition setting)
{
/* Return the setting value or null
Use the SettingStore or another data source */
}
}
````
> Alternatively, you can implement the `ISettingValueProvider` interface. Remember to register it to the [dependency injection](Dependency-Injection.md) in this case.
Every provider should have a unique Name (which is "Custom" here). Built-in providers use the given names:
* `DefaultValueSettingValueProvider`: "**D**".
* `ConfigurationSettingValueProvider`: "**C**".
* `GlobalSettingValueProvider`: "**G**".
* `TenantSettingValueProvider`: "**T**".
* `UserSettingValueProvider`: "**U**".
One-letter names were preferred to reduce the data size in the database (provider name is repeated in each row).
Once you define a custom setting value provider, you need to explicitly register it to the `AbpSettingOptions`:
````csharp
Configure<AbpSettingOptions>(options =>
{
options.ValueProviders.Add<CustomSettingValueProvider>();
});
````
This example adds it as the last item, so it will be the first value provider used by the `ISettingProvider`. You could add it to another index in the `options.ValueProviders` list.
### ISettingStore
While a setting value provider is free to use any source to get the setting value, the`ISettingStore` service is the default source of the setting values. Global, Tenant and User setting value providers use it.
## ISettingEncryptionService
`ISettingEncryptionService` is used to encrypt/decrypt setting values when `IsEncrypted` property of a setting definition was set to `true`.
You can replace this service in the dependency injection system to customize the encryption/decryption process. Default implementation uses the `StringEncryptionService` which is implemented with the AES algorithm by default (see string [encryption document](String-Encryption.md) for more).
## Setting Management Module
The core setting system is pretty independent and doesn't make any assumption about how you manage (change) the setting values. Even the default `ISettingStore` implementation is the `NullSettingStore` which returns null for all setting values.
The setting management module completes it (and implements `ISettingStore`) by managing setting values in a database. See the [Setting Management Module document](Modules/Setting-Management.md) for more.

4
docs/en/String-Encryption.md

@ -0,0 +1,4 @@
# String Encryption
TODO!

48
docs/en/Tutorials/Angular/Part-II.md

@ -137,7 +137,7 @@ createBook() {
Add a `form` variable and inject a `FormBuilder` service to the `book-list.component.ts` as shown below (remember add the import statement).
```js
import { FormGroup, FormBuilder } from '@angular/forms';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
form: FormGroup;
@ -218,25 +218,6 @@ Open `book-list.component.html` and add the form in the body template of the mod
> We've used [NgBootstrap datepicker](https://ng-bootstrap.github.io/#/components/datepicker/overview) in this component.
Open the `book-list.component.ts` and then create an array, named `bookTypeArr`:
```js
//...
form: FormGroup;
bookTypeArr = Object.keys(Books.BookType).filter(
bookType => typeof this.booksType[bookType] === 'number'
);
```
The `bookTypeArr` contains the fields of the `BookType` enum. Resulting array is shown below:
```js
['Adventure', 'Biography', 'Dystopia', 'Fantastic' ...]
```
This array was used in the previous form template (in the `ngFor` loop).
#### Datepicker Requirements
You need to import `NgbDatepickerModule` to the `books.module.ts`:
@ -268,6 +249,28 @@ export class BookListComponent implements OnInit {
> The `NgbDateAdapter` converts Datepicker value to `Date` type. See the [datepicker adapters](https://ng-bootstrap.github.io/#/components/datepicker/overview) for more details.
#### Create the Book Type Array
Open the `book-list.component.ts` and then create an array, named `bookTypeArr`:
```js
//...
booksType = Books.BookType;
bookTypeArr = Object.keys(Books.BookType).filter(
bookType => typeof this.booksType[bookType] === 'number'
);
```
The `bookTypeArr` contains the fields of the `BookType` enum. Resulting array is shown below:
```js
['Adventure', 'Biography', 'Dystopia', 'Fantastic' ...]
```
This array was used in the previous form template (in the `ngFor` loop).
![new-book-form](images/bookstore-new-book-form.png)
#### Saving the Book
@ -293,6 +296,9 @@ This adds a save button to the bottom area of the modal:
Then define a `save` method in the `BookListComponent`:
```js
//...
import { ..., CreateUpdateBook } from '../../store/actions';
//...
save() {
if (this.form.invalid) {
return;
@ -330,7 +336,7 @@ update(updateBookInput: Books.CreateUpdateBookInput, id: string): Observable<Boo
#### CreateUpdateBook Action
Open the `books.actins.ts` and add `id` parameter to the `CreateUpdateBook` action:
Open the `books.actions.ts` and add `id` parameter to the `CreateUpdateBook` action:
```js
export class CreateUpdateBook {

2
docs/en/Tutorials/Angular/Part-III.md

@ -1,4 +1,4 @@
## ASP.NET Core MVC Tutorial - Part III
## Angular Tutorial - Part III
### About this Tutorial

BIN
docs/en/Tutorials/Angular/images/bookstore-confirmation-popup.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 13 KiB

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

@ -44,7 +44,7 @@ If you want to add multiple files, this can be tedious. Alternatively, you can d
This configuration recursively adds all files under the **MyResources** folder of the project (including the files you will add in the future).
Then the module needs to be configured using `VirtualFileSystemOptions` to register the embedded files to the virtual file system. Example:
Then the module needs to be configured using `AbpVirtualFileSystemOptions` to register the embedded files to the virtual file system. Example:
````C#
using Microsoft.Extensions.DependencyInjection;
@ -58,10 +58,10 @@ namespace MyCompany.MyProject
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<VirtualFileSystemOptions>(options =>
Configure<AbpVirtualFileSystemOptions>(options =>
{
//Register all embedded files of this assembly to the virtual file system
options.FileSets.AddEmbedded<MyModule>();
options.FileSets.AddEmbedded<MyModule>("YourRootNameSpace");
});
//...
@ -73,9 +73,12 @@ namespace MyCompany.MyProject
The `AddEmbedded` extension method takes a class, finds all embedded files from the assembly of the given class and registers them to the virtual file system. More concisely it could be written as follows:
````C#
options.FileSets.Add(new EmbeddedFileSet(typeof(MyModule).Assembly));
options.FileSets.Add(
new EmbeddedFileSet(typeof(MyModule).Assembly), "YourRootNameSpace");
````
> "YourRootNameSpace" is the root namespace of your project. It can be empty if your root namespace is empty.
#### Getting Virtual Files: IVirtualFileProvider
After embedding a file into an assembly and registering it to the virtual file system, the `IVirtualFileProvider` interface can be used to get files or directory contents:
@ -122,7 +125,7 @@ public class MyWebAppModule : AbpModule
if (hostingEnvironment.IsDevelopment()) //only for development time
{
Configure<VirtualFileSystemOptions>(options =>
Configure<AbpVirtualFileSystemOptions>(options =>
{
//ReplaceEmbeddedByPhysical gets the root folder of the MyModule project
options.FileSets.ReplaceEmbeddedByPhysical<MyModule>(

12
docs/en/docs-nav.json

@ -56,6 +56,10 @@
{
"text": "Fundamentals",
"items": [
{
"text": "Configuration",
"path": "Configuration.md"
},
{
"text": "Dependency Injection",
"path": "Dependency-Injection.md",
@ -93,7 +97,8 @@
"text": "Auditing"
},
{
"text": "Setting Management"
"text": "Settings",
"path": "Settings.md"
}
]
},
@ -116,6 +121,10 @@
{
"text": "Services",
"items": [
{
"text": "Current User",
"path": "CurrentUser.md"
},
{
"text": "Object to object mapping",
"path": "Object-To-Object-Mapping.md"
@ -248,6 +257,7 @@
},
{
"text": "Data Access",
"path": "Data-Access.md"
"items": [
{
"text": "Entity Framework Core Integration",

8
docs/pt-BR/Getting-Started-Angular-Template.md

@ -26,10 +26,10 @@ abp new Acme.BookStore -u angular
A solução criada requer;
- [Visual Studio 2017 (v15.9.0 +)](https://visualstudio.microsoft.com/tr/downloads/)
- [.NET Core 2.2 ou superior](https://www.microsoft.com/net/download/dotnet-core/)
- [Node v10.16 +](https://nodejs.org/)
- [Yarn v1.17 +](https://yarnpkg.com/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### A Estrutura da Solução

6
docs/pt-BR/Getting-Started-AspNetCore-MVC-Template.md

@ -26,8 +26,10 @@ abp new Acme.BookStore
A solução criada requer;
- [Visual Studio 2017 (v15.9.0 +)](https://visualstudio.microsoft.com/tr/downloads/)
- [.NET Core 2.2 ou superior](https://www.microsoft.com/net/download/dotnet-core/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### A Estrutura da Solução

16
docs/zh-Hans/Application-Services.md

@ -200,15 +200,15 @@ public async Task<BookDto> GetAsync(Guid id)
### CRUD应用服务
如果需要创建具有Create,Update,Delete和Get方法的简单CRUD应用服务,则可以使用ABP的基类轻松构建服务. 你可以继承CrudAppService或 AsyncCrudAppService.
如果需要创建具有Create,Update,Delete和Get方法的简单CRUD应用服务,则可以使用ABP的基类轻松构建服务. 你可以继承CrudAppService.
示例:
创建继承`IAsyncCrudAppService`接口的`IBookAppService`接口.
创建继承`ICrudAppService`接口的`IBookAppService`接口.
````csharp
public interface IBookAppService :
IAsyncCrudAppService< //Defines CRUD methods
ICrudAppService< //Defines CRUD methods
BookDto, //Used to show books
Guid, //Primary key of the book entity
PagedAndSortedResultRequestDto, //Used for paging/sorting on getting a list of books
@ -218,12 +218,12 @@ public interface IBookAppService :
}
````
* IAsyncCrudAppService有泛型参数来获取实体的主键类型和CRUD操作的DTO类型(它不获取实体类型,因为实体类型未向客户端公开使用此接口).
* ICrudAppService有泛型参数来获取实体的主键类型和CRUD操作的DTO类型(它不获取实体类型,因为实体类型未向客户端公开使用此接口).
`IAsyncCrudAppService`声明以下方法:
`ICrudAppService`声明以下方法:
````csharp
public interface IAsyncCrudAppService<
public interface ICrudAppService<
TEntityDto,
in TKey,
in TGetListInput,
@ -278,7 +278,7 @@ public class CreateUpdateBookDto
````csharp
public class BookAppService :
AsyncCrudAppService<Book, BookDto, Guid, PagedAndSortedResultRequestDto,
CrudAppService<Book, BookDto, Guid, PagedAndSortedResultRequestDto,
CreateUpdateBookDto, CreateUpdateBookDto>,
IBookAppService
{
@ -289,7 +289,7 @@ public class BookAppService :
}
````
`AsyncCrudAppService`实现了`IAsyncCrudAppService`接口中声明的所有方法. 然后,你可以添加自己的自定义方法或覆盖和自定义实现.
`CrudAppService`实现了`ICrudAppService`接口中声明的所有方法. 然后,你可以添加自己的自定义方法或覆盖和自定义实现.
### 生命周期

2
docs/zh-Hans/Background-Jobs.md

@ -42,7 +42,7 @@ using Volo.Abp.Emailing;
namespace MyProject
{
public class EmailSendingJob : BackgroundJob<EmailSendingArgs>
public class EmailSendingJob : BackgroundJob<EmailSendingArgs>, ITransientDependency
{
private readonly IEmailSender _emailSender;

2
docs/zh-Hans/Best-Practices/Application-Services.md

@ -45,7 +45,7 @@ public class IssueLabelDto
##### 详细DTO
**Do** 如果实体持有对其他聚合根的引用,那么应该为其定义**详细**DTO.
**推荐** 如果实体持有对其他聚合根的引用,那么应该为其定义**详细**DTO.
* 直接包含实体中所有的 **原始属性**.
- 例外-1: 出于**安全**原因,可以**排除**某些属性(像 `User.Password`).

2
docs/zh-Hans/Best-Practices/Entity-Framework-Core-Integration.md

@ -58,7 +58,7 @@ public static string Schema { get; set; } = AbpIdentityConsts.DefaultDbSchema;
### Model Mapping
- **Do** 重写 `DbContext` 的 `OnModelCreating` 方法显式 **配置所有实体**. 例如:
- **推荐** 重写 `DbContext` 的 `OnModelCreating` 方法显式 **配置所有实体**. 例如:
````C#
protected override void OnModelCreating(ModelBuilder builder)

16
docs/zh-Hans/Best-Practices/Module-Architecture.md

@ -57,33 +57,33 @@
* **推荐** 将领域层划分为两个项目:
* **Domain.Shared** 包(项目) 命名为*CompanyName.ModuleName.Domain.Shared*,包含常量,枚举和其他类型, 它不能包含实体,存储库,域服务或任何其他业务对象. 可以安全地与模块中的所有层使用. 此包也可以与第三方客户端使用.
* **Domain** 包(项目) 命名为*CompanyName.ModuleName.Domain*, 包含实体, 仓储接口,领域服务接口及其实现和其他领域对象.
* Domain package 依赖于 **Domain.Share** package.
* Domain 包依赖于 **Domain.Shared** 包.
#### 应用服务层
* **推荐** 将应用服务层划分为两个项目:
* **Application.Contracts** 包(项目) 命名为*CompanyName.ModuleName.Application.Contracts,包含应用服务接口和相关的数据传输对象(DTO).
* Application contract package 依赖于 **Domain.Shared** package.
* Application contract 包依赖于 **Domain.Shared** 包.
* **Application** 包(项目)命名为*CompanyName.ModuleName.Application*,包含应用服务实现.
* Application package 依赖于 **Domain** 和 **Application.Contracts** packages.
* Application 包依赖于 **Domain** 包和 **Application.Contracts** 包.
#### 基础设施层
* **推荐** 为每个orm/数据库集成创建一个独立的集成包, 比如Entity Framework Core 和 MongoDB.
* **推荐** 例如, 创建一个抽象Entity Framework Core集成的*CompanyName.ModuleName.EntityFrameworkCore* package. ORM 集成 package 依赖于 **Domain** package.
* **推荐** 例如, 创建一个抽象Entity Framework Core集成的*CompanyName.ModuleName.EntityFrameworkCore* 包. ORM 集成包依赖于 **Domain** 包.
* **不推荐** 依赖于orm/数据库集成包中的其他层.
* **推荐** 为每个主要的库创建一个独立的集成包, 在不影响其他包的情况下可以被另一个库替换.
#### HTTP 层
* **推荐** 创建命名为*CompanyName.ModuleName.HttpApi*的**HTTP API**包, 为模块开发REST风格的HTTP API.
* HTTP API package 只依赖于 **Application.Contracts** package. 不要依赖 Application package.
* HTTP API 包只依赖于 **Application.Contracts** 包. 不要依赖 Application 包.
* **推荐** 为每个应用服务创建一个Controller (通常通过实现其接口). 这些控制器使用应用服务接口来委托操作. 它根据需要配置路由, HTTP方法和其他与Web相关的东西.
* **推荐** 创建一个为HTTP API包提供客户端服务的**HTTP API Client**包, 它的命名为*companyname.modulename.httpapi*. 这些客户端服务将应用服务接口实现远程端点的客户端.
* HTTP API Client package 仅依赖于 **Application.Contracts** package.
* **推荐** 创建一个为HTTP API包提供客户端服务的**HTTP API Client**包, 它的命名为*Companyname.ModuleName.HttpApi.Client*. 这些客户端服务将应用服务接口实现远程端点的客户端.
* HTTP API Client 包仅依赖于 **Application.Contracts** 包.
* **推荐** 使用ABP框架提供的动态代理HTTP C#客户端的功能.
#### Web 层
* **推荐** 创建命名为*CompanyName.ModuleName.Web*的 **Web**包. 包含页面,视图,脚本,样式,图像和其他UI组件.
* Web package 仅依赖于 **HttpApi** package.
* Web 包仅依赖于 **HttpApi** 包.

20
docs/zh-Hans/CLI.md

@ -40,19 +40,21 @@ abp new Acme.BookStore
#### Options
* `--template` 或者 `-t`: 指定模板. 默认的模板是 `app`,会生成web项目.可用的模板有:
* `app` (default): [应用程序模板](Startup-Templates/Application.md)。 其他选项:
* `--ui` 或者 `-u`: 指定ui框架。默认`mvc`框架。其他选项:
* `mvc`: ASP.NET Core MVC。此模板的其他选项:
* `--tiered`: 创建分层解决方案,Web和Http Api层在物理上是分开的。如果未指定会创建一个分层的解决方案,此解决方案没有那么复杂,适合大多数场景。
* `app` (default): [应用程序模板](Startup-Templates/Application.md). 其他选项:
* `--ui` 或者 `-u`: 指定ui框架.默认`mvc`框架.其他选项:
* `mvc`: ASP.NET Core MVC.此模板的其他选项:
* `--tiered`: 创建分层解决方案,Web和Http Api层在物理上是分开的.如果未指定会创建一个分层的解决方案,此解决方案没有那么复杂,适合大多数场景.
* `angular`: Angular. 这个模板还有一些额外的选项:
* `--separate-identity-server`: Separates the identity server application from the API host application. If not specified, you will have a single endpoint in the server side.
* `--database-provider` 或者 `-d`: 指定数据库提供程序。默认是 `ef`。其他选项:
* `--separate-identity-server`: 将Identity Server应用程序与API host应用程序分开. 如果未指定,则服务器端将只有一个端点.
* `none`: 无UI. 这个模板还有一些额外的选项:
* `--separate-identity-server`: 将Identity Server应用程序与API host应用程序分开. 如果未指定,则服务器端将只有一个端点.
* `--database-provider` 或者 `-d`: 指定数据库提供程序.默认是 `ef`.其他选项:
* `ef`: Entity Framework Core.
* `mongodb`: MongoDB.
* `module`: [Module template](Startup-Templates/Module.md). 其他选项:
* `--no-ui`: 不包含UI。仅创建服务模块(也称为微服务 - 没有UI)。
* `--output-folder` 或者 `-o`: 指定输出文件夹,默认是当前目录。
* `--version` 或者 `-v`: 指定ABP和模板的版本。它可以是 [release tag](https://github.com/abpframework/abp/releases) 或者 [branch name](https://github.com/abpframework/abp/branches). 如果没有指定,则使用最新版本。大多数情况下,您会希望使用最新的版本。
* `--no-ui`: 不包含UI.仅创建服务模块(也称为微服务 - 没有UI).
* `--output-folder` 或者 `-o`: 指定输出文件夹,默认是当前目录.
* `--version` 或者 `-v`: 指定ABP和模板的版本.它可以是 [release tag](https://github.com/abpframework/abp/releases) 或者 [branch name](https://github.com/abpframework/abp/branches). 如果没有指定,则使用最新版本.大多数情况下,您会希望使用最新的版本.
### add-package

3
docs/zh-Hans/Configuration.md

@ -0,0 +1,3 @@
# 配置
ASP.NET Core 提供了一个灵活可扩展,基于键值的配置系统. 但是配置系统独立于ASP.NET Core是`Microsoft.Extensions` 类库的部分. 它可以用于任何类型的应用程序 . 参见 [微软文档](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/) 学习配置的更多内容. ABP 框架与配置系统百分百兼容.

3
docs/zh-Hans/CurrentUser.md

@ -0,0 +1,3 @@
# Current User
TODO!

222
docs/zh-Hans/Data-Filtering.md

@ -0,0 +1,222 @@
# 数据过滤
[Volo.Abp.Data](https://www.nuget.org/packages/Volo.Abp.Data) 包定义了在查询数据库时自动过滤数据的服务.
## 预定义的过滤
ABP定义了一些开箱即用的过滤.
### ISoftDelete
将[实体](Entities.md)标记为已删除,并不是物理删除. 实现 `ISoftDelete` 接口将你的实体"软删除".
示例:
````csharp
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
namespace Acme.BookStore
{
public class Book : AggregateRoot<Guid>, ISoftDelete
{
public string Name { get; set; }
public bool IsDeleted { get; set; } //Defined by ISoftDelete
}
}
````
`ISoftDelete` 定义了 `IsDeleted` 属性. 当你使用[仓储](Repositories.md)删除一条记录时, ABP会自动将 `IsDeleted` 设置为true,并将删除操作替换为修改操作(如果需要,也可以手动将 `IsDeleted` 设置为true). 在查询数据库时会**自动过滤软删除的实体**.
> `ISoftDelete` 过滤默认启用, 想要真正的从数据库删除实体需要显示的禁用过滤. 参见下面提到的 `IDataFilter` 服务.
### IMultiTenant
[多租户](Multi-Tenancy.md) 是创建 SaaS 应用程序的有效方法. 多租户应用程序通常需要在租户间隔离数据. 实现 `IMultiTenant` 接口使你的实体支持 "多租户".
示例:
````csharp
using System;
using Volo.Abp;
using Volo.Abp.Domain.Entities;
using Volo.Abp.MultiTenancy;
namespace Acme.BookStore
{
public class Book : AggregateRoot<Guid>, ISoftDelete, IMultiTenant
{
public string Name { get; set; }
public bool IsDeleted { get; set; } //Defined by ISoftDelete
public Guid? TenantId { get; set; } //Defined by IMultiTenant
}
}
````
`IMultiTenant` 接口定义了 `TenantId` 属性用于自动过滤当前租户实体. 更多信息参见[多租户](Multi-Tenancy.md)文档.
## IDataFilter 服务: 启用/禁用 数据过滤
你可以使用 `IDataFilter` 服务控制数据过滤.
示例:
````csharp
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
namespace Acme.BookStore
{
public class MyBookService : ITransientDependency
{
private readonly IDataFilter _dataFilter;
private readonly IRepository<Book, Guid> _bookRepository;
public MyBookService(
IDataFilter dataFilter,
IRepository<Book, Guid> bookRepository)
{
_dataFilter = dataFilter;
_bookRepository = bookRepository;
}
public async Task<List<Book>> GetAllBooksIncludingDeletedAsync()
{
//Temporary disable the ISoftDelete filter
using (_dataFilter.Disable<ISoftDelete>())
{
return await _bookRepository.GetListAsync();
}
}
}
}
````
* [注入](Dependency-Injection.md) `IDataFilter` 服务到你的类中.
* 在 `using` 语句中使用 `Disable` 方法创建一个代码块,其中禁用了 `ISoftDelete` 过滤器(始终与 `using` 搭配使用,确保代码块执行后将过滤重置为之前的状态).
`IDataFilter.Enable` 方法可以启用过滤. 可以嵌套使用 `Enable` 和 `Disable` 方法定义内部作用域.
## AbpDataFilterOptions
`AbpDataFilterOptions` 用于设置数据过滤系统[选项](Options.md).
下面的示例代码在默认情况下禁用了 `ISoftDelete` 过滤,除非显示启用,在查询数据库时会包含标记为已删除的实体:
````csharp
Configure<AbpDataFilterOptions>(options =>
{
options.DefaultStates[typeof(ISoftDelete)] = new DataFilterState(isEnabled: false);
});
````
> 更改全局过滤的默认值需要小心,特别是在你使用预构建的模块时该模块可能是在默认启用软删除过滤的情况下开发的. 但你可以安全的为自己定义的数据过滤执行此操作.
## 自定义数据过滤
定义和实现新的过滤很大程序上取决与数据库提供者. ABP为所有的数据库提供者实现了预构建的过滤.
首先为过滤定义一个接口 (如 `ISoftDelete` 和 `IMultiTenant`) 然后用实体实现它.
示例:
````csharp
public interface IIsActive
{
bool IsActive { get; }
}
````
`IIsActive` 接口可以过滤活跃/消极数据,任何[实体](Entities.md)都可以实现它:
````csharp
public class Book : AggregateRoot<Guid>, IIsActive
{
public string Name { get; set; }
public bool IsActive { get; set; } //Defined by IIsActive
}
````
### EntityFramework Core
ABP使用[EF Core的全局过滤](https://docs.microsoft.com/en-us/ef/core/querying/filters)系统用于[EF Core 集成](Entity-Framework-Core.md). 所以它很好的集成到EF Core中,即使你直接使用 `DbContext` 它也可以正常工作.
实现自定义过滤的最佳方法是为重写你的 `DbContext` 的 `CreateFilterExpression` 方法. 示例:
````csharp
protected bool IsActiveFilterEnabled => DataFilter?.IsEnabled<IIsActive>() ?? false;
protected override Expression<Func<TEntity, bool>> CreateFilterExpression<TEntity>()
{
var expression = base.CreateFilterExpression<TEntity>();
if (typeof(IIsActive).IsAssignableFrom(typeof(TEntity)))
{
Expression<Func<TEntity, bool>> isActiveFilter =
e => !IsActiveFilterEnabled || EF.Property<bool>(e, "IsActive");
expression = expression == null
? isActiveFilter
: CombineExpressions(expression, isActiveFilter);
}
return expression;
}
````
* 添加 `IsActiveFilterEnabled` 属性用于检查是否启用了 `IIsActive` . 内部使用了之前介绍到的 `IDataFilter` 服务.
* 重写 `CreateFilterExpression` 方法检查给定实体是否实现 `IIsActive` 接口,在必要时组合表达式.
### MongoDB
ABP直接在[仓储](Repositories.md)级别实现数据过滤用于[MongoDB 集成](MongoDB.md). 所以只有正确的使用仓储,它才会工作. 否则你需要手动过滤数据.
目前为MongoDB集成实现数据过滤的最佳方法是重写派生自 `MongoDbRepository` 仓储的 `AddGlobalFilters` 方法:
````csharp
public class BookRepository : MongoDbRepository<BookStoreMongoDbContext, Book, Guid>
{
protected override void AddGlobalFilters(List<FilterDefinition<Book>> filters)
{
if (DataFilter.IsEnabled<IIsActive>())
{
filters.Add(Builders<Book>.Filter.Eq(e => ((IIsActive)e).IsActive, true));
}
}
}
````
示例中仅为 `Book` 实体实现了过滤. 如果你想要为所有的实体实现过滤 (实现了 `IIsActive` 接口的实体),可以创建自己的MongoDB仓储基类并重 写 `AddGlobalFilters` 方法. 如下所示:
````csharp
public abstract class MyMongoRepository<TMongoDbContext, TEntity, TKey> : MongoDbRepository<TMongoDbContext, TEntity, TKey>
where TMongoDbContext : IAbpMongoDbContext
where TEntity : class, IEntity<TKey>
{
protected MyMongoRepository(IMongoDbContextProvider<TMongoDbContext> dbContextProvider)
: base(dbContextProvider)
{
}
protected override void AddGlobalFilters(List<FilterDefinition<TEntity>> filters)
{
if (typeof(IIsActive).IsAssignableFrom(typeof(TEntity))
&& DataFilter.IsEnabled<IIsActive>())
{
filters.Add(Builders<TEntity>.Filter.Eq(e => ((IIsActive)e).IsActive, true));
}
}
}
````
> 参阅[MongoDb集成文档](MongoDB.md)的 "设置默认仓储" 部分了解如何使用自定义类替换默认仓储.

6
docs/zh-Hans/Getting-Started-AspNetCore-MVC-Template.md

@ -24,8 +24,10 @@ abp new Acme.BookStore
创建项目的要求:
* [Visual Studio 2017 (v15.9.0+)](https://visualstudio.microsoft.com/tr/downloads/)
* [.NET Core 2.2+](https://www.microsoft.com/net/download/dotnet-core/)
* [Visual Studio 2019 (v16.3+)](https://visualstudio.microsoft.com/vs/)
* [.NET Core 3.0+](https://www.microsoft.com/net/download/dotnet-core/)
* [Node v12+](https://nodejs.org)
* [Yarn v1.19+](https://yarnpkg.com/)
### 解决方案结构

6
docs/zh-Hans/Index.md

@ -6,12 +6,6 @@ ABP是一个**开源应用程序框架**,专注于基于ASP.NET Core的Web应用
浏览左侧导航菜单以深入了解文档.
## 项目状态
ABP是开源[ASP.NET Boilerplate](https://aspnetboilerplate.com/)框架的**下一代框架**, 它目前处于早期预览阶段,尚未准备好在生产中使用. 文档仍在进行中,远未完成.
对于短期和生产级应用程序, 建议使用[ASP.NET Boilerplate](https://aspnetboilerplate.com/)框架,该框架具有丰富的功能集,成熟,积极维护和最新.
## 入门
使用ABP开发新项目的最简单方法是使用启动模板:

3
docs/zh-Hans/Localization.md

@ -48,7 +48,8 @@ public class MyModule : AbpModule
{
Configure<VirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<MyModule>();
// "YourRootNameSpace" 是项目的根命名空间名字. 如果你的项目的根命名空间名字为空,则无需传递此参数.
options.FileSets.AddEmbedded<MyModule>("YourRootNameSpace");
});
Configure<AbpLocalizationOptions>(options =>

3
docs/zh-Hans/Modules/Setting-Management.md

@ -0,0 +1,3 @@
# Setting Management Module
TODO

4
docs/zh-Hans/Multi-Tenancy.md

@ -312,10 +312,10 @@ Volo.Abp.AspNetCore.MultiTenancy 添加了下面这些租户解析器,从当前W
http://nginx.org/en/docs/http/ngx_http_core_module.html#ignore_invalid_headers
http://nginx.org/en/docs/http/ngx_http_core_module.html#underscores_in_headers
可以使用AspNetCoreMultiTenancyOptions修改默认的参数名"__tenant".例如:
可以使用AbpAspNetCoreMultiTenancyOptions修改默认的参数名"__tenant".例如:
````C#
services.Configure<AspNetCoreMultiTenancyOptions>(options =>
services.Configure<AbpAspNetCoreMultiTenancyOptions>(options =>
{
options.TenantKey = "MyTenantKey";
});

256
docs/zh-Hans/Object-To-Object-Mapping.md

@ -1,3 +1,255 @@
## Object To Object Mapping
# 对象到对象映射
TODO
将对象映射到另一个对象是常用并且繁琐重复的工作,大部分情况下两个类都具有相同或相似的属性. 例如下面的 [应用服务](Application-Services.md)方法:
```csharp
public class UserAppService : ApplicationService
{
private readonly IRepository<User, Guid> _userRepository;
public UserAppService(IRepository<User, Guid> userRepository)
{
_userRepository = userRepository;
}
public void CreateUser(CreateUserInput input)
{
//Manually creating a User object from the CreateUserInput object
var user = new User
{
Name = input.Name,
Surname = input.Surname,
EmailAddress = input.EmailAddress,
Password = input.Password
};
_userRepository.Insert(user);
}
}
```
`CreateUserInput` 和 `User` 是一个简单的[DTO](Data-Transfer-Objects.md)和[实体](Entities.md)类. 上面的代码使用input对象创建了一个 `User` 实体. 上面的代码很简单,但在实际应用程序中 `User` 实体会拥有很多属性,手动创建实体乏味且容易出错. `User` 和 `CreateUserInput` 添加新属性时还需要再去修改代码.
我们需要一个库自动处理类到类的映射. ABP提供了对象到对象映射的抽象并集成了[AutoMapper](http://automapper.org/)做为对象映射器.
## IObjectMapper
`IObjectMapper` 接口 (在 [Volo.Abp.ObjectMapping](https://www.nuget.org/packages/Volo.Abp.ObjectMapping)包中) 定义了一个简单的 `Map` 方法. 上面的手动映射示例可以用以下方式重写:
````csharp
public class UserAppService : ApplicationService
{
private readonly IRepository<User, Guid> _userRepository;
public UserAppService(IRepository<User, Guid> userRepository)
{
_userRepository = userRepository;
}
public void CreateUser(CreateUserInput input)
{
//Automatically creating a new User object using the CreateUserInput object
var user = ObjectMapper.Map<CreateUserInput, User>(input);
_userRepository.Insert(user);
}
}
````
> 示例中的 `ObjectMapper` 属性在 `ApplicationService` 基类中属性注入. 在其他地方也可以直接注入 `IObjectMapper` 接口.
Map方法有两个泛型参数: 第一个是源对象类型,第二个是目标对象类型.
如果想要设置现有对象属性,可以使用 `Map` 的重载方法:
````csharp
public class UserAppService : ApplicationService
{
private readonly IRepository<User, Guid> _userRepository;
public UserAppService(IRepository<User, Guid> userRepository)
{
_userRepository = userRepository;
}
public async Task UpdateUserAsync(Guid id, UpdateUserInput input)
{
var user = await _userRepository.GetAsync(id);
//Automatically set properties of the user object using the UpdateUserInput
ObjectMapper.Map<UpdateUserInput, User>(input, user);
await _userRepository.UpdateAsync(user);
}
}
````
必须先定义映射,然后才能映射对象. 请参阅AutoMapper集成部分了解如何定义映射.
## AutoMapper 集成
[AutoMapper](http://automapper.org/) 是最流行的对象到对象映射库之一. [Volo.Abp.AutoMapper](https://www.nuget.org/packages/Volo.Abp.AutoMapper)程序包使用AutoMapper实现了 `IObjectMapper`.
定义了以下部分的映射后就可以使 `IObjectMapper` 接口.
### 定义映射
AutoMapper提供了多种定义类之间映射的方法. 有关详细信息请参阅[AutoMapper的文档](https://docs.automapper.org).
其中定义一种映射的方法是创建一个[Profile](https://docs.automapper.org/en/stable/Configuration.html#profile-instances) 类. 例如:
````csharp
public class MyProfile : Profile
{
public MyProfile()
{
CreateMap<User, UserDto>();
}
}
````
然后使用`AbpAutoMapperOptions`注册配置文件:
````csharp
[DependsOn(typeof(AbpAutoMapperModule))]
public class MyModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpAutoMapperOptions>(options =>
{
//Add all mappings defined in the assembly of the MyModule class
options.AddMaps<MyModule>();
});
}
}
````
`AddMaps` 注册给定类的程序集中所有的配置类,通常使用模块类. 它还会注册 [attribute 映射](https://docs.automapper.org/en/stable/Attribute-mapping.html).
### 配置验证
`AddMaps` 使用可选的 `bool` 参数控制[模块](Module-Development-Basics.md)的[配置验证](https://docs.automapper.org/en/stable/Configuration-validation.html):
````csharp
options.AddMaps<MyModule>(validate: true);
````
如果此选项默认是 `false` , 但最佳实践建议启用.
可以使用 `AddProfile` 而不是 `AddMaps` 来控制每个配置文件类的配置验证:
````csharp
options.AddProfile<MyProfile>(validate: true);
````
> 如果你有多个配置文件,并且只需要为其中几个启用验证,那么首先使用`AddMaps`而不进行验证,然后为你想要验证的每个配置文件使用`AddProfile`.
## 高级主题
### IObjectMapper<TContext> 接口
假设你已经创建了一个**可重用的模块**,其中定义了AutoMapper配置文件,并在需要映射对象时使用 `IObjectMapper`. 根据[模块化](Module-Development-Basics.md)的性质,你的模块可以用于不同的应用程序.
`IObjectMapper` 是一个抽象,可以由最终应用程序替换使用另一个映射库. 这里的问题是你的可重用模块设计为使用AutoMapper,因为它为其定义映射配置文件. 这种情况下即使最终应用程序使用另一个默认对象映射库,你也要保证模块始终使用AutoMapper.
`IObjectMapper<TContext>`将对象映射器上下文化,你可以为不同的 模块/上下文 使用不同的库.
用法示例:
````csharp
public class UserAppService : ApplicationService
{
private readonly IRepository<User, Guid> _userRepository;
private readonly IObjectMapper<MyModule> _objectMapper;
public UserAppService(
IRepository<User, Guid> userRepository,
IObjectMapper<MyModule> objectMapper) //Inject module specific mapper
{
_userRepository = userRepository;
_objectMapper = objectMapper;
}
public async Task CreateUserAsync(CreateUserInput input)
{
//Use the module specific mapper
var user = _objectMapper.Map<CreateUserInput, User>(input);
await _userRepository.InsertAsync(user);
}
}
````
`UserAppService` 注入 `IObjectMapper<MyModule>`, 它是模块的特定对象映射器,用法与 `IObjectMapper` 完全相同.
上面的示例代码未使用 `ApplicationService` 中定义的 `ObjectMapper` 属性,而是注入了 `IObjectMapper<MyModule>`. 但是 `ApplicationService` 定义了可以在类构造函数中设置的 `ObjectMapperContext` 属性, 因此仍然可以使用基类属性. 示例可以进行以下重写:
````csharp
public class UserAppService : ApplicationService
{
private readonly IRepository<User, Guid> _userRepository;
public UserAppService(IRepository<User, Guid> userRepository)
{
_userRepository = userRepository;
//Set the object mapper context
ObjectMapperContext = typeof(MyModule);
}
public async Task CreateUserAsync(CreateUserInput input)
{
var user = ObjectMapper.Map<CreateUserInput, User>(input);
await _userRepository.InsertAsync(user);
}
}
````
虽然使用上下文化的对象映射器与普通的对象映射器相同, 但是也应该在模块的 `ConfigureServices` 方法中注册上下文化的映射器:
````csharp
[DependsOn(typeof(AbpAutoMapperModule))]
public class MyModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
//Use AutoMapper for MyModule
context.Services.AddAutoMapperObjectMapper<MyModule>();
Configure<AbpAutoMapperOptions>(options =>
{
options.AddMaps<MyModule>(validate: true);
});
}
}
````
`IObjectMapper<MyModule>`是可重用模块的一项基本功能,可在多个应用程序中使用,每个模块可以使用不同的库进行对象到对象的映射. 所有预构建的ABP模块都在使用它. 但是对于最终应用程序,你可以忽略此接口,始终使用默认的 `IObjectMapper` 接口.
### IObjectMapper<TSource, TDestination> 接口
ABP允许自定义特定类的映射代码. 假设你要创建一个自定义类从 `User` 映射到 `UserDto`. 这种情况下,你可以创建一个实现 `IObjectMapper<User,UserDto>`的类 :
````csharp
public class MyCustomUserMapper : IObjectMapper<User, UserDto>, ITransientDependency
{
public UserDto Map(User source)
{
//TODO: Create a new UserDto
}
public UserDto Map(User source, UserDto destination)
{
//TODO: Set properties of an existing UserDto
return destination;
}
}
````
ABP会自动发现注册 `MyCustomUserMapper`, 在你使用IObjectMapper将用户映射到UserDto时会自动使用自定义映射.
一个类可以为不同的对象实现多个 `IObjectMapper<TSource,TDestination>`.
> 这种方法功能强大, `MyCustomUserMapper`可以注入任何其他服务并在Map方法中使用.

3
docs/zh-Hans/Options.md

@ -0,0 +1,3 @@
# Options
TODO!

180
docs/zh-Hans/Settings.md

@ -0,0 +1,180 @@
# Settings
[配置系统](Configuration.md) 是在启动时配置应用程序很好的方式. 除了配置之外, ABP提供了另外一种设置和获取应用程序设置的方式.
设置存储在动态数据源(通常是数据库)中的键值对. 设置系统预构建了用户,租户,全局和默认设置方法并且可以进行扩展.
## 定义设置
使用设置之前需要定义它. ABP是 [模块化](Module-Development-Basics.md)的, 不同的模块可以拥有不同的设置. 模块中派生 `SettingDefinitionProvider` 类定义模块内的配置. 示例如下:
````csharp
public class EmailSettingProvider : SettingDefinitionProvider
{
public override void Define(ISettingDefinitionContext context)
{
context.Add(
new SettingDefinition("Smtp.Host", "127.0.0.1"),
new SettingDefinition("Smtp.Port", "25"),
new SettingDefinition("Smtp.UserName"),
new SettingDefinition("Smtp.Password", isEncrypted: true),
new SettingDefinition("Smtp.EnableSsl", "false")
);
}
}
````
ABP会自动发现并注册设置的定义.
### SettingDefinition
`SettingDefinition` 类具有以下属性:
* **Name**: 应用程序中设置的唯一名称. 是**具有约束的唯一属性**, 在应用程序获取/设置此设置的值 (设置名称定义为常量而不是`magic`字符串是个好主意).
* **DefaultValue**: 设置的默认值.
* **DisplayName**: 本地化的字符串,用于在UI上显示名称.
* **Description**: 本地化的字符串,用于在UI上显示描述.
* **IsVisibleToClients**: 布尔值,表示此设置是否在客户端可用. 默认为false,避免意外暴漏内部关键设置.
* **IsInherited**: 布尔值,此设置值是否从其他提供程序继承. 如果没有为请求的提供程序设置设定值,那么默认值是true并回退到下一个提供程序 (参阅设置值提供程序部分了解更多).
* **IsEncrypted**: 布尔值,表示是否在保存值是加密,读取时解密. 在数据库中存储加密的值.
* **Providers**: 限制可用于特定的设置值提供程序(参阅设置值提供程序部分了解更多).
* **Properties**: 设置此值的自定义属性 名称/值 集合,可以在之后的应用程序代码中使用.
## 读取设置值
### ISettingProvider
`ISettingProvider` 用于获取指定设置的值或所有设置的值. 示例用法:
````csharp
public class MyService
{
private readonly ISettingProvider _settingProvider;
//Inject ISettingProvider in the constructor
public MyService(ISettingProvider settingProvider)
{
_settingProvider = settingProvider;
}
public async Task FooAsync()
{
//Get a value as string.
string userName = await _settingProvider.GetOrNullAsync("Smtp.UserName");
//Get a bool value and fallback to the default value (false) if not set.
bool enableSsl = await _settingProvider.GetAsync<bool>("Smtp.EnableSsl");
//Get a bool value and fallback to the provided default value (true) if not set.
bool enableSsl = await _settingProvider.GetAsync<bool>(
"Smtp.EnableSsl", defaultValue: true);
//Get a bool value with the IsTrueAsync shortcut extension method
bool enableSsl = await _settingProvider.IsTrueAsync("Smtp.EnableSsl");
//Get an int value or the default value (0) if not set
int port = (await _settingProvider.GetAsync<int>("Smtp.Port"));
//Get an int value or null if not provided
int? port = (await _settingProvider.GetOrNullAsync("Smtp.Port"))?.To<int>();
}
}
````
> `ISettingProvider` 是非常常用的服务,一些基类中(如`IApplicationService`)已经将其属性注入. 这种情况下可以直接使用`SettingProvider`.
### 在客户端读取设置值
如果允许在客户端显示某个设置,可以使用 JavaScript 代码读取设置值. 示例:
````js
//Gets a value as string.
var language = abp.setting.get('Abp.Localization.DefaultLanguage');
//Gets an integer value.
var requiredLength = abp.setting.getInt('Abp.Identity.Password.RequiredLength');
//Gets a boolean value.
var requireDigit = abp.setting.getBoolean('Abp.Identity.Password.RequireDigit');
````
使用 `abp.setting.values` 可以读取所有设置值的字典.
## 设置值提供程序
设置系统是可扩展的, 你可以定义设置值提供程序扩展它,根据任何条件从任何来源获取设置值.
`ISettingProvider` 使用设置值提供程序来获取设置值. 如果值提供程序无法获取设置值,则会回退到下一个值提供程序.
有五个预构建设置值提供程序按以下顺序注册:
* `DefaultValueSettingValueProvider`: 从设置定义的默认值中获取值(参见上面的SettingDefinition部分).
* `ConfigurationSettingValueProvider`: 从[IConfiguration服务](Configuration.md)中获取值.
* `GlobalSettingValueProvider`: 获取设置的全局(系统范围)值.
* `TenantSettingValueProvider`: 获取当前租户的设置值(参阅 [多租户](Multi-Tenancy.md)文档).
* `UserSettingValueProvider`: 获取当前用户的设置值(参阅 [当前用户](CurrentUser.md) 文档).
> 设置回退系统从底部 (用户) 到 (默认) 方向起用用.
全局,租户和用户设置值提供程序使用 `ISettingStore` 从数据源读取值(参见下面的小节).
### 自定义设置值提供程序
扩展设置系统的方式是定义一个派生自 `SettingValueProvider` 的类. 示例:
````csharp
public class CustomSettingValueProvider : SettingValueProvider
{
public override string Name => "Custom";
public CustomSettingValueProvider(ISettingStore settingStore)
: base(settingStore)
{
}
public override Task<string> GetOrNullAsync(SettingDefinition setting)
{
/* Return the setting value or null
Use the SettingStore or another data source */
}
}
````
> 或者你直接可以实现 `ISettingValueProvider` 接口. 这时需要记得将其注册到 [依赖注入](Dependency-Injection.md).
每一个提供程序都应该具有唯一的名称 (这里的名称是 "Custom" ). 内置提供程序使用给定的名称:
* `DefaultValueSettingValueProvider`: "**D**".
* `ConfigurationSettingValueProvider`: "**C**".
* `GlobalSettingValueProvider`: "**G**".
* `TenantSettingValueProvider`: "**T**".
* `UserSettingValueProvider`: "**U**".
最好使用一个字母的名称来减少数据库中的数据大小(提供者名称在每行中重复).
定义自定义设置值提供程序后,需要将其显式注册到 `AbpSettingOptions`:
````csharp
Configure<AbpSettingOptions>(options =>
{
options.ValueProviders.Add<CustomSettingValueProvider>();
});
````
本示例将其添加到最后一项,因此它将成为`ISettingProvider`使用的第一个值提供程序. 你也可以将其添加到`options.ValueProviders`列表的另一个位置.
### ISettingStore
尽管设置值提供程序可以自由使用任何来源来获取设置值,但 `ISettingStore` 服务是设置值的默认来源. 全局,租户和用户设置值提供者都使用它.
## ISettingEncryptionService
`ISettingEncryptionService` 用于在设置定义的 `isencryption` 属性设置为 `true` 时加密/解密设置值.
你可以在依赖项入系统中替换此服务,自定义实现加密/解密过程. 默认实现 `StringEncryptionService` 使用AES算法(参见字符串[加密文档](String-Encryption.md)学习更多).
## 设置管理模块
设置系统核心是相当独立的,不做任何关于如何管理(更改)设置值的假设. 默认的`ISettingStore`实现也是`NullSettingStore`,它为所有设置值返回null.
设置管理模块通过管理数据库中的设置值来完成逻辑(实现`ISettingStore`).有关更多信息参阅[设置管理模块](Modules/Setting-Management.md)学习更多.

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

@ -45,7 +45,7 @@ namespace MyCompany.MyProject
此配置以递归方式添加项目的 **MyResources** 文件夹下的所有文件(包括将来新添加的文件).
然后需要使用 `VirtualFileSystemOptions` 来配置模块, 以便将嵌入式文件注册到虚拟文件系统. 例如:
然后需要使用 `AbpVirtualFileSystemOptions` 来配置模块, 以便将嵌入式文件注册到虚拟文件系统. 例如:
````C#
using Microsoft.Extensions.DependencyInjection;
@ -59,10 +59,10 @@ namespace MyCompany.MyProject
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<VirtualFileSystemOptions>(options =>
Configure<AbpVirtualFileSystemOptions>(options =>
{
//Register all embedded files of this assembly to the virtual file system
options.FileSets.AddEmbedded<MyModule>();
options.FileSets.AddEmbedded<MyModule>("YourRootNameSpace");
});
//...
@ -74,9 +74,11 @@ namespace MyCompany.MyProject
`AddEmbedded` 扩展方法需要一个类, 从给定类的程序集中查找所有嵌入文件, 并将它们注册到虚拟文件系统. 它还有更简洁的写法:
````C#
options.FileSets.Add(new EmbeddedFileSet(typeof(MyModule).Assembly));
options.FileSets.Add(new EmbeddedFileSet(typeof(MyModule).Assembly), "YourRootNameSpace");
````
> "YourRootNameSpace" 是项目的根命名空间名字. 如果你的项目的根命名空间名字为空,则无需传递此参数.
#### 获取虚拟文件: IVirtualFileProvider
将文件嵌入到程序集中并注册到虚拟文件系统后, 可以使用`IVirtualFileProvider`来获取文件或目录内容:
@ -123,7 +125,7 @@ public class MyWebAppModule : AbpModule
if (hostingEnvironment.IsDevelopment()) //only for development time
{
Configure<VirtualFileSystemOptions>(options =>
Configure<AbpVirtualFileSystemOptions>(options =>
{
//ReplaceEmbeddedByPhysical gets the root folder of the MyModule project
options.FileSets.ReplaceEmbeddedByPhysical<MyModule>(

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

@ -48,6 +48,10 @@
{
"text": "基础知识",
"items": [
{
"text": "配置",
"path": "Configuration.md"
},
{
"text": "依赖注入",
"path": "Dependency-Injection.md",
@ -82,9 +86,10 @@
},
{
"text": "审计"
},
},
{
"text": "设置管理"
"text": "设置管理",
"path": "Settings.md"
}
]
},
@ -108,7 +113,13 @@
"text": "服务",
"items": [
{
"text": "对象序列化"
"text": "当前用户",
"path": "CurrentUser.md"
},
{
"text": "对象到对象映射",
"path": "Object-To-Object-Mapping.md"
},
{
"text": "JSON序列化"

16
framework/Volo.Abp.sln

@ -250,7 +250,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.MailKit.Tests", "t
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.ObjectMapping.Tests", "test\Volo.Abp.ObjectMapping.Tests\Volo.Abp.ObjectMapping.Tests.csproj", "{667F5544-C1EB-447C-96FD-9B757F04DE2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Ddd.Application.Contracts", "src\Volo.Abp.Ddd.Application.Contracts\Volo.Abp.Ddd.Application.Contracts.csproj", "{73559227-EBF0-475F-835B-1FF0CD9132AA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Ddd.Application.Contracts", "src\Volo.Abp.Ddd.Application.Contracts\Volo.Abp.Ddd.Application.Contracts.csproj", "{73559227-EBF0-475F-835B-1FF0CD9132AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Minify", "src\Volo.Abp.Minify\Volo.Abp.Minify.csproj", "{928DC30D-C078-4BB4-A9F8-FE7252C67DC6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Minify.Tests", "test\Volo.Abp.Minify.Tests\Volo.Abp.Minify.Tests.csproj", "{E69182B3-350A-43F5-A935-5EBBEBECEF97}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -750,6 +754,14 @@ Global
{73559227-EBF0-475F-835B-1FF0CD9132AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73559227-EBF0-475F-835B-1FF0CD9132AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73559227-EBF0-475F-835B-1FF0CD9132AA}.Release|Any CPU.Build.0 = Release|Any CPU
{928DC30D-C078-4BB4-A9F8-FE7252C67DC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{928DC30D-C078-4BB4-A9F8-FE7252C67DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{928DC30D-C078-4BB4-A9F8-FE7252C67DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{928DC30D-C078-4BB4-A9F8-FE7252C67DC6}.Release|Any CPU.Build.0 = Release|Any CPU
{E69182B3-350A-43F5-A935-5EBBEBECEF97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E69182B3-350A-43F5-A935-5EBBEBECEF97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E69182B3-350A-43F5-A935-5EBBEBECEF97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E69182B3-350A-43F5-A935-5EBBEBECEF97}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -878,6 +890,8 @@ Global
{70DD6E17-B98B-4B00-8F38-C489E291BB53} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{667F5544-C1EB-447C-96FD-9B757F04DE2B} = {447C8A77-E5F0-4538-8687-7383196D04EA}
{73559227-EBF0-475F-835B-1FF0CD9132AA} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{928DC30D-C078-4BB4-A9F8-FE7252C67DC6} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6}
{E69182B3-350A-43F5-A935-5EBBEBECEF97} = {447C8A77-E5F0-4538-8687-7383196D04EA}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5}

1
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo.Abp.AspNetCore.Mvc.UI.Bundling.csproj

@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.csproj" />
<ProjectReference Include="..\Volo.Abp.Minify\Volo.Abp.Minify.csproj" />
</ItemGroup>
</Project>

3
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/AbpAspNetCoreMvcUiBundlingModule.cs

@ -1,9 +1,10 @@
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap;
using Volo.Abp.Minify;
using Volo.Abp.Modularity;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{
[DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule))]
[DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule), typeof(AbpMinifyModule))]
public class AbpAspNetCoreMvcUiBundlingModule : AbpModule
{

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

@ -10,7 +10,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return bundleConfiguration;
}
public static BundleConfiguration AddContributors(this BundleConfiguration bundleConfiguration, params BundleContributor[] contributors)
public static BundleConfiguration AddContributors(this BundleConfiguration bundleConfiguration, params IBundleContributor[] contributors)
{
Check.NotNull(contributors, nameof(contributors));

32
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributor.cs

@ -1,23 +1,49 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
using System;
using System.Threading.Tasks;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{
public abstract class BundleContributor
public abstract class BundleContributor : IBundleContributor
{
public virtual Task PreConfigureBundleAsync(BundleConfigurationContext context)
{
PreConfigureBundle(context);
return Task.CompletedTask;
}
public virtual void PreConfigureBundle(BundleConfigurationContext context)
{
}
public virtual Task ConfigureBundleAsync(BundleConfigurationContext context)
{
ConfigureBundle(context);
return Task.CompletedTask;
}
public virtual void ConfigureBundle(BundleConfigurationContext context)
{
}
public virtual Task PostConfigureBundleAsync(BundleConfigurationContext context)
{
PostConfigureBundle(context);
return Task.CompletedTask;
}
public virtual void PostConfigureBundle(BundleConfigurationContext context)
{
}
//TODO: Reconsider naming and usage!
public virtual Task ConfigureDynamicResourcesAsync(BundleConfigurationContext context)
{
ConfigureDynamicResources(context);
return Task.CompletedTask;
}
public virtual void ConfigureDynamicResources(BundleConfigurationContext context)
{

16
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/BundleContributorCollection.cs

@ -9,14 +9,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{
public class BundleContributorCollection
{
private readonly List<BundleContributor> _contributors;
private readonly List<IBundleContributor> _contributors;
public BundleContributorCollection()
{
_contributors = new List<BundleContributor>();
_contributors = new List<IBundleContributor>();
}
public void Add(BundleContributor contributor)
public void Add(IBundleContributor contributor)
{
foreach (var dependedType in GetDirectDependencies(contributor.GetType()))
{
@ -27,7 +27,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
}
public void Add<TContributor>()
where TContributor : BundleContributor, new()
where TContributor : IBundleContributor, new()
{
Add(typeof(TContributor));
}
@ -39,7 +39,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
AddWithDependencies(contributorType);
}
public IReadOnlyList<BundleContributor> GetAll()
public IReadOnlyList<IBundleContributor> GetAll()
{
return _contributors.ToImmutableList();
}
@ -77,14 +77,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
private void AddInstanceToContributors(Type contributorType)
{
if (!typeof(BundleContributor).IsAssignableFrom(contributorType))
if (!typeof(IBundleContributor).IsAssignableFrom(contributorType))
{
throw new AbpException($"Given {nameof(contributorType)} ({contributorType.AssemblyQualifiedName}) should implement the {typeof(BundleContributor).AssemblyQualifiedName} interface!");
throw new AbpException($"Given {nameof(contributorType)} ({contributorType.AssemblyQualifiedName}) should implement the {typeof(IBundleContributor).AssemblyQualifiedName} interface!");
}
try
{
_contributors.Add((BundleContributor)Activator.CreateInstance(contributorType));
_contributors.Add((IBundleContributor)Activator.CreateInstance(contributorType));
}
catch (Exception ex)
{

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

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@ -58,21 +59,21 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
Logger = NullLogger<BundleManager>.Instance;
}
public virtual IReadOnlyList<string> GetStyleBundleFiles(string bundleName)
public virtual async Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName)
{
return GetBundleFiles(Options.StyleBundles, bundleName, StyleBundler);
return await GetBundleFilesAsync(Options.StyleBundles, bundleName, StyleBundler);
}
public virtual IReadOnlyList<string> GetScriptBundleFiles(string bundleName)
public virtual async Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName)
{
return GetBundleFiles(Options.ScriptBundles, bundleName, ScriptBundler);
return await GetBundleFilesAsync(Options.ScriptBundles, bundleName, ScriptBundler);
}
protected virtual IReadOnlyList<string> GetBundleFiles(BundleConfigurationCollection bundles, string bundleName, IBundler bundler)
protected virtual async Task<IReadOnlyList<string>> GetBundleFilesAsync(BundleConfigurationCollection bundles, string bundleName, IBundler bundler)
{
var contributors = GetContributors(bundles, bundleName);
var bundleFiles = RequestResources.TryAdd(GetBundleFiles(contributors));
var dynamicResources = RequestResources.TryAdd(GetDynamicResources(contributors));
var bundleFiles = RequestResources.TryAdd(await GetBundleFilesAsync(contributors));
var dynamicResources = RequestResources.TryAdd(await GetDynamicResourcesAsync(contributors));
if (!IsBundlingEnabled())
{
@ -178,22 +179,36 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
}
}
protected virtual List<string> GetBundleFiles(List<BundleContributor> contributors)
protected async Task<List<string>> GetBundleFilesAsync(List<IBundleContributor> contributors)
{
var context = CreateBundleConfigurationContext();
contributors.ForEach(c => c.PreConfigureBundle(context));
contributors.ForEach(c => c.ConfigureBundle(context));
contributors.ForEach(c => c.PostConfigureBundle(context));
foreach (var contributor in contributors)
{
await contributor.PreConfigureBundleAsync(context);
}
foreach (var contributor in contributors)
{
await contributor.ConfigureBundleAsync(context);
}
foreach (var contributor in contributors)
{
await contributor.PostConfigureBundleAsync(context);
}
return context.Files;
}
protected virtual List<string> GetDynamicResources(List<BundleContributor> contributors)
protected virtual async Task<List<string>> GetDynamicResourcesAsync(List<IBundleContributor> contributors)
{
var context = CreateBundleConfigurationContext();
contributors.ForEach(c => c.ConfigureDynamicResources(context));
foreach (var contributor in contributors)
{
await contributor.ConfigureDynamicResourcesAsync(context);
}
return context.Files;
}
@ -203,9 +218,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return new BundleConfigurationContext(ServiceProvider, WebContentFileProvider);
}
protected virtual List<BundleContributor> GetContributors(BundleConfigurationCollection bundles, string bundleName)
protected virtual List<IBundleContributor> GetContributors(BundleConfigurationCollection bundles, string bundleName)
{
var contributors = new List<BundleContributor>();
var contributors = new List<IBundleContributor>();
AddContributorsWithBaseBundles(contributors, bundles, bundleName);
@ -222,7 +237,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
return contributors;
}
protected virtual void AddContributorsWithBaseBundles(List<BundleContributor> contributors, BundleConfigurationCollection bundles, string bundleName)
protected virtual void AddContributorsWithBaseBundles(List<IBundleContributor> contributors, BundleConfigurationCollection bundles, string bundleName)
{
var bundleConfiguration = bundles.Get(bundleName);

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

@ -3,9 +3,9 @@ using System.Text;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.AspNetCore.Mvc.UI.Minification;
using Volo.Abp.AspNetCore.VirtualFileSystem;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Minify;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{

15
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/IBundleContributor.cs

@ -0,0 +1,15 @@
using System.Threading.Tasks;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{
public interface IBundleContributor
{
Task PreConfigureBundleAsync(BundleConfigurationContext context);
Task ConfigureBundleAsync(BundleConfigurationContext context);
Task PostConfigureBundleAsync(BundleConfigurationContext context);
Task ConfigureDynamicResourcesAsync(BundleConfigurationContext context);
}
}

5
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/IBundleManager.cs

@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling
{
public interface IBundleManager
{
IReadOnlyList<string> GetStyleBundleFiles(string bundleName);
Task<IReadOnlyList<string>> GetStyleBundleFilesAsync(string bundleName);
IReadOnlyList<string> GetScriptBundleFiles(string bundleName);
Task<IReadOnlyList<string>> GetScriptBundleFilesAsync(string bundleName);
}
}

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Scripts/ScriptBundler.cs

@ -1,6 +1,6 @@
using System;
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts;
using Volo.Abp.AspNetCore.VirtualFileSystem;
using Volo.Abp.Minify.Scripts;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Scripts
{

2
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Bundling/Styles/StyleBundler.cs

@ -1,8 +1,8 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles;
using Volo.Abp.AspNetCore.VirtualFileSystem;
using Volo.Abp.Minify.Styles;
namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Styles
{

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

@ -16,7 +16,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
public abstract class AbpTagHelperResourceService : ITransientDependency
{
public ILogger<AbpTagHelperResourceService> Logger { get; set; }
protected IBundleManager BundleManager { get; }
protected IWebContentFileProvider WebContentFileProvider { get; }
protected IWebHostEnvironment HostingEnvironment { get; }
@ -36,7 +35,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
Logger = NullLogger<AbpTagHelperResourceService>.Instance;
}
public virtual Task ProcessAsync(
public virtual async Task ProcessAsync(
[NotNull] TagHelperContext context,
[NotNull] TagHelperOutput output,
[NotNull] List<BundleTagHelperItem> bundleItems,
@ -57,7 +56,7 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
CreateBundle(bundleName, bundleItems);
var bundleFiles = GetBundleFiles(bundleName);
var bundleFiles = await GetBundleFilesAsync(bundleName);
output.Content.Clear();
@ -74,13 +73,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
stopwatch.Stop();
Logger.LogDebug($"Added bundle '{bundleName}' to the page in {stopwatch.Elapsed.TotalMilliseconds:0.00} ms.");
return Task.CompletedTask;
}
protected abstract void CreateBundle(string bundleName, List<BundleTagHelperItem> bundleItems);
protected abstract IReadOnlyList<string> GetBundleFiles(string bundleName);
protected abstract Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName);
protected abstract void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file);

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

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Hosting;
@ -33,9 +34,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
);
}
protected override IReadOnlyList<string> GetBundleFiles(string bundleName)
protected override async Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName)
{
return BundleManager.GetScriptBundleFiles(bundleName);
return await BundleManager.GetScriptBundleFilesAsync(bundleName);
}
protected override void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file)

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

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Razor.TagHelpers;
using Microsoft.Extensions.Hosting;
@ -33,9 +34,9 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.TagHelpers
);
}
protected override IReadOnlyList<string> GetBundleFiles(string bundleName)
protected override async Task<IReadOnlyList<string>> GetBundleFilesAsync(string bundleName)
{
return BundleManager.GetStyleBundleFiles(bundleName);
return await BundleManager.GetStyleBundleFilesAsync(bundleName);
}
protected override void AddHtmlTag(TagHelperContext context, TagHelperOutput output, string file)

7
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/IMinifier.cs

@ -1,7 +0,0 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification
{
public interface IMinifier
{
string Minify(string source, string fileName = null);
}
}

13
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyCssMinifier.cs

@ -1,13 +0,0 @@
using NUglify;
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles;
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify
{
public class NUglifyCssMinifier : NUglifyMinifierBase, ICssMinifier
{
protected override UglifyResult UglifySource(string source, string fileName)
{
return Uglify.Css(source, fileName);
}
}
}

26
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyException.cs

@ -1,26 +0,0 @@
using System.Collections.Generic;
using System.Runtime.Serialization;
using NUglify;
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify
{
public class NUglifyException : AbpException
{
public List<UglifyError> Errors { get; set; }
public NUglifyException(string message, List<UglifyError> errors)
: base(message)
{
Errors = errors;
}
/// <summary>
/// Constructor for serializing.
/// </summary>
public NUglifyException(SerializationInfo serializationInfo, StreamingContext context)
: base(serializationInfo, context)
{
}
}
}

15
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyJavascriptMinifier.cs

@ -1,15 +0,0 @@
using NUglify;
using NUglify.JavaScript;
using Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify
{
public class NUglifyJavascriptMinifier : NUglifyMinifierBase, IJavascriptMinifier
{
protected override UglifyResult UglifySource(string source, string fileName)
{
return Uglify.Js(source, fileName);
}
}
}

31
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/NUglify/NUglifyMinifierBase.cs

@ -1,31 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NUglify;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.NUglify
{
public abstract class NUglifyMinifierBase : IMinifier, ITransientDependency
{
private static void CheckErrors(UglifyResult result)
{
if (result.HasErrors)
{
throw new NUglifyException(
$"There are some errors on uglifying the given source code!{Environment.NewLine}{result.Errors.Select(err => err.ToString()).JoinAsString(Environment.NewLine)}",
result.Errors
);
}
}
public string Minify(string source, string fileName = null)
{
var result = UglifySource(source, fileName);
CheckErrors(result);
return result.Code;
}
protected abstract UglifyResult UglifySource(string source, string fileName);
}
}

7
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/Scripts/IJavascriptMinifier.cs

@ -1,7 +0,0 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.Scripts
{
public interface IJavascriptMinifier : IMinifier
{
}
}

7
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Bundling/Volo/Abp/AspNetCore/Mvc/UI/Minification/Styles/ICssMinifier.cs

@ -1,7 +0,0 @@
namespace Volo.Abp.AspNetCore.Mvc.UI.Minification.Styles
{
public interface ICssMinifier : IMinifier
{
}
}

3
framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Volo/Abp/AspNetCore/Mvc/UI/MultiTenancy/Localization/zh-Hans.json

@ -5,7 +5,8 @@
"Tenant": "租户",
"Switch": "切换",
"Name": "名称",
"SwitchTenantHint": "将name字段留空以切换到宿主端.",
"SwitchTenantHint": "将名称字段留空以切换到宿主端.",
"SwitchTenant": "切换租户",
"NotSelected": "未选中"
}
}

28
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/LanguageSwitch/Default.cshtml

@ -1,14 +1,18 @@
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch
@using System.Linq
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Themes.Basic.Components.Toolbar.LanguageSwitch
@model LanguageSwitchViewComponentModel
<div class="dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@Model.CurrentLanguage.DisplayName
</a>
@if (Model.OtherLanguages.Any())
{
<div class="dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@Model.CurrentLanguage.DisplayName
</a>
<div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink">
@foreach (var language in Model.OtherLanguages)
{
<a class="dropdown-item" href="/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@Context.Request.Path">@language.DisplayName</a>
}
</div>
</div>
<div class="dropdown-menu dropdown-menu-right border-0 shadow-sm" aria-labelledby="dropdownMenuLink">
@foreach (var language in Model.OtherLanguages)
{
<a class="dropdown-item" href="/Abp/Languages/Switch?culture=@(language.CultureName)&uiCulture=@(language.UiCultureName)&returnUrl=@Context.Request.Path">@language.DisplayName</a>
}
</div>
</div>
}

16
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Components/Toolbar/UserMenu/Default.cshtml

@ -9,7 +9,14 @@
@model ApplicationMenu
<div class="dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@CurrentUser.UserName
@if (CurrentUser.TenantId != null)
{
<small><i>@CurrentTenant.Name</i>\</small>@CurrentUser.UserName
}
else
{
@CurrentUser.UserName
}
</a>
@if (Model.Items.Any())
@ -22,6 +29,13 @@
var disabled = menuItem.IsDisabled ? "disabled" : string.Empty;
<a class="dropdown-item @cssClass @disabled" href="@(menuItem.Url ?? "#")" target="@menuItem.Target" @Html.Raw(elementId)>
@if (menuItem.Icon != null)
{
if (menuItem.Icon.StartsWith("fa"))
{
<i class="@menuItem.Icon"></i>
}
}
@menuItem.DisplayName
</a>
}

14
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Account.cshtml

@ -53,11 +53,14 @@
<div class="@containerClass">
<abp-row>
<abp-column size-md="_5" class="mx-auto">
@if (MultiTenancyOptions.Value.IsEnabled &&
(TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(CookieTenantResolveContributor.ContributorName) == true))
{
<div class="card shadow-sm rounded mb-3">
<div class="card-body px-5">
<div class="row">
<div class="col">
<span style="font-size: .8em;" class="text-uppercase text-muted">@MultiTenancyStringLocalizer["Tenant"]</span><br />
<span style="font-size: .8em;" class="text-uppercase text-muted">@MultiTenancyStringLocalizer["Tenant"]</span><br/>
<h6 class="m-0 d-inline-block">
@if (CurrentTenant.Id == null)
{
@ -72,15 +75,12 @@
</h6>
</div>
<div class="col-auto">
@if (MultiTenancyOptions.Value.IsEnabled &&
(TenantResolveResultAccessor.Result?.AppliedResolvers?.Contains(CookieTenantResolveContributor.ContributorName) == true))
{
<a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm mt-3 btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a>
}
<a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm mt-3 btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a>
</div>
</div>
</div>
</div>
</div>
}
@(await Component.InvokeAsync<PageAlertsViewComponent>())
@RenderBody()
</abp-column>

4
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic/Themes/Basic/Layouts/Application.cshtml

@ -57,7 +57,9 @@
<div class="@containerClass">
@(await Component.InvokeAsync<PageAlertsViewComponent>())
<div id="AbpContentToolbar">
@RenderSection("content_toolbar", false)
<div class="text-right mb-2">
@RenderSection("content_toolbar", false)
</div>
</div>
@RenderBody()
</div>

14
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/AbpErrorPageOptions.cs

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared
{
public class AbpErrorPageOptions
{
public readonly IDictionary<string, string> ErrorViewUrls;
public AbpErrorPageOptions()
{
ErrorViewUrls = new Dictionary<string, string>();
}
}
}

70
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Controllers/ErrorController.cs

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using Localization.Resources.AbpUi;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Options;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Views.Error;
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Controllers
{
public class ErrorController : AbpController
{
private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
private readonly IHttpExceptionStatusCodeFinder _statusCodeFinder;
private readonly IStringLocalizer<AbpUiResource> _localizer;
private readonly AbpErrorPageOptions _abpErrorPageOptions;
public ErrorController(
IExceptionToErrorInfoConverter exceptionToErrorInfoConverter,
IHttpExceptionStatusCodeFinder httpExceptionStatusCodeFinder,
IOptions<AbpErrorPageOptions> abpErrorPageOptions,
IStringLocalizer<AbpUiResource> localizer)
{
_errorInfoConverter = exceptionToErrorInfoConverter;
_statusCodeFinder = httpExceptionStatusCodeFinder;
_localizer = localizer;
_abpErrorPageOptions = abpErrorPageOptions.Value;
}
public IActionResult Index(int httpStatusCode)
{
var exHandlerFeature = HttpContext.Features.Get<IExceptionHandlerFeature>();
var exception = exHandlerFeature != null
? exHandlerFeature.Error
: new Exception(_localizer["UnhandledException"]);
var errorInfo = _errorInfoConverter.Convert(exception);
if (httpStatusCode == 0)
{
httpStatusCode = (int)_statusCodeFinder.GetStatusCode(HttpContext, exception);
}
HttpContext.Response.StatusCode = httpStatusCode;
var page = GetErrorPageUrl(httpStatusCode);
return View(page, new AbpErrorViewModel
{
ErrorInfo = errorInfo,
HttpStatusCode = httpStatusCode
});
}
private string GetErrorPageUrl(int statusCode)
{
var page = _abpErrorPageOptions.ErrorViewUrls.GetOrDefault(statusCode.ToString());
if (string.IsNullOrWhiteSpace(page))
{
return "~/Pages/Error/Default.cshtml";
}
return page;
}
}
}

41
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml

@ -1,41 +0,0 @@
@page
@using System.Linq
@using System.Collections.Generic
@using Localization.Resources.AbpUi
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Error
@model IndexModel
@inject IHtmlLocalizer<AbpUiResource> L
@{
var errorMessage = Model.ErrorInfo.Message;
var errorDetails = Model.ErrorInfo.Details;
if (errorDetails.IsNullOrEmpty())
{
errorDetails = errorMessage;
errorMessage = L["Error"].Value + "!";
}
}
<h1>
[@Model.HttpStatusCode] @errorMessage
</h1>
<div>
<p>
@errorDetails
</p>
<p>
@if (!Model.ErrorInfo.ValidationErrors.IsNullOrEmpty())
{
foreach (var validationError in Model.ErrorInfo.ValidationErrors)
{
<text>* </text>@(validationError.Message)
if (validationError.Members != null && validationError.Members.Any())
{
<text>(@string.Join(", ", validationError.Members))</text>
}
<br />
}
}
</p>
</div>

69
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Pages/Error/Index.cshtml.cs

@ -1,69 +0,0 @@
using System;
using Microsoft.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Volo.Abp.AspNetCore.ExceptionHandling;
using Volo.Abp.Http;
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Error
{
public class IndexModel : PageModel
{
public RemoteServiceErrorInfo ErrorInfo { get; set; }
[BindProperty(SupportsGet = true)]
public int HttpStatusCode { get; set; }
private readonly IExceptionToErrorInfoConverter _errorInfoConverter;
private readonly IHttpExceptionStatusCodeFinder _statusCodeFinder;
public IndexModel(IExceptionToErrorInfoConverter errorInfoConverter, IHttpExceptionStatusCodeFinder statusCodeFinder)
{
_errorInfoConverter = errorInfoConverter;
_statusCodeFinder = statusCodeFinder;
}
public void OnGet()
{
HandleError();
}
public void OnPost()
{
HandleError();
}
public void OnPut()
{
HandleError();
}
public void OnDelete()
{
HandleError();
}
public void OnPatch()
{
HandleError();
}
private void HandleError()
{
var exHandlerFeature = HttpContext.Features.Get<IExceptionHandlerFeature>();
var exception = exHandlerFeature != null
? exHandlerFeature.Error
: new Exception("Unhandled exception!"); //TODO: Localize?
ErrorInfo = _errorInfoConverter.Convert(exception);
if (HttpStatusCode == 0)
{
HttpStatusCode = (int)_statusCodeFinder.GetStatusCode(HttpContext, exception);
}
HttpContext.Response.StatusCode = HttpStatusCode;
}
}
}

11
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/AbpErrorViewModel.cs

@ -0,0 +1,11 @@
using Volo.Abp.Http;
namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Views.Error
{
public class AbpErrorViewModel
{
public RemoteServiceErrorInfo ErrorInfo { get; set; }
public int HttpStatusCode { get; set; }
}
}

40
framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Views/Error/Default.cshtml

@ -0,0 +1,40 @@
@using System.Linq
@using System.Collections.Generic
@using Localization.Resources.AbpUi
@using Microsoft.AspNetCore.Mvc.Localization
@using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Pages.Error
@model AbpErrorPageModel
@inject IHtmlLocalizer<AbpUiResource> L
@{
var errorMessage = Model.ErrorInfo.Message;
var errorDetails = Model.ErrorInfo.Details;
if (errorDetails.IsNullOrEmpty())
{
errorDetails = errorMessage;
errorMessage = L["Error"].Value + "!";
}
}
<h1>
[@Model.HttpStatusCode] @errorMessage
</h1>
<div>
<p>
@errorDetails
</p>
<p>
@if (!Model.ErrorInfo.ValidationErrors.IsNullOrEmpty())
{
foreach (var validationError in Model.ErrorInfo.ValidationErrors)
{
<text>* </text>@(validationError.Message)
if (validationError.Members != null && validationError.Members.Any())
{
<text>(@string.Join(", ", validationError.Members))</text>
}
<br />
}
}
</p>
</div>

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

@ -4,6 +4,7 @@ using Volo.Abp.AspNetCore.Mvc.Auditing;
using Volo.Abp.AspNetCore.Mvc.Conventions;
using Volo.Abp.AspNetCore.Mvc.ExceptionHandling;
using Volo.Abp.AspNetCore.Mvc.Features;
using Volo.Abp.AspNetCore.Mvc.ModelBinding;
using Volo.Abp.AspNetCore.Mvc.Uow;
using Volo.Abp.AspNetCore.Mvc.Validation;
@ -35,7 +36,7 @@ namespace Volo.Abp.AspNetCore.Mvc
private static void AddModelBinders(MvcOptions options)
{
//options.ModelBinderProviders.Add(new AbpDateTimeModelBinderProvider());
options.ModelBinderProviders.Insert(0, new AbpDateTimeModelBinderProvider());
}
private static void AddMetadataProviders(MvcOptions options, IServiceCollection services)

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

@ -3,6 +3,7 @@ using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Auditing;
using Volo.Abp.Http;
using Volo.Abp.Json;
namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
@ -24,11 +25,14 @@ namespace Volo.Abp.AspNetCore.Mvc.ApplicationConfigurations
}
[HttpGet]
[Produces("text/javascript", "text/plain")]
public async Task<string> Get()
[Produces(MimeTypes.Application.Javascript, MimeTypes.Text.Plain)]
public async Task<ActionResult> Get()
{
return CreateAbpExtendScript(
await _configurationAppService.GetAsync()
return Content(
CreateAbpExtendScript(
await _configurationAppService.GetAsync()
),
MimeTypes.Application.Javascript
);
}

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

@ -0,0 +1,49 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Binders;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Volo.Abp.Timing;
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding
{
public class AbpDateTimeModelBinder : IModelBinder
{
private readonly Type _type;
private readonly SimpleTypeModelBinder _simpleTypeModelBinder;
private readonly IClock _clock;
public AbpDateTimeModelBinder(ModelBinderProviderContext context)
{
_type = context.Metadata.ModelType;
_clock = context.Services.GetRequiredService<IClock>();
_simpleTypeModelBinder = new SimpleTypeModelBinder(context.Metadata.ModelType,
context.Services.GetRequiredService<ILoggerFactory>());
}
public async Task BindModelAsync(ModelBindingContext bindingContext)
{
await _simpleTypeModelBinder.BindModelAsync(bindingContext);
if (!bindingContext.Result.IsModelSet)
{
return;
}
if (_type == typeof(DateTime))
{
var dateTime = (DateTime) bindingContext.Result.Model;
bindingContext.Result = ModelBindingResult.Success(_clock.Normalize(dateTime));
}
else
{
var dateTime = (DateTime?) bindingContext.Result.Model;
if (dateTime != null)
{
bindingContext.Result = ModelBindingResult.Success(_clock.Normalize(dateTime.Value));
}
}
}
}
}

47
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ModelBinding/AbpDateTimeModelBinderProvider.cs

@ -0,0 +1,47 @@
using System;
using System.Linq;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
using Volo.Abp.Timing;
namespace Volo.Abp.AspNetCore.Mvc.ModelBinding
{
public class AbpDateTimeModelBinderProvider : IModelBinderProvider
{
public IModelBinder GetBinder(ModelBinderProviderContext context)
{
if (context.Metadata.ModelType != typeof(DateTime) &&
context.Metadata.ModelType != typeof(DateTime?))
{
return null;
}
if (context.Metadata.ContainerType == null)
{
if (context.Metadata is DefaultModelMetadata defaultModelMetadata &&
defaultModelMetadata.Attributes.Attributes.All(x => x.GetType() != typeof(DisableDateTimeNormalizationAttribute)))
{
return new AbpDateTimeModelBinder(context);
}
}
else
{
var dateNormalizationDisabledForClass =
context.Metadata.ContainerType.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true);
var dateNormalizationDisabledForProperty = context.Metadata.ContainerType
.GetProperty(context.Metadata.PropertyName)
?.IsDefined(typeof(DisableDateTimeNormalizationAttribute), true);
if (!dateNormalizationDisabledForClass &&
dateNormalizationDisabledForProperty != null &&
!dateNormalizationDisabledForProperty.Value)
{
return new AbpDateTimeModelBinder(context);
}
}
return null;
}
}
}

7
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/AbpServiceProxyScriptController.cs

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Auditing;
using Volo.Abp.Http;
using Volo.Abp.Http.ProxyScripting;
namespace Volo.Abp.AspNetCore.Mvc.ProxyScripting
@ -17,11 +18,11 @@ namespace Volo.Abp.AspNetCore.Mvc.ProxyScripting
}
[HttpGet]
[Produces("text/javascript", "text/plain")]
public string GetAll(ServiceProxyGenerationModel model)
[Produces(MimeTypes.Application.Javascript, MimeTypes.Text.Plain)]
public ActionResult GetAll(ServiceProxyGenerationModel model)
{
model.Normalize();
return _proxyScriptManager.GetScript(model.CreateOptions());
return Content(_proxyScriptManager.GetScript(model.CreateOptions()), MimeTypes.Application.Javascript);
}
}
}

4
framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/ProxyScripting/ServiceProxyGenerationModel.cs

@ -11,6 +11,8 @@ namespace Volo.Abp.AspNetCore.Mvc.ProxyScripting
public bool UseCache { get; set; }
public bool Minify { get; set; }
public string Modules { get; set; }
public string Controllers { get; set; }
@ -32,7 +34,7 @@ namespace Volo.Abp.AspNetCore.Mvc.ProxyScripting
public ProxyScriptingModel CreateOptions()
{
var options = new ProxyScriptingModel(Type, UseCache);
var options = new ProxyScriptingModel(Type, UseCache, Minify);
if (!Modules.IsNullOrEmpty())
{

4
framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Builder/VirtualFileSystemApplicationBuilderExtensions.cs

@ -5,9 +5,9 @@ namespace Microsoft.AspNetCore.Builder
{
public static class VirtualFileSystemApplicationBuilderExtensions
{
public static void UseVirtualFiles(this IApplicationBuilder app)
public static IApplicationBuilder UseVirtualFiles(this IApplicationBuilder app)
{
app.UseStaticFiles(
return app.UseStaticFiles(
new StaticFileOptions
{
FileProvider = app.ApplicationServices.GetRequiredService<IWebContentFileProvider>()

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

Loading…
Cancel
Save