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]; 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) public static IDataParameter Add(this IDataParameterCollection paramCollection, IDbCommand cmd, string name, DbType type)
{ {
var param = cmd.CreateParameter(); 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 = 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 = item.GetInheritedParentalRatingValue() ?? 0;
_saveItemCommand.GetParameter(index++).Value = LatestSchemaVersion; _saveItemCommand.GetParameter(index++).Value = LatestSchemaVersion;
@ -852,8 +860,23 @@ namespace Emby.Server.Core.Data
} }
_saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder; _saveItemCommand.GetParameter(index++).Value = item.IsInMixedFolder;
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.LockedFields.Select(i => i.ToString()).ToArray()); if (item.LockedFields.Count > 0)
_saveItemCommand.GetParameter(index++).Value = string.Join("|", item.Studios.ToArray()); {
_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) if (item.Audio.HasValue)
{ {
@ -1043,31 +1066,27 @@ namespace Emby.Server.Core.Data
_saveItemCommand.GetParameter(index++).Value = item.TotalBitrate; _saveItemCommand.GetParameter(index++).Value = item.TotalBitrate;
_saveItemCommand.GetParameter(index++).Value = item.ExtraType; _saveItemCommand.GetParameter(index++).Value = item.ExtraType;
string artists = null;
var hasArtists = item as IHasArtist; var hasArtists = item as IHasArtist;
if (hasArtists != null) if (hasArtists != null)
{ {
if (hasArtists.Artists.Count > 0) if (hasArtists.Artists.Count > 0)
{ {
_saveItemCommand.GetParameter(index++).Value = string.Join("|", hasArtists.Artists.ToArray()); artists = string.Join("|", hasArtists.Artists.ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
} }
} }
_saveItemCommand.GetParameter(index++).Value = artists;
string albumArtists = null;
var hasAlbumArtists = item as IHasAlbumArtist; var hasAlbumArtists = item as IHasAlbumArtist;
if (hasAlbumArtists != null) if (hasAlbumArtists != null)
{ {
if (hasAlbumArtists.AlbumArtists.Count > 0) if (hasAlbumArtists.AlbumArtists.Count > 0)
{ {
_saveItemCommand.GetParameter(index++).Value = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray()); albumArtists = string.Join("|", hasAlbumArtists.AlbumArtists.ToArray());
}
else
{
_saveItemCommand.GetParameter(index++).Value = null;
} }
} }
_saveItemCommand.GetParameter(index++).Value = albumArtists;
_saveItemCommand.GetParameter(index++).Value = item.ExternalId; _saveItemCommand.GetParameter(index++).Value = item.ExternalId;

View file

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

View file

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