first commit
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Dispatch.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
public class ClientDemoService : ITransientDependency
|
||||
{
|
||||
private readonly IProfileAppService _profileAppService;
|
||||
|
||||
public ClientDemoService(IProfileAppService profileAppService)
|
||||
{
|
||||
_profileAppService = profileAppService;
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
var output = await _profileAppService.GetAsync();
|
||||
Console.WriteLine($"UserName : {output.UserName}");
|
||||
Console.WriteLine($"Email : {output.Email}");
|
||||
Console.WriteLine($"Name : {output.Name}");
|
||||
Console.WriteLine($"Surname : {output.Surname}");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace KonSoft.Dispatch.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
public class ConsoleTestAppHostedService : IHostedService
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public ConsoleTestAppHostedService(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using (var application = await AbpApplicationFactory.CreateAsync<DispatchConsoleApiClientModule>(options =>
|
||||
{
|
||||
options.Services.ReplaceConfiguration(_configuration);
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
await application.InitializeAsync();
|
||||
|
||||
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
|
||||
await demo.RunAsync();
|
||||
|
||||
await application.ShutdownAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -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 KonSoft.Dispatch.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(DispatchHttpApiClientModule),
|
||||
typeof(AbpHttpClientIdentityModelModule)
|
||||
)]
|
||||
public class DispatchConsoleApiClientModule : 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)))
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.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>
|
||||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" />
|
||||
<ProjectReference Include="..\..\src\KonSoft.Dispatch.HttpApi.Client\KonSoft.Dispatch.HttpApi.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,22 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace KonSoft.Dispatch.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
await CreateHostBuilder(args).RunConsoleAsync();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.AddAppSettingsSecretsJson()
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHostedService<ConsoleTestAppHostedService>();
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
"RemoteServices": {
|
||||
"Default": {
|
||||
"BaseUrl": "https://localhost:44321"
|
||||
}
|
||||
},
|
||||
"IdentityClients": {
|
||||
"Default": {
|
||||
"GrantType": "password",
|
||||
"ClientId": "Dispatch_App",
|
||||
"UserName": "admin",
|
||||
"UserPassword": "1q2w3E*",
|
||||
"Authority": "https://localhost:44321",
|
||||
"Scope": "Dispatch"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user