mirror of https://github.com/abpframework/abp.git
1790 changed files with 272045 additions and 2006 deletions
@ -0,0 +1,10 @@ |
|||
<Project> |
|||
<PropertyGroup> |
|||
<LangVersion>latest</LangVersion> |
|||
<NoWarn>$(NoWarn);CS1591</NoWarn> |
|||
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles> |
|||
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|||
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|||
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53450/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.Authentication.OAuth": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53451/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53760/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.MultiTenancy": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53763/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:52302/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.Mvc.Client": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:52303/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,116 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.Extensions.Caching.Distributed; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Http.Client.DynamicProxying; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.Client |
|||
{ |
|||
public class RemoteTenantStore : ITenantStore, ITransientDependency |
|||
{ |
|||
protected IHttpClientProxy<IAbpTenantAppService> Proxy { get; } |
|||
protected IHttpContextAccessor HttpContextAccessor { get; } |
|||
protected IDistributedCache<TenantConfiguration> Cache { get; } |
|||
|
|||
public RemoteTenantStore( |
|||
IHttpClientProxy<IAbpTenantAppService> proxy, |
|||
IHttpContextAccessor httpContextAccessor, |
|||
IDistributedCache<TenantConfiguration> cache) |
|||
{ |
|||
Proxy = proxy; |
|||
HttpContextAccessor = httpContextAccessor; |
|||
Cache = cache; |
|||
} |
|||
|
|||
public async Task<TenantConfiguration> FindAsync(string name) |
|||
{ |
|||
var cacheKey = CreateCacheKey(name); |
|||
var httpContext = HttpContextAccessor?.HttpContext; |
|||
|
|||
if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) |
|||
{ |
|||
return tenantConfiguration; |
|||
} |
|||
|
|||
tenantConfiguration = await Cache.GetOrAddAsync( |
|||
cacheKey, |
|||
async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByNameAsync(name)), |
|||
() => new DistributedCacheEntryOptions |
|||
{ |
|||
AbsoluteExpirationRelativeToNow = |
|||
TimeSpan.FromMinutes(5) //TODO: Should be configurable.
|
|||
} |
|||
); |
|||
|
|||
if (httpContext != null) |
|||
{ |
|||
httpContext.Items[cacheKey] = tenantConfiguration; |
|||
} |
|||
|
|||
return tenantConfiguration; |
|||
} |
|||
|
|||
public async Task<TenantConfiguration> FindAsync(Guid id) |
|||
{ |
|||
var cacheKey = CreateCacheKey(id); |
|||
var httpContext = HttpContextAccessor?.HttpContext; |
|||
|
|||
if (httpContext != null && httpContext.Items[cacheKey] is TenantConfiguration tenantConfiguration) |
|||
{ |
|||
return tenantConfiguration; |
|||
} |
|||
|
|||
tenantConfiguration = await Cache.GetOrAddAsync( |
|||
cacheKey, |
|||
async () => CreateTenantConfiguration(await Proxy.Service.FindTenantByIdAsync(id)), |
|||
() => new DistributedCacheEntryOptions |
|||
{ |
|||
AbsoluteExpirationRelativeToNow = |
|||
TimeSpan.FromMinutes(5) //TODO: Should be configurable.
|
|||
} |
|||
); |
|||
|
|||
if (httpContext != null) |
|||
{ |
|||
httpContext.Items[cacheKey] = tenantConfiguration; |
|||
} |
|||
|
|||
return tenantConfiguration; |
|||
} |
|||
|
|||
public TenantConfiguration Find(string name) |
|||
{ |
|||
return AsyncHelper.RunSync(() => FindAsync(name)); |
|||
} |
|||
|
|||
public TenantConfiguration Find(Guid id) |
|||
{ |
|||
return AsyncHelper.RunSync(() => FindAsync(id)); |
|||
} |
|||
|
|||
protected virtual TenantConfiguration CreateTenantConfiguration(FindTenantResultDto tenantResultDto) |
|||
{ |
|||
if (!tenantResultDto.Success || tenantResultDto.TenantId == null) |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
return new TenantConfiguration(tenantResultDto.TenantId.Value, tenantResultDto.Name); |
|||
} |
|||
|
|||
protected virtual string CreateCacheKey(string tenantName) |
|||
{ |
|||
return $"RemoteTenantStore_Name_{tenantName}"; |
|||
} |
|||
|
|||
protected virtual string CreateCacheKey(Guid tenantId) |
|||
{ |
|||
return $"RemoteTenantStore_Id_{tenantId:N}"; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy |
|||
{ |
|||
[Serializable] |
|||
public class FindTenantResultDto |
|||
{ |
|||
public bool Success { get; set; } |
|||
|
|||
public Guid? TenantId { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,13 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
|
|||
namespace Volo.Abp.AspNetCore.Mvc.MultiTenancy |
|||
{ |
|||
public interface IAbpTenantAppService : IApplicationService |
|||
{ |
|||
Task<FindTenantResultDto> FindTenantByNameAsync(string name); |
|||
|
|||
Task<FindTenantResultDto> FindTenantByIdAsync(Guid id); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53762/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.Mvc.UI.Bundling": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53765/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,52 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
using Volo.Abp.MultiTenancy; |
|||
|
|||
namespace Pages.Abp.MultiTenancy |
|||
{ |
|||
public class AbpTenantAppService : ApplicationService, IAbpTenantAppService |
|||
{ |
|||
protected ITenantStore TenantStore { get; } |
|||
|
|||
public AbpTenantAppService(ITenantStore tenantStore) |
|||
{ |
|||
TenantStore = tenantStore; |
|||
} |
|||
|
|||
public async Task<FindTenantResultDto> FindTenantByNameAsync(string name) |
|||
{ |
|||
var tenant = await TenantStore.FindAsync(name); |
|||
|
|||
if (tenant == null) |
|||
{ |
|||
return new FindTenantResultDto { Success = false }; |
|||
} |
|||
|
|||
return new FindTenantResultDto |
|||
{ |
|||
Success = true, |
|||
TenantId = tenant.Id, |
|||
Name = tenant.Name |
|||
}; |
|||
} |
|||
|
|||
public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id) |
|||
{ |
|||
var tenant = await TenantStore.FindAsync(id); |
|||
|
|||
if (tenant == null) |
|||
{ |
|||
return new FindTenantResultDto { Success = false }; |
|||
} |
|||
|
|||
return new FindTenantResultDto |
|||
{ |
|||
Success = true, |
|||
TenantId = tenant.Id, |
|||
Name = tenant.Name |
|||
}; |
|||
} |
|||
} |
|||
} |
|||
@ -1,37 +1,34 @@ |
|||
using System.Threading.Tasks; |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Volo.Abp.MultiTenancy; |
|||
using Volo.Abp.AspNetCore.Mvc.MultiTenancy; |
|||
|
|||
namespace Pages.Abp.MultiTenancy |
|||
{ |
|||
[Route("api/abp/multi-tenancy")] |
|||
public class AbpTenantController : AbpController |
|||
public class AbpTenantController : AbpController, IAbpTenantAppService |
|||
{ |
|||
private readonly IAbpTenantAppService _abpTenantAppService; |
|||
|
|||
protected ITenantStore TenantStore { get; } |
|||
|
|||
public AbpTenantController(ITenantStore tenantStore) |
|||
public AbpTenantController(IAbpTenantAppService abpTenantAppService) |
|||
{ |
|||
TenantStore = tenantStore; |
|||
_abpTenantAppService = abpTenantAppService; |
|||
} |
|||
|
|||
[HttpGet] |
|||
[Route("find-tenant/{name}")] |
|||
public async Task<FindTenantResult> FindTenantAsync(string name) |
|||
[Route("find-tenant/{name}")] //TODO: Remove on v1.0
|
|||
[Route("tenants/by-name/{name}")] |
|||
public async Task<FindTenantResultDto> FindTenantByNameAsync(string name) |
|||
{ |
|||
var tenant = await TenantStore.FindAsync(name); |
|||
|
|||
if (tenant == null) |
|||
{ |
|||
return new FindTenantResult{Success = false}; |
|||
} |
|||
return await _abpTenantAppService.FindTenantByNameAsync(name); |
|||
} |
|||
|
|||
return new FindTenantResult |
|||
{ |
|||
Success = true, |
|||
TenantId = tenant.Id |
|||
}; |
|||
[HttpGet] |
|||
[Route("tenants/by-id/{id}")] |
|||
public async Task<FindTenantResultDto> FindTenantByIdAsync(Guid id) |
|||
{ |
|||
return await _abpTenantAppService.FindTenantByIdAsync(id); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,11 +0,0 @@ |
|||
using System; |
|||
|
|||
namespace Pages.Abp.MultiTenancy |
|||
{ |
|||
public class FindTenantResult |
|||
{ |
|||
public bool Success { get; set; } |
|||
|
|||
public Guid? TenantId { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53766/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.Mvc.UI.Packages": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53768/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53761/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.Mvc.UI.Widgets": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53764/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53767/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.Mvc": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53769/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53783/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore.TestBase": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53784/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:53374/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.AspNetCore": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:53375/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
using System; |
|||
|
|||
namespace Volo.Abp.Domain.Entities |
|||
{ |
|||
public class DisableIdGenerationAttribute : Attribute |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:52306/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.Http.Client.IdentityModel": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:52307/" |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
{ |
|||
"iisSettings": { |
|||
"windowsAuthentication": false, |
|||
"anonymousAuthentication": true, |
|||
"iisExpress": { |
|||
"applicationUrl": "http://localhost:52208/", |
|||
"sslPort": 0 |
|||
} |
|||
}, |
|||
"profiles": { |
|||
"IIS Express": { |
|||
"commandName": "IISExpress", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
} |
|||
}, |
|||
"Volo.Abp.Http.Client": { |
|||
"commandName": "Project", |
|||
"launchBrowser": true, |
|||
"environmentVariables": { |
|||
"ASPNETCORE_ENVIRONMENT": "Development" |
|||
}, |
|||
"applicationUrl": "http://localhost:52209/" |
|||
} |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue