Skip to content

Commit a81d81c

Browse files
committed
Add Genocs.Persistence.EFCore project and enhancements
- Introduced a new project "Genocs.Persistence.EFCore" in the solution. - Updated solution configuration and documentation in `Genocs.Common.csproj`. - Enhanced `MessageAttribute` and `PublicContractAttribute` classes. - Added MongoDB support in `Program.cs`. - Changed `UpdatedBy` property type to `DefaultIdType?` in auditing classes. - Introduced new interfaces for job scheduling and notifications. - Created `DomainEvent`, `AuditDto`, and `Trail` classes for event handling and logging. - Implemented connection string validation and security. - Enhanced database context management and added global query filters. - Updated `README_NUGET.md` for better documentation.
1 parent 430a6f8 commit a81d81c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1198
-87
lines changed

genocs.sln

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genocs.OpenTelemetry", "src
133133
EndProject
134134
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genocs.Core.Demo.HelloWorld", "src\Genocs.Core.Demo.HelloWorld\Genocs.Core.Demo.HelloWorld.csproj", "{D7C394CF-487D-470D-B05C-CC2DD7EC290B}"
135135
EndProject
136+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Genocs.Persistence.EFCore", "src\Genocs.Persistence.EFCore\Genocs.Persistence.EFCore.csproj", "{69A6FE21-8FB1-4D4D-8C6B-B18C06EFF2CF}"
137+
EndProject
136138
Global
137139
GlobalSection(SolutionConfigurationPlatforms) = preSolution
138140
Debug|Any CPU = Debug|Any CPU
@@ -307,6 +309,10 @@ Global
307309
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Debug|Any CPU.Build.0 = Debug|Any CPU
308310
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Release|Any CPU.ActiveCfg = Release|Any CPU
309311
{D7C394CF-487D-470D-B05C-CC2DD7EC290B}.Release|Any CPU.Build.0 = Release|Any CPU
312+
{69A6FE21-8FB1-4D4D-8C6B-B18C06EFF2CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
313+
{69A6FE21-8FB1-4D4D-8C6B-B18C06EFF2CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
314+
{69A6FE21-8FB1-4D4D-8C6B-B18C06EFF2CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
315+
{69A6FE21-8FB1-4D4D-8C6B-B18C06EFF2CF}.Release|Any CPU.Build.0 = Release|Any CPU
310316
EndGlobalSection
311317
GlobalSection(SolutionProperties) = preSolution
312318
HideSolutionNode = FALSE

src/Genocs.Common/Genocs.Common.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
<AssemblyName>Genocs.Common</AssemblyName>
88
<Title>The Genocs common components.</Title>
99
<Description>The common components to build .NET Core projects along with Genocs Library.</Description>
10+
<Summary>The common components to build .NET Core projects along with Genocs Library.</Summary>
1011
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1112
<MinClientVersion>5.0.0</MinClientVersion>
1213
<Authors>Nocco Giovanni Emanuele</Authors>
1314
<PackageTags>microservice microservices solid solid-principles genocs</PackageTags>
1415
<PackageReadmeFile>README_NUGET.md</PackageReadmeFile>
15-
<PackageReleaseNotes>Upgraded to NET9.0</PackageReleaseNotes>
1616
<EnableNETAnalyzers>True</EnableNETAnalyzers>
1717
<AnalysisLevel>latest</AnalysisLevel>
18+
<PackageReleaseNotes>
19+
The change log and breaking changes are listed here.
20+
https://github.com/Genocs/genocs-library/releases
21+
</PackageReleaseNotes>
1822
</PropertyGroup>
1923

2024
</Project>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Security.Claims;
2+
3+
namespace Genocs.Common.Interfaces;
4+
5+
/// <summary>
6+
/// The CurrentUser interface.
7+
/// </summary>
8+
public interface ICurrentUser
9+
{
10+
/// <summary>
11+
/// The user id.
12+
/// </summary>
13+
string? Name { get; }
14+
15+
/// <summary>
16+
/// Gets the user id.
17+
/// </summary>
18+
/// <returns>The default Id Type.</returns>
19+
DefaultIdType GetUserId();
20+
21+
string? GetUserEmail();
22+
23+
string? GetTenant();
24+
25+
bool IsAuthenticated();
26+
27+
/// <summary>
28+
/// Checks if the user is in a specific role.
29+
/// </summary>
30+
/// <param name="role">Role to check.</param>
31+
/// <returns>True in case of sucesful otherwise False.</returns>
32+
bool IsInRole(string role);
33+
34+
/// <summary>
35+
/// Gets the user claims.
36+
/// </summary>
37+
/// <returns>List of the claims.</returns>
38+
IEnumerable<Claim>? GetUserClaims();
39+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Genocs.Common.Interfaces;
2+
3+
/// <summary>
4+
/// Interface for DTOs.
5+
/// </summary>
6+
public interface IDto;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Linq.Expressions;
2+
3+
namespace Genocs.Common.Interfaces;
4+
5+
/// <summary>
6+
/// Interface for job service.
7+
/// TODO: This interface is used to define the methods for job scheduling and management.
8+
/// Will be used in the future.
9+
/// </summary>
10+
public interface IJobService : ITransientService
11+
{
12+
string Enqueue(Expression<Action> methodCall);
13+
14+
string Enqueue(Expression<Func<Task>> methodCall);
15+
16+
string Enqueue<T>(Expression<Action<T>> methodCall);
17+
18+
string Enqueue<T>(Expression<Func<T, Task>> methodCall);
19+
20+
string Schedule(Expression<Action> methodCall, TimeSpan delay);
21+
22+
string Schedule(Expression<Func<Task>> methodCall, TimeSpan delay);
23+
24+
string Schedule(Expression<Action> methodCall, DateTimeOffset enqueueAt);
25+
26+
string Schedule(Expression<Func<Task>> methodCall, DateTimeOffset enqueueAt);
27+
28+
string Schedule<T>(Expression<Action<T>> methodCall, TimeSpan delay);
29+
30+
string Schedule<T>(Expression<Func<T, Task>> methodCall, TimeSpan delay);
31+
32+
string Schedule<T>(Expression<Action<T>> methodCall, DateTimeOffset enqueueAt);
33+
34+
string Schedule<T>(Expression<Func<T, Task>> methodCall, DateTimeOffset enqueueAt);
35+
36+
bool Delete(string jobId);
37+
38+
bool Delete(string jobId, string fromState);
39+
40+
bool Requeue(string jobId);
41+
42+
bool Requeue(string jobId, string fromState);
43+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Genocs.Common.Notifications;
2+
3+
namespace Genocs.Common.Interfaces;
4+
5+
/// <summary>
6+
/// This interface is used to send notifications.
7+
/// </summary>
8+
public interface INotificationSender : ITransientService
9+
{
10+
Task BroadcastAsync(INotificationMessage notification, CancellationToken cancellationToken);
11+
Task BroadcastAsync(INotificationMessage notification, IEnumerable<string> excludedConnectionIds, CancellationToken cancellationToken);
12+
13+
Task SendToAllAsync(INotificationMessage notification, CancellationToken cancellationToken);
14+
Task SendToAllAsync(INotificationMessage notification, IEnumerable<string> excludedConnectionIds, CancellationToken cancellationToken);
15+
Task SendToGroupAsync(INotificationMessage notification, string group, CancellationToken cancellationToken);
16+
Task SendToGroupAsync(INotificationMessage notification, string group, IEnumerable<string> excludedConnectionIds, CancellationToken cancellationToken);
17+
Task SendToGroupsAsync(INotificationMessage notification, IEnumerable<string> groupNames, CancellationToken cancellationToken);
18+
Task SendToUserAsync(INotificationMessage notification, string userId, CancellationToken cancellationToken);
19+
Task SendToUsersAsync(INotificationMessage notification, IEnumerable<string> userIds, CancellationToken cancellationToken);
20+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Genocs.Common.Interfaces;
2+
3+
/// <summary>
4+
/// Interface for scoped services.
5+
/// </summary>
6+
public interface IScopedService;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace Genocs.Common.Interfaces;
2+
3+
/// <summary>
4+
/// It is used to serialize and deserialize objects.
5+
/// </summary>
6+
public interface ISerializerService : ITransientService
7+
{
8+
/// <summary>
9+
/// The method is used to serialize an object.
10+
/// </summary>
11+
/// <typeparam name="T">The type of object to serialize.</typeparam>
12+
/// <param name="obj">Instance of object to serialize.</param>
13+
/// <returns></returns>
14+
string Serialize<T>(T obj);
15+
16+
string Serialize<T>(T obj, Type type);
17+
18+
T Deserialize<T>(string text);
19+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Genocs.Common.Interfaces;
2+
3+
/// <summary>
4+
/// It is used to mark the service as a transient service.
5+
/// </summary>
6+
public interface ITransientService;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace Genocs.Common.Notifications;
2+
3+
public class BasicNotification : INotificationMessage
4+
{
5+
public enum LabelType
6+
{
7+
Information,
8+
Success,
9+
Warning,
10+
Error
11+
}
12+
13+
public string? Message { get; set; }
14+
15+
public LabelType Label { get; set; }
16+
}

0 commit comments

Comments
 (0)