public static string GetJobName(this BackgroundJob backgroundJob) { // Check if the job is a recurring job var jobId = backgroundJob.GetJobParameter <string>("RecurringJobId"); if (string.IsNullOrWhiteSpace(jobId)) { // If it's not, try to get the display name of the job var jobDisplayNameAttribute = backgroundJob.Job.Method.GetCustomAttribute <JobDisplayNameAttribute>(); if (jobDisplayNameAttribute != null) { jobId = jobDisplayNameAttribute.DisplayName; } else { var displayNameAttribute = backgroundJob.Job.Method.GetCustomAttribute <DisplayNameAttribute>(); jobId = displayNameAttribute?.DisplayName; } } jobId ??= backgroundJob.Job.ToString(); return(jobId); }
public static DateTime?GetLastSuccess(this BackgroundJob job) { return(job.GetJobParameter <DateTime?>(TrackLastSuccessAttribute.ParameterName)); }