diff --git a/net5/net5.sln b/net5/net5.sln new file mode 100644 index 0000000..2a0439a --- /dev/null +++ b/net5/net5.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31025.194 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "receiver", "receiver\receiver.csproj", "{3C5977DA-6187-49AA-97CF-E713C2A8AF31}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3C5977DA-6187-49AA-97CF-E713C2A8AF31}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C5977DA-6187-49AA-97CF-E713C2A8AF31}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C5977DA-6187-49AA-97CF-E713C2A8AF31}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C5977DA-6187-49AA-97CF-E713C2A8AF31}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {E0910EE0-6323-4191-9902-37105554765C} + EndGlobalSection +EndGlobal diff --git a/net5/receiver/Controllers/WebhookListenerController.cs b/net5/receiver/Controllers/WebhookListenerController.cs new file mode 100644 index 0000000..fb3c4b6 --- /dev/null +++ b/net5/receiver/Controllers/WebhookListenerController.cs @@ -0,0 +1,43 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text.Json; +using System.Threading.Tasks; + +namespace receiver.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class WebhookListenerController : Controller + { + private readonly IWebHostEnvironment _hostEnvironment; + public WebhookListenerController(IWebHostEnvironment hostEnvironment) + { + _hostEnvironment = hostEnvironment; + } + [HttpPost] + public void Receiver([FromBody] dynamic payload) + { + string directoryPath = Path.Combine(_hostEnvironment.ContentRootPath, "WebhookLogs"); + string filePath = Path.Combine(directoryPath, "webhook.txt"); + if (!Directory.Exists(Path.Combine(_hostEnvironment.ContentRootPath, "WebhookLogs"))) + { + Directory.CreateDirectory(Path.Combine(_hostEnvironment.ContentRootPath, "WebhookLogs")); + } + string webHookMessage = JsonSerializer.Serialize(payload); + + using (StreamWriter sw = System.IO.File.AppendText(filePath)) + { + sw.WriteLine(webHookMessage); + } + } + [HttpGet] + public string Reader() + { + return System.IO.File.ReadAllText(Path.Combine(_hostEnvironment.ContentRootPath, "WebhookLogs", "webhook.txt")); + } + } +} diff --git a/net5/receiver/appsettings.Development.json b/net5/receiver/appsettings.Development.json new file mode 100644 index 0000000..dba68eb --- /dev/null +++ b/net5/receiver/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + } +} diff --git a/net5/receiver/appsettings.json b/net5/receiver/appsettings.json new file mode 100644 index 0000000..81ff877 --- /dev/null +++ b/net5/receiver/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*" +} diff --git a/net5/receiver/obj/Debug/net5.0/apphost.exe b/net5/receiver/obj/Debug/net5.0/apphost.exe new file mode 100644 index 0000000..34a198a Binary files /dev/null and b/net5/receiver/obj/Debug/net5.0/apphost.exe differ diff --git a/net5/receiver/obj/Debug/net5.0/receiver.AssemblyInfo.cs b/net5/receiver/obj/Debug/net5.0/receiver.AssemblyInfo.cs new file mode 100644 index 0000000..57c21a4 --- /dev/null +++ b/net5/receiver/obj/Debug/net5.0/receiver.AssemblyInfo.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +using System; +using System.Reflection; + +[assembly: System.Reflection.AssemblyCompanyAttribute("receiver")] +[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] +[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] +[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] +[assembly: System.Reflection.AssemblyProductAttribute("receiver")] +[assembly: System.Reflection.AssemblyTitleAttribute("receiver")] +[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] + +// Generated by the MSBuild WriteCodeFragment class. + diff --git a/net5/receiver/obj/Debug/net5.0/receiver.AssemblyInfoInputs.cache b/net5/receiver/obj/Debug/net5.0/receiver.AssemblyInfoInputs.cache new file mode 100644 index 0000000..46dbda9 --- /dev/null +++ b/net5/receiver/obj/Debug/net5.0/receiver.AssemblyInfoInputs.cache @@ -0,0 +1 @@ +7969be0edacb058732d7a27e5dda15840699ae9e diff --git a/net5/receiver/obj/Debug/net5.0/receiver.assets.cache b/net5/receiver/obj/Debug/net5.0/receiver.assets.cache new file mode 100644 index 0000000..d3ed4ff Binary files /dev/null and b/net5/receiver/obj/Debug/net5.0/receiver.assets.cache differ