This commit is contained in:
h z
2025-03-09 11:51:30 +00:00
commit 22e415bce8
8 changed files with 93 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/

View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Worker">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>dotnet-Alchegos.Gitea.Webhook-61e3506a-2cdc-487d-86e8-706d75fc08ee</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2"/>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Alchegos.Gitea.Webhook", "Alchegos.Gitea.Webhook.csproj", "{9AC7FA18-FDC8-4A3F-A2DC-6C9976339C6A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9AC7FA18-FDC8-4A3F-A2DC-6C9976339C6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9AC7FA18-FDC8-4A3F-A2DC-6C9976339C6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9AC7FA18-FDC8-4A3F-A2DC-6C9976339C6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9AC7FA18-FDC8-4A3F-A2DC-6C9976339C6A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

7
Program.cs Normal file
View File

@@ -0,0 +1,7 @@
using Alchegos.Gitea.Webhook;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddHostedService<Worker>();
var host = builder.Build();
host.Run();

View File

@@ -0,0 +1,12 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"Alchegos.Gitea.Webhook": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
}

24
Worker.cs Normal file
View File

@@ -0,0 +1,24 @@
namespace Alchegos.Gitea.Webhook;
public class Worker : BackgroundService
{
private readonly ILogger<Worker> _logger;
public Worker(ILogger<Worker> logger)
{
_logger = logger;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
while (!stoppingToken.IsCancellationRequested)
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
}
await Task.Delay(1000, stoppingToken);
}
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

8
appsettings.json Normal file
View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}