Merge pull request #930 from iceljc/master

refine agent task
This commit is contained in:
iceljc 2025-03-10 17:12:11 -05:00 committed by GitHub
commit af099514dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 31 additions and 22 deletions

View file

@ -2,10 +2,13 @@ namespace BotSharp.Abstraction.Tasks.Models;
public class AgentTask
{
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public string Id { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string? Description { get; set; }
public bool Enabled { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public string Content { get; set; } = string.Empty;
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
@ -19,9 +22,15 @@ public class AgentTask
/// </summary>
public string Status { get; set; } = TaskStatus.New;
public DateTime? LastExecutedDateTime { get; set; }
public DateTime? NextExecutionDateTime { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? LastExecutionTime { get; set; }
public DateTime CreatedDateTime { get; set; }
public DateTime UpdatedDateTime { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? NextExecutionTime { get; set; }
[JsonPropertyName("created_time")]
public DateTime CreatedTime { get; set; }
[JsonPropertyName("updated_time")]
public DateTime UpdatedTime { get; set; }
}

View file

@ -97,7 +97,7 @@ public class CrontabService : ICrontabService, ITaskFeeder
Status = TaskStatus.Scheduled,
Enabled = !x.Disabled,
Description = cron.Description,
LastExecutedDateTime = cron.LastExecutionTime
LastExecutionTime = cron.LastExecutionTime
}));
}

View file

@ -185,8 +185,8 @@ public partial class AgentService
Enabled = parsedTask.Enabled,
Content = parsedTask.Content,
AgentId = agentId,
CreatedDateTime = parsedTask.CreatedDateTime,
UpdatedDateTime = parsedTask.UpdatedDateTime
CreatedTime = parsedTask.CreatedTime,
UpdatedTime = parsedTask.UpdatedTime
};
tasks.Add(task);
}

View file

@ -129,8 +129,8 @@ public partial class FileRepository
Name = task.Name,
Description = task.Description,
Enabled = task.Enabled,
CreatedDateTime = DateTime.UtcNow,
UpdatedDateTime = DateTime.UtcNow
CreatedTime = DateTime.UtcNow,
UpdatedTime = DateTime.UtcNow
};
var fileContent = BuildAgentTaskFileContent(metaData, task.Content);
@ -163,8 +163,8 @@ public partial class FileRepository
Name = parsedTask.Name,
Description = parsedTask.Description,
Enabled = parsedTask.Enabled,
CreatedDateTime = parsedTask.CreatedDateTime,
UpdatedDateTime = DateTime.UtcNow
CreatedTime = parsedTask.CreatedTime,
UpdatedTime = DateTime.UtcNow
};
var content = parsedTask.Content;

View file

@ -31,7 +31,7 @@ public class AgentTaskService : IAgentTaskService
return new PagedItems<AgentTask>
{
Items = items.OrderByDescending(x => x.UpdatedDateTime)
Items = items.OrderByDescending(x => x.UpdatedTime)
.Skip(filter.Pager.Offset).Take(filter.Pager.Size),
Count = items.Count()
};

View file

@ -13,11 +13,11 @@ public class AgentTaskViewModel
public string Status { get; set; } = null!;
[JsonPropertyName("created_datetime")]
public DateTime CreatedDateTime { get; set; }
[JsonPropertyName("created_time")]
public DateTime CreatedTime { get; set; }
[JsonPropertyName("updated_datetime")]
public DateTime UpdatedDateTime { get; set; }
[JsonPropertyName("updated_time")]
public DateTime UpdatedTime { get; set; }
[JsonPropertyName("agent_id")]
public string AgentId { get; set; } = null!;
@ -37,8 +37,8 @@ public class AgentTaskViewModel
AgentId = task.AgentId,
AgentName = task.Agent?.Name,
Status = task.Status,
CreatedDateTime = task.CreatedDateTime,
UpdatedDateTime = task.UpdatedDateTime
CreatedTime = task.CreatedTime,
UpdatedTime = task.UpdatedTime
};
}
}

View file

@ -23,8 +23,8 @@ public class AgentTaskDocument : MongoBase
Enabled = model.Enabled,
AgentId = model.AgentId,
Status = model.Status,
CreatedDateTime = model.CreatedTime,
UpdatedDateTime = model.UpdatedTime
CreatedTime = model.CreatedTime,
UpdatedTime = model.UpdatedTime
};
}
@ -38,8 +38,8 @@ public class AgentTaskDocument : MongoBase
Enabled = model.Enabled,
AgentId = model.AgentId,
Status = model.Status,
CreatedTime = model.CreatedDateTime,
UpdatedTime = model.UpdatedDateTime
CreatedTime = model.CreatedTime,
UpdatedTime = model.UpdatedTime
};
}
}