add girIgnore

This commit is contained in:
jrojas
2026-06-23 19:03:17 +02:00
parent 52335cc5fa
commit 95c9039c78
321 changed files with 84 additions and 12748 deletions
+8
View File
@@ -0,0 +1,8 @@
namespace audit_logs.Models.AppSettings
{
public class MongoDbSettingsAudit
{
public string? ConnectionString { get; set; }
public string? DatabaseName { get; set; }
}
}
+14
View File
@@ -0,0 +1,14 @@
namespace audit_logs.Models;
public class AuditLogData
{
public string EntityType { get; set; }
public string RecordId { get; set; }
public string UserId { get; set; }
public string ActionType { get; set; }
public string Reason { get; set; }
public DateTime ActionTime { get; set; }
public Object OriginalJson { get; set; }
public string ModifiedJson { get; set; }
public string UserIpAddress { get; set; }
}
+156
View File
@@ -0,0 +1,156 @@
using System.Text;
namespace audit.Model;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using System;
using System.Collections.Generic;
public class AuditRecord
{
[BsonId]
public ObjectId Id { get; set; }
[BsonElement("entity_type")]
public string EntityType { get; set; }
[BsonElement("record_id")]
public string RecordId { get; set; }
[BsonElement("user_id")]
public string UserId { get; set; }
[BsonElement("action_type")]
public string ActionType { get; set; }
[BsonElement("action_time")]
public DateTime ActionTime { get; set; }
[BsonElement("changes")]
public List<Change> Changes { get; set; }
[BsonElement("reason")]
public string Reason { get; set; }
[BsonElement("user_ip_address")]
public string? UserIpAddress { get; set; }
public override string ToString()
{
var changesBuilder = new StringBuilder();
foreach (var change in Changes)
{
changesBuilder.AppendLine($"Field: {change.Field}, Old Value: {FormatBsonValue(change.OldValue)}, New Value: {FormatBsonValue(change.NewValue)}, Value Type: {change.ValueType}");
}
return $"ID: {Id}, Entity Type: {EntityType}, Record ID: {RecordId}, User ID: {UserId}, Action Type: {ActionType}, Action Time: {ActionTime}, Reason: {Reason}, User IP: {UserIpAddress}, Changes: {changesBuilder.ToString()}";
}
private string FormatBsonValue(BsonValue value)
{
if (value == null || value.IsBsonNull)
{
return "null";
}
switch (value.BsonType)
{
case BsonType.Array:
var array = new StringBuilder("[");
foreach (var item in value.AsBsonArray)
{
array.Append(FormatBsonValue(item) + ", ");
}
if (array.Length > 1)
{
array.Length -= 2; // Remove the last comma and space
}
array.Append("]");
return array.ToString();
case BsonType.Document:
var document = new StringBuilder("{");
foreach (var element in value.AsBsonDocument)
{
document.Append(element.Name + ": " + FormatBsonValue(element.Value) + ", ");
}
if (document.Length > 1)
{
document.Length -= 2; // Remove the last comma and space
}
document.Append("}");
return document.ToString();
default:
return value.ToString(); // Use default BsonValue's ToString for other types
}
}
public class Change
{
[BsonElement("field")]
public string Field { get; set; }
[BsonElement("old_value")]
public BsonValue OldValue { get; set; }
[BsonElement("new_value")]
public BsonValue NewValue { get; set; }
[BsonElement("value_type")]
public string ValueType { get; set; }
public static object ConvertBsonValue(BsonValue bsonValue)
{
if (bsonValue == null || bsonValue.IsBsonNull)
{
return null; // Devuelve nulo si el valor BSON es nulo o no existe
}
switch (bsonValue.BsonType)
{
case BsonType.String:
return bsonValue.AsString;
case BsonType.Int32:
return bsonValue.AsInt32;
case BsonType.Int64:
return bsonValue.AsInt64;
case BsonType.Boolean:
return bsonValue.AsBoolean;
case BsonType.DateTime:
return bsonValue.ToUniversalTime();
case BsonType.Double:
return bsonValue.AsDouble;
case BsonType.ObjectId:
return bsonValue.AsObjectId.ToString();
/*case BsonType.Document:
return bsonValue.ToJson(); */
case BsonType.Array:
var array = bsonValue.AsBsonArray;
var resultList = new List<object>();
foreach (var item in array)
{
resultList.Add(ConvertBsonValue(item));
}
return resultList;
case BsonType.Document:
// Convert BSON Document to Dictionary
var document = bsonValue.AsBsonDocument;
var dictionary = new Dictionary<string, object>();
foreach (var element in document)
{
dictionary[element.Name] = ConvertBsonValue(element.Value);
}
return dictionary;
default:
return bsonValue.ToJson(); // Convert to string if type is not directly supported
}
}
}
}
+53
View File
@@ -0,0 +1,53 @@
namespace audit_logs.Models.DTO;
/// <summary>
/// DTO que encapsula los parámetros de búsqueda por texto para los registros de auditoría, incluyendo detalles de paginación.
/// </summary>
public class AuditLogTextOrDateSearchDTO
{
/// <summary>
/// Gets or sets the page number for pagination.
/// </summary>
/// <value>
/// The number of the page to retrieve. Defaults to 1.
/// </value>
public int pageNumber { get; set; } = 1;
/// <summary>
/// Gets or sets the size of the page for pagination.
/// </summary>
/// <value>
/// The number of records per page. Defaults to 10.
/// </value>
public int pageSize { get; set; } = 10;
/// <summary>
/// Optional text to search for in any text field in the audit logs.
/// </summary>
public string? searchText { get; set; }
/// <summary>
/// Gets or sets the date and time at which the audit action is performed..
/// </summary>
/// <value>
/// The specific timestamp of the audit action. Optional.
/// </value>
public DateTime? actionTime { get; set; } = null;
/// <summary>
/// Gets or sets the start date for filtering audit logs by date range.
/// </summary>
/// <value>
/// The earliest date to include in the results. Optional.
/// </value>
public DateTime? startDate { get; set; } = null;
/// <summary>
/// Gets or sets the end date for filtering audit logs by date range.
/// </summary>
/// <value>
/// The latest date to include in the results. Optional.
/// </value>
public DateTime? endDate { get; set; } = null;
}
+23
View File
@@ -0,0 +1,23 @@
namespace audit_logs.Models;
public class AuditRecordDto
{
public string Id { get; set; }
public string EntityType { get; set; }
public string RecordId { get; set; }
public string UserId { get; set; }
public string ActionType { get; set; }
public DateTime ActionTime { get; set; }
public List<ChangeDto> Changes { get; set; }
public string Reason { get; set; }
public string UserIpAddress { get; set; }
}
public class ChangeDto
{
public string Field { get; set; }
public object OldValue { get; set; }
public object NewValue { get; set; }
public string ValueType { get; set; }
}
+10
View File
@@ -0,0 +1,10 @@
namespace audit_logs.Models;
public class PaginatedLogsResultDto<T>
{
public int CurrentPage { get; set; }
public int PageSize { get; set; }
public long TotalRecords { get; set; }
public int TotalPages { get; set; }
public IEnumerable<T> Records { get; set; }
}
+72
View File
@@ -0,0 +1,72 @@
namespace audit_logs.Models.DTO
{
/// <summary>
/// Data Transfer Object (DTO) for filtering and paginating audit log records.
/// </summary>
public class SpecificAuditLogFilterDto
{
/// <summary>
/// Gets or sets the page number for pagination.
/// </summary>
/// <value>
/// The number of the page to retrieve. Defaults to 1.
/// </value>
public int pageNumber { get; set; } = 1;
/// <summary>
/// Gets or sets the size of the page for pagination.
/// </summary>
/// <value>
/// The number of records per page. Defaults to 10.
/// </value>
public int pageSize { get; set; } = 10;
/// <summary>
/// Gets or sets the user ID associated with the author of updates to audit records
/// </summary>
/// <value>
/// The ID of the user who performed the action. Optional.
/// </value>
public string? userId { get; set; } = null;
/// <summary>
/// Gets or sets the record ID within the EntityType collection to search for audit records.
/// </summary>
/// <value>
/// The ID of the record affected by the audit action, for example, patien_id Optional.
/// </value>
public string? recordId { get; set; } = null;
/// <summary>
/// Gets or sets the type of entity (collection) associated with the audit records.
/// </summary>
/// <value>
/// The type of the audited entity (collection) (e.g., "Patient", "Order"). Optional.
/// </value>
public string? entityType { get; set; } = null;
/// <summary>
/// Gets or sets the date and time at which the audit action is performed..
/// </summary>
/// <value>
/// The specific timestamp of the audit action. Optional.
/// </value>
public DateTime? actionTime { get; set; } = null;
/// <summary>
/// Gets or sets the start date for filtering audit logs by date range.
/// </summary>
/// <value>
/// The earliest date to include in the results. Optional.
/// </value>
public DateTime? startDate { get; set; } = null;
/// <summary>
/// Gets or sets the end date for filtering audit logs by date range.
/// </summary>
/// <value>
/// The latest date to include in the results. Optional.
/// </value>
public DateTime? endDate { get; set; } = null;
}
}