Added IDtoService

This commit is contained in:
Luke Pulverenti 2013-09-04 13:02:19 -04:00
parent 981973a028
commit dfe91e43b6
57 changed files with 1031 additions and 1039 deletions

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
@ -30,13 +31,15 @@ namespace MediaBrowser.Api
/// </summary>
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
public AlbumsService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
public AlbumsService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -50,6 +53,7 @@ namespace MediaBrowser.Api
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, item => item is MusicAlbum,
GetAlbumSimilarityScore);

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using ServiceStack.ServiceHost;
@ -34,6 +35,7 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="GamesService" /> class.
@ -42,12 +44,13 @@ namespace MediaBrowser.Api
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="itemRepo">The item repo.</param>
public GamesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
public GamesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -61,6 +64,7 @@ namespace MediaBrowser.Api
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, item => item is Game,
SimilarItemsHelper.GetSimiliarityScore);

View File

@ -337,21 +337,19 @@ namespace MediaBrowser.Api.Images
private readonly IProviderManager _providerManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="ImageService" /> class.
/// </summary>
/// <param name="userManager">The user manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="appPaths">The app paths.</param>
/// <param name="providerManager">The provider manager.</param>
public ImageService(IUserManager userManager, ILibraryManager libraryManager, IApplicationPaths appPaths, IProviderManager providerManager, IItemRepository itemRepo)
public ImageService(IUserManager userManager, ILibraryManager libraryManager, IApplicationPaths appPaths, IProviderManager providerManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_libraryManager = libraryManager;
_appPaths = appPaths;
_providerManager = providerManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -361,7 +359,7 @@ namespace MediaBrowser.Api.Images
/// <returns>System.Object.</returns>
public object Get(GetItemImageInfos request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.Id);
var result = GetItemImageInfos(item).Result;
@ -512,7 +510,7 @@ namespace MediaBrowser.Api.Images
/// <returns>System.Object.</returns>
public object Get(GetItemImage request)
{
var item = string.IsNullOrEmpty(request.Id) ? _libraryManager.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = string.IsNullOrEmpty(request.Id) ? _libraryManager.RootFolder : _dtoService.GetItemByDtoId(request.Id);
return GetImage(request, item);
}
@ -824,9 +822,10 @@ namespace MediaBrowser.Api.Images
}
}
var memoryStream = new MemoryStream(bytes);
memoryStream.Position = 0;
var memoryStream = new MemoryStream(bytes)
{
Position = 0
};
var imageIndex = 0;

View File

@ -1,7 +1,6 @@
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Querying;
using ServiceStack.ServiceHost;
using System;
@ -42,22 +41,20 @@ namespace MediaBrowser.Api
public class InstantMixService : BaseApiService
{
private readonly IUserManager _userManager;
private readonly IUserDataRepository _userDataRepository;
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
public InstantMixService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
public InstantMixService(IUserManager userManager, ILibraryManager libraryManager, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
public object Get(GetInstantMixFromSong request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.Id);
var result = GetInstantMixResult(request, item.Genres).Result;
@ -66,7 +63,7 @@ namespace MediaBrowser.Api
public object Get(GetInstantMixFromAlbum request)
{
var album = (MusicAlbum)DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var album = (MusicAlbum)_dtoService.GetItemByDtoId(request.Id);
var genres = album
.RecursiveChildren
@ -112,8 +109,6 @@ namespace MediaBrowser.Api
var fields = request.GetItemFields().ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var inputItems = user == null
? _libraryManager.RootFolder.RecursiveChildren
: user.RootFolder.GetRecursiveChildren(user);
@ -138,7 +133,7 @@ namespace MediaBrowser.Api
};
var tasks = items.Take(request.Limit ?? items.Length)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user));
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
result.Items = await Task.WhenAll(tasks).ConfigureAwait(false);

View File

@ -1,9 +1,9 @@
using System.Linq;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using ServiceStack.ServiceHost;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -92,12 +92,12 @@ namespace MediaBrowser.Api
public class ItemRefreshService : BaseApiService
{
private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager;
private readonly IDtoService _dtoService;
public ItemRefreshService(ILibraryManager libraryManager, IUserManager userManager)
public ItemRefreshService(ILibraryManager libraryManager, IDtoService dtoService)
{
_libraryManager = libraryManager;
_userManager = userManager;
_dtoService = dtoService;
}
public void Post(RefreshArtist request)
@ -244,7 +244,7 @@ namespace MediaBrowser.Api
/// <returns>Task.</returns>
private async Task RefreshItem(RefreshItem request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.Id);
var folder = item as Folder;

View File

@ -72,12 +72,12 @@ namespace MediaBrowser.Api
public class ItemUpdateService : BaseApiService
{
private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager;
private readonly IDtoService _dtoService;
public ItemUpdateService(ILibraryManager libraryManager, IUserManager userManager)
public ItemUpdateService(ILibraryManager libraryManager, IDtoService dtoService)
{
_libraryManager = libraryManager;
_userManager = userManager;
_dtoService = dtoService;
}
public void Post(UpdateItem request)
@ -89,7 +89,7 @@ namespace MediaBrowser.Api
private Task UpdateItem(UpdateItem request)
{
var item = DtoBuilder.GetItemByClientId(request.ItemId, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.ItemId);
UpdateItem(request, item);

View File

@ -187,27 +187,24 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager;
private readonly IUserDataRepository _userDataRepository;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="LibraryService" /> class.
/// </summary>
/// <param name="itemRepo">The item repo.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="userManager">The user manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
public LibraryService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager,
IUserDataRepository userDataRepository)
IDtoService dtoService)
{
_itemRepo = itemRepo;
_libraryManager = libraryManager;
_userManager = userManager;
_userDataRepository = userDataRepository;
_dtoService = dtoService;
}
public object Get(GetFile request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.Id);
if (item.LocationType == LocationType.Remote || item.LocationType == LocationType.Virtual)
{
@ -240,7 +237,7 @@ namespace MediaBrowser.Api
/// <returns>Task{BaseItemDto[]}.</returns>
public async Task<BaseItemDto[]> GetAncestors(GetAncestors request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.Id);
var tasks = new List<Task<BaseItemDto>>();
@ -251,8 +248,6 @@ namespace MediaBrowser.Api
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
BaseItem parent = item.Parent;
while (parent != null)
@ -262,7 +257,7 @@ namespace MediaBrowser.Api
parent = TranslateParentItem(parent, user);
}
tasks.Add(dtoBuilder.GetBaseItemDto(parent, fields, user));
tasks.Add(_dtoService.GetBaseItemDto(parent, fields, user));
if (parent is UserRootFolder)
{
@ -379,7 +374,7 @@ namespace MediaBrowser.Api
private async Task DeleteItem(DeleteItem request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.Id);
var parent = item.Parent;
@ -505,7 +500,7 @@ namespace MediaBrowser.Api
? (request.UserId.HasValue
? user.RootFolder
: (Folder)_libraryManager.RootFolder)
: DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
: _dtoService.GetItemByDtoId(request.Id, request.UserId);
while (item.ThemeSongIds.Count == 0 && request.InheritFromParent && item.Parent != null)
{
@ -517,11 +512,9 @@ namespace MediaBrowser.Api
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var tasks = item.ThemeSongIds.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item));
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
var items = await Task.WhenAll(tasks).ConfigureAwait(false);
@ -529,7 +522,7 @@ namespace MediaBrowser.Api
{
Items = items,
TotalRecordCount = items.Length,
OwnerId = DtoBuilder.GetClientItemId(item)
OwnerId = _dtoService.GetDtoId(item)
};
}
@ -553,7 +546,7 @@ namespace MediaBrowser.Api
? (request.UserId.HasValue
? user.RootFolder
: (Folder)_libraryManager.RootFolder)
: DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
: _dtoService.GetItemByDtoId(request.Id, request.UserId);
while (item.ThemeVideoIds.Count == 0 && request.InheritFromParent && item.Parent != null)
{
@ -566,11 +559,9 @@ namespace MediaBrowser.Api
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var tasks = item.ThemeVideoIds.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item));
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
var items = await Task.WhenAll(tasks).ConfigureAwait(false);
@ -578,7 +569,7 @@ namespace MediaBrowser.Api
{
Items = items,
TotalRecordCount = items.Length,
OwnerId = DtoBuilder.GetClientItemId(item)
OwnerId = _dtoService.GetDtoId(item)
};
}
}

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
@ -42,19 +43,21 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="MoviesService"/> class.
/// </summary>
/// <param name="userManager">The user manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="libraryManager">The library manager.</param>
public MoviesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
public MoviesService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -68,6 +71,7 @@ namespace MediaBrowser.Api
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, item => item is Movie || (item is Trailer && request.IncludeTrailers),
SimilarItemsHelper.GetSimiliarityScore);

View File

@ -31,31 +31,32 @@ namespace MediaBrowser.Api.Playback
/// Gets or sets the application paths.
/// </summary>
/// <value>The application paths.</value>
protected IServerApplicationPaths ApplicationPaths { get; set; }
protected IServerApplicationPaths ApplicationPaths { get; private set; }
/// <summary>
/// Gets or sets the user manager.
/// </summary>
/// <value>The user manager.</value>
protected IUserManager UserManager { get; set; }
protected IUserManager UserManager { get; private set; }
/// <summary>
/// Gets or sets the library manager.
/// </summary>
/// <value>The library manager.</value>
protected ILibraryManager LibraryManager { get; set; }
protected ILibraryManager LibraryManager { get; private set; }
/// <summary>
/// Gets or sets the iso manager.
/// </summary>
/// <value>The iso manager.</value>
protected IIsoManager IsoManager { get; set; }
protected IIsoManager IsoManager { get; private set; }
/// <summary>
/// Gets or sets the media encoder.
/// </summary>
/// <value>The media encoder.</value>
protected IMediaEncoder MediaEncoder { get; set; }
protected IMediaEncoder MediaEncoder { get; private set; }
protected IDtoService DtoService { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseStreamingService" /> class.
@ -65,8 +66,9 @@ namespace MediaBrowser.Api.Playback
/// <param name="libraryManager">The library manager.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
protected BaseStreamingService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder)
protected BaseStreamingService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService)
{
DtoService = dtoService;
ApplicationPaths = appPaths;
UserManager = userManager;
LibraryManager = libraryManager;
@ -751,7 +753,7 @@ namespace MediaBrowser.Api.Playback
/// <returns>StreamState.</returns>
protected StreamState GetState(StreamRequest request)
{
var item = DtoBuilder.GetItemByClientId(request.Id, UserManager, LibraryManager);
var item = DtoService.GetItemByDtoId(request.Id);
var media = (IHasMediaStreams)item;

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.IO;
@ -53,8 +54,8 @@ namespace MediaBrowser.Api.Playback.Hls
/// <param name="libraryManager">The library manager.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
public AudioHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder)
public AudioHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService)
{
}

View File

@ -3,6 +3,7 @@ using MediaBrowser.Common.IO;
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.IO;
@ -37,8 +38,8 @@ namespace MediaBrowser.Api.Playback.Hls
/// <param name="libraryManager">The library manager.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
protected BaseHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder)
protected BaseHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService)
{
}

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.IO;
using ServiceStack.ServiceHost;
@ -69,8 +70,8 @@ namespace MediaBrowser.Api.Playback.Hls
/// <param name="libraryManager">The library manager.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
public VideoHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder)
public VideoHlsService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IDtoService dtoService)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService)
{
}

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.IO;
@ -48,8 +49,8 @@ namespace MediaBrowser.Api.Playback.Progressive
/// <param name="libraryManager">The library manager.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
public AudioService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, itemRepo)
public AudioService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IDtoService dtoService)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, itemRepo, dtoService)
{
}

View File

@ -2,6 +2,7 @@
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
@ -23,9 +24,9 @@ namespace MediaBrowser.Api.Playback.Progressive
public abstract class BaseProgressiveStreamingService : BaseStreamingService
{
protected readonly IItemRepository ItemRepository;
protected BaseProgressiveStreamingService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepository) :
base(appPaths, userManager, libraryManager, isoManager, mediaEncoder)
protected BaseProgressiveStreamingService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepository, IDtoService dtoService) :
base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, dtoService)
{
ItemRepository = itemRepository;
}
@ -302,7 +303,7 @@ namespace MediaBrowser.Api.Playback.Progressive
}
}
return new ImageService(UserManager, LibraryManager, ApplicationPaths, null, ItemRepository)
return new ImageService(UserManager, LibraryManager, ApplicationPaths, null, ItemRepository, DtoService)
{
Logger = Logger,
RequestContext = RequestContext,
@ -342,7 +343,7 @@ namespace MediaBrowser.Api.Playback.Progressive
ApiEntryPoint.Instance.OnTranscodeBeginRequest(outputPath, TranscodingJobType.Progressive);
}
var result = new ProgressiveStreamWriter(outputPath, state, Logger);
var result = new ProgressiveStreamWriter(outputPath, Logger);
result.Options["Accept-Ranges"] = "none";
result.Options["Content-Type"] = contentType;

View File

@ -12,7 +12,6 @@ namespace MediaBrowser.Api.Playback.Progressive
public class ProgressiveStreamWriter : IStreamWriter, IHasOptions
{
private string Path { get; set; }
private StreamState State { get; set; }
private ILogger Logger { get; set; }
/// <summary>
@ -32,12 +31,10 @@ namespace MediaBrowser.Api.Playback.Progressive
/// Initializes a new instance of the <see cref="ProgressiveStreamWriter" /> class.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="state">The state.</param>
/// <param name="logger">The logger.</param>
public ProgressiveStreamWriter(string path, StreamState state, ILogger logger)
public ProgressiveStreamWriter(string path, ILogger logger)
{
Path = path;
State = state;
Logger = logger;
}

View File

@ -1,5 +1,6 @@
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
@ -60,8 +61,8 @@ namespace MediaBrowser.Api.Playback.Progressive
/// <param name="libraryManager">The library manager.</param>
/// <param name="isoManager">The iso manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
public VideoService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, itemRepo)
public VideoService(IServerApplicationPaths appPaths, IUserManager userManager, ILibraryManager libraryManager, IIsoManager isoManager, IMediaEncoder mediaEncoder, IItemRepository itemRepo, IDtoService dtoService)
: base(appPaths, userManager, libraryManager, isoManager, mediaEncoder, itemRepo, dtoService)
{
}

View File

@ -65,6 +65,7 @@ namespace MediaBrowser.Api
/// </summary>
private readonly ILibrarySearchEngine _searchEngine;
private readonly ILibraryManager _libraryManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="SearchService" /> class.
@ -72,11 +73,12 @@ namespace MediaBrowser.Api
/// <param name="userManager">The user manager.</param>
/// <param name="searchEngine">The search engine.</param>
/// <param name="libraryManager">The library manager.</param>
public SearchService(IUserManager userManager, ILibrarySearchEngine searchEngine, ILibraryManager libraryManager)
public SearchService(IUserManager userManager, ILibrarySearchEngine searchEngine, ILibraryManager libraryManager, IDtoService dtoService)
{
_userManager = userManager;
_searchEngine = searchEngine;
_libraryManager = libraryManager;
_dtoService = dtoService;
}
/// <summary>
@ -149,7 +151,7 @@ namespace MediaBrowser.Api
Name = item.Name,
IndexNumber = item.IndexNumber,
ParentIndexNumber = item.ParentIndexNumber,
ItemId = DtoBuilder.GetClientItemId(item),
ItemId = _dtoService.GetDtoId(item),
Type = item.GetType().Name,
MediaType = item.MediaType,
MatchedTerm = hintInfo.MatchedTerm,

View File

@ -180,13 +180,16 @@ namespace MediaBrowser.Api
/// </summary>
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="SessionsService" /> class.
/// </summary>
/// <param name="sessionManager">The session manager.</param>
public SessionsService(ISessionManager sessionManager)
public SessionsService(ISessionManager sessionManager, IDtoService dtoService)
{
_sessionManager = sessionManager;
_dtoService = dtoService;
}
/// <summary>
@ -203,7 +206,7 @@ namespace MediaBrowser.Api
result = result.Where(i => i.SupportsRemoteControl == request.SupportsRemoteControl.Value);
}
return ToOptimizedResult(result.Select(SessionInfoDtoBuilder.GetSessionInfoDto).ToList());
return ToOptimizedResult(result.Select(_dtoService.GetSessionInfoDto).ToList());
}
public void Post(SendPlaystateCommand request)

View File

@ -87,23 +87,22 @@ namespace MediaBrowser.Api
/// <param name="itemRepository">The item repository.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="dtoService">The dto service.</param>
/// <param name="logger">The logger.</param>
/// <param name="request">The request.</param>
/// <param name="includeInSearch">The include in search.</param>
/// <param name="getSimilarityScore">The get similarity score.</param>
/// <returns>ItemsResult.</returns>
internal static ItemsResult GetSimilarItemsResult(IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataRepository userDataRepository, ILogger logger, BaseGetSimilarItemsFromItem request, Func<BaseItem, bool> includeInSearch, Func<BaseItem, BaseItem, int> getSimilarityScore)
internal static ItemsResult GetSimilarItemsResult(IUserManager userManager, IItemRepository itemRepository, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IDtoService dtoService, ILogger logger, BaseGetSimilarItemsFromItem request, Func<BaseItem, bool> includeInSearch, Func<BaseItem, BaseItem, int> getSimilarityScore)
{
var user = request.UserId.HasValue ? userManager.GetUserById(request.UserId.Value) : null;
var item = string.IsNullOrEmpty(request.Id) ?
(request.UserId.HasValue ? user.RootFolder :
(Folder)libraryManager.RootFolder) : DtoBuilder.GetItemByClientId(request.Id, userManager, libraryManager, request.UserId);
(Folder)libraryManager.RootFolder) : dtoService.GetItemByDtoId(request.Id, request.UserId);
var fields = request.GetItemFields().ToList();
var dtoBuilder = new DtoBuilder(logger, libraryManager, userDataRepository, itemRepository);
var inputItems = user == null
? libraryManager.RootFolder.RecursiveChildren
: user.RootFolder.GetRecursiveChildren(user);
@ -113,7 +112,7 @@ namespace MediaBrowser.Api
var result = new ItemsResult
{
Items = items.Take(request.Limit ?? items.Length).Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToArray(),
Items = items.Take(request.Limit ?? items.Length).Select(i => dtoService.GetBaseItemDto(i, fields, user)).Select(t => t.Result).ToArray(),
TotalRecordCount = items.Length
};

View File

@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
@ -35,19 +36,21 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="TrailersService"/> class.
/// </summary>
/// <param name="userManager">The user manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="libraryManager">The library manager.</param>
public TrailersService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
public TrailersService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -61,6 +64,7 @@ namespace MediaBrowser.Api
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, item => item is Movie || item is Trailer,
SimilarItemsHelper.GetSimiliarityScore);

View File

@ -101,19 +101,21 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="TvShowsService" /> class.
/// </summary>
/// <param name="userManager">The user manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="libraryManager">The library manager.</param>
public TvShowsService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo)
public TvShowsService(IUserManager userManager, IUserDataRepository userDataRepository, ILibraryManager libraryManager, IItemRepository itemRepo, IDtoService dtoService)
{
_userManager = userManager;
_userDataRepository = userDataRepository;
_libraryManager = libraryManager;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -127,6 +129,7 @@ namespace MediaBrowser.Api
_itemRepo,
_libraryManager,
_userDataRepository,
_dtoService,
Logger,
request, item => item is Series,
SimilarItemsHelper.GetSimiliarityScore);
@ -253,9 +256,7 @@ namespace MediaBrowser.Api
/// <returns>Task.</returns>
private Task<BaseItemDto[]> GetItemDtos(IEnumerable<BaseItem> pagedItems, User user, List<ItemFields> fields)
{
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
return Task.WhenAll(pagedItems.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user)));
return Task.WhenAll(pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user)));
}
/// <summary>

View File

@ -75,8 +75,8 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="libraryManager">The library manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="itemRepo">The item repo.</param>
public ArtistsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public ArtistsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -104,16 +104,14 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -30,6 +30,7 @@ namespace MediaBrowser.Api.UserLibrary
protected readonly ILibraryManager LibraryManager;
protected readonly IUserDataRepository UserDataRepository;
protected readonly IItemRepository ItemRepository;
protected IDtoService DtoService { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="BaseItemsByNameService{TItemType}" /> class.
@ -37,12 +38,13 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="userManager">The user manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
protected BaseItemsByNameService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepository)
protected BaseItemsByNameService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepository, IDtoService dtoService)
{
UserManager = userManager;
LibraryManager = libraryManager;
UserDataRepository = userDataRepository;
ItemRepository = itemRepository;
DtoService = dtoService;
}
/// <summary>
@ -58,11 +60,11 @@ namespace MediaBrowser.Api.UserLibrary
if (request.UserId.HasValue)
{
user = UserManager.GetUserById(request.UserId.Value);
item = string.IsNullOrEmpty(request.ParentId) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.ParentId, UserManager, LibraryManager, user.Id);
item = string.IsNullOrEmpty(request.ParentId) ? user.RootFolder : DtoService.GetItemByDtoId(request.ParentId, user.Id);
}
else
{
item = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.RootFolder : DtoBuilder.GetItemByClientId(request.ParentId, UserManager, LibraryManager);
item = string.IsNullOrEmpty(request.ParentId) ? LibraryManager.RootFolder : DtoService.GetItemByDtoId(request.ParentId);
}
IEnumerable<BaseItem> items;
@ -285,8 +287,8 @@ namespace MediaBrowser.Api.UserLibrary
return null;
}
var dto = user == null ? await new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository).GetBaseItemDto(item, fields).ConfigureAwait(false) :
await new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository).GetBaseItemDto(item, fields, user).ConfigureAwait(false);
var dto = user == null ? await DtoService.GetBaseItemDto(item, fields).ConfigureAwait(false) :
await DtoService.GetBaseItemDto(item, fields, user).ConfigureAwait(false);
if (fields.Contains(ItemFields.ItemCounts))
{

View File

@ -63,8 +63,8 @@ namespace MediaBrowser.Api.UserLibrary
public class GameGenresService : BaseItemsByNameService<GameGenre>
{
public GameGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public GameGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -92,16 +92,14 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -69,8 +69,8 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
public class GenresService : BaseItemsByNameService<Genre>
{
public GenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public GenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -98,16 +98,14 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -138,16 +138,18 @@ namespace MediaBrowser.Api.UserLibrary
/// The library manager
/// </summary>
protected readonly ILibraryManager LibraryManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="ItemByNameUserDataService" /> class.
/// </summary>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="libraryManager">The library manager.</param>
public ItemByNameUserDataService(IUserDataRepository userDataRepository, ILibraryManager libraryManager)
public ItemByNameUserDataService(IUserDataRepository userDataRepository, ILibraryManager libraryManager, IDtoService dtoService)
{
UserDataRepository = userDataRepository;
LibraryManager = libraryManager;
_dtoService = dtoService;
}
/// <summary>
@ -230,7 +232,7 @@ namespace MediaBrowser.Api.UserLibrary
data = UserDataRepository.GetUserData(userId, key);
return DtoBuilder.GetUserItemDataDto(data);
return _dtoService.GetUserItemDataDto(data);
}
/// <summary>
@ -256,7 +258,7 @@ namespace MediaBrowser.Api.UserLibrary
data = UserDataRepository.GetUserData(userId, key);
return DtoBuilder.GetUserItemDataDto(data);
return _dtoService.GetUserItemDataDto(data);
}
}
}

View File

@ -210,8 +210,8 @@ namespace MediaBrowser.Api.UserLibrary
private readonly ILibrarySearchEngine _searchEngine;
private readonly ILocalizationManager _localization;
private readonly IItemRepository _itemRepo;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="ItemsService" /> class.
/// </summary>
@ -219,14 +219,14 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="libraryManager">The library manager.</param>
/// <param name="searchEngine">The search engine.</param>
/// <param name="userDataRepository">The user data repository.</param>
public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILibrarySearchEngine searchEngine, IUserDataRepository userDataRepository, ILocalizationManager localization, IItemRepository itemRepo)
public ItemsService(IUserManager userManager, ILibraryManager libraryManager, ILibrarySearchEngine searchEngine, IUserDataRepository userDataRepository, ILocalizationManager localization, IDtoService dtoService)
{
_userManager = userManager;
_libraryManager = libraryManager;
_searchEngine = searchEngine;
_userDataRepository = userDataRepository;
_localization = localization;
_itemRepo = itemRepo;
_dtoService = dtoService;
}
/// <summary>
@ -275,9 +275,7 @@ namespace MediaBrowser.Api.UserLibrary
var fields = request.GetItemFields().ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var returnItems = await Task.WhenAll(pagedItems.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user))).ConfigureAwait(false);
var returnItems = await Task.WhenAll(pagedItems.Select(i => _dtoService.GetBaseItemDto(i, fields, user))).ConfigureAwait(false);
return new ItemsResult
{
@ -295,7 +293,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <exception cref="System.InvalidOperationException"></exception>
private IEnumerable<BaseItem> GetItemsToSerialize(GetItems request, User user)
{
var item = string.IsNullOrEmpty(request.ParentId) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.ParentId, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(request.ParentId) ? user.RootFolder : _dtoService.GetItemByDtoId(request.ParentId, user.Id);
// Default list type = children
@ -303,7 +301,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var idList = request.Ids.Split(',').ToList();
return idList.Select(i => DtoBuilder.GetItemByClientId(i, _userManager, _libraryManager, user.Id));
return idList.Select(i => _dtoService.GetItemByDtoId(i, user.Id));
}
if (request.Recursive)
@ -492,7 +490,7 @@ namespace MediaBrowser.Api.UserLibrary
if (!string.IsNullOrEmpty(request.AdjacentTo))
{
var item = DtoBuilder.GetItemByClientId(request.AdjacentTo, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(request.AdjacentTo);
var allSiblings = item.Parent.GetChildren(user, true).OrderBy(i => i.SortName).ToList();

View File

@ -63,8 +63,8 @@ namespace MediaBrowser.Api.UserLibrary
public class MusicGenresService : BaseItemsByNameService<MusicGenre>
{
public MusicGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public MusicGenresService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -92,16 +92,14 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -6,7 +6,6 @@ using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using ServiceStack.ServiceHost;
using System;
@ -86,8 +85,8 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="libraryManager">The library manager.</param>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="itemRepo">The item repo.</param>
public PersonsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public PersonsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -114,17 +113,15 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -70,8 +70,8 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
public class StudiosService : BaseItemsByNameService<Studio>
{
public StudiosService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public StudiosService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -98,17 +98,15 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -366,6 +366,7 @@ namespace MediaBrowser.Api.UserLibrary
private readonly IItemRepository _itemRepo;
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="UserLibraryService" /> class.
@ -375,13 +376,14 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="itemRepo">The item repo.</param>
/// <exception cref="System.ArgumentNullException">jsonSerializer</exception>
public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, ISessionManager sessionManager)
public UserLibraryService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, ISessionManager sessionManager, IDtoService dtoService)
{
_userManager = userManager;
_libraryManager = libraryManager;
_userDataRepository = userDataRepository;
_itemRepo = itemRepo;
_sessionManager = sessionManager;
_dtoService = dtoService;
}
/// <summary>
@ -400,13 +402,11 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _dtoService.GetItemByDtoId(request.Id, user.Id);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var movie = item as Movie;
// Get them from the db
@ -418,7 +418,7 @@ namespace MediaBrowser.Api.UserLibrary
var tasks = movie.SpecialFeatureIds
.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, movie1));
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, movie1));
return Task.WhenAll(tasks);
}
@ -446,7 +446,7 @@ namespace MediaBrowser.Api.UserLibrary
return DateTime.MinValue;
})
.ThenBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user));
.Select(i => _dtoService.GetBaseItemDto(i, fields, user));
return Task.WhenAll(tasks);
}
@ -470,17 +470,15 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _dtoService.GetItemByDtoId(request.Id, user.Id);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var tasks = item.LocalTrailerIds
.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, item));
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, item));
return Task.WhenAll(tasks);
}
@ -494,14 +492,12 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _dtoService.GetItemByDtoId(request.Id, user.Id);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var result = dtoBuilder.GetBaseItemDto(item, fields, user).Result;
var result = _dtoService.GetBaseItemDto(item, fields, user).Result;
return ToOptimizedResult(result);
}
@ -520,9 +516,7 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var result = dtoBuilder.GetBaseItemDto(item, fields, user).Result;
var result = _dtoService.GetBaseItemDto(item, fields, user).Result;
return ToOptimizedResult(result);
}
@ -536,7 +530,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(request.Id) ? user.RootFolder : _dtoService.GetItemByDtoId(request.Id, user.Id);
var result = _libraryManager.GetIntros(item, user);
@ -569,7 +563,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(userId);
var item = string.IsNullOrEmpty(itemId) ? user.RootFolder : DtoBuilder.GetItemByClientId(itemId, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(itemId) ? user.RootFolder : _dtoService.GetItemByDtoId(itemId, user.Id);
var key = item.GetUserDataKey();
@ -583,7 +577,7 @@ namespace MediaBrowser.Api.UserLibrary
data = _userDataRepository.GetUserData(user.Id, key);
return DtoBuilder.GetUserItemDataDto(data);
return _dtoService.GetUserItemDataDto(data);
}
/// <summary>
@ -612,7 +606,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(userId);
var item = string.IsNullOrEmpty(itemId) ? user.RootFolder : DtoBuilder.GetItemByClientId(itemId, _userManager, _libraryManager, user.Id);
var item = string.IsNullOrEmpty(itemId) ? user.RootFolder : _dtoService.GetItemByDtoId(itemId, user.Id);
var key = item.GetUserDataKey();
@ -625,7 +619,7 @@ namespace MediaBrowser.Api.UserLibrary
data = _userDataRepository.GetUserData(user.Id, key);
return DtoBuilder.GetUserItemDataDto(data);
return _dtoService.GetUserItemDataDto(data);
}
/// <summary>
@ -666,7 +660,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = _dtoService.GetItemByDtoId(request.Id, user.Id);
_sessionManager.OnPlaybackStart(item, GetSession().Id);
}
@ -679,7 +673,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = _dtoService.GetItemByDtoId(request.Id, user.Id);
var task = _sessionManager.OnPlaybackProgress(item, request.PositionTicks, request.IsPaused, request.IsMuted, GetSession().Id);
@ -694,7 +688,7 @@ namespace MediaBrowser.Api.UserLibrary
{
var user = _userManager.GetUserById(request.UserId);
var item = DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, user.Id);
var item = _dtoService.GetItemByDtoId(request.Id, user.Id);
var task = _sessionManager.OnPlaybackStopped(item, request.PositionTicks, GetSession().Id);
@ -723,11 +717,11 @@ namespace MediaBrowser.Api.UserLibrary
/// <returns>Task.</returns>
private async Task<UserItemDataDto> UpdatePlayedStatus(User user, string itemId, bool wasPlayed)
{
var item = DtoBuilder.GetItemByClientId(itemId, _userManager, _libraryManager, user.Id);
var item = _dtoService.GetItemByDtoId(itemId, user.Id);
await item.SetPlayedStatus(user, wasPlayed, _userDataRepository).ConfigureAwait(false);
return DtoBuilder.GetUserItemDataDto(_userDataRepository.GetUserData(user.Id, item.GetUserDataKey()));
return _dtoService.GetUserItemDataDto(_userDataRepository.GetUserData(user.Id, item.GetUserDataKey()));
}
}
}

View File

@ -54,8 +54,8 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
private static readonly CultureInfo UsCulture = new CultureInfo("en-US");
public YearsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo)
: base(userManager, libraryManager, userDataRepository, itemRepo)
public YearsService(IUserManager userManager, ILibraryManager libraryManager, IUserDataRepository userDataRepository, IItemRepository itemRepo, IDtoService dtoService)
: base(userManager, libraryManager, userDataRepository, itemRepo, dtoService)
{
}
@ -82,17 +82,15 @@ namespace MediaBrowser.Api.UserLibrary
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true));
var builder = new DtoBuilder(Logger, LibraryManager, UserDataRepository, ItemRepository);
if (request.UserId.HasValue)
{
var user = UserManager.GetUserById(request.UserId.Value);
return await builder.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList(), user).ConfigureAwait(false);
}
return await builder.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
return await DtoService.GetBaseItemDto(item, fields.ToList()).ConfigureAwait(false);
}
/// <summary>

View File

@ -171,16 +171,15 @@ namespace MediaBrowser.Api
/// The _user manager
/// </summary>
private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="UserService" /> class.
/// </summary>
/// <param name="xmlSerializer">The XML serializer.</param>
/// <param name="userManager">The user manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <exception cref="System.ArgumentNullException">xmlSerializer</exception>
public UserService(IXmlSerializer xmlSerializer, IUserManager userManager, ILibraryManager libraryManager)
public UserService(IXmlSerializer xmlSerializer, IUserManager userManager, IDtoService dtoService)
: base()
{
if (xmlSerializer == null)
@ -190,7 +189,7 @@ namespace MediaBrowser.Api
_xmlSerializer = xmlSerializer;
_userManager = userManager;
_libraryManager = libraryManager;
_dtoService = dtoService;
}
public object Get(GetPublicUsers request)
@ -209,8 +208,6 @@ namespace MediaBrowser.Api
/// <returns>System.Object.</returns>
public object Get(GetUsers request)
{
var dtoBuilder = new UserDtoBuilder(Logger);
var users = _userManager.Users;
if (request.IsDisabled.HasValue)
@ -223,7 +220,7 @@ namespace MediaBrowser.Api
users = users.Where(i => i.Configuration.IsHidden == request.IsHidden.Value);
}
var tasks = users.OrderBy(u => u.Name).Select(dtoBuilder.GetUserDto).Select(i => i.Result);
var tasks = users.OrderBy(u => u.Name).Select(_dtoService.GetUserDto).Select(i => i.Result);
return ToOptimizedResult(tasks.ToList());
}
@ -242,9 +239,7 @@ namespace MediaBrowser.Api
throw new ResourceNotFoundException("User not found");
}
var dtoBuilder = new UserDtoBuilder(Logger);
var result = dtoBuilder.GetUserDto(user).Result;
var result = _dtoService.GetUserDto(user).Result;
return ToOptimizedResult(result);
}
@ -310,7 +305,7 @@ namespace MediaBrowser.Api
var result = new AuthenticationResult
{
User = await new UserDtoBuilder(Logger).GetUserDto(user).ConfigureAwait(false)
User = await _dtoService.GetUserDto(user).ConfigureAwait(false)
};
return result;
@ -409,9 +404,7 @@ namespace MediaBrowser.Api
newUser.UpdateConfiguration(dtoUser.Configuration, _xmlSerializer);
var dtoBuilder = new UserDtoBuilder(Logger);
var result = dtoBuilder.GetUserDto(newUser).Result;
var result = _dtoService.GetUserDto(newUser).Result;
return ToOptimizedResult(result);
}

View File

@ -30,14 +30,14 @@ namespace MediaBrowser.Api
private readonly ILibraryManager _libraryManager;
private readonly IUserManager _userManager;
private readonly IUserDataRepository _userDataRepository;
private readonly IDtoService _dtoService;
public VideosService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, IUserDataRepository userDataRepository)
public VideosService(IItemRepository itemRepo, ILibraryManager libraryManager, IUserManager userManager, IDtoService dtoService)
{
_itemRepo = itemRepo;
_libraryManager = libraryManager;
_userManager = userManager;
_userDataRepository = userDataRepository;
_dtoService = dtoService;
}
/// <summary>
@ -53,20 +53,18 @@ namespace MediaBrowser.Api
? (request.UserId.HasValue
? user.RootFolder
: (Folder)_libraryManager.RootFolder)
: DtoBuilder.GetItemByClientId(request.Id, _userManager, _libraryManager, request.UserId);
: _dtoService.GetItemByDtoId(request.Id, request.UserId);
// Get everything
var fields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList();
var dtoBuilder = new DtoBuilder(Logger, _libraryManager, _userDataRepository, _itemRepo);
var video = (Video)item;
var items = video.AdditionalPartIds.Select(_itemRepo.RetrieveItem)
.OrderBy(i => i.SortName)
.Select(i => dtoBuilder.GetBaseItemDto(i, fields, user, video))
.Select(i => _dtoService.GetBaseItemDto(i, fields, user, video))
.Select(t => t.Result)
.ToArray();

View File

@ -14,6 +14,8 @@ namespace MediaBrowser.Api.WebSocket
/// </summary>
class SessionInfoWebSocketListener : BasePeriodicWebSocketListener<IEnumerable<SessionInfoDto>, object>
{
private readonly IDtoService _dtoService;
/// <summary>
/// Gets the name.
/// </summary>
@ -33,10 +35,11 @@ namespace MediaBrowser.Api.WebSocket
/// </summary>
/// <param name="logger">The logger.</param>
/// <param name="sessionManager">The session manager.</param>
public SessionInfoWebSocketListener(ILogger logger, ISessionManager sessionManager)
public SessionInfoWebSocketListener(ILogger logger, ISessionManager sessionManager, IDtoService dtoService)
: base(logger)
{
_sessionManager = sessionManager;
_dtoService = dtoService;
}
/// <summary>
@ -46,7 +49,7 @@ namespace MediaBrowser.Api.WebSocket
/// <returns>Task{SystemInfo}.</returns>
protected override Task<IEnumerable<SessionInfoDto>> GetDataToSend(object state)
{
return Task.FromResult(_sessionManager.Sessions.Select(SessionInfoDtoBuilder.GetSessionInfoDto));
return Task.FromResult(_sessionManager.Sessions.Select(_dtoService.GetSessionInfoDto));
}
}
}

View File

@ -612,7 +612,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="supportedEnhancers">The supported enhancers.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">originalImagePath</exception>
public async Task<string> GetEnhancedImage(string originalImagePath, DateTime dateModified, BaseItem item, ImageType imageType, int imageIndex, IEnumerable<IImageEnhancer> supportedEnhancers)
public async Task<string> GetEnhancedImage(string originalImagePath, DateTime dateModified, BaseItem item, ImageType imageType, int imageIndex, List<IImageEnhancer> supportedEnhancers)
{
if (string.IsNullOrEmpty(originalImagePath))
{

View File

@ -0,0 +1,71 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Session;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Dto
{
/// <summary>
/// Interface IDtoService
/// </summary>
public interface IDtoService
{
/// <summary>
/// Gets the user dto.
/// </summary>
/// <param name="user">The user.</param>
/// <returns>Task{UserDto}.</returns>
Task<UserDto> GetUserDto(User user);
/// <summary>
/// Gets the session info dto.
/// </summary>
/// <param name="session">The session.</param>
/// <returns>SessionInfoDto.</returns>
SessionInfoDto GetSessionInfoDto(SessionInfo session);
/// <summary>
/// Gets the base item info.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>BaseItemInfo.</returns>
BaseItemInfo GetBaseItemInfo(BaseItem item);
/// <summary>
/// Gets the dto id.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>System.String.</returns>
string GetDtoId(BaseItem item);
/// <summary>
/// Gets the user item data dto.
/// </summary>
/// <param name="data">The data.</param>
/// <returns>UserItemDataDto.</returns>
UserItemDataDto GetUserItemDataDto(UserItemData data);
/// <summary>
/// Gets the item by dto id.
/// </summary>
/// <param name="id">The id.</param>
/// <param name="userId">The user id.</param>
/// <returns>BaseItem.</returns>
BaseItem GetItemByDtoId(string id, Guid? userId = null);
/// <summary>
/// Gets the base item dto.
/// </summary>
/// <param name="item">The item.</param>
/// <param name="fields">The fields.</param>
/// <param name="user">The user.</param>
/// <param name="owner">The owner.</param>
/// <returns>Task{BaseItemDto}.</returns>
Task<BaseItemDto> GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null);
}
}

View File

@ -1,50 +0,0 @@
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Session;
namespace MediaBrowser.Controller.Dto
{
/// <summary>
/// Class SessionInfoDtoBuilder
/// </summary>
public static class SessionInfoDtoBuilder
{
/// <summary>
/// Gets the session info dto.
/// </summary>
/// <param name="session">The session.</param>
/// <returns>SessionInfoDto.</returns>
public static SessionInfoDto GetSessionInfoDto(SessionInfo session)
{
var dto = new SessionInfoDto
{
Client = session.Client,
DeviceId = session.DeviceId,
DeviceName = session.DeviceName,
Id = session.Id.ToString("N"),
LastActivityDate = session.LastActivityDate,
NowPlayingPositionTicks = session.NowPlayingPositionTicks,
SupportsRemoteControl = session.SupportsRemoteControl,
IsPaused = session.IsPaused,
IsMuted = session.IsMuted,
NowViewingContext = session.NowViewingContext,
NowViewingItemId = session.NowViewingItemId,
NowViewingItemName = session.NowViewingItemName,
NowViewingItemType = session.NowViewingItemType,
ApplicationVersion = session.ApplicationVersion
};
if (session.NowPlayingItem != null)
{
dto.NowPlayingItem = DtoBuilder.GetBaseItemInfo(session.NowPlayingItem);
}
if (session.User != null)
{
dto.UserId = session.User.Id.ToString("N");
dto.UserName = session.User.Name;
}
return dto;
}
}
}

View File

@ -1,72 +0,0 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Dto
{
/// <summary>
/// Class UserDtoBuilder
/// </summary>
public class UserDtoBuilder
{
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// Initializes a new instance of the <see cref="UserDtoBuilder"/> class.
/// </summary>
/// <param name="logger">The logger.</param>
public UserDtoBuilder(ILogger logger)
{
_logger = logger;
}
/// <summary>
/// Converts a User to a DTOUser
/// </summary>
/// <param name="user">The user.</param>
/// <returns>DtoUser.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
public async Task<UserDto> GetUserDto(User user)
{
if (user == null)
{
throw new ArgumentNullException("user");
}
var dto = new UserDto
{
Id = user.Id.ToString("N"),
Name = user.Name,
HasPassword = !String.IsNullOrEmpty(user.Password),
LastActivityDate = user.LastActivityDate,
LastLoginDate = user.LastLoginDate,
Configuration = user.Configuration
};
var image = user.PrimaryImagePath;
if (!string.IsNullOrEmpty(image))
{
dto.PrimaryImageTag = Kernel.Instance.ImageManager.GetImageCacheTag(user, ImageType.Primary, image);
try
{
await DtoBuilder.AttachPrimaryImageAspectRatio(dto, user, _logger).ConfigureAwait(false);
}
catch (Exception ex)
{
// Have to use a catch-all unfortunately because some .net image methods throw plain Exceptions
_logger.ErrorException("Error generating PrimaryImageAspectRatio for {0}", ex, user.Name);
}
}
return dto;
}
}
}

View File

@ -71,10 +71,10 @@
<Compile Include="..\SharedVersion.cs">
<Link>Properties\SharedVersion.cs</Link>
</Compile>
<Compile Include="Dto\IDtoService.cs" />
<Compile Include="Entities\AdultVideo.cs" />
<Compile Include="Entities\Book.cs" />
<Compile Include="Notifications\Configuration\IServerConfigurationManager.cs" />
<Compile Include="Dto\SessionInfoDtoBuilder.cs" />
<Compile Include="Entities\Audio\MusicGenre.cs" />
<Compile Include="Entities\Game.cs" />
<Compile Include="Entities\GameGenre.cs" />
@ -93,7 +93,6 @@
<Compile Include="Drawing\ImageExtensions.cs" />
<Compile Include="Drawing\ImageHeader.cs" />
<Compile Include="Drawing\ImageManager.cs" />
<Compile Include="Dto\UserDtoBuilder.cs" />
<Compile Include="Entities\AggregateFolder.cs" />
<Compile Include="Entities\Audio\Artist.cs" />
<Compile Include="Entities\Audio\Audio.cs" />
@ -128,7 +127,6 @@
<Compile Include="IO\NativeMethods.cs" />
<Compile Include="IServerApplicationHost.cs" />
<Compile Include="IServerApplicationPaths.cs" />
<Compile Include="Dto\DtoBuilder.cs" />
<Compile Include="Library\SearchHintInfo.cs" />
<Compile Include="Providers\IProviderManager.cs" />
<Compile Include="MediaInfo\MediaEncoderHelpers.cs" />

View File

@ -1,12 +1,11 @@
using System.Collections.Generic;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
@ -31,8 +30,6 @@ namespace MediaBrowser.Controller.MediaInfo
/// <value>The subtitle cache.</value>
internal FileSystemRepository SubtitleCache { get; set; }
private readonly ILibraryManager _libraryManager;
private readonly IServerApplicationPaths _appPaths;
private readonly IMediaEncoder _encoder;
private readonly ILogger _logger;
@ -43,15 +40,13 @@ namespace MediaBrowser.Controller.MediaInfo
/// </summary>
/// <param name="appPaths">The app paths.</param>
/// <param name="encoder">The encoder.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="itemRepo">The item repo.</param>
/// <exception cref="System.ArgumentNullException">zipClient</exception>
public FFMpegManager(IServerApplicationPaths appPaths, IMediaEncoder encoder, ILibraryManager libraryManager, ILogger logger, IItemRepository itemRepo)
public FFMpegManager(IServerApplicationPaths appPaths, IMediaEncoder encoder, ILogger logger, IItemRepository itemRepo)
{
_appPaths = appPaths;
_encoder = encoder;
_libraryManager = libraryManager;
_logger = logger;
_itemRepo = itemRepo;

View File

@ -1,5 +1,4 @@
using System;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Persistence
{

View File

@ -38,22 +38,15 @@ namespace MediaBrowser.Providers.MediaInfo
/// </summary>
private readonly IMediaEncoder _mediaEncoder;
/// <summary>
/// The _library manager
/// </summary>
private readonly ILibraryManager _libraryManager;
/// <summary>
/// Initializes a new instance of the <see cref="BaseMetadataProvider" /> class.
/// </summary>
/// <param name="logManager">The log manager.</param>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="mediaEncoder">The media encoder.</param>
public AudioImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager, ILibraryManager libraryManager, IMediaEncoder mediaEncoder)
public AudioImageProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IMediaEncoder mediaEncoder)
: base(logManager, configurationManager)
{
_libraryManager = libraryManager;
_mediaEncoder = mediaEncoder;
ImageCache = new FileSystemRepository(Kernel.Instance.FFMpegManager.AudioImagesDataPath);

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
@ -11,7 +10,6 @@ using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -38,11 +36,6 @@ namespace MediaBrowser.Providers.Movies
/// </summary>
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// The _HTTP client
/// </summary>
private readonly IHttpClient _httpClient;
/// <summary>
/// Initializes a new instance of the <see cref="MovieDbImagesProvider"/> class.
/// </summary>
@ -50,13 +43,11 @@ namespace MediaBrowser.Providers.Movies
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="providerManager">The provider manager.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="httpClient">The HTTP client.</param>
public MovieDbImagesProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IJsonSerializer jsonSerializer, IHttpClient httpClient)
public MovieDbImagesProvider(ILogManager logManager, IServerConfigurationManager configurationManager, IProviderManager providerManager, IJsonSerializer jsonSerializer)
: base(logManager, configurationManager)
{
_providerManager = providerManager;
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
}
/// <summary>

View File

@ -69,7 +69,9 @@ namespace MediaBrowser.Providers.Music
protected override async Task FetchLastfmData(BaseItem item, string id, CancellationToken cancellationToken)
{
var result = await GetAlbumResult(item, cancellationToken).ConfigureAwait(false);
var album = (MusicAlbum)item;
var result = await GetAlbumResult(album, cancellationToken).ConfigureAwait(false);
if (result != null && result.album != null)
{
@ -83,15 +85,35 @@ namespace MediaBrowser.Providers.Music
item.ProviderData[Id] = data;
}
data.FileStamp = GetComparisonData(item as MusicAlbum);
data.FileStamp = GetComparisonData(album);
}
private async Task<LastfmGetAlbumResult> GetAlbumResult(BaseItem item, CancellationToken cancellationToken)
private async Task<LastfmGetAlbumResult> GetAlbumResult(MusicAlbum item, CancellationToken cancellationToken)
{
var folder = (Folder)item;
// Try album release Id
if (!string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.Musicbrainz)))
{
var result = await GetAlbumResult(item.GetProviderId(MetadataProviders.Musicbrainz), cancellationToken).ConfigureAwait(false);
if (result != null && result.album != null)
{
return result;
}
}
// Try album release group Id
if (!string.IsNullOrEmpty(item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup)))
{
var result = await GetAlbumResult(item.GetProviderId(MetadataProviders.MusicBrainzReleaseGroup), cancellationToken).ConfigureAwait(false);
if (result != null && result.album != null)
{
return result;
}
}
// Get each song, distinct by the combination of AlbumArtist and Album
var songs = folder.RecursiveChildren.OfType<Audio>().DistinctBy(i => (i.AlbumArtist ?? string.Empty) + (i.Album ?? string.Empty), StringComparer.OrdinalIgnoreCase).ToList();
var songs = item.RecursiveChildren.OfType<Audio>().DistinctBy(i => (i.AlbumArtist ?? string.Empty) + (i.Album ?? string.Empty), StringComparer.OrdinalIgnoreCase).ToList();
foreach (var song in songs.Where(song => !string.IsNullOrEmpty(song.Album) && !string.IsNullOrEmpty(song.AlbumArtist)))
{
@ -124,6 +146,24 @@ namespace MediaBrowser.Providers.Music
return JsonSerializer.DeserializeFromStream<LastfmGetAlbumResult>(json);
}
}
private async Task<LastfmGetAlbumResult> GetAlbumResult(string musicbraizId, CancellationToken cancellationToken)
{
// Get albu info using artist and album name
var url = RootUrl + string.Format("method=album.getInfo&mbid={0}&api_key={1}&format=json", musicbraizId, ApiKey);
using (var json = await HttpClient.Get(new HttpRequestOptions
{
Url = url,
ResourcePool = LastfmResourcePool,
CancellationToken = cancellationToken,
EnableHttpCompression = false
}).ConfigureAwait(false))
{
return JsonSerializer.DeserializeFromStream<LastfmGetAlbumResult>(json);
}
}
protected override Task FetchData(BaseItem item, CancellationToken cancellationToken)
{

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;

View File

@ -8,9 +8,7 @@ using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Tasks;
using MediaBrowser.Model.Updates;
using System;
namespace MediaBrowser.Server.Implementations.EntryPoints
@ -24,10 +22,6 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// The _server manager
/// </summary>
private readonly IServerManager _serverManager;
/// <summary>
/// The _logger
/// </summary>
private readonly ILogger _logger;
/// <summary>
/// The _user manager
@ -49,20 +43,22 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// </summary>
private readonly ITaskManager _taskManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="WebSocketEvents" /> class.
/// </summary>
/// <param name="serverManager">The server manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="userManager">The user manager.</param>
public WebSocketEvents(IServerManager serverManager, IServerApplicationHost appHost, ILogger logger, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager)
public WebSocketEvents(IServerManager serverManager, IServerApplicationHost appHost, IUserManager userManager, IInstallationManager installationManager, ITaskManager taskManager, IDtoService dtoService)
{
_serverManager = serverManager;
_logger = logger;
_userManager = userManager;
_installationManager = installationManager;
_appHost = appHost;
_taskManager = taskManager;
_dtoService = dtoService;
}
public void Run()
@ -140,7 +136,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
/// <param name="e">The e.</param>
async void userManager_UserUpdated(object sender, GenericEventArgs<User> e)
{
var dto = await new UserDtoBuilder(_logger).GetUserDto(e.Argument).ConfigureAwait(false);
var dto = await _dtoService.GetUserDto(e.Argument).ConfigureAwait(false);
_serverManager.SendWebSocketMessage("UserUpdated", dto);
}

View File

@ -250,14 +250,6 @@ namespace MediaBrowser.Server.Implementations.Library
}
}
/// <summary>
/// The _internet providers enabled
/// </summary>
private bool _internetProvidersEnabled;
/// <summary>
/// The _people image fetching enabled
/// </summary>
private bool _peopleImageFetchingEnabled;
/// <summary>
/// The _items by name path
/// </summary>
@ -275,8 +267,6 @@ namespace MediaBrowser.Server.Implementations.Library
{
_seasonZeroDisplayName = ConfigurationManager.Configuration.SeasonZeroDisplayName;
_itemsByNamePath = ConfigurationManager.ApplicationPaths.ItemsByNamePath;
_internetProvidersEnabled = configuration.EnableInternetProviders;
_peopleImageFetchingEnabled = configuration.InternetProviderExcludeTypes == null || !configuration.InternetProviderExcludeTypes.Contains(typeof(Person).Name, StringComparer.OrdinalIgnoreCase);
}
/// <summary>

View File

@ -112,6 +112,7 @@
</Compile>
<Compile Include="BdInfo\BdInfoExaminer.cs" />
<Compile Include="Configuration\ServerConfigurationManager.cs" />
<Compile Include="Dto\DtoService.cs" />
<Compile Include="EntryPoints\LibraryChangedNotifier.cs" />
<Compile Include="EntryPoints\LoadRegistrations.cs" />
<Compile Include="EntryPoints\Notifications\Notifier.cs" />

View File

@ -1,5 +1,4 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
@ -40,32 +39,21 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// <value>The json serializer.</value>
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// The _app paths
/// </summary>
private readonly IApplicationPaths _appPaths;
/// <summary>
/// Initializes a new instance of the <see cref="SqliteUserRepository" /> class.
/// </summary>
/// <param name="connection">The connection.</param>
/// <param name="appPaths">The app paths.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="logManager">The log manager.</param>
/// <exception cref="System.ArgumentNullException">appPaths</exception>
public SqliteUserRepository(IDbConnection connection, IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
public SqliteUserRepository(IDbConnection connection, IJsonSerializer jsonSerializer, ILogManager logManager)
{
if (appPaths == null)
{
throw new ArgumentNullException("appPaths");
}
if (jsonSerializer == null)
{
throw new ArgumentNullException("jsonSerializer");
}
_connection = connection;
_appPaths = appPaths;
_jsonSerializer = jsonSerializer;
_logger = logManager.GetLogger(GetType().Name);

View File

@ -5,7 +5,6 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using MoreLinq;
using System;
using System.Collections.Generic;
@ -21,8 +20,6 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
/// </summary>
class ChapterImagesTask : IScheduledTask
{
private readonly IJsonSerializer _jsonSerializer;
/// <summary>
/// The _kernel
/// </summary>
@ -54,14 +51,12 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
/// <param name="kernel">The kernel.</param>
/// <param name="logManager">The log manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="jsonSerializer">The json serializer.</param>
/// <param name="itemRepo">The item repo.</param>
public ChapterImagesTask(Kernel kernel, ILogManager logManager, ILibraryManager libraryManager, IJsonSerializer jsonSerializer, IItemRepository itemRepo)
public ChapterImagesTask(Kernel kernel, ILogManager logManager, ILibraryManager libraryManager, IItemRepository itemRepo)
{
_kernel = kernel;
_logger = logManager.GetLogger(GetType().Name);
_libraryManager = libraryManager;
_jsonSerializer = jsonSerializer;
_itemRepo = itemRepo;
libraryManager.ItemAdded += libraryManager_ItemAdded;

View File

@ -1,13 +1,11 @@
using System.Globalization;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using System;
using System.Linq;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Server.Implementations.Session
{
@ -31,22 +29,22 @@ namespace MediaBrowser.Server.Implementations.Session
/// </summary>
private readonly ILogger _logger;
private readonly IUserManager _userManager;
private readonly ILibraryManager _libraryManager;
/// <summary>
/// The _dto service
/// </summary>
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="SessionWebSocketListener" /> class.
/// </summary>
/// <param name="sessionManager">The session manager.</param>
/// <param name="logManager">The log manager.</param>
/// <param name="libraryManager">The library manager.</param>
/// <param name="userManager">The user manager.</param>
public SessionWebSocketListener(ISessionManager sessionManager, ILogManager logManager, ILibraryManager libraryManager, IUserManager userManager)
/// <param name="dtoService">The dto service.</param>
public SessionWebSocketListener(ISessionManager sessionManager, ILogManager logManager, IDtoService dtoService)
{
_sessionManager = sessionManager;
_logger = logManager.GetLogger(GetType().Name);
_libraryManager = libraryManager;
_userManager = userManager;
_dtoService = dtoService;
}
/// <summary>
@ -109,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.Session
if (session != null && session.User != null)
{
var item = DtoBuilder.GetItemByClientId(message.Data, _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(message.Data);
_sessionManager.OnPlaybackStart(item, session.Id);
}
@ -122,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.Session
{
var vals = message.Data.Split('|');
var item = DtoBuilder.GetItemByClientId(vals[0], _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(vals[0]);
long? positionTicks = null;
@ -152,7 +150,7 @@ namespace MediaBrowser.Server.Implementations.Session
{
var vals = message.Data.Split('|');
var item = DtoBuilder.GetItemByClientId(vals[0], _userManager, _libraryManager);
var item = _dtoService.GetItemByDtoId(vals[0]);
long? positionTicks = null;

View File

@ -12,6 +12,7 @@ using MediaBrowser.Common.Net;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
@ -32,6 +33,7 @@ using MediaBrowser.Providers;
using MediaBrowser.Server.Implementations;
using MediaBrowser.Server.Implementations.BdInfo;
using MediaBrowser.Server.Implementations.Configuration;
using MediaBrowser.Server.Implementations.Dto;
using MediaBrowser.Server.Implementations.HttpServer;
using MediaBrowser.Server.Implementations.IO;
using MediaBrowser.Server.Implementations.Library;
@ -155,6 +157,7 @@ namespace MediaBrowser.ServerApplication
/// </summary>
/// <value>The HTTP server.</value>
private IHttpServer HttpServer { get; set; }
private IDtoService DtoService { get; set; }
/// <summary>
/// Gets or sets the media encoder.
@ -290,6 +293,9 @@ namespace MediaBrowser.ServerApplication
LocalizationManager = new LocalizationManager(ServerConfigurationManager);
RegisterSingleInstance(LocalizationManager);
DtoService = new DtoService(Logger, LibraryManager, UserManager, UserDataRepository, ItemRepository);
RegisterSingleInstance(DtoService);
var displayPreferencesTask = Task.Run(async () => await ConfigureDisplayPreferencesRepositories().ConfigureAwait(false));
var itemsTask = Task.Run(async () => await ConfigureItemRepositories().ConfigureAwait(false));
var userdataTask = Task.Run(async () => await ConfigureUserDataRepositories().ConfigureAwait(false));
@ -309,7 +315,7 @@ namespace MediaBrowser.ServerApplication
ServerKernel.ImageManager = new ImageManager(LogManager.GetLogger("ImageManager"),
ApplicationPaths, ItemRepository);
Parallel.Invoke(
() => ServerKernel.FFMpegManager = new FFMpegManager(ApplicationPaths, MediaEncoder, LibraryManager, Logger, ItemRepository),
() => ServerKernel.FFMpegManager = new FFMpegManager(ApplicationPaths, MediaEncoder, Logger, ItemRepository),
() => ServerKernel.ImageManager.ImageEnhancers = GetExports<IImageEnhancer>().OrderBy(e => e.Priority).ToArray(),
() => LocalizedStrings.StringFiles = GetExports<LocalizedStringData>(),
SetStaticProperties
@ -322,7 +328,7 @@ namespace MediaBrowser.ServerApplication
var connection = await ConnectToDb(dbFile).ConfigureAwait(false);
var repo = new SqliteUserRepository(connection, ApplicationPaths, JsonSerializer, LogManager);
var repo = new SqliteUserRepository(connection, JsonSerializer, LogManager);
repo.Initialize();

View File

@ -1,7 +1,7 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Common.ScheduledTasks;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Logging;
using System.Threading.Tasks;
@ -31,6 +31,7 @@ namespace MediaBrowser.WebDashboard.Api
private readonly ITaskManager _taskManager;
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="DashboardInfoWebSocketListener" /> class.
@ -39,12 +40,13 @@ namespace MediaBrowser.WebDashboard.Api
/// <param name="logger">The logger.</param>
/// <param name="taskManager">The task manager.</param>
/// <param name="sessionManager">The session manager.</param>
public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, ISessionManager sessionManager)
public DashboardInfoWebSocketListener(IServerApplicationHost appHost, ILogger logger, ITaskManager taskManager, ISessionManager sessionManager, IDtoService dtoService)
: base(logger)
{
_appHost = appHost;
_taskManager = taskManager;
_sessionManager = sessionManager;
_dtoService = dtoService;
}
/// <summary>
@ -54,7 +56,7 @@ namespace MediaBrowser.WebDashboard.Api
/// <returns>Task{IEnumerable{TaskInfo}}.</returns>
protected override Task<DashboardInfo> GetDataToSend(object state)
{
return Task.FromResult(DashboardService.GetDashboardInfo(_appHost, _taskManager, _sessionManager));
return Task.FromResult(DashboardService.GetDashboardInfo(_appHost, _taskManager, _sessionManager, _dtoService));
}
}
}

View File

@ -117,6 +117,7 @@ namespace MediaBrowser.WebDashboard.Api
private readonly IServerConfigurationManager _serverConfigurationManager;
private readonly ISessionManager _sessionManager;
private readonly IDtoService _dtoService;
/// <summary>
/// Initializes a new instance of the <see cref="DashboardService" /> class.
@ -125,12 +126,13 @@ namespace MediaBrowser.WebDashboard.Api
/// <param name="appHost">The app host.</param>
/// <param name="serverConfigurationManager">The server configuration manager.</param>
/// <param name="sessionManager">The session manager.</param>
public DashboardService(ITaskManager taskManager, IServerApplicationHost appHost, IServerConfigurationManager serverConfigurationManager, ISessionManager sessionManager)
public DashboardService(ITaskManager taskManager, IServerApplicationHost appHost, IServerConfigurationManager serverConfigurationManager, ISessionManager sessionManager, IDtoService dtoService)
{
_taskManager = taskManager;
_appHost = appHost;
_serverConfigurationManager = serverConfigurationManager;
_sessionManager = sessionManager;
_dtoService = dtoService;
}
/// <summary>
@ -169,7 +171,7 @@ namespace MediaBrowser.WebDashboard.Api
/// <returns>System.Object.</returns>
public object Get(GetDashboardInfo request)
{
var result = GetDashboardInfo(_appHost, _taskManager, _sessionManager);
var result = GetDashboardInfo(_appHost, _taskManager, _sessionManager, _dtoService);
return ResultFactory.GetOptimizedResult(RequestContext, result);
}
@ -183,7 +185,7 @@ namespace MediaBrowser.WebDashboard.Api
/// <returns>DashboardInfo.</returns>
public static DashboardInfo GetDashboardInfo(IServerApplicationHost appHost,
ITaskManager taskManager,
ISessionManager connectionManager)
ISessionManager connectionManager, IDtoService dtoService)
{
var connections = connectionManager.Sessions.Where(i => i.IsActive).ToArray();
@ -197,7 +199,7 @@ namespace MediaBrowser.WebDashboard.Api
ApplicationUpdateTaskId = taskManager.ScheduledTasks.First(t => t.ScheduledTask.GetType().Name.Equals("SystemUpdateTask", StringComparison.OrdinalIgnoreCase)).Id,
ActiveConnections = connections.Select(SessionInfoDtoBuilder.GetSessionInfoDto).ToArray()
ActiveConnections = connections.Select(dtoService.GetSessionInfoDto).ToArray()
};
}