Browse Source

Merge branch 'master' into dev

pull/4353/head
Halil İbrahim Kalkan 6 years ago
parent
commit
8a7468d14f
  1. 23
      docs/en/API/Application-Configuration.md
  2. 3
      docs/en/API/JavaScript-API/Auth.md
  3. 2
      docs/en/AspNet-Boilerplate-Migration-Guide.md
  4. 3
      docs/en/AspNetCore/JavaScript-API/Auth.md
  5. 3
      docs/en/AspNetCore/JavaScript-API/Index.md
  6. 3
      docs/en/Clock.md
  7. 3
      docs/en/Json.md
  8. 113
      docs/en/Timing.md
  9. 5
      docs/en/UI/AspNetCore/JavaScript-API/Index.md
  10. 13
      docs/en/docs-nav.json

23
docs/en/API/Application-Configuration.md

@ -0,0 +1,23 @@
# Application Configuration Endpoint
ABP Framework provides a pre-built and standard endpoint that contains some useful information about the application/service. Here, the list of some fundamental information at this endpoint:
* [Localization](Localization.md) values, supported and the current language of the application.
* Available and granted [policies](Authorization.md) (permissions) for the current user.
* [Setting](Settings.md) values for the current user.
* Info about the [current user](CurrentUser.md) (like id and user name).
* Info about the current [tenant](Multi-Tenancy.md) (like id and name).
* [Time zone](Timing.md) information for the current user and the [clock](Timing.md) type of the application.
## HTTP API
If you navigate to the `/api/abp/application-configuration` URL of an ABP Framework based web application or HTTP Service, you can access the configuration as a JSON object. This endpoint is useful to create the client of your application.
## Script
For ASP.NET Core MVC (Razor Pages) applications, the same configuration values are also available on the JavaScript side. `/Abp/ApplicationConfigurationScript` is the URL of the script that is auto-generated based on the HTTP API above.
See the [JavaScript API document](../UI/AspNetCore/JavaScript-API/Index.md) for the ASP.NET Core UI.
Other UI types provide services native to the related platform. For example, see the [Angular UI localization documentation](../UI/Angular/Localization.md) to learn how to use the localization values exposes by this endpoint.

3
docs/en/API/JavaScript-API/Auth.md

@ -1,3 +0,0 @@
# abp.auth JavaScript API
TODO

2
docs/en/AspNet-Boilerplate-Migration-Guide.md

@ -595,7 +595,7 @@ ABP Framework separates it and provides the setting management module (pre-added
ASP.NET Boilerplate has a static `Clock` service ([see](https://aspnetboilerplate.com/Pages/Documents/Timing)) which is used to abstract the `DateTime` kind, so you can easily switch between Local and UTC times. You don't inject it, but just use the `Clock.Now` static method to obtain the current time.
ABP Framework has the `IClock` service ([see](Clock.md)) which has a similar goal, but now you need to inject it whenever you need it.
ABP Framework has the `IClock` service ([see](Timing.md)) which has a similar goal, but now you need to inject it whenever you need it.
### Event Bus

3
docs/en/AspNetCore/JavaScript-API/Auth.md

@ -1,3 +0,0 @@
This document has moved.
[Click to navigate to JavaScript Auth document](../../API/JavaScript-API/Auth.md)

3
docs/en/AspNetCore/JavaScript-API/Index.md

@ -1,3 +0,0 @@
This document has moved.
[Click to navigate to JavaScript API document](../../API/JavaScript-API/Index.md)

3
docs/en/Clock.md

@ -1,3 +0,0 @@
# Clock
TODO

3
docs/en/Json.md

@ -0,0 +1,3 @@
# JSON
TODO

113
docs/en/Timing.md

@ -0,0 +1,113 @@
# Timing
Working with times & [time zones](https://en.wikipedia.org/wiki/Time_zone) is always tricky, especially if you need to build a **global system** that is used by users in **different time zones**.
ABP provides a basic infrastructure to make it easy and handle automatically wherever possible. This document covers the ABP Framework services and systems related to time and time zones.
> If you are creating a local application that runs in a single time zone region, you may not need all these systems. But even in this case, it is suggested to use the `IClock` service introduced in this document.
## IClock
`DateTime.Now` returns a `DateTime` object with the **local date & time of the server**. A `DateTime` object **doesn't store the time zone information**. So, you can not know the **absolute date & time** stored in this object. You can only make **assumptions**, like assuming that it was created in UTC+05 time zone. The things especially gets complicated when you save this value to a database and read later, or send it to a client in a **different time zone**.
One solution to this problem is always use `DateTime.UtcNow` and assume all `DateTime` objects as UTC time. In this was, you can convert it to the time zone of the target client when needed.
`IClock` provides an abstraction while getting the current time, so you can control the kind of the date time (UTC or local) in a single point in your application.
**Example: Getting the current time**
````csharp
using Volo.Abp.DependencyInjection;
using Volo.Abp.Timing;
namespace AbpDemo
{
public class MyService : ITransientDependency
{
private readonly IClock _clock;
public MyService(IClock clock)
{
_clock = clock;
}
public void Foo()
{
//Get the current time!
var now = _clock.Now;
}
}
}
````
* Inject the `IClock` service when you need to get the current time. Common base classes (like ApplicationService) already injects it and provides as a base property - so, you can directly use as `Clock`.
* Use the `Now` property to get the current time.
> Most of the times, `IClock` is the only service you need to know and use in your application.
### Clock Options
`AbpClockOptions` is the [options](Options.md) class that used to set the clock kind.
**Example: Use UTC Clock**
````csharp
Configure<AbpClockOptions>(options =>
{
options.Kind = DateTimeKind.Utc;
});
````
Write this inside the `ConfigureServices` method of your [module](Module-Development-Basics.md).
> Default `Kind` is `Unspecified`, that actually make the Clock as it doesn't exists at all. Either make it `Utc` or `Local` if you want to get benefit of the Clock system.
### DateTime Normalization
Other important function of the `IClock` is to normalize `DateTime` objects.
**Example usage:**
````csharp
DateTime dateTime = ...; //Get from somewhere
var normalizedDateTime = Clock.Normalize(dateTime)
````
`Normalize` method works as described below:
* Converts the given `DateTime` to the UTC (by using the `DateTime.ToUniversalTime()` method) if current Clock is UTC and given `DateTime` is local.
* Converts the given `DateTime` to the local (by using the `DateTime.ToLocalTime()` method) if current Clock is local and given `DateTime` is UTC.
* Sets `Kind` of the given `DateTime` (using the `DateTime.SpecifyKind(...)` method) to the `Kind` of the current Clock if given `DateTime`'s `Kind` is `Unspecified`.
`Normalize` method is used by the ABP Framework when the it gets a `DateTime` that is not created by `IClock.Now` and may not be compatible with the current Clock type. Examples;
* `DateTime` type binding in the ASP.NET Core MVC model binding.
* Saving data to and reading data from database via [Entity Framework Core](Entity-Framework-Core.md).
* Working with `DateTime` objects on [JSON deserialization](Json.md).
#### DisableDateTimeNormalization Attribute
`DisableDateTimeNormalization` attribute can be used to disable the normalization operation for desired classes or properties.
### Other IClock Properties
In addition to the `Now`, `IClock` service has the following properties:
* `Kind`: Returns a `DateTimeKind` for the currently used clock type (`DateTimeKind.Utc`, `DateTimeKind.Local` or `DateTimeKind.Unspecified`).
* `SupportsMultipleTimezone`: Returns `true` if currently used clock is UTC.
## Time Zones
This section covers the ABP Framework infrastructure related to managing time zones.
### TimeZone Setting
ABP Framework defines a setting, named `Abp.Timing.Timezone`, that can be used to set and get the time zone for a user, [tenant](Multi-Tenancy.md) or globally for the application. The default value is `UTC`.
See the [setting documentation](Settings.md) to learn more about the setting system.
### ITimezoneProvider
`ITimezoneProvider` is a service to simple convert [Windows Time Zone Id](https://support.microsoft.com/en-us/help/973627/microsoft-time-zone-index-values) values to [Iana Time Zone Name](https://www.iana.org/time-zones) values and vice verse. It also provides methods to get list of these time zones and get a `TimeZoneInfo` with a given name.
It has been implemented using the [TimeZoneConverter](https://github.com/mj1856/TimeZoneConverter) library.

5
docs/en/API/JavaScript-API/Index.md → docs/en/UI/AspNetCore/JavaScript-API/Index.md

@ -5,7 +5,7 @@ ABP provides some JavaScript APIs for ASP.NET Core MVC / Razor Pages application
## APIs
* abp.ajax
* [abp.auth](Auth.md)
* abp.auth
* abp.currentUser
* abp.dom
* abp.event
@ -20,5 +20,4 @@ ABP provides some JavaScript APIs for ASP.NET Core MVC / Razor Pages application
* abp.utils
* abp.ResourceLoader
* abp.WidgetManager
* Other APIs
* Other APIs

13
docs/en/docs-nav.json

@ -216,6 +216,10 @@
{
"text": "GUID Generation",
"path": "Guid-Generation.md"
},
{
"text": "Timing",
"path": "Timing.md"
}
]
},
@ -296,6 +300,15 @@
{
"text": "Dynamic C# API Clients",
"path": "API/Dynamic-CSharp-API-Clients.md"
},
{
"text": "ABP Endpoints",
"items": [
{
"text": "Application Configuration",
"path": "API/Application-Configuration.md"
}
]
}
]
},

Loading…
Cancel
Save