Skip to content

Commit 672db9c

Browse files
committed
added in AuditlogService
1 parent e68fd9c commit 672db9c

24 files changed

Lines changed: 450 additions & 24 deletions

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ RUN dotnet restore
2424
RUN dotnet build -c Release --no-restore -p:Version=$Version
2525
RUN dotnet pack -c Release --no-restore -p:Version=$Version -o "../../dist/pack"
2626
RUN dotnet publish -c Release --no-restore -o "../../dist/publish/CustomerManagementAPI.Host/" "./src/CustomerManagementAPI.Host/CustomerManagementAPI.Host.csproj"
27+
RUN dotnet publish -c Release --no-restore -o "../../dist/publish/AuditlogService/" "./src/AuditlogService/AuditlogService.csproj"
2728

2829
# RUN dotnet publish -c Release --no-restore -o "../../dist/publish"
2930
# RUN dotnet pack -c Release --no-restore -o "../../dist/pack"

PitStopPro.sln

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Eventing", "Eventing", "{AE
5252
EndProject
5353
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Pitstop.Infrastructure.Messaging", "src\Pitstop.Infrastructure.Messaging\Pitstop.Infrastructure.Messaging.csproj", "{A8B77573-1C51-492E-A979-CC411163C186}"
5454
EndProject
55-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MassTransitAbstractions", "MasstransitAbstractions\MassTransitAbstractions.csproj", "{9A652B8D-48DC-47E4-A9F8-CAE814F08758}"
55+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AuditlogService", "src\AuditlogService\AuditlogService.csproj", "{445E025A-F592-41A2-95D8-9B69CCE1BDCB}"
56+
EndProject
57+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MassTransitAbstractions", "src\MasstransitAbstractions\MassTransitAbstractions.csproj", "{40AE6FE3-9179-467B-8630-84A1BB120A16}"
58+
EndProject
59+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessageContracts", "src\MessageContracts\MessageContracts.csproj", "{82968788-E573-4C0A-B6B1-ABFA8338C19A}"
5660
EndProject
5761
Global
5862
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -124,10 +128,18 @@ Global
124128
{A8B77573-1C51-492E-A979-CC411163C186}.Debug|Any CPU.Build.0 = Debug|Any CPU
125129
{A8B77573-1C51-492E-A979-CC411163C186}.Release|Any CPU.ActiveCfg = Release|Any CPU
126130
{A8B77573-1C51-492E-A979-CC411163C186}.Release|Any CPU.Build.0 = Release|Any CPU
127-
{9A652B8D-48DC-47E4-A9F8-CAE814F08758}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
128-
{9A652B8D-48DC-47E4-A9F8-CAE814F08758}.Debug|Any CPU.Build.0 = Debug|Any CPU
129-
{9A652B8D-48DC-47E4-A9F8-CAE814F08758}.Release|Any CPU.ActiveCfg = Release|Any CPU
130-
{9A652B8D-48DC-47E4-A9F8-CAE814F08758}.Release|Any CPU.Build.0 = Release|Any CPU
131+
{445E025A-F592-41A2-95D8-9B69CCE1BDCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
132+
{445E025A-F592-41A2-95D8-9B69CCE1BDCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
133+
{445E025A-F592-41A2-95D8-9B69CCE1BDCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
134+
{445E025A-F592-41A2-95D8-9B69CCE1BDCB}.Release|Any CPU.Build.0 = Release|Any CPU
135+
{40AE6FE3-9179-467B-8630-84A1BB120A16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
136+
{40AE6FE3-9179-467B-8630-84A1BB120A16}.Debug|Any CPU.Build.0 = Debug|Any CPU
137+
{40AE6FE3-9179-467B-8630-84A1BB120A16}.Release|Any CPU.ActiveCfg = Release|Any CPU
138+
{40AE6FE3-9179-467B-8630-84A1BB120A16}.Release|Any CPU.Build.0 = Release|Any CPU
139+
{82968788-E573-4C0A-B6B1-ABFA8338C19A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
140+
{82968788-E573-4C0A-B6B1-ABFA8338C19A}.Debug|Any CPU.Build.0 = Debug|Any CPU
141+
{82968788-E573-4C0A-B6B1-ABFA8338C19A}.Release|Any CPU.ActiveCfg = Release|Any CPU
142+
{82968788-E573-4C0A-B6B1-ABFA8338C19A}.Release|Any CPU.Build.0 = Release|Any CPU
131143
EndGlobalSection
132144
GlobalSection(SolutionProperties) = preSolution
133145
HideSolutionNode = FALSE
@@ -149,7 +161,9 @@ Global
149161
{F393D369-F9B7-4AD1-BE5F-2EDDB01E27D9} = {6BB94A19-F5D7-4CEF-88A3-9E8610CB564A}
150162
{6069BCCE-159D-48F0-BC19-D39FF0874AEA} = {6BB94A19-F5D7-4CEF-88A3-9E8610CB564A}
151163
{A8B77573-1C51-492E-A979-CC411163C186} = {AE5A72AB-69BF-4365-B251-39EDB0B452C6}
152-
{9A652B8D-48DC-47E4-A9F8-CAE814F08758} = {AE5A72AB-69BF-4365-B251-39EDB0B452C6}
164+
{445E025A-F592-41A2-95D8-9B69CCE1BDCB} = {336D3FC0-1BF9-45D1-9DA2-09CAEE08FDC2}
165+
{40AE6FE3-9179-467B-8630-84A1BB120A16} = {AE5A72AB-69BF-4365-B251-39EDB0B452C6}
166+
{82968788-E573-4C0A-B6B1-ABFA8338C19A} = {AE5A72AB-69BF-4365-B251-39EDB0B452C6}
153167
EndGlobalSection
154168
GlobalSection(ExtensibilityGlobals) = postSolution
155169
SolutionGuid = {40CA8DF3-11D5-48E1-9D3D-DE4FF71A97B4}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
6+
<UserSecretsId>aa52d06b-440c-446a-8ec1-6331d2444fc0</UserSecretsId>
7+
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.AspNetCore.App" />
12+
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="2.2.5" />
13+
<PackageReference Include="Microsoft.AspNetCore.HealthChecks" Version="1.0.0" />
14+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
15+
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" />
16+
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
17+
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
18+
<PackageReference Include="Serilog" Version="2.8.0" />
19+
<PackageReference Include="Serilog.Extensions.Hosting" Version="2.0.0" />
20+
<PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
21+
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
22+
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
23+
<PackageReference Include="Swashbuckle.AspNetCore" Version="4.0.1" />
24+
</ItemGroup>
25+
26+
<ItemGroup>
27+
<ProjectReference Include="..\AuthRequiredDemo.GraphQL\AuthRequiredDemo.GraphQL.csproj" />
28+
<ProjectReference Include="..\CustomerManagementAPI\CustomerManagementAPI.csproj" />
29+
<ProjectReference Include="..\GQL.GraphQLHost.Core\GQL.GraphQLHost.Core.csproj" />
30+
<ProjectReference Include="..\MasstransitAbstractions\MassTransitAbstractions.csproj" />
31+
<ProjectReference Include="..\MessageContracts\MessageContracts.csproj" />
32+
</ItemGroup>
33+
34+
</Project>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace AuditlogService.Controllers
8+
{
9+
[Route("api/[controller]")]
10+
[ApiController]
11+
public class ValuesController : ControllerBase
12+
{
13+
// GET api/values
14+
[HttpGet]
15+
public ActionResult<IEnumerable<string>> Get()
16+
{
17+
return new string[] { "value1", "value2" };
18+
}
19+
20+
// GET api/values/5
21+
[HttpGet("{id}")]
22+
public ActionResult<string> Get(int id)
23+
{
24+
return "value";
25+
}
26+
27+
// POST api/values
28+
[HttpPost]
29+
public void Post([FromBody] string value)
30+
{
31+
}
32+
33+
// PUT api/values/5
34+
[HttpPut("{id}")]
35+
public void Put(int id, [FromBody] string value)
36+
{
37+
}
38+
39+
// DELETE api/values/5
40+
[HttpDelete("{id}")]
41+
public void Delete(int id)
42+
{
43+
}
44+
}
45+
}

src/AuditlogService/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2-stretch-slim AS base
2+
WORKDIR /app
3+
EXPOSE 80
4+
EXPOSE 443
5+
6+
FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
7+
WORKDIR /src
8+
COPY ["src/AuditlogService/AuditlogService.csproj", "src/AuditlogService/"]
9+
RUN dotnet restore "src/AuditlogService/AuditlogService.csproj"
10+
COPY . .
11+
WORKDIR "/src/src/AuditlogService"
12+
RUN dotnet build "AuditlogService.csproj" -c Release -o /app
13+
14+
FROM build AS publish
15+
RUN dotnet publish "AuditlogService.csproj" -c Release -o /app
16+
17+
FROM base AS final
18+
WORKDIR /app
19+
COPY --from=publish /app .
20+
ENTRYPOINT ["dotnet", "AuditlogService.dll"]
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using MassTransit;
2+
using MassTransitAbstractions;
3+
using Microsoft.Extensions.Options;
4+
using MassTransit.RabbitMqTransport;
5+
using MessageContracts;
6+
7+
namespace AuditlogService
8+
{
9+
public class MessageQueueService : MessageQueueServiceBase
10+
{
11+
public MessageQueueService(IOptions<MassTransitOptions> options) : base(options)
12+
{
13+
14+
}
15+
protected override void OnAddReceiveEndpoint(IRabbitMqBusFactoryConfigurator cfg, IRabbitMqHost host)
16+
{
17+
cfg.ReceiveEndpoint(host, "order-service", e =>
18+
{
19+
e.Handler<SubmitOrder>(context => context.RespondAsync<OrderAccepted>(new
20+
{
21+
context.Message.OrderId
22+
}));
23+
});
24+
}
25+
}
26+
}

src/AuditlogService/Program.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Threading.Tasks;
6+
using Microsoft.AspNetCore;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Logging;
11+
using Serilog;
12+
13+
namespace AuditlogService
14+
{
15+
public class Program
16+
{
17+
public static void Main(string[] args)
18+
{
19+
var host = CreateWebHostBuilder(args).Build();
20+
var logger = host.Services.GetRequiredService<ILogger<Program>>();
21+
logger.LogInformation("About to run......");
22+
host.Run();
23+
}
24+
25+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
26+
WebHost.CreateDefaultBuilder(args)
27+
.UseSerilog()
28+
.ConfigureAppConfiguration((hostingContext, config) =>
29+
{
30+
var environmentName = hostingContext.HostingEnvironment.EnvironmentName;
31+
LoadConfigurations(config, environmentName);
32+
config.AddEnvironmentVariables();
33+
config.AddUserSecrets<Startup>();
34+
})
35+
.UseStartup<Startup>()
36+
.UseHealthChecks("/hc");
37+
38+
public static void LoadConfigurations(IConfigurationBuilder config, string environmentName)
39+
{
40+
config
41+
.AddJsonFile($"appsettings.json", optional: false, reloadOnChange: true)
42+
.AddJsonFile($"appsettings.{environmentName}.json", optional: false, reloadOnChange: true)
43+
.AddJsonFile($"appsettings.graphql.json", optional: false, reloadOnChange: true);
44+
}
45+
}
46+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:61440",
7+
"sslPort": 44390
8+
}
9+
},
10+
"$schema": "http://json.schemastore.org/launchsettings.json",
11+
"profiles": {
12+
"IIS Express": {
13+
"commandName": "IISExpress",
14+
"launchBrowser": true,
15+
"launchUrl": "api/values",
16+
"environmentVariables": {
17+
"ASPNETCORE_ENVIRONMENT": "Development"
18+
}
19+
},
20+
"AuditlogService": {
21+
"commandName": "Project",
22+
"launchBrowser": true,
23+
"launchUrl": "api/values",
24+
"environmentVariables": {
25+
"ASPNETCORE_ENVIRONMENT": "Development"
26+
},
27+
"applicationUrl": "https://localhost:5021;http://localhost:5020"
28+
},
29+
"Docker": {
30+
"commandName": "Docker",
31+
"launchBrowser": true,
32+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/api/values",
33+
"environmentVariables": {
34+
"ASPNETCORE_URLS": "https://+:443;http://+:80",
35+
"ASPNETCORE_HTTPS_PORT": "44391"
36+
},
37+
"httpPort": 61441,
38+
"useSSL": true,
39+
"sslPort": 44391
40+
}
41+
}
42+
}

src/AuditlogService/Startup.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
using AuthRequiredDemoGraphQL.Extensions;
2+
using CustomerManagementAPI.Extensions;
3+
using CustomerManagementStore.Extensions;
4+
using GQL.GraphQLCore.Extensions;
5+
using GQL.GraphQLCore.Stores;
6+
using Microsoft.AspNetCore.Builder;
7+
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.DependencyInjection.Extensions;
11+
using Microsoft.Extensions.HealthChecks;
12+
using Microsoft.Extensions.Logging;
13+
using Serilog;
14+
using MassTransitAbstractions.Extensions;
15+
using GQL.GraphQLHost.Core;
16+
17+
namespace AuditlogService
18+
{
19+
public class Startup : GraphQLRollupStartup<Startup>
20+
{
21+
public Startup(IHostingEnvironment env, IConfiguration configuration, ILogger<Startup> logger) :
22+
base(env, configuration, logger)
23+
{
24+
25+
}
26+
27+
public override void AddGraphQLFieldAuthority(IServiceCollection services)
28+
{
29+
services.TryAddSingleton<IGraphQLFieldAuthority,
30+
InMemoryGraphQLFieldAuthority>();
31+
services.RegisterGraphQLCoreConfigurationServices(Configuration);
32+
}
33+
public override void AddGraphQLApis(IServiceCollection services)
34+
{
35+
36+
// services.AddBurnerGraphQL();
37+
// services.AddBurnerGraphQL2();
38+
services.AddGraphQLAuthRequiredQuery();
39+
}
40+
41+
protected override void AddHealthChecks(HealthCheckBuilder checks)
42+
{
43+
checks.AddUrlCheck("https://www.google.com");
44+
}
45+
46+
protected override void AddAdditionalServices(IServiceCollection services)
47+
{
48+
services.AddMassTransitOptions(Configuration.GetSection("MassTransitOptions"));
49+
services.AddHostedService<MessageQueueService>();
50+
51+
var configSection = Configuration.GetSection("RabbitMQ");
52+
string host = configSection["Host"];
53+
string userName = configSection["UserName"];
54+
string password = configSection["Password"];
55+
56+
services.AddStackExchangeRedisCache(options =>
57+
{
58+
options.Configuration = "localhost";
59+
options.InstanceName = "redis";
60+
});
61+
services.AddInMemoryCustomerManagmentStore();
62+
63+
64+
}
65+
protected override void OnConfigureStart(IApplicationBuilder app, IHostingEnvironment env)
66+
{
67+
Log.Logger = new LoggerConfiguration()
68+
.ReadFrom.Configuration(Configuration)
69+
.Enrich.WithMachineName()
70+
.CreateLogger();
71+
}
72+
73+
protected override void OnConfigureEnd(IApplicationBuilder app, IHostingEnvironment env)
74+
{
75+
76+
}
77+
}
78+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"MassTransitOptions": {
3+
"TransportType": "RabbitMQ",
4+
"Username": "rabbitmquser",
5+
"Password": "DEBmbwkSrzy9D1T9cJfa"
6+
},
7+
"RabbitMQ": {
8+
"Host": "localhost",
9+
"Username": "rabbitmquser",
10+
"Password": "DEBmbwkSrzy9D1T9cJfa"
11+
},
12+
"Serilog": {
13+
"Using": [ "Serilog.Sinks.Console" ],
14+
"MinimumLevel": "Information",
15+
"WriteTo": [
16+
{ "Name": "Console" },
17+
{
18+
"Name": "Seq",
19+
"Args": { "serverUrl": "http://localhost:5341" }
20+
}
21+
],
22+
"Properties": {
23+
"Application": "AuditlogService"
24+
}
25+
},
26+
"Logging": {
27+
"LogLevel": {
28+
"Default": "Debug",
29+
"System": "Information",
30+
"Microsoft": "Information"
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)