PeopleValidationTask.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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, ILocalizationManager localization)
  28. {
  29. _libraryManager = libraryManager;
  30. _appHost = appHost;
  31. _localization = localization;
  32. }
  33. /// <summary>
  34. /// Creates the triggers that define when the task will run.
  35. /// </summary>
  36. public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
  37. {
  38. return new[]
  39. {
  40. new TaskTriggerInfo
  41. {
  42. Type = TaskTriggerInfo.TriggerInterval,
  43. IntervalTicks = TimeSpan.FromDays(7).Ticks
  44. }
  45. };
  46. }
  47. /// <summary>
  48. /// Returns the task to be executed.
  49. /// </summary>
  50. /// <param name="cancellationToken">The cancellation token.</param>
  51. /// <param name="progress">The progress.</param>
  52. /// <returns>Task.</returns>
  53. public Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
  54. {
  55. return _libraryManager.ValidatePeople(cancellationToken, progress);
  56. }
  57. public string Name => _localization.GetLocalizedString("TaskRefreshPeople");
  58. public string Description => _localization.GetLocalizedString("TaskRefreshPeopleDescription");
  59. public string Category => _localization.GetLocalizedString("TasksLibraryCategory");
  60. public string Key => "RefreshPeople";
  61. public bool IsHidden => false;
  62. public bool IsEnabled => true;
  63. public bool IsLogged => true;
  64. }
  65. }