PeopleValidationTask.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using MediaBrowser.Controller;
  6. using MediaBrowser.Controller.Library;
  7. using MediaBrowser.Model.Tasks;
  8. using MediaBrowser.Model.Globalization;
  9. namespace Emby.Server.Implementations.ScheduledTasks
  10. {
  11. /// <summary>
  12. /// Class PeopleValidationTask.
  13. /// </summary>
  14. public class PeopleValidationTask : IScheduledTask
  15. {
  16. /// <summary>
  17. /// The library manager.
  18. /// </summary>
  19. private readonly ILibraryManager _libraryManager;
  20. private readonly IServerApplicationHost _appHost;
  21. private readonly ILocalizationManager _localization;
  22. /// <summary>
  23. /// Initializes a new instance of the <see cref="PeopleValidationTask" /> class.
  24. /// </summary>
  25. /// <param name="libraryManager">The library manager.</param>
  26. /// <param name="appHost">The server application host</param>
  27. public PeopleValidationTask(ILibraryManager libraryManager, IServerApplicationHost appHost)
  28. {
  29. _libraryManager = libraryManager;
  30. _appHost = appHost;
  31. }
  32. /// <summary>
  33. /// Creates the triggers that define when the task will run.
  34. /// </summary>
  35. public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
  36. {
  37. return new[]
  38. {
  39. new TaskTriggerInfo
  40. {
  41. Type = TaskTriggerInfo.TriggerInterval,
  42. IntervalTicks = TimeSpan.FromDays(7).Ticks
  43. }
  44. };
  45. }
  46. /// <summary>
  47. /// Returns the task to be executed.
  48. /// </summary>
  49. /// <param name="cancellationToken">The cancellation token.</param>
  50. /// <param name="progress">The progress.</param>
  51. /// <returns>Task.</returns>
  52. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  53. {
  54. return _libraryManager.ValidatePeople(cancellationToken, progress);
  55. }
  56. public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
  57. public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
  58. public string Category => _localization.GetLocalizedString("TasksLibrary");
  59. public string Key => "RefreshPeople";
  60. public bool IsHidden => false;
  61. public bool IsEnabled => true;
  62. public bool IsLogged => true;
  63. }
  64. }