mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-21 01:24:44 +01:00
@@ -1,7 +1,8 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for configurable scheduled tasks.
|
||||
/// </summary>
|
||||
public interface IConfigurableScheduledTask
|
||||
{
|
||||
/// <summary>
|
||||
@@ -16,6 +17,10 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// <value><c>true</c> if this instance is enabled; otherwise, <c>false</c>.</value>
|
||||
bool IsEnabled { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether this instance is logged.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is logged; otherwise, <c>false</c>.</value>
|
||||
bool IsLogged { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable disable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Jellyfin.Data.Events;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
@@ -60,7 +61,7 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// Gets or sets the triggers that define when the task will run.
|
||||
/// </summary>
|
||||
/// <value>The triggers.</value>
|
||||
TaskTriggerInfo[] Triggers { get; set; }
|
||||
IReadOnlyList<TaskTriggerInfo> Triggers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique id.
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
@@ -7,17 +5,26 @@ using Jellyfin.Data.Events;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for the TaskManager class.
|
||||
/// </summary>
|
||||
public interface ITaskManager : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Event handler for task execution.
|
||||
/// </summary>
|
||||
event EventHandler<GenericEventArgs<IScheduledTaskWorker>>? TaskExecuting;
|
||||
|
||||
/// <summary>
|
||||
/// Event handler for task completion.
|
||||
/// </summary>
|
||||
event EventHandler<TaskCompletionEventArgs>? TaskCompleted;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of Scheduled Tasks.
|
||||
/// </summary>
|
||||
/// <value>The scheduled tasks.</value>
|
||||
IScheduledTaskWorker[] ScheduledTasks { get; }
|
||||
IReadOnlyList<IScheduledTaskWorker> ScheduledTasks { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Cancels if running and queue.
|
||||
@@ -56,6 +63,10 @@ namespace MediaBrowser.Model.Tasks
|
||||
void QueueScheduledTask<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
/// <summary>
|
||||
/// Queues the scheduled task if it is not already running.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
||||
void QueueIfNotRunning<T>()
|
||||
where T : IScheduledTask;
|
||||
|
||||
@@ -72,10 +83,24 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// <param name="tasks">The tasks.</param>
|
||||
void AddTasks(IEnumerable<IScheduledTask> tasks);
|
||||
|
||||
/// <summary>
|
||||
/// Adds the tasks.
|
||||
/// </summary>
|
||||
/// <param name="task">The tasks.</param>
|
||||
void Cancel(IScheduledTaskWorker task);
|
||||
|
||||
/// <summary>
|
||||
/// Executes the tasks.
|
||||
/// </summary>
|
||||
/// <param name="task">The tasks.</param>
|
||||
/// <param name="options">The options.</param>
|
||||
/// <returns>The executed tasks.</returns>
|
||||
Task Execute(IScheduledTaskWorker task, TaskOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// Executes the tasks.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">An implementation of <see cref="IScheduledTask" />.</typeparam>
|
||||
void Execute<T>()
|
||||
where T : IScheduledTask;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,33 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing event arguments for task completion.
|
||||
/// </summary>
|
||||
public class TaskCompletionEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TaskCompletionEventArgs"/> class.
|
||||
/// </summary>
|
||||
/// <param name="task">Instance of the <see cref="IScheduledTaskWorker"/> interface.</param>
|
||||
/// <param name="result">The task result.</param>
|
||||
public TaskCompletionEventArgs(IScheduledTaskWorker task, TaskResult result)
|
||||
{
|
||||
Task = task;
|
||||
Result = result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the task.
|
||||
/// </summary>
|
||||
/// <value>The task.</value>
|
||||
public IScheduledTaskWorker Task { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the result.
|
||||
/// </summary>
|
||||
/// <value>The result.</value>
|
||||
public TaskResult Result { get; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#nullable disable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
@@ -13,7 +14,7 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// </summary>
|
||||
public TaskInfo()
|
||||
{
|
||||
Triggers = Array.Empty<TaskTriggerInfo>();
|
||||
Triggers = [];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -50,7 +51,7 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// Gets or sets the triggers.
|
||||
/// </summary>
|
||||
/// <value>The triggers.</value>
|
||||
public TaskTriggerInfo[] Triggers { get; set; }
|
||||
public IReadOnlyList<TaskTriggerInfo> Triggers { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description.
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#pragma warning disable CS1591
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
{
|
||||
/// <summary>
|
||||
/// Class containing options for tasks.
|
||||
/// </summary>
|
||||
public class TaskOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum runtime in ticks.
|
||||
/// </summary>
|
||||
/// <value>The ticks.</value>
|
||||
public long? MaxRuntimeTicks { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#nullable disable
|
||||
#pragma warning disable CS1591
|
||||
|
||||
using System;
|
||||
|
||||
namespace MediaBrowser.Model.Tasks
|
||||
@@ -10,9 +8,24 @@ namespace MediaBrowser.Model.Tasks
|
||||
/// </summary>
|
||||
public class TaskTriggerInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// The daily trigger.
|
||||
/// </summary>
|
||||
public const string TriggerDaily = "DailyTrigger";
|
||||
|
||||
/// <summary>
|
||||
/// The weekly trigger.
|
||||
/// </summary>
|
||||
public const string TriggerWeekly = "WeeklyTrigger";
|
||||
|
||||
/// <summary>
|
||||
/// The interval trigger.
|
||||
/// </summary>
|
||||
public const string TriggerInterval = "IntervalTrigger";
|
||||
|
||||
/// <summary>
|
||||
/// The startup trigger.
|
||||
/// </summary>
|
||||
public const string TriggerStartup = "StartupTrigger";
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user