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