Skip to content

Commit b110900

Browse files
authored
Merge pull request #799 from iceljc/master
add count in cron tab
2 parents 28b6bcb + 47135c8 commit b110900

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Infrastructure/BotSharp.Abstraction/Crontab/Models/CrontabItem.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ public class CrontabItem : ScheduleTaskArgs
1414
[JsonPropertyName("execution_result")]
1515
public string ExecutionResult { get; set; } = null!;
1616

17+
[JsonPropertyName("execution_count")]
18+
public int ExecutionCount { get; set; }
19+
20+
[JsonPropertyName("max_execution_count")]
21+
public int MaxExecutionCount { get; set; }
22+
23+
[JsonPropertyName("expire_seconds")]
24+
public int ExpireSeconds { get; set; } = 60;
25+
1726
[JsonPropertyName("created_time")]
1827
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
1928

src/Plugins/BotSharp.Plugin.MongoStorage/Collections/CrontabItemDocument.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public class CrontabItemDocument : MongoBase
1111
public string Cron { get; set; }
1212
public string Title { get; set; }
1313
public string Description { get; set; }
14+
public int ExecutionCount { get; set; }
15+
public int MaxExecutionCount { get; set; }
16+
public int ExpireSeconds { get; set; }
1417
public IEnumerable<CronTaskMongoElement> Tasks { get; set; } = [];
1518
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
1619

@@ -25,6 +28,9 @@ public static CrontabItem ToDomainModel(CrontabItemDocument item)
2528
Cron = item.Cron,
2629
Title = item.Title,
2730
Description = item.Description,
31+
ExecutionCount = item.ExecutionCount,
32+
MaxExecutionCount = item.MaxExecutionCount,
33+
ExpireSeconds = item.ExpireSeconds,
2834
Tasks = item.Tasks?.Select(x => CronTaskMongoElement.ToDomainElement(x))?.ToArray() ?? [],
2935
CreatedTime = item.CreatedTime
3036
};
@@ -41,6 +47,9 @@ public static CrontabItemDocument ToMongoModel(CrontabItem item)
4147
Cron = item.Cron,
4248
Title = item.Title,
4349
Description = item.Description,
50+
ExecutionCount = item.ExecutionCount,
51+
MaxExecutionCount = item.MaxExecutionCount,
52+
ExpireSeconds = item.ExpireSeconds,
4453
Tasks = item.Tasks?.Select(x => CronTaskMongoElement.ToMongoElement(x))?.ToList() ?? [],
4554
CreatedTime = item.CreatedTime
4655
};

0 commit comments

Comments
 (0)