@ -1,5 +1,4 @@
using System.Text ;
using MediaBrowser.Controller ;
using MediaBrowser.Controller ;
using MediaBrowser.Controller.Sync ;
using MediaBrowser.Controller.Sync ;
using MediaBrowser.Model.Dto ;
using MediaBrowser.Model.Dto ;
using MediaBrowser.Model.Logging ;
using MediaBrowser.Model.Logging ;
@ -51,7 +50,7 @@ namespace MediaBrowser.Server.Implementations.Sync
string [ ] queries = {
string [ ] queries = {
"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 table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Profile TEXT, Quality TEXT, Bitrate INT, 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 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)" ,
"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)" ,
@ -66,6 +65,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_connection . RunQueries ( queries , _logger ) ;
_connection . RunQueries ( queries , _logger ) ;
_connection . AddColumn ( _logger , "SyncJobs" , "Profile" , "TEXT" ) ;
_connection . AddColumn ( _logger , "SyncJobs" , "Profile" , "TEXT" ) ;
_connection . AddColumn ( _logger , "SyncJobs" , "Bitrate" , "INT" ) ;
PrepareStatements ( ) ;
PrepareStatements ( ) ;
}
}
@ -84,13 +84,14 @@ namespace MediaBrowser.Server.Implementations.Sync
// _insertJobCommand
// _insertJobCommand
_insertJobCommand = _connection . CreateCommand ( ) ;
_insertJobCommand = _connection . CreateCommand ( ) ;
_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 . CommandText = "insert into SyncJobs (Id, TargetId, Name, Profile, Quality, Bitrate, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Profile, @Quality, @Bitrate , @Status, @Progress, @UserId, @ItemIds, @Category, @ParentId, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Id" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Id" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@TargetId" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@TargetId" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Name" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Name" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Profile" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Profile" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Quality" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Quality" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Bitrate" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Status" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Status" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Progress" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@Progress" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@UserId" ) ;
_insertJobCommand . Parameters . Add ( _insertJobCommand , "@UserId" ) ;
@ -106,13 +107,14 @@ namespace MediaBrowser.Server.Implementations.Sync
// _updateJobCommand
// _updateJobCommand
_updateJobCommand = _connection . CreateCommand ( ) ;
_updateJobCommand = _connection . CreateCommand ( ) ;
_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 . CommandText = "update SyncJobs set TargetId=@TargetId,Name=@Name,Profile=@Profile,Quality=@Quality, Bitrate=@Bitrate, 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 , "@Id" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@TargetId" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@TargetId" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Name" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Name" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Profile" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Profile" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Quality" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Quality" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Bitrate" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Status" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Status" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Progress" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@Progress" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@UserId" ) ;
_updateJobCommand . Parameters . Add ( _updateJobCommand , "@UserId" ) ;
@ -167,7 +169,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_updateJobItemCommand . Parameters . Add ( _updateJobItemCommand , "@JobItemIndex" ) ;
_updateJobItemCommand . Parameters . Add ( _updateJobItemCommand , "@JobItemIndex" ) ;
}
}
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 BaseJobSelectText = "select Id, TargetId, Name, Profile, Quality, Bitrate, 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" ;
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 )
public SyncJob GetJob ( string id )
@ -225,49 +227,54 @@ namespace MediaBrowser.Server.Implementations.Sync
if ( ! reader . IsDBNull ( 5 ) )
if ( ! reader . IsDBNull ( 5 ) )
{
{
info . Status = ( SyncJobStatus ) Enum . Parse ( typeof ( SyncJobStatus ) , reader . GetString ( 5 ) , true ) ;
info . Bitrate = reader . GetInt32 ( 5 ) ;
}
}
if ( ! reader . IsDBNull ( 6 ) )
if ( ! reader . IsDBNull ( 6 ) )
{
{
info . Progress = reader . GetDouble ( 6 ) ;
info . Status = ( SyncJobStatus ) Enum . Parse ( typeof ( SyncJobStatus ) , reader . GetString ( 6 ) , true ) ;
}
}
if ( ! reader . IsDBNull ( 7 ) )
if ( ! reader . IsDBNull ( 7 ) )
{
{
info . UserId = reader . GetString ( 7 ) ;
info . Progress = reader . GetDouble ( 7 ) ;
}
}
if ( ! reader . IsDBNull ( 8 ) )
if ( ! reader . IsDBNull ( 8 ) )
{
{
info . RequestedItemIds = reader . GetString ( 8 ) . Split ( new [ ] { ',' } , StringSplitOptions . RemoveEmptyEntries ) . ToList ( ) ;
info . UserId = reader . GetString ( 8 ) ;
}
}
if ( ! reader . IsDBNull ( 9 ) )
if ( ! reader . IsDBNull ( 9 ) )
{
{
info . Category = ( SyncCategory ) Enum . Parse ( typeof ( SyncCategory ) , reader . GetString ( 9 ) , true ) ;
info . RequestedItemIds = reader . GetString ( 9 ) . Split ( new [ ] { ',' } , StringSplitOptions . RemoveEmptyEntries ) . ToList ( ) ;
}
}
if ( ! reader . IsDBNull ( 10 ) )
if ( ! reader . IsDBNull ( 10 ) )
{
{
info . ParentId = reader . GetString ( 10 ) ;
info . Category = ( SyncCategory ) Enum . Parse ( typeof ( SyncCategory ) , reader . GetString ( 10 ) , true ) ;
}
}
if ( ! reader . IsDBNull ( 11 ) )
if ( ! reader . IsDBNull ( 11 ) )
{
{
info . UnwatchedOnly = reader . GetBoolean ( 11 ) ;
info . ParentId = reader . GetString ( 11 ) ;
}
}
if ( ! reader . IsDBNull ( 12 ) )
if ( ! reader . IsDBNull ( 12 ) )
{
{
info . ItemLimit = reader . GetInt32 ( 12 ) ;
info . UnwatchedOnly = reader . GetBoolean ( 12 ) ;
}
}
info . SyncNewContent = reader . GetBoolean ( 13 ) ;
if ( ! reader . IsDBNull ( 13 ) )
{
info . ItemLimit = reader . GetInt32 ( 13 ) ;
}
info . SyncNewContent = reader . GetBoolean ( 14 ) ;
info . DateCreated = reader . GetDateTime ( 14 ) . ToUniversalTime ( ) ;
info . DateCreated = reader . GetDateTime ( 1 5 ) . ToUniversalTime ( ) ;
info . DateLastModified = reader . GetDateTime ( 15 ) . ToUniversalTime ( ) ;
info . DateLastModified = reader . GetDateTime ( 1 6 ) . ToUniversalTime ( ) ;
info . ItemCount = reader . GetInt32 ( 16 ) ;
info . ItemCount = reader . GetInt32 ( 1 7 ) ;
return info ;
return info ;
}
}
@ -306,6 +313,7 @@ namespace MediaBrowser.Server.Implementations.Sync
cmd . GetParameter ( index + + ) . Value = job . Name ;
cmd . GetParameter ( index + + ) . Value = job . Name ;
cmd . GetParameter ( index + + ) . Value = job . Profile ;
cmd . GetParameter ( index + + ) . Value = job . Profile ;
cmd . GetParameter ( index + + ) . Value = job . Quality ;
cmd . GetParameter ( index + + ) . Value = job . Quality ;
cmd . GetParameter ( index + + ) . Value = job . Bitrate ;
cmd . GetParameter ( index + + ) . Value = job . Status . ToString ( ) ;
cmd . GetParameter ( index + + ) . Value = job . Status . ToString ( ) ;
cmd . GetParameter ( index + + ) . Value = job . Progress ;
cmd . GetParameter ( index + + ) . Value = job . Progress ;
cmd . GetParameter ( index + + ) . Value = job . UserId ;
cmd . GetParameter ( index + + ) . Value = job . UserId ;