save appVersion with device record

pull/702/head
Luke Pulverenti 9 years ago
parent cde1df51ec
commit 99c991f001

@ -238,6 +238,10 @@ namespace MediaBrowser.Api.Sync
result.QualityOptions = _syncManager
.GetQualityOptions(request.TargetId)
.ToList();
result.ProfileOptions = _syncManager
.GetProfileOptions(request.TargetId)
.ToList();
}
if (request.Category.HasValue)

@ -25,9 +25,10 @@ namespace MediaBrowser.Controller.Devices
/// <param name="reportedId">The reported identifier.</param>
/// <param name="name">The name.</param>
/// <param name="appName">Name of the application.</param>
/// <param name="appVersion">The application version.</param>
/// <param name="usedByUserId">The used by user identifier.</param>
/// <returns>Task.</returns>
Task<DeviceInfo> RegisterDevice(string reportedId, string name, string appName, string usedByUserId);
Task<DeviceInfo> RegisterDevice(string reportedId, string name, string appName, string appVersion, string usedByUserId);
/// <summary>
/// Saves the capabilities.

@ -28,6 +28,12 @@ namespace MediaBrowser.Controller.Security
/// <value>The name of the application.</value>
public string AppName { get; set; }
/// <summary>
/// Gets or sets the application version.
/// </summary>
/// <value>The application version.</value>
public string AppVersion { get; set; }
/// <summary>
/// Gets or sets the name of the device.
/// </summary>

@ -74,7 +74,7 @@ namespace MediaBrowser.Controller.Session
/// <summary>
/// Logs the user activity.
/// </summary>
/// <param name="clientType">Type of the client.</param>
/// <param name="appName">Type of the client.</param>
/// <param name="appVersion">The app version.</param>
/// <param name="deviceId">The device id.</param>
/// <param name="deviceName">Name of the device.</param>
@ -82,7 +82,7 @@ namespace MediaBrowser.Controller.Session
/// <param name="user">The user.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
Task<SessionInfo> LogSessionActivity(string clientType, string appVersion, string deviceId, string deviceName, string remoteEndPoint, User user);
Task<SessionInfo> LogSessionActivity(string appName, string appVersion, string deviceId, string deviceName, string remoteEndPoint, User user);
/// <summary>
/// Used to report that playback has started for an item

@ -166,5 +166,12 @@ namespace MediaBrowser.Controller.Sync
/// <param name="targetId">The target identifier.</param>
/// <returns>IEnumerable&lt;SyncQualityOption&gt;.</returns>
IEnumerable<SyncQualityOption> GetQualityOptions(string targetId);
/// <summary>
/// Gets the profile options.
/// </summary>
/// <param name="targetId">The target identifier.</param>
/// <returns>IEnumerable&lt;SyncQualityOption&gt;.</returns>
IEnumerable<SyncQualityOption> GetProfileOptions(string targetId);
}
}

@ -46,6 +46,11 @@ namespace MediaBrowser.Model.Devices
/// <value>The name of the application.</value>
public string AppName { get; set; }
/// <summary>
/// Gets or sets the application version.
/// </summary>
/// <value>The application version.</value>
public string AppVersion { get; set; }
/// <summary>
/// Gets or sets the last user identifier.
/// </summary>
/// <value>The last user identifier.</value>

@ -4,5 +4,10 @@
{
public int? GuideDays { get; set; }
public bool EnableMovieProviders { get; set; }
public LiveTvOptions()
{
EnableMovieProviders = true;
}
}
}

@ -19,12 +19,18 @@ namespace MediaBrowser.Model.Sync
/// </summary>
/// <value>The quality options.</value>
public List<SyncQualityOption> QualityOptions { get; set; }
/// <summary>
/// Gets or sets the profile options.
/// </summary>
/// <value>The profile options.</value>
public List<SyncQualityOption> ProfileOptions { get; set; }
public SyncDialogOptions()
{
Targets = new List<SyncTarget>();
Options = new List<SyncJobOption>();
QualityOptions = new List<SyncQualityOption>();
ProfileOptions = new List<SyncQualityOption>();
}
}
}

@ -26,6 +26,11 @@ namespace MediaBrowser.Model.Sync
/// <value>The quality.</value>
public string Quality { get; set; }
/// <summary>
/// Gets or sets the profile.
/// </summary>
/// <value>The profile.</value>
public string Profile { get; set; }
/// <summary>
/// Gets or sets the category.
/// </summary>
/// <value>The category.</value>

@ -44,7 +44,7 @@ namespace MediaBrowser.Server.Implementations.Devices
_logger = logger;
}
public async Task<DeviceInfo> RegisterDevice(string reportedId, string name, string appName, string usedByUserId)
public async Task<DeviceInfo> RegisterDevice(string reportedId, string name, string appName, string appVersion, string usedByUserId)
{
var device = GetDevice(reportedId) ?? new DeviceInfo
{
@ -53,6 +53,7 @@ namespace MediaBrowser.Server.Implementations.Devices
device.ReportedName = name;
device.AppName = appName;
device.AppVersion = appVersion;
if (!string.IsNullOrWhiteSpace(usedByUserId))
{

@ -1,4 +1,5 @@
using MediaBrowser.Model.Logging;
using System.Text;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Serialization;
using System;
using System.Data;
@ -173,5 +174,36 @@ namespace MediaBrowser.Server.Implementations.Persistence
return stream.ToArray();
}
}
public static void AddColumn(this IDbConnection connection, ILogger logger, string table, string columnName, string type)
{
using (var cmd = connection.CreateCommand())
{
cmd.CommandText = "PRAGMA table_info(" + table + ")";
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{
while (reader.Read())
{
if (!reader.IsDBNull(1))
{
var name = reader.GetString(1);
if (string.Equals(name, columnName, StringComparison.OrdinalIgnoreCase))
{
return;
}
}
}
}
}
var builder = new StringBuilder();
builder.AppendLine("alter table " + table);
builder.AppendLine("add column " + columnName + " " + type);
connection.RunQueries(new[] { builder.ToString() }, logger);
}
}
}

@ -37,7 +37,7 @@ namespace MediaBrowser.Server.Implementations.Security
string[] queries = {
"create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
"create table if not exists AccessTokens (Id GUID PRIMARY KEY, AccessToken TEXT NOT NULL, DeviceId TEXT, AppName TEXT, AppVersion TEXT, DeviceName TEXT, UserId TEXT, IsActive BIT, DateCreated DATETIME NOT NULL, DateRevoked DATETIME)",
"create index if not exists idx_AccessTokens on AccessTokens(Id)",
//pragmas
@ -48,18 +48,21 @@ namespace MediaBrowser.Server.Implementations.Security
_connection.RunQueries(queries, _logger);
_connection.AddColumn(_logger, "AccessTokens", "AppVersion", "TEXT");
PrepareStatements();
}
private void PrepareStatements()
{
_saveInfoCommand = _connection.CreateCommand();
_saveInfoCommand.CommandText = "replace into AccessTokens (Id, AccessToken, DeviceId, AppName, DeviceName, UserId, IsActive, DateCreated, DateRevoked) values (@Id, @AccessToken, @DeviceId, @AppName, @DeviceName, @UserId, @IsActive, @DateCreated, @DateRevoked)";
_saveInfoCommand.CommandText = "replace into AccessTokens (Id, AccessToken, DeviceId, AppName, AppVersion, DeviceName, UserId, IsActive, DateCreated, DateRevoked) values (@Id, @AccessToken, @DeviceId, @AppName, @AppVersion, @DeviceName, @UserId, @IsActive, @DateCreated, @DateRevoked)";
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@Id");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@AccessToken");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@DeviceId");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@AppName");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@AppVersion");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@DeviceName");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@UserId");
_saveInfoCommand.Parameters.Add(_saveInfoCommand, "@IsActive");
@ -97,6 +100,7 @@ namespace MediaBrowser.Server.Implementations.Security
_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;
@ -140,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Security
}
}
private const string BaseSelectText = "select Id, AccessToken, DeviceId, AppName, DeviceName, UserId, IsActive, DateCreated, DateRevoked from AccessTokens";
private const string BaseSelectText = "select Id, AccessToken, DeviceId, AppName, AppVersion, DeviceName, UserId, IsActive, DateCreated, DateRevoked from AccessTokens";
public QueryResult<AuthenticationInfo> Get(AuthenticationInfoQuery query)
{
@ -264,8 +268,6 @@ namespace MediaBrowser.Server.Implementations.Security
private AuthenticationInfo Get(IDataReader reader)
{
var s = "select Id, AccessToken, DeviceId, AppName, DeviceName, UserId, IsActive, DateCreated, DateRevoked from AccessTokens";
var info = new AuthenticationInfo
{
Id = reader.GetGuid(0).ToString("N"),
@ -284,20 +286,25 @@ namespace MediaBrowser.Server.Implementations.Security
if (!reader.IsDBNull(4))
{
info.DeviceName = reader.GetString(4);
info.AppVersion = reader.GetString(4);
}
if (!reader.IsDBNull(5))
{
info.UserId = reader.GetString(5);
info.DeviceName = reader.GetString(5);
}
if (!reader.IsDBNull(6))
{
info.UserId = reader.GetString(6);
}
info.IsActive = reader.GetBoolean(6);
info.DateCreated = reader.GetDateTime(7).ToUniversalTime();
info.IsActive = reader.GetBoolean(7);
info.DateCreated = reader.GetDateTime(8).ToUniversalTime();
if (!reader.IsDBNull(8))
if (!reader.IsDBNull(9))
{
info.DateRevoked = reader.GetDateTime(8).ToUniversalTime();
info.DateRevoked = reader.GetDateTime(9).ToUniversalTime();
}
return info;

@ -202,7 +202,7 @@ namespace MediaBrowser.Server.Implementations.Session
/// <summary>
/// Logs the user activity.
/// </summary>
/// <param name="clientType">Type of the client.</param>
/// <param name="appName">Type of the client.</param>
/// <param name="appVersion">The app version.</param>
/// <param name="deviceId">The device id.</param>
/// <param name="deviceName">Name of the device.</param>
@ -211,16 +211,16 @@ namespace MediaBrowser.Server.Implementations.Session
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
/// <exception cref="System.UnauthorizedAccessException"></exception>
public async Task<SessionInfo> LogSessionActivity(string clientType,
public async Task<SessionInfo> LogSessionActivity(string appName,
string appVersion,
string deviceId,
string deviceName,
string remoteEndPoint,
User user)
{
if (string.IsNullOrEmpty(clientType))
if (string.IsNullOrEmpty(appName))
{
throw new ArgumentNullException("clientType");
throw new ArgumentNullException("appName");
}
if (string.IsNullOrEmpty(appVersion))
{
@ -237,7 +237,7 @@ namespace MediaBrowser.Server.Implementations.Session
var activityDate = DateTime.UtcNow;
var session = await GetSessionInfo(clientType, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false);
var session = await GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndPoint, user).ConfigureAwait(false);
session.LastActivityDate = activityDate;
@ -362,24 +362,24 @@ namespace MediaBrowser.Server.Implementations.Session
}
}
private string GetSessionKey(string clientType, string deviceId)
private string GetSessionKey(string appName, string deviceId)
{
return clientType + deviceId;
return appName + deviceId;
}
/// <summary>
/// Gets the connection.
/// </summary>
/// <param name="clientType">Type of the client.</param>
/// <param name="appName">Type of the client.</param>
/// <param name="appVersion">The app version.</param>
/// <param name="deviceId">The device id.</param>
/// <param name="deviceName">Name of the device.</param>
/// <param name="remoteEndPoint">The remote end point.</param>
/// <param name="user">The user.</param>
/// <returns>SessionInfo.</returns>
private async Task<SessionInfo> GetSessionInfo(string clientType, string appVersion, string deviceId, string deviceName, string remoteEndPoint, User user)
private async Task<SessionInfo> GetSessionInfo(string appName, string appVersion, string deviceId, string deviceName, string remoteEndPoint, User user)
{
var key = GetSessionKey(clientType, deviceId);
var key = GetSessionKey(appName, deviceId);
await _sessionLock.WaitAsync(CancellationToken.None).ConfigureAwait(false);
@ -395,7 +395,7 @@ namespace MediaBrowser.Server.Implementations.Session
{
sessionInfo = new SessionInfo
{
Client = clientType,
Client = appName,
DeviceId = deviceId,
ApplicationVersion = appVersion,
Id = key.GetMD5().ToString("N")
@ -413,7 +413,7 @@ namespace MediaBrowser.Server.Implementations.Session
if (!string.IsNullOrEmpty(deviceId))
{
var userIdString = userId.HasValue ? userId.Value.ToString("N") : null;
device = await _deviceManager.RegisterDevice(deviceId, deviceName, clientType, userIdString).ConfigureAwait(false);
device = await _deviceManager.RegisterDevice(deviceId, deviceName, appName, appVersion, userIdString).ConfigureAwait(false);
}
}
@ -1651,10 +1651,11 @@ namespace MediaBrowser.Server.Implementations.Session
: _userManager.GetUserById(info.UserId);
appVersion = string.IsNullOrWhiteSpace(appVersion)
? "1"
? info.AppVersion
: appVersion;
var deviceName = info.DeviceName;
var appName = info.AppName;
if (!string.IsNullOrWhiteSpace(deviceId))
{
@ -1663,6 +1664,12 @@ namespace MediaBrowser.Server.Implementations.Session
if (device != null)
{
deviceName = device.Name;
appName = device.AppName;
if (!string.IsNullOrWhiteSpace(device.AppVersion))
{
appVersion = device.AppVersion;
}
}
}
else
@ -1670,7 +1677,7 @@ namespace MediaBrowser.Server.Implementations.Session
deviceId = info.DeviceId;
}
return GetSessionInfo(info.AppName, appVersion, deviceId, deviceName, remoteEndpoint, user);
return GetSessionInfo(appName, appVersion, deviceId, deviceName, remoteEndpoint, user);
}
public Task<SessionInfo> GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint)

@ -32,12 +32,12 @@ namespace MediaBrowser.Server.Implementations.Sync
});
}
public DeviceProfile GetDeviceProfile(SyncTarget target, string quality)
public DeviceProfile GetDeviceProfile(SyncTarget target, string profile, string quality)
{
var caps = _deviceManager.GetCapabilities(target.Id);
var profile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
var maxBitrate = profile.MaxStaticBitrate;
var deviceProfile = caps == null || caps.DeviceProfile == null ? new DeviceProfile() : caps.DeviceProfile;
var maxBitrate = deviceProfile.MaxStaticBitrate;
if (maxBitrate.HasValue)
{
@ -50,10 +50,10 @@ namespace MediaBrowser.Server.Implementations.Sync
maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);
}
profile.MaxStaticBitrate = maxBitrate;
deviceProfile.MaxStaticBitrate = maxBitrate;
}
return profile;
return deviceProfile;
}
public string Name
@ -101,5 +101,10 @@ namespace MediaBrowser.Server.Implementations.Sync
}
};
}
public IEnumerable<SyncQualityOption> GetProfileOptions(SyncTarget target)
{
return new List<SyncQualityOption>();
}
}
}

@ -10,9 +10,10 @@ namespace MediaBrowser.Server.Implementations.Sync
/// Gets the device profile.
/// </summary>
/// <param name="target">The target.</param>
/// <param name="profile">The profile.</param>
/// <param name="quality">The quality.</param>
/// <returns>DeviceProfile.</returns>
DeviceProfile GetDeviceProfile(SyncTarget target, string quality);
DeviceProfile GetDeviceProfile(SyncTarget target, string profile, string quality);
/// <summary>
/// Gets the quality options.
@ -20,5 +21,12 @@ namespace MediaBrowser.Server.Implementations.Sync
/// <param name="target">The target.</param>
/// <returns>IEnumerable&lt;SyncQualityOption&gt;.</returns>
IEnumerable<SyncQualityOption> GetQualityOptions(SyncTarget target);
/// <summary>
/// Gets the profile options.
/// </summary>
/// <param name="target">The target.</param>
/// <returns>IEnumerable&lt;SyncQualityOption&gt;.</returns>
IEnumerable<SyncQualityOption> GetProfileOptions(SyncTarget target);
}
}

@ -982,7 +982,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public AudioOptions GetAudioOptions(SyncJobItem jobItem, SyncJob job)
{
var profile = GetDeviceProfile(jobItem.TargetId, null);
var profile = GetDeviceProfile(jobItem.TargetId, null, null);
return new AudioOptions
{
@ -992,7 +992,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public VideoOptions GetVideoOptions(SyncJobItem jobItem, SyncJob job)
{
var profile = GetDeviceProfile(jobItem.TargetId, job.Quality);
var profile = GetDeviceProfile(jobItem.TargetId, job.Profile, job.Quality);
return new VideoOptions
{
@ -1000,7 +1000,7 @@ namespace MediaBrowser.Server.Implementations.Sync
};
}
public DeviceProfile GetDeviceProfile(string targetId, string quality)
private DeviceProfile GetDeviceProfile(string targetId, string profile, string quality)
{
foreach (var provider in _providers)
{
@ -1008,7 +1008,7 @@ namespace MediaBrowser.Server.Implementations.Sync
{
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
{
return GetDeviceProfile(provider, target, quality);
return GetDeviceProfile(provider, target, profile, quality);
}
}
}
@ -1016,22 +1016,22 @@ namespace MediaBrowser.Server.Implementations.Sync
return null;
}
private DeviceProfile GetDeviceProfile(ISyncProvider provider, SyncTarget target, string quality)
private DeviceProfile GetDeviceProfile(ISyncProvider provider, SyncTarget target, string profile, string quality)
{
var hasProfile = provider as IHasSyncQuality;
if (hasProfile != null)
{
return hasProfile.GetDeviceProfile(target, quality);
return hasProfile.GetDeviceProfile(target, profile, quality);
}
return GetDefaultProfile(quality);
return GetDeviceProfile(profile, quality);
}
private DeviceProfile GetDefaultProfile(string quality)
private DeviceProfile GetDeviceProfile(string profile, string quality)
{
var profile = new CloudSyncProfile(true, false);
var maxBitrate = profile.MaxStaticBitrate;
var deviceProfile = new CloudSyncProfile(true, false);
var maxBitrate = deviceProfile.MaxStaticBitrate;
if (maxBitrate.HasValue)
{
@ -1044,10 +1044,10 @@ namespace MediaBrowser.Server.Implementations.Sync
maxBitrate = Convert.ToInt32(maxBitrate.Value * .5);
}
profile.MaxStaticBitrate = maxBitrate;
deviceProfile.MaxStaticBitrate = maxBitrate;
}
return profile;
return deviceProfile;
}
public IEnumerable<SyncQualityOption> GetQualityOptions(string targetId)
@ -1100,5 +1100,40 @@ namespace MediaBrowser.Server.Implementations.Sync
}
};
}
public IEnumerable<SyncQualityOption> GetProfileOptions(string targetId)
{
foreach (var provider in _providers)
{
foreach (var target in GetSyncTargets(provider))
{
if (string.Equals(target.Id, targetId, StringComparison.OrdinalIgnoreCase))
{
return GetProfileOptions(provider, target);
}
}
}
return new List<SyncQualityOption>();
}
private IEnumerable<SyncQualityOption> GetProfileOptions(ISyncProvider provider, SyncTarget target)
{
var hasQuality = provider as IHasSyncQuality;
if (hasQuality != null)
{
return hasQuality.GetProfileOptions(target);
}
var list = new List<SyncQualityOption>();
list.Add(new SyncQualityOption
{
Name = SyncQuality.Low.ToString(),
Id = SyncQuality.Low.ToString()
});
return list;
}
}
}

@ -1,4 +1,5 @@
using MediaBrowser.Controller;
using System.Text;
using MediaBrowser.Controller;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Logging;
@ -50,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.Sync
string[] queries = {
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT)",
@ -64,6 +65,8 @@ namespace MediaBrowser.Server.Implementations.Sync
_connection.RunQueries(queries, _logger);
_connection.AddColumn(_logger, "SyncJobs", "Profile", "TEXT");
PrepareStatements();
}
@ -81,11 +84,12 @@ namespace MediaBrowser.Server.Implementations.Sync
// _insertJobCommand
_insertJobCommand = _connection.CreateCommand();
_insertJobCommand.CommandText = "insert into SyncJobs (Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Quality, @Status, @Progress, @UserId, @ItemIds, @Category, @ParentId, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_insertJobCommand.CommandText = "insert into SyncJobs (Id, TargetId, Name, Profile, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Profile, @Quality, @Status, @Progress, @UserId, @ItemIds, @Category, @ParentId, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_insertJobCommand.Parameters.Add(_insertJobCommand, "@Id");
_insertJobCommand.Parameters.Add(_insertJobCommand, "@TargetId");
_insertJobCommand.Parameters.Add(_insertJobCommand, "@Name");
_insertJobCommand.Parameters.Add(_insertJobCommand, "@Profile");
_insertJobCommand.Parameters.Add(_insertJobCommand, "@Quality");
_insertJobCommand.Parameters.Add(_insertJobCommand, "@Status");
_insertJobCommand.Parameters.Add(_insertJobCommand, "@Progress");
@ -102,11 +106,12 @@ namespace MediaBrowser.Server.Implementations.Sync
// _updateJobCommand
_updateJobCommand = _connection.CreateCommand();
_updateJobCommand.CommandText = "update SyncJobs set TargetId=@TargetId,Name=@Name,Quality=@Quality,Status=@Status,Progress=@Progress,UserId=@UserId,ItemIds=@ItemIds,Category=@Category,ParentId=@ParentId,UnwatchedOnly=@UnwatchedOnly,ItemLimit=@ItemLimit,SyncNewContent=@SyncNewContent,DateCreated=@DateCreated,DateLastModified=@DateLastModified,ItemCount=@ItemCount where Id=@ID";
_updateJobCommand.CommandText = "update SyncJobs set TargetId=@TargetId,Name=@Name,Profile=@Profile,Quality=@Quality,Status=@Status,Progress=@Progress,UserId=@UserId,ItemIds=@ItemIds,Category=@Category,ParentId=@ParentId,UnwatchedOnly=@UnwatchedOnly,ItemLimit=@ItemLimit,SyncNewContent=@SyncNewContent,DateCreated=@DateCreated,DateLastModified=@DateLastModified,ItemCount=@ItemCount where Id=@ID";
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Id");
_updateJobCommand.Parameters.Add(_updateJobCommand, "@TargetId");
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Name");
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Profile");
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Quality");
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Status");
_updateJobCommand.Parameters.Add(_updateJobCommand, "@Progress");
@ -162,7 +167,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_updateJobItemCommand.Parameters.Add(_updateJobItemCommand, "@JobItemIndex");
}
private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobSelectText = "select Id, TargetId, Name, Profile, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobItemSelectText = "select Id, ItemId, ItemName, MediaSourceId, JobId, TemporaryPath, OutputPath, Status, TargetId, DateCreated, Progress, AdditionalFiles, MediaSource, IsMarkedForRemoval, JobItemIndex from SyncJobItems";
public SyncJob GetJob(string id)
@ -210,54 +215,59 @@ namespace MediaBrowser.Server.Implementations.Sync
if (!reader.IsDBNull(3))
{
info.Quality = reader.GetString(3);
info.Profile = reader.GetString(3);
}
if (!reader.IsDBNull(4))
{
info.Status = (SyncJobStatus)Enum.Parse(typeof(SyncJobStatus), reader.GetString(4), true);
info.Quality = reader.GetString(4);
}
if (!reader.IsDBNull(5))
{
info.Progress = reader.GetDouble(5);
info.Status = (SyncJobStatus)Enum.Parse(typeof(SyncJobStatus), reader.GetString(5), true);
}
if (!reader.IsDBNull(6))
{
info.UserId = reader.GetString(6);
info.Progress = reader.GetDouble(6);
}
if (!reader.IsDBNull(7))
{
info.RequestedItemIds = reader.GetString(7).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
info.UserId = reader.GetString(7);
}
if (!reader.IsDBNull(8))
{
info.Category = (SyncCategory)Enum.Parse(typeof(SyncCategory), reader.GetString(8), true);
info.RequestedItemIds = reader.GetString(8).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
}
if (!reader.IsDBNull(9))
{
info.ParentId = reader.GetString(9);
info.Category = (SyncCategory)Enum.Parse(typeof(SyncCategory), reader.GetString(9), true);
}
if (!reader.IsDBNull(10))
{
info.UnwatchedOnly = reader.GetBoolean(10);
info.ParentId = reader.GetString(10);
}
if (!reader.IsDBNull(11))
{
info.ItemLimit = reader.GetInt32(11);
info.UnwatchedOnly = reader.GetBoolean(11);
}
if (!reader.IsDBNull(12))
{
info.ItemLimit = reader.GetInt32(12);
}
info.SyncNewContent = reader.GetBoolean(12);
info.SyncNewContent = reader.GetBoolean(13);
info.DateCreated = reader.GetDateTime(13).ToUniversalTime();
info.DateLastModified = reader.GetDateTime(14).ToUniversalTime();
info.ItemCount = reader.GetInt32(15);
info.DateCreated = reader.GetDateTime(14).ToUniversalTime();
info.DateLastModified = reader.GetDateTime(15).ToUniversalTime();
info.ItemCount = reader.GetInt32(16);
return info;
}
@ -294,6 +304,7 @@ namespace MediaBrowser.Server.Implementations.Sync
cmd.GetParameter(index++).Value = new Guid(job.Id);
cmd.GetParameter(index++).Value = job.TargetId;
cmd.GetParameter(index++).Value = job.Name;
cmd.GetParameter(index++).Value = job.Profile;
cmd.GetParameter(index++).Value = job.Quality;
cmd.GetParameter(index++).Value = job.Status.ToString();
cmd.GetParameter(index++).Value = job.Progress;

Loading…
Cancel
Save