Removed guids from the model project

This commit is contained in:
Luke Pulverenti
2014-05-08 16:09:53 -04:00
parent 374dd8d441
commit f02c326027
72 changed files with 380 additions and 503 deletions

View File

@@ -4,6 +4,7 @@ using MediaBrowser.Common.Implementations.Configuration;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;

View File

@@ -649,7 +649,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
/// <param name="image">The image.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public Guid GetImageCacheTag(IHasImages item, ItemImageInfo image)
public string GetImageCacheTag(IHasImages item, ItemImageInfo image)
{
if (item == null)
{
@@ -676,7 +676,7 @@ namespace MediaBrowser.Server.Implementations.Drawing
/// <param name="imageEnhancers">The image enhancers.</param>
/// <returns>Guid.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public Guid GetImageCacheTag(IHasImages item, ImageType imageType, string originalImagePath, DateTime dateModified, List<IImageEnhancer> imageEnhancers)
public string GetImageCacheTag(IHasImages item, ImageType imageType, string originalImagePath, DateTime dateModified, List<IImageEnhancer> imageEnhancers)
{
if (item == null)
{
@@ -696,14 +696,14 @@ namespace MediaBrowser.Server.Implementations.Drawing
// Optimization
if (imageEnhancers.Count == 0)
{
return (originalImagePath + dateModified.Ticks).GetMD5();
return (originalImagePath + dateModified.Ticks).GetMD5().ToString("N");
}
// Cache name is created with supported enhancers combined with the last config change so we pick up new config changes
var cacheKeys = imageEnhancers.Select(i => i.GetConfigurationCacheKey(item, imageType)).ToList();
cacheKeys.Add(originalImagePath + dateModified.Ticks);
return string.Join("|", cacheKeys.ToArray()).GetMD5();
return string.Join("|", cacheKeys.ToArray()).GetMD5().ToString("N");
}
/// <summary>

View File

@@ -326,7 +326,7 @@ namespace MediaBrowser.Server.Implementations.Dto
/// </summary>
/// <param name="item">The item.</param>
/// <returns>List{System.String}.</returns>
private List<Guid> GetBackdropImageTags(BaseItem item)
private List<string> GetBackdropImageTags(BaseItem item)
{
return GetCacheTags(item, ImageType.Backdrop).ToList();
}
@@ -336,26 +336,25 @@ namespace MediaBrowser.Server.Implementations.Dto
/// </summary>
/// <param name="item">The item.</param>
/// <returns>List{Guid}.</returns>
private List<Guid> GetScreenshotImageTags(BaseItem item)
private List<string> GetScreenshotImageTags(BaseItem item)
{
var hasScreenshots = item as IHasScreenshots;
if (hasScreenshots == null)
{
return new List<Guid>();
return new List<string>();
}
return GetCacheTags(item, ImageType.Screenshot).ToList();
}
private IEnumerable<Guid> GetCacheTags(BaseItem item, ImageType type)
private IEnumerable<string> GetCacheTags(BaseItem item, ImageType type)
{
return item.GetImages(type)
.Select(p => GetImageCacheTag(item, p))
.Where(i => i.HasValue)
.Select(i => i.Value)
.Where(i => i != null)
.ToList();
}
private Guid? GetImageCacheTag(BaseItem item, ImageType type)
private string GetImageCacheTag(BaseItem item, ImageType type)
{
try
{
@@ -368,7 +367,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
}
private Guid? GetImageCacheTag(BaseItem item, ItemImageInfo image)
private string GetImageCacheTag(BaseItem item, ItemImageInfo image)
{
try
{
@@ -677,7 +676,7 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.Genres = item.Genres;
}
dto.ImageTags = new Dictionary<ImageType, Guid>();
dto.ImageTags = new Dictionary<ImageType, string>();
// Prevent implicitly captured closure
var currentItem = item;
@@ -685,9 +684,9 @@ namespace MediaBrowser.Server.Implementations.Dto
{
var tag = GetImageCacheTag(item, image);
if (tag.HasValue)
if (tag != null)
{
dto.ImageTags[image.Type] = tag.Value;
dto.ImageTags[image.Type] = tag;
}
}
@@ -1216,7 +1215,7 @@ namespace MediaBrowser.Server.Implementations.Dto
}
}
var bitrate = i.TotalBitrate ??
var bitrate = i.TotalBitrate ??
info.MediaStreams.Where(m => m.Type != MediaStreamType.Subtitle && !string.Equals(m.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase))
.Select(m => m.BitRate ?? 0)
.Sum();

View File

@@ -252,15 +252,15 @@ namespace MediaBrowser.Server.Implementations.EntryPoints
return new LibraryUpdateInfo
{
ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(),
ItemsAdded = itemsAdded.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(),
ItemsUpdated = itemsUpdated.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren, true)).Select(i => i.Id).Distinct().ToList(),
ItemsRemoved = itemsRemoved.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren, true)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList(),
FoldersAddedTo = foldersAddedTo.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id.ToString("N")).Distinct().ToList(),
FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id).Distinct().ToList()
FoldersRemovedFrom = foldersRemovedFrom.SelectMany(i => TranslatePhysicalItemToUserLibrary(i, user, collections, allRecursiveChildren)).Select(i => i.Id.ToString("N")).Distinct().ToList()
};
}

View File

@@ -11,6 +11,7 @@ using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Configuration;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Notifications;
using MediaBrowser.Model.Tasks;

View File

@@ -9,6 +9,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Controller.Session;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Tasks;
using System;
using System.Threading;

View File

@@ -5,6 +5,7 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Events;
using MediaBrowser.Model.Logging;
using System;
using System.Collections.Generic;

View File

@@ -241,9 +241,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var imageTag = GetImageTag(recording);
if (imageTag.HasValue)
if (imageTag != null)
{
dto.ImageTags[ImageType.Primary] = imageTag.Value;
dto.ImageTags[ImageType.Primary] = imageTag;
}
if (user != null)
@@ -328,9 +328,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var imageTag = GetImageTag(info);
if (imageTag.HasValue)
if (imageTag != null)
{
dto.ImageTags[ImageType.Primary] = imageTag.Value;
dto.ImageTags[ImageType.Primary] = imageTag;
}
if (currentProgram != null)
@@ -389,9 +389,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv
var imageTag = GetImageTag(item);
if (imageTag.HasValue)
if (imageTag != null)
{
dto.ImageTags[ImageType.Primary] = imageTag.Value;
dto.ImageTags[ImageType.Primary] = imageTag;
}
if (user != null)
@@ -404,7 +404,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
return dto;
}
private Guid? GetImageTag(IHasImages info)
private string GetImageTag(IHasImages info)
{
try
{

View File

@@ -111,7 +111,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
throw new ArgumentNullException("displayPreferences");
}
if (displayPreferences.Id == Guid.Empty)
if (string.IsNullOrWhiteSpace(displayPreferences.Id))
{
throw new ArgumentNullException("displayPreferences.Id");
}
@@ -132,7 +132,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
cmd.CommandText = "replace into userdisplaypreferences (id, userid, client, data) values (@1, @2, @3, @4)";
cmd.Parameters.Add(cmd, "@1", DbType.Guid).Value = displayPreferences.Id;
cmd.Parameters.Add(cmd, "@1", DbType.Guid).Value = new Guid(displayPreferences.Id);
cmd.Parameters.Add(cmd, "@2", DbType.Guid).Value = userId;
cmd.Parameters.Add(cmd, "@3", DbType.String).Value = client;
cmd.Parameters.Add(cmd, "@4", DbType.Binary).Value = serialized;
@@ -183,9 +183,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
/// <param name="client">The client.</param>
/// <returns>Task{DisplayPreferences}.</returns>
/// <exception cref="System.ArgumentNullException">item</exception>
public DisplayPreferences GetDisplayPreferences(Guid displayPreferencesId, Guid userId, string client)
public DisplayPreferences GetDisplayPreferences(string displayPreferencesId, Guid userId, string client)
{
if (displayPreferencesId == Guid.Empty)
if (string.IsNullOrWhiteSpace(displayPreferencesId))
{
throw new ArgumentNullException("displayPreferencesId");
}
@@ -193,7 +193,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
var cmd = _connection.CreateCommand();
cmd.CommandText = "select data from userdisplaypreferences where id = @id and userId=@userId and client=@client";
cmd.Parameters.Add(cmd, "@id", DbType.Guid).Value = displayPreferencesId;
cmd.Parameters.Add(cmd, "@id", DbType.Guid).Value = new Guid(displayPreferencesId);
cmd.Parameters.Add(cmd, "@userId", DbType.Guid).Value = userId;
cmd.Parameters.Add(cmd, "@client", DbType.String).Value = client;
@@ -208,7 +208,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
}
return new DisplayPreferences { Id = displayPreferencesId };
return null;
}
/// <summary>

View File

@@ -56,16 +56,6 @@ namespace MediaBrowser.Server.Implementations.Roku
return Task.FromResult(true);
}
public Task SendMessageCommand(MessageCommand command, CancellationToken cancellationToken)
{
return SendCommand(new WebSocketMessage<MessageCommand>
{
MessageType = "MessageCommand",
Data = command
}, cancellationToken);
}
public Task SendPlayCommand(PlayRequest command, CancellationToken cancellationToken)
{
return SendCommand(new WebSocketMessage<PlayRequest>

View File

@@ -1,4 +1,5 @@
using MediaBrowser.Common.Events;
using System.Globalization;
using MediaBrowser.Common.Events;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Drawing;
@@ -712,12 +713,20 @@ namespace MediaBrowser.Server.Implementations.Session
public Task SendMessageCommand(string controllingSessionId, string sessionId, MessageCommand command, CancellationToken cancellationToken)
{
var session = GetSessionForRemoteControl(sessionId);
var generalCommand = new GeneralCommand
{
Name = GeneralCommandType.DisplayMessage.ToString()
};
var controllingSession = GetSession(controllingSessionId);
AssertCanControl(session, controllingSession);
generalCommand.Arguments["Header"] = command.Header;
generalCommand.Arguments["Text"] = command.Text;
return session.SessionController.SendMessageCommand(command, cancellationToken);
if (command.TimeoutMs.HasValue)
{
generalCommand.Arguments["TimeoutMs"] = command.TimeoutMs.Value.ToString(CultureInfo.InvariantCulture);
}
return SendGeneralCommand(controllingSessionId, sessionId, generalCommand, cancellationToken);
}
public Task SendGeneralCommand(string controllingSessionId, string sessionId, GeneralCommand command, CancellationToken cancellationToken)
@@ -1199,7 +1208,7 @@ namespace MediaBrowser.Server.Implementations.Session
};
info.PrimaryImageTag = GetImageCacheTag(item, ImageType.Primary);
if (info.PrimaryImageTag.HasValue)
if (info.PrimaryImageTag != null)
{
info.PrimaryImageItemId = GetDtoId(item);
}
@@ -1237,14 +1246,14 @@ namespace MediaBrowser.Server.Implementations.Session
info.Album = audio.Album;
info.Artists = audio.Artists;
if (!info.PrimaryImageTag.HasValue)
if (info.PrimaryImageTag == null)
{
var album = audio.Parents.OfType<MusicAlbum>().FirstOrDefault();
if (album != null && album.HasImage(ImageType.Primary))
{
info.PrimaryImageTag = GetImageCacheTag(album, ImageType.Primary);
if (info.PrimaryImageTag.HasValue)
if (info.PrimaryImageTag != null)
{
info.PrimaryImageItemId = GetDtoId(album);
}
@@ -1345,7 +1354,7 @@ namespace MediaBrowser.Server.Implementations.Session
return info;
}
private Guid? GetImageCacheTag(BaseItem item, ImageType type)
private string GetImageCacheTag(BaseItem item, ImageType type)
{
try
{

View File

@@ -57,18 +57,6 @@ namespace MediaBrowser.Server.Implementations.Session
return socket;
}
public Task SendMessageCommand(MessageCommand command, CancellationToken cancellationToken)
{
var socket = GetActiveSocket();
return socket.SendAsync(new WebSocketMessage<MessageCommand>
{
MessageType = "MessageCommand",
Data = command
}, cancellationToken);
}
public Task SendPlayCommand(PlayRequest command, CancellationToken cancellationToken)
{
var socket = GetActiveSocket();