diff --git a/src/NzbDrone.Core/Books/Calibre/CalibreSettings.cs b/src/NzbDrone.Core/Books/Calibre/CalibreSettings.cs index f90e8006d..6a53f85ca 100644 --- a/src/NzbDrone.Core/Books/Calibre/CalibreSettings.cs +++ b/src/NzbDrone.Core/Books/Calibre/CalibreSettings.cs @@ -2,8 +2,7 @@ using System; using System.Linq; using FluentValidation; using NzbDrone.Common.Extensions; -using NzbDrone.Core.Annotations; -using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Validation; namespace NzbDrone.Core.Books.Calibre @@ -23,7 +22,7 @@ namespace NzbDrone.Core.Books.Calibre } } - public class CalibreSettings : IProviderConfig + public class CalibreSettings : IEmbeddedDocument { private static readonly CalibreSettingsValidator Validator = new CalibreSettingsValidator(); @@ -32,28 +31,13 @@ namespace NzbDrone.Core.Books.Calibre Port = 8080; } - [FieldDefinition(0, Label = "Host", Type = FieldType.Textbox)] public string Host { get; set; } - - [FieldDefinition(1, Label = "Port", Type = FieldType.Textbox)] - public int Port { get; set; } - - [FieldDefinition(2, Label = "Url Base", Type = FieldType.Textbox, Advanced = true, HelpText = "Adds a prefix to the calibre url, e.g. http://[host]:[port]/[urlBase]")] + public int Port { get; set; } = 8080; public string UrlBase { get; set; } - - [FieldDefinition(3, Label = "Username", Type = FieldType.Textbox)] public string Username { get; set; } - - [FieldDefinition(4, Label = "Password", Type = FieldType.Password)] public string Password { get; set; } - - [FieldDefinition(5, Label = "Convert to Format", Type = FieldType.Textbox, HelpText = "Optionally ask calibre to convert to other formats on import. Comma separated list.")] public string OutputFormat { get; set; } - - [FieldDefinition(6, Label = "Conversion Profile", Type = FieldType.Select, SelectOptions = typeof(CalibreProfile), HelpText = "The output profile to use for conversion")] public int OutputProfile { get; set; } - - [FieldDefinition(9, Label = "Use SSL", Type = FieldType.Checkbox)] public bool UseSsl { get; set; } public NzbDroneValidationResult Validate() diff --git a/src/NzbDrone.Core/RootFolders/RootFolderRepository.cs b/src/NzbDrone.Core/RootFolders/RootFolderRepository.cs index bac996311..47cc06d55 100644 --- a/src/NzbDrone.Core/RootFolders/RootFolderRepository.cs +++ b/src/NzbDrone.Core/RootFolders/RootFolderRepository.cs @@ -1,9 +1,4 @@ -using System.Collections.Generic; -using System.Text.Json; -using Dapper; -using NzbDrone.Common.Extensions; -using NzbDrone.Core.Books.Calibre; -using NzbDrone.Core.Datastore; +using NzbDrone.Core.Datastore; using NzbDrone.Core.Messaging.Events; namespace NzbDrone.Core.RootFolders @@ -21,37 +16,6 @@ namespace NzbDrone.Core.RootFolders protected override bool PublishModelEvents => true; - protected override List Query(SqlBuilder builder) - { - var type = typeof(RootFolder); - var sql = builder.Select(type).AddSelectTemplate(type); - - var results = new List(); - - using (var conn = _database.OpenConnection()) - using (var reader = conn.ExecuteReader(sql.RawSql, sql.Parameters)) - { - var parser = reader.GetRowParser(type); - var settingsIndex = reader.GetOrdinal(nameof(RootFolder.CalibreSettings)); - var serializerSettings = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; - - while (reader.Read()) - { - var body = reader.IsDBNull(settingsIndex) ? null : reader.GetString(settingsIndex); - var item = parser(reader); - - if (body.IsNotNullOrWhiteSpace()) - { - item.CalibreSettings = JsonSerializer.Deserialize(body, serializerSettings); - } - - results.Add(item); - } - } - - return results; - } - public new void Delete(int id) { var model = Get(id);