zhaolei
8 days ago 4a2e5b9a21940f11757be37d99f0944e240e908b
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
@inherits TasksBase
 
<div class="card">
    <div class="card-header">任务介绍</div>
    <div class="card-body">
        <div class="alert alert-info">
            <p class="font-weight-bold">后台任务说明:</p>
            <p>1. 默认任务 (立即执行,仅执行一次)</p>
            <p>
                <code>
                    TaskServicesManager.GetOrAdd("简单任务", token => Task.Delay(1000));
                </code>
            </p>
            <p>2. 周期性任务 (1 分钟后间隔 5 秒执行 2 次任务)</p>
            <p>
                <code>
                    var trigger = TriggerBuilder.Default.WithInterval(TimeSpan.FromSeconds(5)).WithRepeatCount(2).WithStartTime(DateTimeOffset.Now.AddMinutes(1)).Build();
                    <br />
                    TaskServicesManager.GetOrAdd("测试任务", token => Task.Delay(1000), trigger);
                </code>
            </p>
            <p>3. Cron 表达式任务 (间隔 5 秒循环执行任务)</p>
            <div>
                <code>
                    TaskServicesManager.GetOrAdd("Cron 表达式任务", token => Task.Delay(1000), TriggerBuilder.Build("*/5 * * * * *"));
                </code>
            </div>
        </div>
    </div>
</div>
 
<div class="card">
    <div class="card-header">
        <span>查询结果</span>
    </div>
    <div class="card-body">
        <ConditionComponent>
            <div class="alert alert-danger" role="alert">
                <span>演示系统禁止修改定时后台任务</span>
            </div>
        </ConditionComponent>
        <Table Id="task" TItem="DefaultScheduler" ShowToolBar="true" ShowRefresh="true" ShowExtendButtons="true" EditModel="DataContext" OnQuery="Query">
            <TableHeader>
                <LgbTableHeader TItem="string" @bind-Value="@context.Name"></LgbTableHeader>
                <LgbTableHeader TItem="DateTimeOffset" @bind-Value="@context.CreatedTime" class="text-nowrap datetime"></LgbTableHeader>
                <LgbTableHeader TItem="DateTimeOffset?" @bind-Value="@context.LastRuntime" class="text-nowrap datetime"></LgbTableHeader>
                <LgbTableHeader TItem="DateTimeOffset?" @bind-Value="@context.NextRuntime" class="text-nowrap datetime"></LgbTableHeader>
                <LgbTableHeader TItem="string" @bind-Value="@context.TriggerExpression"></LgbTableHeader>
                <LgbTableHeader TItem="Prow.Tasks.TriggerResult" @bind-Value="@context.LastRunResult" class="text-nowrap"></LgbTableHeader>
                <LgbTableHeader TItem="Prow.Tasks.SchedulerStatus" @bind-Value="@context.Status"></LgbTableHeader>
            </TableHeader>
            <RowTemplate>
                <td class="text-nowrap">@context.Name</td>
                <td>@context.CreatedTime.DateTime</td>
                <td>@context.LastRuntime?.DateTime</td>
                <td>@context.NextRuntime?.DateTime</td>
                <td>@context.TriggerExpression</td>
                <td>@FormatterResult(context.LastRunResult)</td>
                <td>@FormatterStatus(context.Status)</td>
            </RowTemplate>
            <ButtonTemplate>
                <div class='btn-group'>
                    <button class='pause btn btn-sm btn-danger' asp-auth="pause"><i class='fa fa-pause-circle'></i><span>暂停</span></button>
                    <button class='run btn btn-sm btn-success' asp-auth="pause"><i class='fa fa-play-circle'></i><span>运行</span></button>
                    <button class='info btn btn-sm btn-info' asp-auth="info"><i class='fa fa-info-circle'></i><span>日志</span></button>
                </div>
            </ButtonTemplate>
        </Table>
    </div>
</div>