public override void Add(JobSetting jobSetting) { var(methodCall, x) = GetMethodCall(JobMethodInfo); var methodCallExpression = Expression.Call( typeof(BackgroundJob), nameof(BackgroundJob.Enqueue), new Type[] { JobMethodInfo.DeclaringType }, new Expression[] { Expression.Lambda(methodCall, x), }); Expression.Lambda(methodCallExpression).Compile().DynamicInvoke(); }
public override void Add(JobSetting jobSetting) { var(methodCall, x) = GetMethodCall(JobMethodInfo); var methodCallExpression = Expression.Call( typeof(BackgroundJob), nameof(BackgroundJob.Schedule), new Type[] { JobMethodInfo.DeclaringType }, new Expression[] { Expression.Lambda(methodCall, x), Expression.Constant(TimeSpan.FromSeconds(jobSetting.DelaySeconds.Value)), }); Expression.Lambda(methodCallExpression).Compile().DynamicInvoke(); }
private static void InitJobRunType(JobSetting setting) { if (setting.RunType == JobRunType.Unkown) { if (!string.IsNullOrWhiteSpace(setting.Cron)) { setting.RunType = JobRunType.Recurring; return; } if (setting.DelaySeconds.HasValue && setting.DelaySeconds > 0) { setting.RunType = JobRunType.Delayed; return; } setting.RunType = JobRunType.OneTime; } }
public override void Add(JobSetting jobSetting) { var(methodCall, x) = GetMethodCall(JobMethodInfo); var methodCallExpression = Expression.Call( typeof(RecurringJob), nameof(RecurringJob.AddOrUpdate), new Type[] { JobMethodInfo.DeclaringType }, new Expression[] { Expression.Constant(jobSetting.TypeName), Expression.Lambda(methodCall, x), Expression.Constant(jobSetting.Cron), Expression.Constant(TimeZoneInfo.Utc), Expression.Constant(jobSetting.Queue) }); Expression.Lambda(methodCallExpression).Compile().DynamicInvoke(); }
public abstract void Add(JobSetting jobSetting);