// = "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
// = "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, TimeBase TEXT NULL, CodecTimeBase TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
public UserItemData GetUserData(Guid userId, string key)
// public UserItemData GetUserData(Guid userId, string key)
{
// {
if (userId == Guid.Empty)
// if (userId == Guid.Empty)
{
// {
throw new ArgumentNullException("userId");
// throw new ArgumentNullException("userId");
}
// }
if (string.IsNullOrEmpty(key))
// if (string.IsNullOrEmpty(key))
{
// {
throw new ArgumentNullException("key");
// throw new ArgumentNullException("key");
}
// }
var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = ? and userId=?";
// var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = ? and userId=?";
var paramList = new List<object>();
// var paramList = new List<object>();
paramList.Add(key);
// paramList.Add(key);
paramList.Add(userId.ToGuidParamValue());
// paramList.Add(userId.ToGuidParamValue());
foreach (var row in _connection.Query(commandText, paramList.ToArray()))
// foreach (var row in _connection.Query(commandText, paramList.ToArray()))
{
// {
return ReadRow(row);
// return ReadRow(row);
}
// }
return null;
// return null;
}
// }
public UserItemData GetUserData(Guid userId, List<string> keys)
// public UserItemData GetUserData(Guid userId, List<string> keys)
{
// {
if (userId == Guid.Empty)
// if (userId == Guid.Empty)
{
// {
throw new ArgumentNullException("userId");
// throw new ArgumentNullException("userId");
}
// }
if (keys == null)
// if (keys == null)
{
// {
throw new ArgumentNullException("keys");
// throw new ArgumentNullException("keys");
}
// }
if (keys.Count == 0)
// if (keys.Count == 0)
{
// {
return null;
// return null;
}
// }
return GetUserData(userId, keys[0]);
// return GetUserData(userId, keys[0]);
}
// }
/// <summary>
// /// <summary>
/// Return all user-data associated with the given user
// /// Return all user-data associated with the given user
/// </summary>
// /// </summary>
/// <param name="userId"></param>
// /// <param name="userId"></param>
/// <returns></returns>
// /// <returns></returns>
public IEnumerable<UserItemData> GetAllUserData(Guid userId)
// public IEnumerable<UserItemData> GetAllUserData(Guid userId)
{
// {
if (userId == Guid.Empty)
// if (userId == Guid.Empty)
{
// {
throw new ArgumentNullException("userId");
// throw new ArgumentNullException("userId");
}
// }
var list = new List<UserItemData>();
// var list = new List<UserItemData>();
using (WriteLock.Read())
// using (WriteLock.Read())
{
// {
var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=?";
// var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=?";
var paramList = new List<object>();
// var paramList = new List<object>();
paramList.Add(userId.ToGuidParamValue());
// paramList.Add(userId.ToGuidParamValue());
foreach (var row in _connection.Query(commandText, paramList.ToArray()))
// foreach (var row in _connection.Query(commandText, paramList.ToArray()))
{
// {
list.Add(ReadRow(row));
// list.Add(ReadRow(row));
}
// }
}
// }
return list;
// return list;
}
// }
/// <summary>
// /// <summary>
/// Read a row from the specified reader into the provided userData object
// /// Read a row from the specified reader into the provided userData object