|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using NzbDrone.Core.Jobs;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.System.Tasks
|
|
|
|
@ -9,6 +10,8 @@ namespace NzbDrone.Api.System.Tasks
|
|
|
|
|
{
|
|
|
|
|
private readonly ITaskManager _taskManager;
|
|
|
|
|
|
|
|
|
|
private static readonly Regex NameRegex = new Regex("(?<!^)[A-Z]", RegexOptions.Compiled);
|
|
|
|
|
|
|
|
|
|
public TaskModule(ITaskManager taskManager)
|
|
|
|
|
: base("system/task")
|
|
|
|
|
{
|
|
|
|
@ -23,11 +26,13 @@ namespace NzbDrone.Api.System.Tasks
|
|
|
|
|
|
|
|
|
|
private static TaskResource ConvertToResource(ScheduledTask scheduledTask)
|
|
|
|
|
{
|
|
|
|
|
var taskName = scheduledTask.TypeName.Split('.').Last().Replace("Command", "");
|
|
|
|
|
|
|
|
|
|
return new TaskResource
|
|
|
|
|
{
|
|
|
|
|
Id = scheduledTask.Id,
|
|
|
|
|
Name = scheduledTask.TypeName.Split('.').Last().Replace("Command", ""),
|
|
|
|
|
CommandName = scheduledTask.TypeName.Split('.').Last(),
|
|
|
|
|
Name = NameRegex.Replace(taskName, match => " " + match.Value),
|
|
|
|
|
TaskName = taskName,
|
|
|
|
|
Interval = scheduledTask.Interval,
|
|
|
|
|
LastExecution = scheduledTask.LastExecution,
|
|
|
|
|
NextExecution = scheduledTask.LastExecution.AddMinutes(scheduledTask.Interval)
|
|
|
|
|