using System; namespace HRM.UI.Realtime.Jobs { public enum JobStatus { Queued = 1, Running = 2, Succeeded = 3, Failed = 4 } /// Who besides the owner may watch a job. public enum JobAudience { /// Only the user who started it. Owner = 1, /// Every user of the same payroll type (e.g. a second admin opening the Salary Process screen). PayrollType = 2 } /// /// A job as the browser sees it - one immutable copy per message. Sent over SignalR and returned by api/jobs, /// always with the same shape (Angular model: src/app/_models/realtime/job-snapshot.ts). /// public class JobSnapshot { public string RunId { get; set; } /// The job's kind + scope, e.g. "salary-process:3". Only one job per key runs at a time. public string Key { get; set; } public string Title { get; set; } public JobStatus Status { get; set; } /// 0 - 100, never goes backwards. public double Percent { get; set; } public string Stage { get; set; } public string Detail { get; set; } public int? Current { get; set; } public int? Total { get; set; } public DateTime QueuedAt { get; set; } public DateTime? StartedAt { get; set; } public DateTime? FinishedAt { get; set; } public double ElapsedSeconds { get; set; } /// Estimated seconds left, from the speed measured so far. Null until there is enough to measure. public double? EtaSeconds { get; set; } /// Grows with every change. A browser ignores a message older than the one it already shows. public long Sequence { get; set; } /// What the work returned (set when Succeeded). Its shape is the job's own business. public object Result { get; set; } /// Why it failed (set when Failed). public string Error { get; set; } public bool IsFinished => Status == JobStatus.Succeeded || Status == JobStatus.Failed; } }