From e17b9cd30f8062c5b0d1cede17cd2887b99f44eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Wed, 14 Mar 2018 11:46:31 +0300 Subject: [PATCH] #233 added standard auditing interfaces. --- Volo.Abp.sln | 7 ++++++ .../Volo.Abp.Auditing.csproj | 21 ++++++++++++++++ .../Volo/Abp/Auditing/AbpAuditingModule.cs | 15 +++++++++++ .../Volo/Abp/Auditing/IAudited.cs | 19 ++++++++++++++ .../Volo/Abp/Auditing/ICreationAudited.cs | 25 +++++++++++++++++++ .../Volo/Abp/Auditing/IDeletionAudited.cs | 25 +++++++++++++++++++ .../Volo/Abp/Auditing/IFullAudited.cs | 19 ++++++++++++++ .../Volo/Abp/Auditing/IHasCreationTime.cs | 15 +++++++++++ .../Volo/Abp/Auditing/IHasDeletionTime.cs | 16 ++++++++++++ .../Volo/Abp/Auditing/IHasModificationTime.cs | 15 +++++++++++ .../Volo/Abp/Auditing/IModificationAudited.cs | 25 +++++++++++++++++++ 11 files changed, 202 insertions(+) create mode 100644 src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAudited.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/ICreationAudited.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IDeletionAudited.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IFullAudited.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasCreationTime.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasDeletionTime.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasModificationTime.cs create mode 100644 src/Volo.Abp.Auditing/Volo/Abp/Auditing/IModificationAudited.cs diff --git a/Volo.Abp.sln b/Volo.Abp.sln index 14d8299ef7..cf2f59c46e 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -306,6 +306,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{F33F EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Users", "src\Volo.Abp.Users\Volo.Abp.Users.csproj", "{DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Auditing", "src\Volo.Abp.Auditing\Volo.Abp.Auditing.csproj", "{03F51721-DA51-4BAE-9909-3FC88FAB7774}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -808,6 +810,10 @@ Global {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Debug|Any CPU.Build.0 = Debug|Any CPU {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Release|Any CPU.ActiveCfg = Release|Any CPU {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE}.Release|Any CPU.Build.0 = Release|Any CPU + {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Debug|Any CPU.Build.0 = Debug|Any CPU + {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Release|Any CPU.ActiveCfg = Release|Any CPU + {03F51721-DA51-4BAE-9909-3FC88FAB7774}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -957,6 +963,7 @@ Global {EBD87D3A-8130-4FBB-9A47-4A81717BB915} = {447C8A77-E5F0-4538-8687-7383196D04EA} {F33F751F-1260-40C0-8F76-E3D680605662} = {447C8A77-E5F0-4538-8687-7383196D04EA} {DAE9088E-6E30-4D5D-9DF8-2188E8D386FE} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} + {03F51721-DA51-4BAE-9909-3FC88FAB7774} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj b/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj new file mode 100644 index 0000000000..450efb7de6 --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo.Abp.Auditing.csproj @@ -0,0 +1,21 @@ + + + + + + netstandard2.0 + Volo.Abp.Auditing + Volo.Abp.Auditing + $(AssetTargetFallback);portable-net45+win8+wp8+wpa81; + false + false + false + + + + + + + + + diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs new file mode 100644 index 0000000000..42532bfb3a --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/AbpAuditingModule.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Data; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Auditing +{ + [DependsOn(typeof(AbpDataModule))] //TODO: Can we remove data module dependency since it only contains ISoftDelete related to auditing module! + public class AbpAuditingModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAudited.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAudited.cs new file mode 100644 index 0000000000..2591441252 --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IAudited.cs @@ -0,0 +1,19 @@ +namespace Volo.Abp.Auditing +{ + /// + /// This interface can be implemented to add standard auditing properties to a class. + /// + public interface IAudited : ICreationAudited, IModificationAudited + { + + } + + /// + /// Extends to add user navigation properties. + /// + /// Type of the user + public interface IAudited : IAudited, ICreationAudited, IModificationAudited + { + + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/ICreationAudited.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/ICreationAudited.cs new file mode 100644 index 0000000000..f132d676d6 --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/ICreationAudited.cs @@ -0,0 +1,25 @@ +namespace Volo.Abp.Auditing +{ + /// + /// This interface can be implemented to store creation information (who and when created). + /// + public interface ICreationAudited : IHasCreationTime + { + /// + /// Id of the creator user. + /// + long? CreatorUserId { get; set; } + } + + /// + /// Adds navigation properties to interface for user. + /// + /// Type of the user + public interface ICreationAudited : ICreationAudited + { + /// + /// Reference to the creator user. + /// + TUser CreatorUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IDeletionAudited.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IDeletionAudited.cs new file mode 100644 index 0000000000..25991cd3d7 --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IDeletionAudited.cs @@ -0,0 +1,25 @@ +namespace Volo.Abp.Auditing +{ + /// + /// This interface can be implemented to store deletion information (who delete and when deleted). + /// + public interface IDeletionAudited : IHasDeletionTime + { + /// + /// Id of the deleter user. + /// + long? DeleterUserId { get; set; } + } + + /// + /// Extends to add user navigation propery. + /// + /// Type of the user + public interface IDeletionAudited : IDeletionAudited + { + /// + /// Reference to the deleter user. + /// + TUser DeleterUser { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IFullAudited.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IFullAudited.cs new file mode 100644 index 0000000000..7a934f94d4 --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IFullAudited.cs @@ -0,0 +1,19 @@ +namespace Volo.Abp.Auditing +{ + /// + /// This interface adds to . + /// + public interface IFullAudited : IAudited, IDeletionAudited + { + + } + + /// + /// Adds user navigation properties to interface for user. + /// + /// Type of the user + public interface IFullAudited : IAudited, IFullAudited, IDeletionAudited + { + + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasCreationTime.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasCreationTime.cs new file mode 100644 index 0000000000..58e64cabef --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasCreationTime.cs @@ -0,0 +1,15 @@ +using System; + +namespace Volo.Abp.Auditing +{ + /// + /// A standard interface to add CreationTime property. + /// + public interface IHasCreationTime + { + /// + /// Creation time. + /// + DateTime CreationTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasDeletionTime.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasDeletionTime.cs new file mode 100644 index 0000000000..f882b321ea --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasDeletionTime.cs @@ -0,0 +1,16 @@ +using System; + +namespace Volo.Abp.Auditing +{ + /// + /// A standard interface to add DeletionTime property to a class. + /// It also makes the class soft delete (see ). + /// + public interface IHasDeletionTime : ISoftDelete + { + /// + /// Deletion time. + /// + DateTime? DeletionTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasModificationTime.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasModificationTime.cs new file mode 100644 index 0000000000..b1740f66af --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IHasModificationTime.cs @@ -0,0 +1,15 @@ +using System; + +namespace Volo.Abp.Auditing +{ + /// + /// A standard interface to add DeletionTime property to a class. + /// + public interface IHasModificationTime + { + /// + /// The last modified time for this entity. + /// + DateTime? LastModificationTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IModificationAudited.cs b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IModificationAudited.cs new file mode 100644 index 0000000000..b5b4f6a591 --- /dev/null +++ b/src/Volo.Abp.Auditing/Volo/Abp/Auditing/IModificationAudited.cs @@ -0,0 +1,25 @@ +namespace Volo.Abp.Auditing +{ + /// + /// This interface can be implemented to store modification information (who and when modified lastly). + /// + public interface IModificationAudited : IHasModificationTime + { + /// + /// Last modifier user for this entity. + /// + long? LastModifierUserId { get; set; } + } + + /// + /// Adds navigation properties to interface for a user. + /// + /// Type of the user + public interface IModificationAudited : IModificationAudited + { + /// + /// Reference to the last modifier user of this entity. + /// + TUser LastModifierUser { get; set; } + } +} \ No newline at end of file