Browse Source

Created a console test app.

pull/798/head
Halil ibrahim Kalkan 7 years ago
parent
commit
b98ef48364
  1. 10
      samples/MicroserviceDemo/MicroserviceDemo.sln
  2. 11
      samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs
  3. 35
      samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/ClientDemoService.cs
  4. 30
      samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/ConsoleClientDemo.csproj
  5. 17
      samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/ConsoleClientDemoModule.cs
  6. 55
      samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/Program.cs
  7. 18
      samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/appsettings.json
  8. 13
      samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs

10
samples/MicroserviceDemo/MicroserviceDemo.sln

@ -15,6 +15,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "authserver", "authserver",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuthServer.Host", "applications\authserver\AuthServer.Host\AuthServer.Host.csproj", "{E015158C-BCDB-4890-8B3B-1CEE1FC817CC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "consoleclient", "consoleclient", "{72DA455F-4BD5-401D-8B2B-EE20F0C8D1AE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleClientDemo", "applications\consoleclient\ConsoleClientDemo\ConsoleClientDemo.csproj", "{06383443-5840-4C95-A038-A4B9E9211202}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -29,6 +33,10 @@ Global
{E015158C-BCDB-4890-8B3B-1CEE1FC817CC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E015158C-BCDB-4890-8B3B-1CEE1FC817CC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E015158C-BCDB-4890-8B3B-1CEE1FC817CC}.Release|Any CPU.Build.0 = Release|Any CPU
{06383443-5840-4C95-A038-A4B9E9211202}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{06383443-5840-4C95-A038-A4B9E9211202}.Debug|Any CPU.Build.0 = Debug|Any CPU
{06383443-5840-4C95-A038-A4B9E9211202}.Release|Any CPU.ActiveCfg = Release|Any CPU
{06383443-5840-4C95-A038-A4B9E9211202}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -38,6 +46,8 @@ Global
{DBED3AEE-9861-48B3-9F8C-49D2779CDBB8} = {146D0838-B1E3-44C2-BD81-BED2153C02CE}
{C53F39BA-7409-4957-8FF8-C04D7377CA62} = {8F6834D7-E6FA-4A04-83BB-955F68EA0A0A}
{E015158C-BCDB-4890-8B3B-1CEE1FC817CC} = {C53F39BA-7409-4957-8FF8-C04D7377CA62}
{72DA455F-4BD5-401D-8B2B-EE20F0C8D1AE} = {8F6834D7-E6FA-4A04-83BB-955F68EA0A0A}
{06383443-5840-4C95-A038-A4B9E9211202} = {72DA455F-4BD5-401D-8B2B-EE20F0C8D1AE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {37474F0D-2E52-4D2F-B39B-7FE3FF31B4EC}

11
samples/MicroserviceDemo/applications/authserver/AuthServer.Host/Startup.cs

@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
using Volo.Abp;
namespace AuthServer.Host
@ -22,16 +21,6 @@ namespace AuthServer.Host
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//TODO: Need to this?
loggerFactory
.AddConsole()
.AddDebug()
.AddSerilog(new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File("Logs/logs.txt")
.CreateLogger()
);
app.InitializeApplication();
}
}

35
samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/ClientDemoService.cs

@ -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}");
}
}
}
}

30
samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/ConsoleClientDemo.csproj

@ -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>

17
samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/ConsoleClientDemoModule.cs

@ -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
{
}
}

55
samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/Program.cs

@ -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();
}
}
}

18
samples/MicroserviceDemo/applications/consoleclient/ConsoleClientDemo/appsettings.json

@ -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"
}
}
}

13
samples/MicroserviceDemo/microservices/identity/IdentityService.Host/Startup.cs

@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Serilog;
using Volo.Abp;
namespace IdentityService.Host
@ -23,17 +22,7 @@ namespace IdentityService.Host
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
//TODO: Need to this?
loggerFactory
.AddConsole()
.AddDebug()
.AddSerilog(new LoggerConfiguration()
.Enrich.FromLogContext()
.WriteTo.File("Logs/logs.txt")
.CreateLogger()
);
app.InitializeApplication();
app.InitializeApplication();
}
}
}

Loading…
Cancel
Save