Pandatech.AuditTrail
1.2.3
See the version list below for details.
dotnet add package Pandatech.AuditTrail --version 1.2.3
NuGet\Install-Package Pandatech.AuditTrail -Version 1.2.3
<PackageReference Include="Pandatech.AuditTrail" Version="1.2.3" />
paket add Pandatech.AuditTrail --version 1.2.3
#r "nuget: Pandatech.AuditTrail, 1.2.3"
// Install Pandatech.AuditTrail as a Cake Addin #addin nuget:?package=Pandatech.AuditTrail&version=1.2.3 // Install Pandatech.AuditTrail as a Cake Tool #tool nuget:?package=Pandatech.AuditTrail&version=1.2.3
1. Pandatech.AuditTrail
Pandatech.AuditTrail is a tool meticulously crafted to gather vital entity data from the change tracker post DbContext SaveChanges operation.
1.1 Features
Audits necessary entities for logging or preserving modified property data. Offers a convenient fluent configuration to specify tracked entities with ease.
1.2 Getting Started
Install the package via NuGet Package Manager or use the following command:
Install-Package Pandatech.AuditTrail
1.3 Usage
- Implement
IAuditTrailConsumer
interface. - Add AddAuditTrail services by providing
IAuditTrailConsumer
implementation. - Create a rules derived from
EntityRule
.
1.3.1. Implement IAuditTrailConsumer Example:
Implement the IAuditTrailConsumer
interface.
To be able to retrive modified entities data after save operation.
public class AuditTrailConsumer<TPermission>() : IAuditTrailConsumer<TPermission>
{
public Task ConsumeAsync(IEnumerable<AuditTrailDataAfterSave<TPermission>> entitiesData,
CancellationToken cancellationToken = default)
{
// Handle tracked entites here.
}
public async Task ConsumeTransactionAsync(IEnumerable<AuditTrailDataAfterSave<TPermission>> entitiesData,
TransactionEndEventData dbContextEventData,
CancellationToken cancellationToken = default)
{
// Handle tracked entites after transaction commit
}
}
1.3.2. Add Services Example:
builder.Services.AddAuditTrail<PermissionType?, AuditTrailConsumer<PermissionType?>>(typeof(Registration).Assembly);
services.AddDbContextPool<SomeDbContext>((sp, options) =>
{
options.UseAuditTrail<PermissionType?>(sp);
});
1.3.3 Create rule example:
Create a rule derived from EntityRule
.
public class UserRule : EntityRule<UserEntity, PermissionType?>
{
public UserRule(ISomeService someService)
{
SetPermission(PermissionType.Users_Read);
RuleFor(s => s.PasswordHash).Ignore();
RuleFor(s => s.Status).ChangeName("UserStatus");
}
}
1.3.4 Create Custom Rule Example:
You can create your own rules and modify properties as needed.
public class ChangeNamePropertyRule<TEntity, TProperty> : PropertyRule<TEntity, TProperty>
{
private readonly string _changeName;
public override NameValue ExecuteRule(string name, object value)
{
return new NameValue(_changeName, value);
}
public ChangeNamePropertyRule(string name)
{
_changeName = name;
}
}
public static class RuleExtensions
{
public static IRuleBulder<T, TPermission, TProperty?> ChangeName<T, TPermission, TProperty>(this IRuleBulder<T, TPermission, TProperty> ruleBuilder, string name)
where T : class
{
var rule = new ChangeNamePropertyRule<T, TProperty?>(name);
return ruleBuilder.SetRule(rule!)!;
}
}
1.4 Limitations
- In case of composite keys only first key will be selected as entityId.
1.5. Contributing
Contributions are welcome! Please submit a pull request or open an issue to propose changes or report bugs.
1.6 License
Pandatech.AuditTrail is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.ApplicationInsights.AspNetCore (>= 2.22.0)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.8 | 115 | 6/11/2024 |
1.2.7 | 82 | 6/11/2024 |
1.2.6 | 97 | 6/9/2024 |
1.2.5 | 114 | 5/30/2024 |
1.2.4 | 104 | 5/30/2024 |
1.2.3 | 113 | 5/29/2024 |
1.2.2 | 99 | 5/29/2024 |
1.2.1 | 91 | 5/29/2024 |
1.2.0 | 105 | 5/29/2024 |
1.1.8 | 97 | 5/28/2024 |
1.1.7 | 97 | 5/28/2024 |
1.1.6 | 109 | 5/28/2024 |
1.1.5 | 103 | 5/28/2024 |
1.1.4 | 104 | 5/27/2024 |
1.1.3 | 111 | 5/27/2024 |
1.1.2 | 102 | 5/24/2024 |
1.1.1 | 84 | 5/16/2024 |
1.1.0 | 51 | 5/16/2024 |
1.0.0 | 125 | 5/5/2024 |
0.1.5 | 110 | 5/4/2024 |
0.1.4 | 115 | 5/4/2024 |
0.1.3 | 66 | 5/2/2024 |
0.1.2 | 63 | 5/2/2024 |
0.1.1 | 58 | 5/2/2024 |
0.1.0 | 64 | 5/2/2024 |
0.0.8 | 106 | 4/30/2024 |
0.0.7 | 114 | 4/30/2024 |
0.0.6 | 92 | 4/29/2024 |
0.0.5 | 94 | 4/29/2024 |
0.0.4 | 101 | 4/29/2024 |
0.0.3 | 104 | 4/28/2024 |
0.0.2 | 103 | 4/27/2024 |
0.0.1 | 90 | 4/26/2024 |
Breaking changes -> Rename "AuditTrailCommanModel" into "AuditTrailDataAfterSave" and "AuditTrailEntityData" into "AuditTrailDataBeforeSave"