using HRM.BO; using System; namespace HRM.UI.Realtime.Jobs { /// /// What to run in the background. Build it inside the controller action: the work runs after the request has /// ended, so it must not touch HttpContext / CurrentUser - copy what it needs (user id, payroll type, ...) first. /// public class JobRequest { /// /// Kind + scope, e.g. "salary-process:" + payrollTypeId. While a job with this key is queued or running, /// starting another returns the running one instead (no double processing on a double click or a second tab). /// public string Key { get; set; } /// Shown above the progress bar, e.g. "Salary Process". public string Title { get; set; } public int OwnerUserId { get; set; } public int? PayrollTypeId { get; set; } public JobAudience Audience { get; set; } = JobAudience.Owner; /// /// The work itself. Report progress through the IJobProgress it gets; whatever it returns becomes /// JobSnapshot.Result. An exception marks the job Failed with the exception's message (and is logged). /// public Func Work { get; set; } } /// What IJobRunner.Start answers. public class JobStartResult { public JobSnapshot Job { get; set; } /// True when a job with the same key was already queued/running and is returned instead of a new one. public bool AlreadyRunning { get; set; } } }