fix ExternalId being lost

This commit is contained in:
Luke Pulverenti 2016-11-17 01:54:24 -05:00
parent 827665390d
commit 1adfbfadf1
4 changed files with 57 additions and 35 deletions

View File

@ -25,6 +25,11 @@ namespace Emby.Server.Core.Data
return (IDataParameter)cmd.Parameters[index];
}
public static IDataParameter GetParameter(this IDbCommand cmd, string name)
{
return (IDataParameter)cmd.Parameters[name];
}
public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name, DbType type)
{
var param = cmd.CreateParameter();

View File

@ -810,7 +810,15 @@ namespace Emby.Server.Core.Data
_saveItemCommand.GetParameter(index++).Value = item.ParentId;
}
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());
if (item.Genres.Count > 0)
{
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Genres.ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
}
_saveItemCommand.GetParameter(index++).Value = item.GetInheritedParentalRatingValue() ?? 0;
_saveItemCommand.GetParameter(index++).Value = LatestSchemaVersion;
@ -852,8 +860,23 @@ namespace Emby.Server.Core.Data
}
_saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder;
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());
if (item.LockedFields.Count > 0)
{
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
}
if (item.Studios.Count > 0)
{
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
}
if (item.Audio.HasValue)
{
@ -1043,31 +1066,27 @@ namespace Emby.Server.Core.Data
_saveItemCommand.GetParameter(index++).Value = item.TotalBitrate;
_saveItemCommand.GetParameter(index++).Value = item.ExtraType;
string artists = null;
var hasArtists = item as IHasArtist;
if (hasArtists != null)
{
if (hasArtists.Artists.Count > 0)
{
_saveItemCommand.GetParameter(index++).Value = string.Join("|", hasArtists.Artists.ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
artists = string.Join("|", hasArtists.Artists.ToArray());
}
}
_saveItemCommand.GetParameter(index++).Value = artists;
string albumArtists = null;
var hasAlbumArtists = item as IHasAlbumArtist;
if (hasAlbumArtists != null)
{
if (hasAlbumArtists.AlbumArtists.Count > 0)
{
_saveItemCommand.GetParameter(index++).Value = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
albumArtists = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());
}
}
_saveItemCommand.GetParameter(index++).Value = albumArtists;
_saveItemCommand.GetParameter(index++).Value = item.ExternalId;

View File

@ -260,16 +260,16 @@ namespace Emby.Server.Core.Notifications
{
transaction = connection.BeginTransaction();
replaceNotificationCommand.GetParameter(0).Value = new Guid(notification.Id);
replaceNotificationCommand.GetParameter(1).Value = new Guid(notification.UserId);
replaceNotificationCommand.GetParameter(2).Value = notification.Date.ToUniversalTime();
replaceNotificationCommand.GetParameter(3).Value = notification.Name;
replaceNotificationCommand.GetParameter(4).Value = notification.Description;
replaceNotificationCommand.GetParameter(5).Value = notification.Url;
replaceNotificationCommand.GetParameter(6).Value = notification.Level.ToString();
replaceNotificationCommand.GetParameter(7).Value = notification.IsRead;
replaceNotificationCommand.GetParameter(8).Value = string.Empty;
replaceNotificationCommand.GetParameter(9).Value = string.Empty;
replaceNotificationCommand.GetParameter("@Id").Value = new Guid(notification.Id);
replaceNotificationCommand.GetParameter("@UserId").Value = new Guid(notification.UserId);
replaceNotificationCommand.GetParameter("@Date").Value = notification.Date.ToUniversalTime();
replaceNotificationCommand.GetParameter("@Name").Value = notification.Name;
replaceNotificationCommand.GetParameter("@Description").Value = notification.Description;
replaceNotificationCommand.GetParameter("@Url").Value = notification.Url;
replaceNotificationCommand.GetParameter("@Level").Value = notification.Level.ToString();
replaceNotificationCommand.GetParameter("@IsRead").Value = notification.IsRead;
replaceNotificationCommand.GetParameter("@Category").Value = string.Empty;
replaceNotificationCommand.GetParameter("@RelatedId").Value = string.Empty;
replaceNotificationCommand.Transaction = transaction;

View File

@ -80,18 +80,16 @@ namespace Emby.Server.Core.Security
{
transaction = connection.BeginTransaction();
var index = 0;
saveInfoCommand.GetParameter(index++).Value = new Guid(info.Id);
saveInfoCommand.GetParameter(index++).Value = info.AccessToken;
saveInfoCommand.GetParameter(index++).Value = info.DeviceId;
saveInfoCommand.GetParameter(index++).Value = info.AppName;
saveInfoCommand.GetParameter(index++).Value = info.AppVersion;
saveInfoCommand.GetParameter(index++).Value = info.DeviceName;
saveInfoCommand.GetParameter(index++).Value = info.UserId;
saveInfoCommand.GetParameter(index++).Value = info.IsActive;
saveInfoCommand.GetParameter(index++).Value = info.DateCreated;
saveInfoCommand.GetParameter(index++).Value = info.DateRevoked;
saveInfoCommand.GetParameter("@Id").Value = new Guid(info.Id);
saveInfoCommand.GetParameter("@AccessToken").Value = info.AccessToken;
saveInfoCommand.GetParameter("@DeviceId").Value = info.DeviceId;
saveInfoCommand.GetParameter("@AppName").Value = info.AppName;
saveInfoCommand.GetParameter("@AppVersion").Value = info.AppVersion;
saveInfoCommand.GetParameter("@DeviceName").Value = info.DeviceName;
saveInfoCommand.GetParameter("@UserId").Value = info.UserId;
saveInfoCommand.GetParameter("@IsActive").Value = info.IsActive;
saveInfoCommand.GetParameter("@DateCreated").Value = info.DateCreated;
saveInfoCommand.GetParameter("@DateRevoked").Value = info.DateRevoked;
saveInfoCommand.Transaction = transaction;