forked from SciSharp/BotSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrontabItemDocument.cs
More file actions
69 lines (65 loc) · 2.81 KB
/
CrontabItemDocument.cs
File metadata and controls
69 lines (65 loc) · 2.81 KB
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
using BotSharp.Abstraction.Crontab.Models;
namespace BotSharp.Plugin.MongoStorage.Collections;
public class CrontabItemDocument : MongoBase
{
public string UserId { get; set; } = default!;
public string AgentId { get; set; } = default!;
public string ConversationId { get; set; } = default!;
public string ExecutionResult { get; set; } = default!;
public string Cron { get; set; } = default!;
public string Title { get; set; } = default!;
public string Description { get; set; } = default!;
public int ExecutionCount { get; set; }
public int MaxExecutionCount { get; set; }
public int ExpireSeconds { get; set; }
public DateTime? LastExecutionTime { get; set; }
public bool LessThan60Seconds { get; set; } = false;
public IEnumerable<CronTaskMongoElement> Tasks { get; set; } = [];
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
public int TriggerType { get; set; }
public bool ReentryProtection { get; set; }
public static CrontabItem ToDomainModel(CrontabItemDocument item)
{
return new CrontabItem
{
UserId = item.UserId,
AgentId = item.AgentId,
ConversationId = item.ConversationId,
ExecutionResult = item.ExecutionResult,
Cron = item.Cron,
Title = item.Title,
Description = item.Description,
ExecutionCount = item.ExecutionCount,
MaxExecutionCount = item.MaxExecutionCount,
ExpireSeconds = item.ExpireSeconds,
LastExecutionTime = item.LastExecutionTime,
LessThan60Seconds = item.LessThan60Seconds,
Tasks = item.Tasks?.Select(x => CronTaskMongoElement.ToDomainElement(x))?.ToArray() ?? [],
CreatedTime = item.CreatedTime,
TriggerType = (CronTabItemTriggerType)item.TriggerType,
ReentryProtection = item.ReentryProtection
};
}
public static CrontabItemDocument ToMongoModel(CrontabItem item)
{
return new CrontabItemDocument
{
UserId = item.UserId,
AgentId = item.AgentId,
ConversationId = item.ConversationId,
ExecutionResult = item.ExecutionResult,
Cron = item.Cron,
Title = item.Title,
Description = item.Description,
ExecutionCount = item.ExecutionCount,
MaxExecutionCount = item.MaxExecutionCount,
ExpireSeconds = item.ExpireSeconds,
LastExecutionTime = item.LastExecutionTime,
LessThan60Seconds = item.LessThan60Seconds,
Tasks = item.Tasks?.Select(x => CronTaskMongoElement.ToMongoElement(x))?.ToList() ?? [],
CreatedTime = item.CreatedTime,
TriggerType = (int)item.TriggerType,
ReentryProtection = item.ReentryProtection
};
}
}