|
|
@ -58,31 +58,37 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
|
|
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (WriteLock.Write())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var paramList = new List<object>();
|
|
|
|
var commandText = "replace into FileOrganizerResults (ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (@ResultId, @OriginalPath, @TargetPath, @FileLength, @OrganizationDate, @Status, @OrganizationType, @StatusMessage, @ExtractedName, @ExtractedYear, @ExtractedSeasonNumber, @ExtractedEpisodeNumber, @ExtractedEndingEpisodeNumber, @DuplicatePaths)";
|
|
|
|
var commandText = "replace into FileOrganizerResults (ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
|
|
|
|
|
|
|
|
|
|
|
using (var statement = db.PrepareStatement(commandText))
|
|
|
|
paramList.Add(result.Id.ToGuidParamValue());
|
|
|
|
{
|
|
|
|
paramList.Add(result.OriginalPath);
|
|
|
|
statement.TryBind("@ResultId", result.Id.ToGuidParamValue());
|
|
|
|
paramList.Add(result.TargetPath);
|
|
|
|
statement.TryBind("@OriginalPath", result.OriginalPath);
|
|
|
|
paramList.Add(result.FileSize);
|
|
|
|
|
|
|
|
paramList.Add(result.Date.ToDateTimeParamValue());
|
|
|
|
statement.TryBind("@TargetPath", result.TargetPath);
|
|
|
|
paramList.Add(result.Status.ToString());
|
|
|
|
statement.TryBind("@FileLength", result.FileSize);
|
|
|
|
paramList.Add(result.Type.ToString());
|
|
|
|
statement.TryBind("@OrganizationDate", result.Date.ToDateTimeParamValue());
|
|
|
|
paramList.Add(result.StatusMessage);
|
|
|
|
statement.TryBind("@Status", result.Status.ToString());
|
|
|
|
paramList.Add(result.ExtractedName);
|
|
|
|
statement.TryBind("@OrganizationType", result.Type.ToString());
|
|
|
|
paramList.Add(result.ExtractedSeasonNumber);
|
|
|
|
statement.TryBind("@StatusMessage", result.StatusMessage);
|
|
|
|
paramList.Add(result.ExtractedEpisodeNumber);
|
|
|
|
statement.TryBind("@ExtractedName", result.ExtractedName);
|
|
|
|
paramList.Add(result.ExtractedEndingEpisodeNumber);
|
|
|
|
statement.TryBind("@ExtractedYear", result.ExtractedYear);
|
|
|
|
paramList.Add(string.Join("|", result.DuplicatePaths.ToArray()));
|
|
|
|
statement.TryBind("@ExtractedSeasonNumber", result.ExtractedSeasonNumber);
|
|
|
|
|
|
|
|
statement.TryBind("@ExtractedEpisodeNumber", result.ExtractedEpisodeNumber);
|
|
|
|
|
|
|
|
statement.TryBind("@ExtractedEndingEpisodeNumber", result.ExtractedEndingEpisodeNumber);
|
|
|
|
db.Execute(commandText, paramList.ToArray());
|
|
|
|
statement.TryBind("@DuplicatePaths", string.Join("|", result.DuplicatePaths.ToArray()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
statement.MoveNext();
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task Delete(string id)
|
|
|
|
public async Task Delete(string id)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -92,22 +98,26 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (WriteLock.Write())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var paramList = new List<object>();
|
|
|
|
using (var statement = db.PrepareStatement("delete from FileOrganizerResults where ResultId = @ResultId"))
|
|
|
|
var commandText = "delete from FileOrganizerResults where ResultId = ?";
|
|
|
|
{
|
|
|
|
|
|
|
|
statement.TryBind("@ResultId", id.ToGuidParamValue());
|
|
|
|
paramList.Add(id.ToGuidParamValue());
|
|
|
|
statement.MoveNext();
|
|
|
|
|
|
|
|
}
|
|
|
|
db.Execute(commandText, paramList.ToArray());
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task DeleteAll()
|
|
|
|
public async Task DeleteAll()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
using (var connection = CreateConnection())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (WriteLock.Write())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
connection.RunInTransaction(db =>
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -117,6 +127,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public QueryResult<FileOrganizationResult> GetResults(FileOrganizationResultQuery query)
|
|
|
|
public QueryResult<FileOrganizationResult> GetResults(FileOrganizationResultQuery query)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -126,6 +137,8 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
using (var connection = CreateConnection(true))
|
|
|
|
using (var connection = CreateConnection(true))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
using (WriteLock.Read())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var commandText = "SELECT ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults";
|
|
|
|
var commandText = "SELECT ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults";
|
|
|
|
|
|
|
|
|
|
|
@ -143,12 +156,20 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var list = new List<FileOrganizationResult>();
|
|
|
|
var list = new List<FileOrganizationResult>();
|
|
|
|
var count = connection.Query("select count (ResultId) from FileOrganizerResults").SelectScalarInt().First();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var row in connection.Query(commandText))
|
|
|
|
using (var statement = connection.PrepareStatement(commandText))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
foreach (var row in statement.ExecuteQuery())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
list.Add(GetResult(row));
|
|
|
|
list.Add(GetResult(row));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int count;
|
|
|
|
|
|
|
|
using (var statement = connection.PrepareStatement("select count (ResultId) from FileOrganizerResults"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
count = statement.ExecuteQuery().SelectScalarInt().First();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new QueryResult<FileOrganizationResult>()
|
|
|
|
return new QueryResult<FileOrganizationResult>()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -157,6 +178,7 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FileOrganizationResult GetResult(string id)
|
|
|
|
public FileOrganizationResult GetResult(string id)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -167,18 +189,23 @@ namespace Emby.Server.Implementations.Data
|
|
|
|
|
|
|
|
|
|
|
|
using (var connection = CreateConnection(true))
|
|
|
|
using (var connection = CreateConnection(true))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var paramList = new List<object>();
|
|
|
|
using (WriteLock.Read())
|
|
|
|
|
|
|
|
{
|
|
|
|
paramList.Add(id.ToGuidParamValue());
|
|
|
|
using (var statement = connection.PrepareStatement("select ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults where ResultId=@ResultId"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
statement.TryBind("@ResultId", id.ToGuidParamValue());
|
|
|
|
|
|
|
|
statement.MoveNext();
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var row in connection.Query("select ResultId, OriginalPath, TargetPath, FileLength, OrganizationDate, Status, OrganizationType, StatusMessage, ExtractedName, ExtractedYear, ExtractedSeasonNumber, ExtractedEpisodeNumber, ExtractedEndingEpisodeNumber, DuplicatePaths from FileOrganizerResults where ResultId=?", paramList.ToArray()))
|
|
|
|
foreach (var row in statement.ExecuteQuery())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return GetResult(row);
|
|
|
|
return GetResult(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public FileOrganizationResult GetResult(IReadOnlyList<IResultSetValue> reader)
|
|
|
|
public FileOrganizationResult GetResult(IReadOnlyList<IResultSetValue> reader)
|
|
|
|
{
|
|
|
|
{
|
|
|
|