From e0e641944886019f43b96e0ed9eb8bfe711b86fd Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 18 Oct 2019 17:30:57 +0300 Subject: [PATCH 1/6] fix blocking div z-index to 102. because header z-index:103 --- npm/packs/core/src/abp.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/npm/packs/core/src/abp.css b/npm/packs/core/src/abp.css index 1d3af876c7..8d2de280ce 100644 --- a/npm/packs/core/src/abp.css +++ b/npm/packs/core/src/abp.css @@ -14,7 +14,7 @@ left: 0; width: 100%; height: 100%; - z-index: 999999999; + z-index: 102; background-color: #fff; opacity: .8; transition: opacity .25s; From a14cceb1dd7fa877c03250a55e113246da9f50d0 Mon Sep 17 00:00:00 2001 From: Galip Tolga Erdem Date: Sat, 19 Oct 2019 21:56:31 +0300 Subject: [PATCH 2/6] Updated cache documentation with IDistributedCache usage. --- docs/en/Caching.md | 107 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) diff --git a/docs/en/Caching.md b/docs/en/Caching.md index c413a4599c..433c34921f 100644 --- a/docs/en/Caching.md +++ b/docs/en/Caching.md @@ -19,7 +19,7 @@ See [ASP.NET Core's distributed caching document](https://docs.microsoft.com/en- ## IDistributedCache Interface -ABP framework defines the generic `IDistributedCache` interface in the [Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/) package. `TCacheItem` is the type of the object stored in the cache. +ABP framework defines the generic `IDistributedCache` interface in the [Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/) package. `TCacheItem` is the type of the object stored in the cache. `IDistributedCache` solves the difficulties explained above; @@ -80,6 +80,111 @@ public class BookService : ITransientDependency Other methods of the `IDistributedCache` are same as ASP.NET Core's `IDistributedCache` interface, so you can refer [it's documentation](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed). +## IDistributedCache Interface + +ABP framework also defines the generic `IDistributedCache` interface in the [Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/) package. `TCacheItem` is the type of the object and `TCacheKey` as the type of the key stored in the cache. `IDistributedCache` interface is a type of `IDistributedCache` for simplified usage. + +### Usage + +An example class to store an item in the cache: + +````csharp +public class BookCacheItem +{ + public string Name { get; set; } + + public float Price { get; set; } +} +```` + +Example usage: + +````csharp +public class BookService : ITransientDependency +{ + private readonly IDistributedCache _cache; + + public BookService(IDistributedCache cache) + { + _cache = cache; + } + + public async Task GetAsync(Guid bookId) + { + return await _cache.GetOrAddAsync( + bookId, //Guid type used as Cache key + async () => await GetBookFromDatabaseAsync(bookId), + () => new DistributedCacheEntryOptions + { + AbsoluteExpiration = DateTimeOffset.Now.AddHours(1) + } + ); + } + private Task GetBookFromDatabaseAsync(Guid bookId) + { + //TODO: get from database + } +} +```` + +* This sample service uses the `GetOrAddAsync()` method to get a book item from the cache. +* Since cache explicitly implemented as using `Guid` as cache key, `Guid` value passed to `_cache_GetOrAddAsync()` method. + +In some cases may also want to use a complex object as cache key. + +An example class to store an item in the cache and using itself as the cache key: + +````csharp +public class BookCacheItem +{ + public Guid Id { get; set; } + + public string Name { get; set; } + + public float Price { get; set; } + + public override string ToString() + { + return $"{Id}_{Name}_{Price}"; //Return selective fields joined with underscore + } +} +```` + +Example usage: + +````csharp +public class BookService : ITransientDependency +{ + private readonly IDistributedCache _cache; + + public BookService(IDistributedCache cache) + { + _cache = cache; + } + + public async Task GetAsync(BookCacheItem bookItem) + { + return await _cache.GetOrAddAsync( + bookItem, //Object itself used as Cache key + async () => await GetBookFromDatabaseAsync(bookItem.Id), + () => new DistributedCacheEntryOptions + { + AbsoluteExpiration = DateTimeOffset.Now.AddHours(1) + } + ); + } + private Task GetBookFromDatabaseAsync(Guid bookId) + { + //TODO: get from database + } +} +```` + +* This sample service uses the `GetOrAddAsync()` method using complex object as a cache key to cache the same object. +* **Important note to use complex object as cache key** is to override the `ToString` method of your object since default `ToString` method returns the class name and will be same for all the objects. +* Since cache explicitly implemented as using complex `BookCacheItem` as cache key, `BookCacheItem` type value passed to `_cache_GetOrAddAsync()` method. +* Any class can be used as cache key while keeping on mind to override the `ToString` method of the class to produce a unique string. + ### DistributedCacheOptions TODO \ No newline at end of file From 5398621c01537bcdfee3d1688365d47cd6d0bd2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 20 Oct 2019 17:19:46 +0300 Subject: [PATCH 3/6] Remove "Preview" stage note! --- docs/en/Index.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/docs/en/Index.md b/docs/en/Index.md index b40efffb9d..48935d70c3 100644 --- a/docs/en/Index.md +++ b/docs/en/Index.md @@ -4,18 +4,12 @@ ABP is an **open source application framework** focused on ASP.NET Core based we Explore the left navigation menu to deep dive in the documentation. -## Project Status - -ABP is the **next generation** of the open source [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework. It's currently in preview stage and not ready to use in production. The documentation is still in progress and it is far from complete. - -For short-term and production level applications, it's suggested to use [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework which has rich feature set, mature, actively maintained and up-to-date. - ## Getting Started Easiest way to start a new project with ABP is to use the startup templates: -* [ASP.NET Core MVC (Razor Pages) UI Template](Getting-Started-AspNetCore-MVC-Template.md) -* [Angular UI Template](Getting-Started-Angular-Template.md) +* [ASP.NET Core MVC (Razor Pages) UI Startup Template](Getting-Started-AspNetCore-MVC-Template.md) +* [Angular UI Startup Template](Getting-Started-Angular-Template.md) If you want to start from scratch (with an empty project) then manually install the ABP Framework and use the following tutorials: From 9fca7d416c0328860f3c16b3b416666c32fe66ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Sun, 20 Oct 2019 21:07:14 +0300 Subject: [PATCH 4/6] #1951: Enhance the cache document --- docs/en/Caching.md | 52 +++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/docs/en/Caching.md b/docs/en/Caching.md index 1bea78ba77..8aa9f00657 100644 --- a/docs/en/Caching.md +++ b/docs/en/Caching.md @@ -80,9 +80,9 @@ public class BookService : ITransientDependency Other methods of the `IDistributedCache` are same as ASP.NET Core's `IDistributedCache` interface, so you can refer [it's documentation](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed). -## IDistributedCache Interface +## `IDistributedCache` Interface -ABP framework also defines the generic `IDistributedCache` interface in the [Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/) package. `TCacheItem` is the type of the object and `TCacheKey` as the type of the key stored in the cache. `IDistributedCache` interface is a type of `IDistributedCache` for simplified usage. +`IDistributedCache` interface assumes that the type of your cache key is `string` (so, you need to manually convert your key to string if you need to use a different kind of cache key). `IDistributedCache` can be used when your cache key type is not `string`. ### Usage @@ -97,7 +97,7 @@ public class BookCacheItem } ```` -Example usage: +Example usage (assumes that your cache key type is `Guid`): ````csharp public class BookService : ITransientDependency @@ -112,7 +112,7 @@ public class BookService : ITransientDependency public async Task GetAsync(Guid bookId) { return await _cache.GetOrAddAsync( - bookId, //Guid type used as Cache key + bookId, //Guid type used as the cache key async () => await GetBookFromDatabaseAsync(bookId), () => new DistributedCacheEntryOptions { @@ -130,22 +130,21 @@ public class BookService : ITransientDependency * This sample service uses the `GetOrAddAsync()` method to get a book item from the cache. * Since cache explicitly implemented as using `Guid` as cache key, `Guid` value passed to `_cache_GetOrAddAsync()` method. -In some cases may also want to use a complex object as cache key. +`IDistributedCache` internally uses `ToString()` method of the key object to convert it to a string. If you need to use a complex object as the cache key, you need to override `ToString` method of your class. -An example class to store an item in the cache and using itself as the cache key: +An example class that is used as a cache key: ````csharp -public class BookCacheItem +public class UserInOrganizationCacheKey { - public Guid Id { get; set; } - - public string Name { get; set; } + public Guid UserId { get; set; } - public float Price { get; set; } + public Guid OrganizationId { get; set; } + //Builds the cache key public override string ToString() { - return $"{Id}_{Name}_{Price}"; //Return selective fields joined with underscore + return $"{UserId}_{OrganizationId}"; } } ```` @@ -155,36 +154,19 @@ Example usage: ````csharp public class BookService : ITransientDependency { - private readonly IDistributedCache _cache; + private readonly IDistributedCache _cache; - public BookService(IDistributedCache cache) + public BookService( + IDistributedCache cache) { _cache = cache; } - - public async Task GetAsync(BookCacheItem bookItem) - { - return await _cache.GetOrAddAsync( - bookItem, //Object itself used as Cache key - async () => await GetBookFromDatabaseAsync(bookItem.Id), - () => new DistributedCacheEntryOptions - { - AbsoluteExpiration = DateTimeOffset.Now.AddHours(1) - } - ); - } - private Task GetBookFromDatabaseAsync(Guid bookId) - { - //TODO: get from database - } + + ... } ```` -* This sample service uses the `GetOrAddAsync()` method using complex object as a cache key to cache the same object. -* **Important note to use complex object as cache key** is to override the `ToString` method of your object since default `ToString` method returns the class name and will be same for all the objects. -* Since cache explicitly implemented as using complex `BookCacheItem` as cache key, `BookCacheItem` type value passed to `_cache_GetOrAddAsync()` method. -* Any class can be used as cache key while keeping on mind to override the `ToString` method of the class to produce a unique string. - ### DistributedCacheOptions TODO + From ed62b77efdcb2534918d1df192bffee12289e601 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 21 Oct 2019 10:07:47 +0800 Subject: [PATCH 5/6] Remove unnecessary cacheOption. --- .../Volo/Abp/Caching/DistributedCache.cs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index 2a1f109f5c..4140cceeb3 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -19,13 +19,11 @@ namespace Volo.Abp.Caching where TCacheItem : class { public DistributedCache( - IOptions cacheOption, - IOptions distributedCacheOption, + IOptions distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, IDistributedCacheSerializer serializer, ICurrentTenant currentTenant) : base( - cacheOption: cacheOption, distributedCacheOption: distributedCacheOption, cache: cache, cancellationTokenProvider: cancellationTokenProvider, @@ -62,12 +60,9 @@ namespace Volo.Abp.Caching protected DistributedCacheEntryOptions DefaultCacheOptions; - private readonly AbpDistributedCacheOptions _cacheOption; - private readonly AbpDistributedCacheOptions _distributedCacheOption; public DistributedCache( - IOptions cacheOption, IOptions distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, @@ -75,7 +70,6 @@ namespace Volo.Abp.Caching ICurrentTenant currentTenant) { _distributedCacheOption = distributedCacheOption.Value; - _cacheOption = cacheOption.Value; Cache = cache; CancellationTokenProvider = cancellationTokenProvider; Logger = NullLogger>.Instance; @@ -88,7 +82,7 @@ namespace Volo.Abp.Caching } protected virtual string NormalizeKey(TCacheKey key) { - var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + key.ToString(); + var normalizedKey = "c:" + CacheName + ",k:" + _distributedCacheOption.KeyPrefix + key.ToString(); if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) { @@ -100,7 +94,7 @@ namespace Volo.Abp.Caching protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() { - foreach (var configure in _cacheOption.CacheConfigurators) + foreach (var configure in _distributedCacheOption.CacheConfigurators) { var options = configure.Invoke(CacheName); if (options != null) @@ -108,7 +102,7 @@ namespace Volo.Abp.Caching return options; } } - return _cacheOption.GlobalCacheEntryOptions; + return _distributedCacheOption.GlobalCacheEntryOptions; } protected virtual void SetDefaultOptions() From 5400d41917c11313f6e25b10db5b027c0f116549 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 21 Oct 2019 10:20:45 +0800 Subject: [PATCH 6/6] Added localization of the account module. Resolve #1953 --- .../Volo/Abp/Account/Localization/Resources/en.json | 2 ++ .../Volo/Abp/Account/Localization/Resources/zh-Hans.json | 2 ++ .../account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml | 2 +- .../src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json index f5167f51f2..bc507158b1 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json @@ -14,6 +14,8 @@ "Login": "Login", "Cancel": "Cancel", "Register": "Register", + "AreYouANewUser": "Are you a new user?", + "AlreadyRegistered": "Already registered?", "InvalidLoginRequest": "Invalid login request", "ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.", "LogInUsingYourProviderAccount": "Log in using your {0} account", diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json index 6aee740de6..cc616961f1 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json @@ -14,6 +14,8 @@ "Login": "登录", "Cancel": "取消", "Register": "注册", + "AreYouANewUser": "你是新用户吗?", + "AlreadyRegistered": "已经注册过了?", "InvalidLoginRequest": "登录请求无效", "ThereAreNoLoginSchemesConfiguredForThisClient": "没有为此客户端配置登录方案.", "LogInUsingYourProviderAccount": "使用你的{0}帐户登录" diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml index 1703042d42..cba1fec431 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml @@ -11,7 +11,7 @@ @if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase)) { - Are you new user? + @L["AreYouANewUser"] @L["Register"] } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml index 7b6f090d7f..44d352153c 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml @@ -6,7 +6,7 @@

@L["Register"]

- Already registered? + @L["AlreadyRegistered"] @L["Login"]