public async Task Run <T>(T configuration, CancellationToken cancellationToken, PerformContext context) where T : BaseJobConfiguration { if (typeof(T) != typeof(HttpJobConfiguration)) { throw new ArgumentException("Wrong configuration type for this job."); } var config = configuration as HttpJobConfiguration; context.AddTags(config.Tags); var restService = new RestService <object, Tout>(config.Endpoint); await restService.Post(config.Body, config.Headers, null, cancellationToken); }
public async Task Run <T>(T configuration, CancellationToken cancellationToken, PerformContext context) where T : BaseJobConfiguration { if (typeof(T) != typeof(StoredProcedureJobConfiguration)) { throw new ArgumentException("Wrong configuration type for this job."); } var config = configuration as StoredProcedureJobConfiguration; context.AddTags(config.Tags); var parameterValues = config.Parameters.Select(pair => new SqlParameter(pair.Key, pair.Value)); var parameterKeys = config.Parameters.Select(x => x.Key); var sqlCommand = SqlStoredProcedureStringBuilder.Build(config.StoredProcedureName, parameterKeys); unitOfWork.Context.Database.ExecuteSqlCommand(sqlCommand, parameterValues); await unitOfWork.Commit(); }
public void Job(string name, PerformContext ctx) { // TextBuffer.WriteLine("Background Job completed succesfully!"); ctx.AddTags("finished"); }
public static PerformContext AddTags(this PerformContext context, IEnumerable <string> tags) { return(context.AddTags(tags.ToArray())); }
public void DoJob(PerformContext context) { context?.AddTags("server-two-tag-three", "server-two-tag-four", "server-two-tag-five"); }
[AutomaticRetry(Attempts = 0)] // Disable retry public void FailedTask(PerformContext context) { context.AddTags("throw"); throw new Exception("Fail please!"); }
public void SuccessTask(PerformContext context, IJobCancellationToken token) { TextBuffer.WriteLine("Recurring Job completed successfully!"); context.AddTags("finished"); }
public void DoJob(PerformContext context) { context?.AddTags("server-one-tag-one", "server-one-tag-two"); }
[AutomaticRetry(Attempts = 0)] // Disable retry public void FailedTask(PerformContext context, IJobCancellationToken token) { context.AddTags("throw"); throw new Exception("Fail please!"); }