2016-10-23 12:47:34 -07:00
|
|
|
|
using System;
|
2013-02-20 18:33:05 -07:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2016-10-23 12:47:34 -07:00
|
|
|
|
namespace MediaBrowser.Model.Tasks
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class ScheduledTaskHelpers
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class ScheduledTaskHelpers
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the task info.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="task">The task.</param>
|
|
|
|
|
/// <returns>TaskInfo.</returns>
|
2013-02-25 20:43:04 -07:00
|
|
|
|
public static TaskInfo GetTaskInfo(IScheduledTaskWorker task)
|
2013-02-20 18:33:05 -07:00
|
|
|
|
{
|
2013-11-29 09:58:24 -07:00
|
|
|
|
var isHidden = false;
|
|
|
|
|
|
|
|
|
|
var configurableTask = task.ScheduledTask as IConfigurableScheduledTask;
|
|
|
|
|
|
|
|
|
|
if (configurableTask != null)
|
|
|
|
|
{
|
|
|
|
|
isHidden = configurableTask.IsHidden;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 12:14:57 -07:00
|
|
|
|
string key = task.ScheduledTask.Key;
|
2014-09-28 08:27:26 -07:00
|
|
|
|
|
|
|
|
|
var triggers = task.Triggers
|
|
|
|
|
.OrderBy(i => i.Type)
|
|
|
|
|
.ThenBy(i => i.DayOfWeek ?? DayOfWeek.Sunday)
|
|
|
|
|
.ThenBy(i => i.TimeOfDayTicks ?? 0)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
return new TaskInfo
|
|
|
|
|
{
|
|
|
|
|
Name = task.Name,
|
2013-02-21 21:23:06 -07:00
|
|
|
|
CurrentProgressPercentage = task.CurrentProgress,
|
2013-02-20 18:33:05 -07:00
|
|
|
|
State = task.State,
|
2014-05-09 12:43:06 -07:00
|
|
|
|
Id = task.Id,
|
2013-02-20 18:33:05 -07:00
|
|
|
|
LastExecutionResult = task.LastExecutionResult,
|
2014-09-28 08:27:26 -07:00
|
|
|
|
|
|
|
|
|
Triggers = triggers,
|
|
|
|
|
|
2013-02-20 18:33:05 -07:00
|
|
|
|
Description = task.Description,
|
2013-11-29 09:58:24 -07:00
|
|
|
|
Category = task.Category,
|
2014-04-03 15:50:04 -07:00
|
|
|
|
IsHidden = isHidden,
|
|
|
|
|
Key = key
|
2013-02-20 18:33:05 -07:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|