mirror of https://github.com/abpframework/eventhub
9 changed files with 4 additions and 165 deletions
@ -1,26 +0,0 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace EventHub.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}"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
using Microsoft.Extensions.Hosting; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp; |
|||
|
|||
namespace EventHub.HttpApi.Client.ConsoleTestApp |
|||
{ |
|||
public class ConsoleTestAppHostedService : IHostedService |
|||
{ |
|||
public async Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<EventHubConsoleApiClientModule>()) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>(); |
|||
await demo.RunAsync(); |
|||
|
|||
application.Shutdown(); |
|||
} |
|||
} |
|||
|
|||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; |
|||
} |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>net5.0</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Include="appsettings.json"> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="4.2.0-rc.1" /> |
|||
<ProjectReference Include="..\..\src\EventHub.HttpApi.Client\EventHub.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.*" /> |
|||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="5.0.*" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -1,29 +0,0 @@ |
|||
using System; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Polly; |
|||
using Volo.Abp.Http.Client; |
|||
using Volo.Abp.Http.Client.IdentityModel; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace EventHub.HttpApi.Client.ConsoleTestApp |
|||
{ |
|||
[DependsOn( |
|||
typeof(EventHubHttpApiClientModule), |
|||
typeof(AbpHttpClientIdentityModelModule) |
|||
)] |
|||
public class EventHubConsoleApiClientModule : 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))) |
|||
); |
|||
}); |
|||
}); |
|||
} |
|||
} |
|||
} |
|||
@ -1,21 +0,0 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.Hosting; |
|||
|
|||
namespace EventHub.HttpApi.Client.ConsoleTestApp |
|||
{ |
|||
class Program |
|||
{ |
|||
static async Task Main(string[] args) |
|||
{ |
|||
await CreateHostBuilder(args).RunConsoleAsync(); |
|||
} |
|||
|
|||
public static IHostBuilder CreateHostBuilder(string[] args) => |
|||
Host.CreateDefaultBuilder(args) |
|||
.ConfigureServices((hostContext, services) => |
|||
{ |
|||
services.AddHostedService<ConsoleTestAppHostedService>(); |
|||
}); |
|||
} |
|||
} |
|||
@ -1,18 +0,0 @@ |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"BaseUrl": "https://localhost:44362" |
|||
} |
|||
}, |
|||
"IdentityClients": { |
|||
"Default": { |
|||
"GrantType": "password", |
|||
"ClientId": "EventHub_App", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "https://localhost:44313", |
|||
"Scope": "EventHub" |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue