ActivityManager.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using MediaBrowser.Common.Events;
  2. using MediaBrowser.Controller.Activity;
  3. using MediaBrowser.Model.Activity;
  4. using MediaBrowser.Model.Events;
  5. using MediaBrowser.Model.Logging;
  6. using MediaBrowser.Model.Querying;
  7. using System;
  8. using System.Threading.Tasks;
  9. namespace MediaBrowser.Server.Implementations.Activity
  10. {
  11. public class ActivityManager : IActivityManager
  12. {
  13. public event EventHandler<GenericEventArgs<ActivityLogEntry>> EntryCreated;
  14. private readonly IActivityRepository _repo;
  15. private readonly ILogger _logger;
  16. public ActivityManager(ILogger logger, IActivityRepository repo)
  17. {
  18. _logger = logger;
  19. _repo = repo;
  20. }
  21. public async Task Create(ActivityLogEntry entry)
  22. {
  23. entry.Id = Guid.NewGuid().ToString("N");
  24. entry.Date = DateTime.UtcNow;
  25. await _repo.Create(entry).ConfigureAwait(false);
  26. EventHelper.FireEventIfNotNull(EntryCreated, this, new GenericEventArgs<ActivityLogEntry>(entry), _logger);
  27. }
  28. public QueryResult<ActivityLogEntry> GetActivityLogEntries(DateTime? minDate, int? startIndex, int? limit)
  29. {
  30. return _repo.GetActivityLogEntries(minDate, startIndex, limit);
  31. }
  32. }
  33. }