2013-05-09 22:43:11 +00:00
|
|
|
|
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,
|
2013-08-28 14:00:51 +00:00
|
|
|
|
Id = session.Id.ToString("N"),
|
2013-05-09 22:43:11 +00:00
|
|
|
|
LastActivityDate = session.LastActivityDate,
|
2013-05-10 12:18:07 +00:00
|
|
|
|
NowPlayingPositionTicks = session.NowPlayingPositionTicks,
|
|
|
|
|
SupportsRemoteControl = session.SupportsRemoteControl,
|
|
|
|
|
IsPaused = session.IsPaused,
|
|
|
|
|
NowViewingContext = session.NowViewingContext,
|
2013-05-22 03:59:55 +00:00
|
|
|
|
NowViewingItemId = session.NowViewingItemId,
|
|
|
|
|
NowViewingItemName = session.NowViewingItemName,
|
2013-07-09 16:11:16 +00:00
|
|
|
|
NowViewingItemType = session.NowViewingItemType,
|
|
|
|
|
ApplicationVersion = session.ApplicationVersion
|
2013-05-09 22:43:11 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (session.NowPlayingItem != null)
|
|
|
|
|
{
|
|
|
|
|
dto.NowPlayingItem = DtoBuilder.GetBaseItemInfo(session.NowPlayingItem);
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-30 22:22:15 +00:00
|
|
|
|
if (session.User != null)
|
2013-05-09 22:43:11 +00:00
|
|
|
|
{
|
2013-05-30 22:22:15 +00:00
|
|
|
|
dto.UserId = session.User.Id.ToString("N");
|
|
|
|
|
dto.UserName = session.User.Name;
|
2013-05-09 22:43:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dto;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|