Introduced a new `ResultType` enum to represent job execution result types, including `Ok`, `Error`, `Warning`, and `Unknown`. Added a `Result` property in the `ProfileHistory` class as a wrapper around the `ResultId` property, with logic to map `ResultId` to `ResultType` values. Updated `ProfileHistory.cs` to include necessary namespaces.
94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
using ECMJobRunner.Domain.ValueObjects;
|
|
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
|
namespace ECMJobRunner.Domain.Entities
|
|
{
|
|
/// <summary>
|
|
/// Profile Execution History
|
|
/// Stores the execution history and results of job runner profiles
|
|
/// Result ID: 0 = OK; 1 = ERROR; 2 = WARNING
|
|
/// </summary>
|
|
[Table("TBJR_OUT_PROFILE_HISTORY", Schema = "dbo")]
|
|
public class ProfileHistory
|
|
{
|
|
/// <summary>
|
|
/// Primary Key
|
|
/// </summary>
|
|
[Key]
|
|
[Column("PK_TBJR_OUT_PROFILE_HISTORY_ID")]
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
public long Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// Foreign Key to Profile
|
|
/// </summary>
|
|
[Required]
|
|
[Column("FK_TBJR_CFG_PROFILE_ID")]
|
|
[ForeignKey(nameof(CfgProfile))]
|
|
public long ProfileId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Result ID: 0 = OK; 1 = ERROR; 2 = WARNING
|
|
/// </summary>
|
|
[Required]
|
|
[Column("RESULT_ID")]
|
|
public byte ResultId { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets or sets the result type of the job execution.
|
|
/// This property is not mapped to a database column; it wraps <see cref="ResultId"/>.
|
|
/// If <see cref="ResultId"/> does not correspond to a defined <see cref="ResultType"/> value, returns <see cref="ResultType.Unknown"/>.
|
|
/// </summary>
|
|
[NotMapped]
|
|
public ResultType Result
|
|
{
|
|
get => Enum.IsDefined(typeof(ResultType), ResultId) ? (ResultType)ResultId : ResultType.Unknown;
|
|
set => ResultId = (byte)value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Result text/message
|
|
/// </summary>
|
|
[Required]
|
|
[Column("RESULT_TEXT")]
|
|
public string ResultText { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// Created by (max 50 chars)
|
|
/// </summary>
|
|
[Required]
|
|
[Column("ADDED_WHO")]
|
|
[MaxLength(50)]
|
|
public string AddedWho { get; set; } = "DEFAULT";
|
|
|
|
/// <summary>
|
|
/// Created at
|
|
/// </summary>
|
|
[Required]
|
|
[Column("ADDED_WHEN")]
|
|
public DateTime AddedWhen { get; set; } = DateTime.Now;
|
|
|
|
/// <summary>
|
|
/// Modified by (max 50 chars)
|
|
/// </summary>
|
|
[Column("CHANGED_WHO")]
|
|
[MaxLength(50)]
|
|
public string? ChangedWho { get; set; }
|
|
|
|
/// <summary>
|
|
/// Modified at
|
|
/// </summary>
|
|
[Column("CHANGED_WHEN")]
|
|
public DateTime? ChangedWhen { get; set; }
|
|
|
|
// Navigation properties
|
|
|
|
/// <summary>
|
|
/// Associated Profile
|
|
/// </summary>
|
|
public virtual CfgProfile? CfgProfile { get; set; }
|
|
}
|
|
}
|