| | | 1 | | using System; |
| | | 2 | | using System.ComponentModel.DataAnnotations; |
| | | 3 | | using System.ComponentModel.DataAnnotations.Schema; |
| | | 4 | | using Jellyfin.Database.Implementations.Interfaces; |
| | | 5 | | using Microsoft.Extensions.Logging; |
| | | 6 | | |
| | | 7 | | namespace Jellyfin.Database.Implementations.Entities |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// An entity referencing an activity log entry. |
| | | 11 | | /// </summary> |
| | | 12 | | public class ActivityLog : IHasConcurrencyToken |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="ActivityLog"/> class. |
| | | 16 | | /// Public constructor with required data. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="name">The name.</param> |
| | | 19 | | /// <param name="type">The type.</param> |
| | | 20 | | /// <param name="userId">The user id.</param> |
| | | 21 | | public ActivityLog(string name, string type, Guid userId) |
| | | 22 | | { |
| | 34 | 23 | | ArgumentException.ThrowIfNullOrEmpty(name); |
| | 34 | 24 | | ArgumentException.ThrowIfNullOrEmpty(type); |
| | | 25 | | |
| | 34 | 26 | | Name = name; |
| | 34 | 27 | | Type = type; |
| | 34 | 28 | | UserId = userId; |
| | 34 | 29 | | DateCreated = DateTime.UtcNow; |
| | 34 | 30 | | LogSeverity = LogLevel.Information; |
| | 34 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets the identity of this instance. |
| | | 35 | | /// </summary> |
| | | 36 | | [DatabaseGenerated(DatabaseGeneratedOption.Identity)] |
| | | 37 | | public int Id { get; private set; } |
| | | 38 | | |
| | | 39 | | /// <summary> |
| | | 40 | | /// Gets or sets the name. |
| | | 41 | | /// </summary> |
| | | 42 | | /// <remarks> |
| | | 43 | | /// Required, Max length = 512. |
| | | 44 | | /// </remarks> |
| | | 45 | | [MaxLength(512)] |
| | | 46 | | [StringLength(512)] |
| | | 47 | | public string Name { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets or sets the overview. |
| | | 51 | | /// </summary> |
| | | 52 | | /// <remarks> |
| | | 53 | | /// Max length = 512. |
| | | 54 | | /// </remarks> |
| | | 55 | | [MaxLength(512)] |
| | | 56 | | [StringLength(512)] |
| | | 57 | | public string? Overview { get; set; } |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Gets or sets the short overview. |
| | | 61 | | /// </summary> |
| | | 62 | | /// <remarks> |
| | | 63 | | /// Max length = 512. |
| | | 64 | | /// </remarks> |
| | | 65 | | [MaxLength(512)] |
| | | 66 | | [StringLength(512)] |
| | | 67 | | public string? ShortOverview { get; set; } |
| | | 68 | | |
| | | 69 | | /// <summary> |
| | | 70 | | /// Gets or sets the type. |
| | | 71 | | /// </summary> |
| | | 72 | | /// <remarks> |
| | | 73 | | /// Required, Max length = 256. |
| | | 74 | | /// </remarks> |
| | | 75 | | [MaxLength(256)] |
| | | 76 | | [StringLength(256)] |
| | | 77 | | public string Type { get; set; } |
| | | 78 | | |
| | | 79 | | /// <summary> |
| | | 80 | | /// Gets or sets the user id. |
| | | 81 | | /// </summary> |
| | | 82 | | /// <remarks> |
| | | 83 | | /// Required. |
| | | 84 | | /// </remarks> |
| | | 85 | | public Guid UserId { get; set; } |
| | | 86 | | |
| | | 87 | | /// <summary> |
| | | 88 | | /// Gets or sets the item id. |
| | | 89 | | /// </summary> |
| | | 90 | | /// <remarks> |
| | | 91 | | /// Max length = 256. |
| | | 92 | | /// </remarks> |
| | | 93 | | [MaxLength(256)] |
| | | 94 | | [StringLength(256)] |
| | | 95 | | public string? ItemId { get; set; } |
| | | 96 | | |
| | | 97 | | /// <summary> |
| | | 98 | | /// Gets or sets the date created. This should be in UTC. |
| | | 99 | | /// </summary> |
| | | 100 | | /// <remarks> |
| | | 101 | | /// Required. |
| | | 102 | | /// </remarks> |
| | | 103 | | public DateTime DateCreated { get; set; } |
| | | 104 | | |
| | | 105 | | /// <summary> |
| | | 106 | | /// Gets or sets the log severity. Default is <see cref="LogLevel.Trace"/>. |
| | | 107 | | /// </summary> |
| | | 108 | | /// <remarks> |
| | | 109 | | /// Required. |
| | | 110 | | /// </remarks> |
| | | 111 | | public LogLevel LogSeverity { get; set; } |
| | | 112 | | |
| | | 113 | | /// <inheritdoc /> |
| | | 114 | | [ConcurrencyCheck] |
| | | 115 | | public uint RowVersion { get; private set; } |
| | | 116 | | |
| | | 117 | | /// <inheritdoc /> |
| | | 118 | | public void OnSavingChanges() |
| | | 119 | | { |
| | 0 | 120 | | RowVersion++; |
| | 0 | 121 | | } |
| | | 122 | | } |
| | | 123 | | } |