jellyfin/Jellyfin.Data/Entities/ActivityLog.cs

132 lines
3.6 KiB
C#
Raw Normal View History

2020-05-02 15:32:22 -07:00
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Jellyfin.Data.Interfaces;
2020-05-13 12:03:35 -07:00
using Microsoft.Extensions.Logging;
2020-05-02 15:32:22 -07:00
namespace Jellyfin.Data.Entities
{
2020-05-14 14:13:45 -07:00
/// <summary>
/// An entity referencing an activity log entry.
/// </summary>
2020-09-01 08:12:31 -07:00
public class ActivityLog : IHasConcurrencyToken
2020-05-02 15:32:22 -07:00
{
/// <summary>
2020-05-14 14:13:45 -07:00
/// Initializes a new instance of the <see cref="ActivityLog"/> class.
/// Public constructor with required data.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-05-14 14:13:45 -07:00
/// <param name="name">The name.</param>
/// <param name="type">The type.</param>
/// <param name="userId">The user id.</param>
public ActivityLog(string name, string type, Guid userId)
2020-05-02 15:32:22 -07:00
{
2020-05-13 12:03:35 -07:00
if (string.IsNullOrEmpty(name))
{
throw new ArgumentNullException(nameof(name));
}
2020-05-02 15:32:22 -07:00
2020-05-13 12:03:35 -07:00
if (string.IsNullOrEmpty(type))
{
throw new ArgumentNullException(nameof(type));
}
2020-05-02 15:32:22 -07:00
2020-09-01 08:12:31 -07:00
Name = name;
Type = type;
UserId = userId;
DateCreated = DateTime.UtcNow;
LogSeverity = LogLevel.Information;
2020-05-02 15:32:22 -07:00
}
/// <summary>
2020-05-15 09:51:18 -07:00
/// Gets or sets the identity of this instance.
2020-05-14 14:13:45 -07:00
/// This is the key in the backing database.
2020-05-02 15:32:22 -07:00
/// </summary>
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; protected set; }
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the name.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Required, Max length = 512.
/// </remarks>
2020-05-02 15:32:22 -07:00
[MaxLength(512)]
[StringLength(512)]
public string Name { get; set; }
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the overview.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Max length = 512.
/// </remarks>
2020-05-02 15:32:22 -07:00
[MaxLength(512)]
[StringLength(512)]
public string? Overview { get; set; }
2020-05-02 15:32:22 -07:00
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the short overview.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Max length = 512.
/// </remarks>
2020-05-02 15:32:22 -07:00
[MaxLength(512)]
[StringLength(512)]
public string? ShortOverview { get; set; }
2020-05-02 15:32:22 -07:00
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the type.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Required, Max length = 256.
/// </remarks>
2020-05-02 15:32:22 -07:00
[MaxLength(256)]
[StringLength(256)]
public string Type { get; set; }
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the user id.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Required.
/// </remarks>
2020-05-02 15:32:22 -07:00
public Guid UserId { get; set; }
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the item id.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Max length = 256.
/// </remarks>
2020-05-02 15:32:22 -07:00
[MaxLength(256)]
[StringLength(256)]
public string? ItemId { get; set; }
2020-05-02 15:32:22 -07:00
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the date created. This should be in UTC.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Required.
/// </remarks>
2020-05-02 15:32:22 -07:00
public DateTime DateCreated { get; set; }
/// <summary>
2020-05-14 14:13:45 -07:00
/// Gets or sets the log severity. Default is <see cref="LogLevel.Trace"/>.
2020-05-02 15:32:22 -07:00
/// </summary>
2020-09-01 08:12:31 -07:00
/// <remarks>
/// Required.
/// </remarks>
2020-05-13 12:03:35 -07:00
public LogLevel LogSeverity { get; set; }
2020-05-02 15:32:22 -07:00
2020-09-01 08:12:31 -07:00
/// <inheritdoc />
2020-05-02 15:32:22 -07:00
[ConcurrencyCheck]
public uint RowVersion { get; set; }
2020-05-14 14:13:45 -07:00
/// <inheritdoc />
2020-05-02 15:32:22 -07:00
public void OnSavingChanges()
{
RowVersion++;
}
}
}