@ -35,13 +35,13 @@ namespace MediaBrowser.Server.Implementations.Sync
public async Task Initialize ( )
{
var dbFile = Path . Combine ( _appPaths . DataPath , "sync 4 .db") ;
var dbFile = Path . Combine ( _appPaths . DataPath , "sync 5 .db") ;
_connection = await SqliteExtensions . ConnectToDb ( dbFile , _logger ) . ConfigureAwait ( false ) ;
string [ ] queries = {
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, UnwatchedOnly BIT, ItemLimit INT, RemoveWhenWatched BIT, 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, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, 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, JobId TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT)" ,
@ -65,7 +65,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_deleteJobCommand . Parameters . Add ( _deleteJobCommand , "@Id" ) ;
_saveJobCommand = _connection . CreateCommand ( ) ;
_saveJobCommand . CommandText = "replace into SyncJobs (Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, UnwatchedOnly, ItemLimit, RemoveWhenWatched, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Quality, @Status, @Progress, @UserId, @ItemIds, @UnwatchedOnly, @ItemLimit, @RemoveWhenWatched , @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_saveJobCommand . CommandText = "replace into SyncJobs (Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount) values (@Id, @TargetId, @Name, @Quality, @Status, @Progress, @UserId, @ItemIds, @UnwatchedOnly, @ItemLimit, @SyncNewContent, @DateCreated, @DateLastModified, @ItemCount)";
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@Id" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@TargetId" ) ;
@ -77,7 +77,6 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@ItemIds" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@UnwatchedOnly" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@ItemLimit" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@RemoveWhenWatched" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@SyncNewContent" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@DateCreated" ) ;
_saveJobCommand . Parameters . Add ( _saveJobCommand , "@DateLastModified" ) ;
@ -96,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobItemCommand . Parameters . Add ( _saveJobCommand , "@Progress" ) ;
}
private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, UnwatchedOnly, ItemLimit, RemoveWhenWatched, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobItemSelectText = "select Id, ItemId, JobId, OutputPath, Status, TargetId, DateCreated, Progress from SyncJobItems" ;
public SyncJob GetJob ( string id )
@ -175,12 +174,11 @@ namespace MediaBrowser.Server.Implementations.Sync
info . ItemLimit = reader . GetInt32 ( 9 ) ;
}
info . RemoveWhenWatched = reader . GetBoolean ( 10 ) ;
info . SyncNewContent = reader . GetBoolean ( 11 ) ;
info . SyncNewContent = reader . GetBoolean ( 10 ) ;
info . DateCreated = reader . GetDateTime ( 1 2 ) . ToUniversalTime ( ) ;
info . DateLastModified = reader . GetDateTime ( 1 3 ) . ToUniversalTime ( ) ;
info . ItemCount = reader . GetInt32 ( 1 4 ) ;
info . DateCreated = reader . GetDateTime ( 1 1 ) . ToUniversalTime ( ) ;
info . DateLastModified = reader . GetDateTime ( 1 2 ) . ToUniversalTime ( ) ;
info . ItemCount = reader . GetInt32 ( 1 3 ) ;
return info ;
}
@ -217,7 +215,6 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobCommand . GetParameter ( index + + ) . Value = string . Join ( "," , job . RequestedItemIds . ToArray ( ) ) ;
_saveJobCommand . GetParameter ( index + + ) . Value = job . UnwatchedOnly ;
_saveJobCommand . GetParameter ( index + + ) . Value = job . ItemLimit ;
_saveJobCommand . GetParameter ( index + + ) . Value = job . RemoveWhenWatched ;
_saveJobCommand . GetParameter ( index + + ) . Value = job . SyncNewContent ;
_saveJobCommand . GetParameter ( index + + ) . Value = job . DateCreated ;
_saveJobCommand . GetParameter ( index + + ) . Value = job . DateLastModified ;