diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Trace.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Trace.cs new file mode 100644 index 00000000..6ee1bbcb --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.Models/Trace.cs @@ -0,0 +1,57 @@ +namespace BootstrapAdmin.DataAccess.Models; + +/// +/// +/// +public class Trace +{ + /// + /// + /// + public string? Id { get; set; } + + /// + /// + /// + public string? UserName { get; set; } + + /// + /// + /// + public DateTime LogTime { get; set; } + + /// + /// + /// + public string? Ip { get; set; } + + /// + /// + /// + public string? Browser { get; set; } + + /// + /// + /// + public string? OS { get; set; } + + /// + /// + /// + public string? City { get; set; } + + /// + /// + /// + public string? RequestUrl { get; set; } + + /// + /// + /// + public string? UserAgent { get; set; } + + /// + /// + /// + public string? Referer { get; set; } +} diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs index eccb6f8a..5d6ea285 100644 --- a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Extensions/ServiceCollectionExtensions.cs @@ -78,6 +78,7 @@ public static class ServiceCollectionExtensions services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); return services; } } diff --git a/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/TraceService.cs b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/TraceService.cs new file mode 100644 index 00000000..621ebe3c --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.DataAccess.PetaPoco/Services/TraceService.cs @@ -0,0 +1,25 @@ +using BootstrapAdmin.DataAccess.Models; +using BootstrapAdmin.Web.Core; +using PetaPoco; + +namespace BootstrapAdmin.DataAccess.PetaPoco.Services; + +class TraceService : ITrace +{ + private IDatabase Database { get; } + + /// + /// + /// + /// + public TraceService(IDatabase db) => Database = db; + + /// + /// + /// + /// + public void Log(Trace trace) + { + Database.Insert(trace); + } +} diff --git a/src/blazor/admin/BootstrapAdmin.Web.Core/ITrace.cs b/src/blazor/admin/BootstrapAdmin.Web.Core/ITrace.cs new file mode 100644 index 00000000..17fb4d89 --- /dev/null +++ b/src/blazor/admin/BootstrapAdmin.Web.Core/ITrace.cs @@ -0,0 +1,15 @@ +using BootstrapAdmin.DataAccess.Models; + +namespace BootstrapAdmin.Web.Core; + +/// +/// +/// +public interface ITrace +{ + /// + /// + /// + /// + public void Log(Trace trace); +}