HRM-10/HRM.UI/Realtime/Jobs/JobRequest.cs
2026-11-30 13:35:21 +06:00

41 lines
1.6 KiB
C#

using HRM.BO;
using System;
namespace HRM.UI.Realtime.Jobs
{
/// <summary>
/// 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.
/// </summary>
public class JobRequest
{
/// <summary>
/// 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).
/// </summary>
public string Key { get; set; }
/// <summary>Shown above the progress bar, e.g. "Salary Process".</summary>
public string Title { get; set; }
public int OwnerUserId { get; set; }
public int? PayrollTypeId { get; set; }
public JobAudience Audience { get; set; } = JobAudience.Owner;
/// <summary>
/// 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).
/// </summary>
public Func<IJobProgress, object> Work { get; set; }
}
/// <summary>What IJobRunner.Start answers.</summary>
public class JobStartResult
{
public JobSnapshot Job { get; set; }
/// <summary>True when a job with the same key was already queued/running and is returned instead of a new one.</summary>
public bool AlreadyRunning { get; set; }
}
}