mirror of https://github.com/abpframework/abp.git
8 changed files with 166 additions and 23 deletions
@ -0,0 +1,35 @@ |
|||
using System; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace ConsoleClientDemo |
|||
{ |
|||
public class ClientDemoService : ITransientDependency |
|||
{ |
|||
private readonly IIdentityUserAppService _userAppService; |
|||
|
|||
public ClientDemoService(IIdentityUserAppService userAppService) |
|||
{ |
|||
_userAppService = userAppService; |
|||
} |
|||
|
|||
public async Task RunAsync() |
|||
{ |
|||
await TestIdentityService(); |
|||
} |
|||
|
|||
private async Task TestIdentityService() |
|||
{ |
|||
var output = await _userAppService.GetListAsync(new GetIdentityUsersInput()); |
|||
|
|||
Console.WriteLine("*** IdentityService ***"); |
|||
Console.WriteLine("Total user count: " + output.TotalCount); |
|||
|
|||
foreach (var user in output.Items) |
|||
{ |
|||
Console.WriteLine($"- UserName={user.UserName}, Email={user.Email}, Name={user.Name}, Surname={user.Surname}"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp2.2</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> |
|||
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Autofac\Volo.Abp.Autofac.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\framework\src\Volo.Abp.Http.Client.IdentityModel\Volo.Abp.Http.Client.IdentityModel.csproj" /> |
|||
<ProjectReference Include="..\..\..\..\..\modules\identity\src\Volo.Abp.Identity.HttpApi.Client\Volo.Abp.Identity.HttpApi.Client.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="appsettings.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<Content Include="appsettings.json"> |
|||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
|||
</Content> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,17 @@ |
|||
using Volo.Abp.Autofac; |
|||
using Volo.Abp.Http.Client.IdentityModel; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace ConsoleClientDemo |
|||
{ |
|||
[DependsOn( |
|||
typeof(AbpAutofacModule), |
|||
typeof(AbpHttpClientIdentityModelModule), |
|||
typeof(AbpIdentityHttpApiClientModule) |
|||
)] |
|||
public class ConsoleClientDemoModule : AbpModule |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using Serilog; |
|||
using Serilog.Events; |
|||
using System; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Threading; |
|||
|
|||
namespace ConsoleClientDemo |
|||
{ |
|||
internal class Program |
|||
{ |
|||
private static void Main(string[] args) |
|||
{ |
|||
InitializeSerilog(); |
|||
|
|||
Log.Information("Starting ConsoleClientDemo..."); |
|||
|
|||
try |
|||
{ |
|||
using (var application = AbpApplicationFactory.Create<ConsoleClientDemoModule>(options => |
|||
{ |
|||
options.Services.AddLogging(loggingBuilder => |
|||
{ |
|||
loggingBuilder.AddSerilog(dispose: true); |
|||
}); |
|||
})) |
|||
{ |
|||
application.Initialize(); |
|||
|
|||
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>(); |
|||
AsyncHelper.RunSync(() => demo.RunAsync()); |
|||
|
|||
Console.WriteLine("Press ENTER to stop application..."); |
|||
Console.ReadLine(); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Log.Error(ex.Message); |
|||
Log.Error(ex.StackTrace); |
|||
throw; |
|||
} |
|||
} |
|||
|
|||
private static void InitializeSerilog() |
|||
{ |
|||
Log.Logger = new LoggerConfiguration() |
|||
.MinimumLevel.Debug() |
|||
.MinimumLevel.Override("Microsoft", LogEventLevel.Information) |
|||
.Enrich.FromLogContext() |
|||
.WriteTo.File("Logs/logs.txt") |
|||
.CreateLogger(); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
{ |
|||
"RemoteServices": { |
|||
"Default": { |
|||
"BaseUrl": "http://localhost:63568/" |
|||
} |
|||
}, |
|||
"IdentityClients": { |
|||
"Default": { |
|||
"GrantType": "password", |
|||
"ClientId": "console-client-demo", |
|||
"ClientSecret": "1q2w3e*", |
|||
"UserName": "admin", |
|||
"UserPassword": "1q2w3E*", |
|||
"Authority": "http://localhost:64999", |
|||
"Scope": "IdentityService" |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue