/
HelloJob.cs
41 lines (35 loc) · 1.11 KB
/
HelloJob.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace ServiceStack.Quartz.NetCore.Quartz.Jobs
{
using System;
using System.Threading;
using System.Threading.Tasks;
using global::Quartz;
using ServiceStack;
using ServiceStack.Quartz.ServiceInterface;
using ServiceStack.Quartz.ServiceModel;
public class HelloJob : IJob
{
/// <summary>
/// TODO Is null?
/// </summary>
public IServiceGateway Gateway { get; set; }
/// <summary>
/// Is injected ok
/// </summary>
public MyServices Services { get; set; }
public Task Execute(IJobExecutionContext context)
{
Thread.Sleep(TimeSpan.FromMinutes(1));
// get job data
var contextMergedJobData = context.MergedJobDataMap["Name"]?.ToString();
var jobDataName = context.Get("Name");
// do some work, call a service
var response = Services.Any(new Hello
{
Name = contextMergedJobData ?? "there!"
});
context.Result = response.Result;
return context.AsTaskResult();
}
}
}