Skip to content

Commit

Permalink
Combined commit message for updates up to 0162cdb
Browse files Browse the repository at this point in the history
  • Loading branch information
ANcpLua committed Jan 16, 2025
1 parent 21e2615 commit df8cb9f
Show file tree
Hide file tree
Showing 643 changed files with 13,150 additions and 22,569 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Dockerized CI with Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Install Docker Compose
run: |
DOCKER_COMPOSE_VERSION=2.20.2
curl -L "https://github.com/docker/compose/releases/download/v${DOCKER_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose version
- name: Start Docker Services
run: |
docker compose -f compose.yaml up --build -d
shell: bash

- name: Restore .NET Dependencies
run: dotnet restore
shell: bash

- name: Build .NET Solution
run: dotnet build --no-restore --configuration Debug
shell: bash

- name: Run Tests
run: dotnet test --no-build --configuration Debug --verbosity normal
shell: bash

- name: Cleanup Docker Services
if: always()
run: docker compose -f compose.yaml down --volumes
shell: bash
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Binaries
*.dll
*.exe
*.pdb

# Build directories
/bin
/obj

13 changes: 13 additions & 0 deletions .idea/.idea.Paperless/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/.idea.Paperless/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/.idea.Paperless/.idea/indexLayout.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/.idea.Paperless/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 15 additions & 13 deletions Contract/Contract.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.2" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Contract/DocumentDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public record DocumentDto
public string Content { get; set; } = string.Empty;
public string FilePath { get; set; } = string.Empty;
public DateTime DateUploaded { get; set; }
public string? OcrText { get; set; }
public string OcrText { get; set; } = string.Empty;
public IFormFile? File { get; init; }
}
2 changes: 1 addition & 1 deletion Contract/DocumentUploadedEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ public record DocumentUploadedEvent
public int DocumentId { get; set; }
public string FileName { get; set; } = string.Empty;
public DateTime UploadedAt { get; set; } = DateTime.UtcNow;
}
}
7 changes: 7 additions & 0 deletions Contract/Logger/IOperationLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Contract.Logger;

public interface IOperationLogger
{
Task LogOperation(LogOperationAttribute attribute, string methodName, object?[] parameters);
Task LogOperationError(LogOperationAttribute attribute, string methodName, Exception ex);
}
20 changes: 20 additions & 0 deletions Contract/Logger/LogOperationAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Microsoft.Extensions.Logging;

namespace Contract.Logger;

[AttributeUsage(AttributeTargets.Method)]
public class LogOperationAttribute : Attribute
{
public string Component { get; }
public string Category { get; }
public LogLevel Level { get; }
public bool LogParameters { get; set; } = true;
public bool LogResponse { get; set; } = true;

public LogOperationAttribute(string component, string category, LogLevel level = LogLevel.Information)
{
Component = component;
Category = category;
Level = level;
}
}
14 changes: 14 additions & 0 deletions Contract/Logger/LoggerExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Contract.Logger;

public static class LoggerExtensions
{
public static void AddOperationLogging(this IServiceCollection services, string environment)
{
services.AddScoped<IOperationLogger>(sp => new OperationLogger(
sp.GetRequiredService<ILoggerFactory>().CreateLogger<OperationLogger>(),
environment));
}
}
61 changes: 61 additions & 0 deletions Contract/Logger/OperationLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Microsoft.Extensions.Logging;

namespace Contract.Logger;

public class OperationLogger : IOperationLogger
{
private readonly ILogger _logger;
private readonly string _environment;

public OperationLogger(ILogger logger, string environment)
{
_logger = logger;
_environment = environment;
}

public async Task LogOperation(LogOperationAttribute attribute, string methodName, params object?[] parameters)
{
if (attribute.LogParameters && parameters is { Length: > 0 })
{
var paramString = string.Join(", ", parameters.Select(p => p?.ToString() ?? "null"));
_logger.Log(attribute.Level,
"[{Environment}][{Component}][{Category}] {Method} started - Parameters: {Parameters}",
_environment, attribute.Component, attribute.Category, methodName, paramString);
}
else
{
_logger.Log(attribute.Level,
"[{Environment}][{Component}][{Category}] {Method} started",
_environment, attribute.Component, attribute.Category, methodName);
}

await Task.CompletedTask;
}

public async Task LogOperationComplete(LogOperationAttribute attribute, string methodName, object? result = null)
{
if (result != null && attribute.LogResponse)
{
_logger.Log(attribute.Level,
"[{Environment}][{Component}][{Category}] {Method} completed - Result: {Result}",
_environment, attribute.Component, attribute.Category, methodName, result);
}
else
{
_logger.Log(attribute.Level,
"[{Environment}][{Component}][{Category}] {Method} completed",
_environment, attribute.Component, attribute.Category, methodName);
}

await Task.CompletedTask;
}

public async Task LogOperationError(LogOperationAttribute attribute, string methodName, Exception ex)
{
_logger.LogError(ex,
"[{Environment}][{Component}][{Category}] {Method} failed - {Error}",
_environment, attribute.Component, attribute.Category, methodName, ex.Message);

await Task.CompletedTask;
}
}
8 changes: 0 additions & 8 deletions Contract/TextMessage.cs

This file was deleted.

75 changes: 0 additions & 75 deletions Contract/bin/Release/net8.0/Contract.deps.json

This file was deleted.

Binary file removed Contract/bin/Release/net8.0/Contract.dll
Binary file not shown.
Binary file removed Contract/bin/Release/net8.0/Contract.pdb
Binary file not shown.
Loading

0 comments on commit df8cb9f

Please sign in to comment.