2016-10-23 19:47:34 +00:00
|
|
|
|
using System;
|
2013-02-21 01:33:05 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2016-10-23 19:47:34 +00:00
|
|
|
|
namespace MediaBrowser.Model.Tasks
|
2013-02-21 01:33:05 +00: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-26 03:43:04 +00:00
|
|
|
|
public static TaskInfo GetTaskInfo(IScheduledTaskWorker task)
|
2013-02-21 01:33:05 +00:00
|
|
|
|
{
|
2013-11-29 16:58:24 +00:00
|
|
|
|
var isHidden = false;
|
|
|
|
|
|
|
|
|
|
var configurableTask = task.ScheduledTask as IConfigurableScheduledTask;
|
|
|
|
|
|
|
|
|
|
if (configurableTask != null)
|
|
|
|
|
{
|
|
|
|
|
isHidden = configurableTask.IsHidden;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-23 19:14:57 +00:00
|
|
|
|
string key = task.ScheduledTask.Key;
|
2014-09-28 15:27:26 +00:00
|
|
|
|
|
|
|
|
|
var triggers = task.Triggers
|
|
|
|
|
.OrderBy(i => i.Type)
|
|
|
|
|
.ThenBy(i => i.DayOfWeek ?? DayOfWeek.Sunday)
|
|
|
|
|
.ThenBy(i => i.TimeOfDayTicks ?? 0)
|
|
|
|
|
.ToList();
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
return new TaskInfo
|
|
|
|
|
{
|
|
|
|
|
Name = task.Name,
|
2013-02-22 04:23:06 +00:00
|
|
|
|
CurrentProgressPercentage = task.CurrentProgress,
|
2013-02-21 01:33:05 +00:00
|
|
|
|
State = task.State,
|
2014-05-09 19:43:06 +00:00
|
|
|
|
Id = task.Id,
|
2013-02-21 01:33:05 +00:00
|
|
|
|
LastExecutionResult = task.LastExecutionResult,
|
2014-09-28 15:27:26 +00:00
|
|
|
|
|
|
|
|
|
Triggers = triggers,
|
|
|
|
|
|
2013-02-21 01:33:05 +00:00
|
|
|
|
Description = task.Description,
|
2013-11-29 16:58:24 +00:00
|
|
|
|
Category = task.Category,
|
2014-04-03 22:50:04 +00:00
|
|
|
|
IsHidden = isHidden,
|
|
|
|
|
Key = key
|
2013-02-21 01:33:05 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|