|
|
|
@ -7,12 +7,14 @@ using Volo.Abp.DependencyInjection; |
|
|
|
using Volo.Abp.Http.Client; |
|
|
|
using Volo.Abp.Identity; |
|
|
|
using Volo.Abp.IdentityModel; |
|
|
|
using Volo.Abp.TenantManagement; |
|
|
|
|
|
|
|
namespace ConsoleClientDemo |
|
|
|
{ |
|
|
|
public class ClientDemoService : ITransientDependency |
|
|
|
{ |
|
|
|
private readonly IIdentityUserAppService _userAppService; |
|
|
|
private readonly ITenantAppService _tenantAppService; |
|
|
|
private readonly IProductAppService _productAppService; |
|
|
|
private readonly IIdentityModelAuthenticationService _authenticator; |
|
|
|
private readonly AbpRemoteServiceOptions _remoteServiceOptions; |
|
|
|
@ -21,10 +23,12 @@ namespace ConsoleClientDemo |
|
|
|
IIdentityUserAppService userAppService, |
|
|
|
IProductAppService productAppService, |
|
|
|
IIdentityModelAuthenticationService authenticator, |
|
|
|
IOptions<AbpRemoteServiceOptions> remoteServiceOptions) |
|
|
|
IOptions<AbpRemoteServiceOptions> remoteServiceOptions, |
|
|
|
ITenantAppService tenantAppService) |
|
|
|
{ |
|
|
|
_userAppService = userAppService; |
|
|
|
_authenticator = authenticator; |
|
|
|
_tenantAppService = tenantAppService; |
|
|
|
_remoteServiceOptions = remoteServiceOptions.Value; |
|
|
|
_productAppService = productAppService; |
|
|
|
} |
|
|
|
@ -33,6 +37,7 @@ namespace ConsoleClientDemo |
|
|
|
{ |
|
|
|
await TestWithHttpClient(); |
|
|
|
await TestIdentityService(); |
|
|
|
await TestTenantManagementService(); |
|
|
|
await TestProductService(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -101,6 +106,35 @@ namespace ConsoleClientDemo |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Shows how to use application service interfaces (ITenantAppService in this sample)
|
|
|
|
/// to call a remote service which is possible by the dynamic http client proxy system.
|
|
|
|
/// No need to use IIdentityModelAuthenticationService since the dynamic http client proxy
|
|
|
|
/// system internally uses it. You just inject a service (ITenantAppService)
|
|
|
|
/// and call a method (GetListAsync) like a local method.
|
|
|
|
/// </summary>
|
|
|
|
private async Task TestTenantManagementService() |
|
|
|
{ |
|
|
|
Console.WriteLine(); |
|
|
|
Console.WriteLine("*** TestTenantManagementService ************************************"); |
|
|
|
|
|
|
|
try |
|
|
|
{ |
|
|
|
var output = await _tenantAppService.GetListAsync(new GetTenantsInput()); |
|
|
|
|
|
|
|
Console.WriteLine("Total tenant count: " + output.TotalCount); |
|
|
|
|
|
|
|
foreach (var tenant in output.Items) |
|
|
|
{ |
|
|
|
Console.WriteLine($"- Id={tenant.Id}, Name={tenant.Name}"); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception e) |
|
|
|
{ |
|
|
|
Console.WriteLine(e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Shows how to use application service interfaces (IProductAppService in this sample)
|
|
|
|
/// to call a remote service which is possible by the dynamic http client proxy system.
|
|
|
|
|