2020-05-02 22:32:22 +00:00
|
|
|
using System;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
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>
|
|
|
|
public partial class ActivityLog : ISavingChanges
|
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>
|
2020-05-13 19:03:35 +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-05-13 19:03:35 +00:00
|
|
|
this.Name = name;
|
|
|
|
this.Type = type;
|
|
|
|
this.UserId = userId;
|
|
|
|
this.DateCreated = DateTime.UtcNow;
|
|
|
|
this.LogSeverity = LogLevel.Trace;
|
2020-05-02 22:32:22 +00:00
|
|
|
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2020-05-14 21:13:45 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="ActivityLog"/> class.
|
|
|
|
/// Default constructor. Protected due to required properties, but present because EF needs it.
|
|
|
|
/// </summary>
|
|
|
|
protected ActivityLog()
|
|
|
|
{
|
|
|
|
Init();
|
|
|
|
}
|
|
|
|
|
2020-05-02 22:32:22 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Static create function (for use in LINQ queries, etc.)
|
|
|
|
/// </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's id.</param>
|
2020-05-15 16:51:18 +00:00
|
|
|
/// <returns>The new <see cref="ActivityLog"/> instance.</returns>
|
2020-05-13 19:03:35 +00:00
|
|
|
public static ActivityLog Create(string name, string type, Guid userId)
|
2020-05-02 22:32:22 +00:00
|
|
|
{
|
2020-05-13 19:03:35 +00:00
|
|
|
return new ActivityLog(name, type, userId);
|
2020-05-02 22:32:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* Properties
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-15 16:51:18 +00:00
|
|
|
/// Gets or sets the identity of this instance.
|
2020-05-14 21:13:45 +00:00
|
|
|
/// This is the key in the backing database.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[Key]
|
|
|
|
[Required]
|
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
|
|
public int Id { get; protected set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the name.
|
|
|
|
/// Required, Max length = 512.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[Required]
|
|
|
|
[MaxLength(512)]
|
|
|
|
[StringLength(512)]
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the overview.
|
|
|
|
/// Max length = 512.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[MaxLength(512)]
|
|
|
|
[StringLength(512)]
|
|
|
|
public string Overview { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the short overview.
|
|
|
|
/// Max length = 512.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[MaxLength(512)]
|
|
|
|
[StringLength(512)]
|
|
|
|
public string ShortOverview { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the type.
|
|
|
|
/// Required, Max length = 256.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[Required]
|
|
|
|
[MaxLength(256)]
|
|
|
|
[StringLength(256)]
|
|
|
|
public string Type { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the user id.
|
|
|
|
/// Required.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[Required]
|
|
|
|
public Guid UserId { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the item id.
|
|
|
|
/// Max length = 256.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[MaxLength(256)]
|
|
|
|
[StringLength(256)]
|
|
|
|
public string ItemId { get; set; }
|
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the date created. This should be in UTC.
|
|
|
|
/// Required.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[Required]
|
|
|
|
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"/>.
|
|
|
|
/// Required.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[Required]
|
2020-05-13 19:03:35 +00:00
|
|
|
public LogLevel LogSeverity { get; set; }
|
2020-05-02 22:32:22 +00:00
|
|
|
|
|
|
|
/// <summary>
|
2020-05-14 21:13:45 +00:00
|
|
|
/// Gets or sets the row version.
|
2020-05-13 19:03:35 +00:00
|
|
|
/// Required, ConcurrencyToken.
|
2020-05-02 22:32:22 +00:00
|
|
|
/// </summary>
|
|
|
|
[ConcurrencyCheck]
|
|
|
|
[Required]
|
|
|
|
public uint RowVersion { get; set; }
|
|
|
|
|
2020-05-14 21:13:45 +00:00
|
|
|
partial void Init();
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2020-05-02 22:32:22 +00:00
|
|
|
public void OnSavingChanges()
|
|
|
|
{
|
|
|
|
RowVersion++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|