update extension
This commit is contained in:
parent
64d15be839
commit
a385ab5142
|
@ -173,6 +173,15 @@ namespace Emby.Server.Implementations.Data
|
|||
return result[index].ReadGuid();
|
||||
}
|
||||
|
||||
public static void TryBind(this IReadOnlyDictionary<string, IBindParameter> bindParameters, string name, double value)
|
||||
{
|
||||
IBindParameter bindParam;
|
||||
if (bindParameters.TryGetValue(name, out bindParam))
|
||||
{
|
||||
bindParam.Bind(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void TryBind(this IReadOnlyDictionary<string, IBindParameter> bindParameters, string name, string value)
|
||||
{
|
||||
IBindParameter bindParam;
|
||||
|
@ -191,6 +200,24 @@ namespace Emby.Server.Implementations.Data
|
|||
}
|
||||
}
|
||||
|
||||
public static void TryBind(this IReadOnlyDictionary<string, IBindParameter> bindParameters, string name, int value)
|
||||
{
|
||||
IBindParameter bindParam;
|
||||
if (bindParameters.TryGetValue(name, out bindParam))
|
||||
{
|
||||
bindParam.Bind(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void TryBind(this IReadOnlyDictionary<string, IBindParameter> bindParameters, string name, long value)
|
||||
{
|
||||
IBindParameter bindParam;
|
||||
if (bindParameters.TryGetValue(name, out bindParam))
|
||||
{
|
||||
bindParam.Bind(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void TryBind(this IReadOnlyDictionary<string, IBindParameter> bindParameters, string name, byte[] value)
|
||||
{
|
||||
IBindParameter bindParam;
|
||||
|
|
|
@ -150,29 +150,54 @@
|
|||
|
||||
// private void SaveUserData(IDatabaseConnection db, Guid userId, string key, UserItemData userData)
|
||||
// {
|
||||
// var paramList = new List<object>();
|
||||
// var commandText = "replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (?, ?, ?,?,?,?,?,?,?,?)";
|
||||
|
||||
// paramList.Add(key);
|
||||
// paramList.Add(userId.ToGuidParamValue());
|
||||
// paramList.Add(userData.Rating);
|
||||
// paramList.Add(userData.Played);
|
||||
// paramList.Add(userData.PlayCount);
|
||||
// paramList.Add(userData.IsFavorite);
|
||||
// paramList.Add(userData.PlaybackPositionTicks);
|
||||
|
||||
// if (userData.LastPlayedDate.HasValue)
|
||||
// using (var statement = _connection.PrepareStatement("replace into userdata (key, userId, rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex) values (@key, @userId, @rating,@played,@playCount,@isFavorite,@playbackPositionTicks,@lastPlayedDate,@AudioStreamIndex,@SubtitleStreamIndex)"))
|
||||
// {
|
||||
// paramList.Add(userData.LastPlayedDate.Value.ToDateTimeParamValue());
|
||||
// statement.BindParameters.TryBind("@UserId", userId.ToGuidParamValue());
|
||||
// statement.BindParameters.TryBind("@Key", key);
|
||||
|
||||
// if (userData.Rating.HasValue)
|
||||
// {
|
||||
// statement.BindParameters.TryBind("@rating", userData.Rating.Value);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// paramList.Add(null);
|
||||
// statement.BindParameters.TryBindNull("@rating");
|
||||
// }
|
||||
// paramList.Add(userData.AudioStreamIndex);
|
||||
// paramList.Add(userData.SubtitleStreamIndex);
|
||||
|
||||
// db.Execute(commandText, paramList.ToArray());
|
||||
// statement.BindParameters.TryBind("@played", userData.Played);
|
||||
// statement.BindParameters.TryBind("@playCount", userData.PlayCount);
|
||||
// statement.BindParameters.TryBind("@isFavorite", userData.IsFavorite);
|
||||
// statement.BindParameters.TryBind("@playbackPositionTicks", userData.PlaybackPositionTicks);
|
||||
|
||||
// if (userData.LastPlayedDate.HasValue)
|
||||
// {
|
||||
// statement.BindParameters.TryBind("@lastPlayedDate", userData.LastPlayedDate.Value.ToDateTimeParamValue());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// statement.BindParameters.TryBindNull("@lastPlayedDate");
|
||||
// }
|
||||
|
||||
// if (userData.AudioStreamIndex.HasValue)
|
||||
// {
|
||||
// statement.BindParameters.TryBind("@AudioStreamIndex", userData.AudioStreamIndex.Value);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// statement.BindParameters.TryBindNull("@AudioStreamIndex");
|
||||
// }
|
||||
|
||||
// if (userData.SubtitleStreamIndex.HasValue)
|
||||
// {
|
||||
// statement.BindParameters.TryBind("@SubtitleStreamIndex", userData.SubtitleStreamIndex.Value);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// statement.BindParameters.TryBindNull("@SubtitleStreamIndex");
|
||||
// }
|
||||
|
||||
// statement.MoveNext();
|
||||
// }
|
||||
// }
|
||||
|
||||
// /// <summary>
|
||||
|
@ -216,16 +241,16 @@
|
|||
// throw new ArgumentNullException("key");
|
||||
// }
|
||||
|
||||
// var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key = ? and userId=?";
|
||||
// using (var statement = _connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where key =@Key and userId=@UserId"))
|
||||
// {
|
||||
// statement.BindParameters.TryBind("@UserId", userId.ToGuidParamValue());
|
||||
// statement.BindParameters.TryBind("@Key", key);
|
||||
|
||||
// var paramList = new List<object>();
|
||||
// paramList.Add(key);
|
||||
// paramList.Add(userId.ToGuidParamValue());
|
||||
|
||||
// foreach (var row in _connection.Query(commandText, paramList.ToArray()))
|
||||
// foreach (var row in statement.ExecuteQuery())
|
||||
// {
|
||||
// return ReadRow(row);
|
||||
// }
|
||||
// }
|
||||
|
||||
// return null;
|
||||
// }
|
||||
|
@ -265,16 +290,16 @@
|
|||
|
||||
// using (WriteLock.Read())
|
||||
// {
|
||||
// var commandText = "select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=?";
|
||||
// using (var statement = _connection.PrepareStatement("select key,userid,rating,played,playCount,isFavorite,playbackPositionTicks,lastPlayedDate,AudioStreamIndex,SubtitleStreamIndex from userdata where userId=@UserId"))
|
||||
// {
|
||||
// statement.BindParameters.TryBind("@UserId", userId.ToGuidParamValue());
|
||||
|
||||
// var paramList = new List<object>();
|
||||
// paramList.Add(userId.ToGuidParamValue());
|
||||
|
||||
// foreach (var row in _connection.Query(commandText, paramList.ToArray()))
|
||||
// foreach (var row in statement.ExecuteQuery())
|
||||
// {
|
||||
// list.Add(ReadRow(row));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// return list;
|
||||
// }
|
||||
|
|
Loading…
Reference in New Issue
Block a user