Skip to content

Commit

Permalink
Support EntityFramework only
Browse files Browse the repository at this point in the history
  • Loading branch information
saturn72 committed May 21, 2023
1 parent 2b2f9c6 commit 31aeb24
Show file tree
Hide file tree
Showing 63 changed files with 102 additions and 455 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/cont-delivery.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: EfAudit ci

on:
push:
branches:
- main

jobs:
continunous_delivery:
name: build, test & deploy

defaults:
run:
working-directory: ./

runs-on: ubuntu-latest
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 7.0.x

- name: Checkout main branch
uses: actions/checkout@main
with:
dotnet-version: 7.0.x

# - name: Build Solution
# run: dotnet build --configuration Release

- name: Test
run: dotnet test ./EfAudit.Tests/EfAudit.Tests.csproj --verbosity normal --configuration Release /p:CollectCoverage=true

- name: Publish
run: dotnet publish ./EfAudit/EfAudit.csproj --configuration Release

- name: Upload Artifacts
uses: actions/[email protected]
with:
name: EfAudit for publish
path: ./EfAudit/bin/Release/net7.0/publish/
if-no-files-found: error

- name: pack nuget package
working-directory: ./
run: dotnet pack ./EfAudit/EfAudit.csproj --configuration Release --output ./nupkg --include-symbols --include-source -p:SymbolPackageFormat=snupkg

- name: Push packages to nuget
working-directory: ./nupkg
run: dotnet nuget push *.nupkg --api-key $nuget_api_key --source https://api.nuget.org/v3/index.json
env:
nuget_api_key: ${{secrets.NUGET_DEPLOY_KEY}}
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ _ReSharper*/
.vs/
#Nuget packages folder
packages/
/EntityFramework/Server/catalog.db-shm
/EntityFramework/Server/catalog.db-wal
/EntityFramework/Server/catalog.db
catalog.db-shm
catalog.db-wal
catalog.db
nupkg/
17 changes: 0 additions & 17 deletions AuditTrail.Common/AuditTrail.Common.csproj

This file was deleted.

2 changes: 0 additions & 2 deletions AuditTrail.Common/Usings.cs

This file was deleted.

87 changes: 0 additions & 87 deletions AuditTrail.sln

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
Expand Down Expand Up @@ -28,7 +28,7 @@

<ItemGroup>
<ProjectReference Include="..\EfAudit\EfAudit.csproj" />
<ProjectReference Include="..\Server\EfAuditServerSample.csproj" />
<ProjectReference Include="..\Sample\Server\Server.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Options;
using static AuditTrail.Common.EntityAudit;

Expand Down Expand Up @@ -40,13 +39,12 @@ public ValueTask<InterceptionResult<int>> SavingChangesAsync(
_record = CreateAuditRecord(eventData.Context);
return ValueTask.FromResult(result);
}

public ValueTask<InterceptionResult<int>> SavingChanges(
public InterceptionResult<int> SavingChanges(
DbContextEventData eventData,
InterceptionResult<int> result)
{
_record = CreateAuditRecord(eventData.Context);
return ValueTask.FromResult(result);
return result;
}

public int SavedChanges(SaveChangesCompletedEventData eventData, int result)
Expand All @@ -66,13 +64,10 @@ public async ValueTask<int> SavedChangesAsync(

private async Task OnSavedChanges(DbContext? context)
{
#warning - remove this one
CreateAuditRecord(context);

if (_record == default)
throw new InvalidOperationException();
_record.TransactionId = context.GetCurrentTransactionId();

_record.TransactionId = context.GetCurrentTransactionId();
foreach (var e in _record.Entities.Where(x => x.State == Added))
{
var te = _trackedEntities[e.Uuid];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using static AuditTrail.Common.AuditTrailRecord;
using AuditTrail.Common;
using static AuditTrail.Common.AuditTrailRecord;

namespace EfAudit.Extractors
namespace EfAudit.Common.Extractors
{
public class DefaultDataChangedExtractor : IDataChangedExtractor
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace EfAudit.Extractors
using AuditTrail.Common;

namespace EfAudit.Common.Extractors
{
public interface IDataChangedExtractor
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@



namespace AuditTrail.Common.Services
{
public class DefaultEventBus : IEventBus
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ public static DbContextOptionsBuilder AddAuditInterceptor(
this DbContextOptionsBuilder builder,
IServiceProvider services)
{
var interceptor = services.GetRequiredService<AuditSaveChangesInterceptor>();
builder.AddInterceptors(interceptor);
builder.AddInterceptors(services.GetRequiredService<AuditSaveChangesInterceptor>());

return builder;
}
Expand Down
16 changes: 12 additions & 4 deletions EntityFramework/EfAudit/EfAudit.csproj → EfAudit/EfAudit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageId>EfAudit</PackageId>
<PackageVersion>1.0.1</PackageVersion>
<Authors>[email protected]</Authors>
<Company>saturn technologies</Company>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
</PropertyGroup>
<ItemGroup>
<None Include="README.md" Pack="true" PackagePath=""/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\AuditTrail.Common\AuditTrail.Common.csproj" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="7.0.5" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions EfAudit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# AuditTrail
Multiple `AuditTrail` solutions to be used in `C#`
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using EfAudit.Extractors;
using EfAudit.Common.Extractors;
using Microsoft.Extensions.Configuration;
using System.Reflection;

Expand Down
1 change: 1 addition & 0 deletions EntityFramework/EfAudit/Usings.cs → EfAudit/Usings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
global using Microsoft.EntityFrameworkCore.Diagnostics;
global using Microsoft.Extensions.DependencyInjection;
global using Microsoft.Extensions.DependencyInjection.Extensions;
global using Microsoft.Extensions.Logging;
global using System;
2 changes: 0 additions & 2 deletions EntityFramework/Server/Usings.cs

This file was deleted.

11 changes: 0 additions & 11 deletions EntityFramework/Sinks/DaprSinks.Tests/DaprCollection.cs

This file was deleted.

64 changes: 0 additions & 64 deletions EntityFramework/Sinks/DaprSinks.Tests/DaprFixture.cs

This file was deleted.

Loading

0 comments on commit 31aeb24

Please sign in to comment.