工具生成版本
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Account;
|
||||
|
||||
namespace Hua.Abp.Demo.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
public class ClientDemoService : ITransientDependency
|
||||
{
|
||||
private readonly IProfileAppService _profileAppService;
|
||||
private readonly IIdentityUserAppService _identityUserAppService;
|
||||
|
||||
public ClientDemoService(
|
||||
IProfileAppService profileAppService,
|
||||
IIdentityUserAppService identityUserAppService)
|
||||
{
|
||||
_profileAppService = profileAppService;
|
||||
_identityUserAppService = identityUserAppService;
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
var profileDto = await _profileAppService.GetAsync();
|
||||
Console.WriteLine($"UserName : {profileDto.UserName}");
|
||||
Console.WriteLine($"Email : {profileDto.Email}");
|
||||
Console.WriteLine($"Name : {profileDto.Name}");
|
||||
Console.WriteLine($"Surname : {profileDto.Surname}");
|
||||
Console.WriteLine();
|
||||
|
||||
var resultDto = await _identityUserAppService.GetListAsync(new GetIdentityUsersInput());
|
||||
Console.WriteLine($"Total users: {resultDto.TotalCount}");
|
||||
foreach (var identityUserDto in resultDto.Items)
|
||||
{
|
||||
Console.WriteLine($"- [{identityUserDto.Id}] {identityUserDto.Name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Polly;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Http.Client;
|
||||
using Volo.Abp.Http.Client.IdentityModel;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace Hua.Abp.Demo.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(DemoHttpApiClientModule),
|
||||
typeof(AbpHttpClientIdentityModelModule)
|
||||
)]
|
||||
public class DemoConsoleApiClientModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PreConfigure<AbpHttpClientBuilderOptions>(options =>
|
||||
{
|
||||
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
|
||||
{
|
||||
clientBuilder.AddTransientHttpErrorPolicy(
|
||||
policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"role": "lib.test"
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="appsettings.secrets.json" />
|
||||
<Content Include="appsettings.secrets.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Hua.Abp.Demo.HttpApi.Client\Hua.Abp.Demo.HttpApi.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="10.0.1" />
|
||||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="10.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="**\*.abppkg" />
|
||||
<None Remove="**\*.abppkg.analyze.json" />
|
||||
<Content Remove="$(UserProfile)\.nuget\packages\*\*\contentFiles\any\*\*.abppkg*" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace Hua.Abp.Demo.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
using (var application = await AbpApplicationFactory.CreateAsync<DemoConsoleApiClientModule>(options =>
|
||||
{
|
||||
var builder = new ConfigurationBuilder();
|
||||
builder.AddJsonFile("appsettings.json", false);
|
||||
builder.AddJsonFile("appsettings.secrets.json", true);
|
||||
options.Services.ReplaceConfiguration(builder.Build());
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
await application.InitializeAsync();
|
||||
|
||||
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
|
||||
await demo.RunAsync();
|
||||
|
||||
Console.WriteLine("Press ENTER to stop application...");
|
||||
Console.ReadLine();
|
||||
|
||||
await application.ShutdownAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"RemoteServices": {
|
||||
"Default": {
|
||||
"BaseUrl": "https://localhost:44322/"
|
||||
}
|
||||
},
|
||||
"IdentityClients": {
|
||||
"Default": {
|
||||
"GrantType": "password",
|
||||
"ClientId": "Demo_App",
|
||||
"UserName": "admin",
|
||||
"UserPassword": "1q2w3E*",
|
||||
"Authority": "https://localhost:44322/",
|
||||
"Scope": "Demo"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user