Ejemplo n.º 1
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "users.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists users (guid GUID primary key, data BLOB)",
                "create index if not exists idx_users on users(guid)",
                "create table if not exists schema_version (table_name primary key, version)",
                //pragmas
                "pragma temp_store = memory"
            };

            _connection.RunQueries(queries, _logger);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "userdata_v2.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists userdata (key nvarchar, userId GUID, rating float null, played bit, playCount int, isFavorite bit, playbackPositionTicks bigint, lastPlayedDate datetime null)",

                "create unique index if not exists userdataindex on userdata (key, userId)",

                //pragmas
                "pragma temp_store = memory"
            };

            _connection.RunQueries(queries, _logger);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists userdisplaypreferences (id GUID, userId GUID, client text, data BLOB)",
                "create unique index if not exists userdisplaypreferencesindex on userdisplaypreferences (id, userId, client)",

                //pragmas
                "pragma temp_store = memory",

                "pragma shrink_memory"
            };

            _connection.RunQueries(queries, Logger);
        }
Ejemplo n.º 4
0
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "notifications.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists Notifications (Id GUID NOT NULL, UserId GUID NOT NULL, Date DATETIME NOT NULL, Name TEXT NOT NULL, Description TEXT, Url TEXT, Level TEXT NOT NULL, IsRead BOOLEAN NOT NULL, Category TEXT NOT NULL, RelatedId TEXT, PRIMARY KEY (Id, UserId))",
                "create index if not exists idx_Notifications on Notifications(Id, UserId)",

                //pragmas
                "pragma temp_store = memory"
            };

            _connection.RunQueries(queries, _logger);

            PrepareStatements();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "library.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists TypedBaseItems (guid GUID primary key, type TEXT, data BLOB)",
                "create index if not exists idx_TypedBaseItems on TypedBaseItems(guid)",

                "create table if not exists ChildrenIds (ParentId GUID, ItemId GUID, PRIMARY KEY (ParentId, ItemId))",
                "create index if not exists idx_ChildrenIds on ChildrenIds(ParentId,ItemId)",

                //pragmas
                "pragma temp_store = memory",

                "pragma shrink_memory"
            };

            _connection.RunQueries(queries, _logger);

            _connection.AddColumn(_logger, "TypedBaseItems", "Path", "Text");
            _connection.AddColumn(_logger, "TypedBaseItems", "StartDate", "DATETIME");
            _connection.AddColumn(_logger, "TypedBaseItems", "EndDate", "DATETIME");
            _connection.AddColumn(_logger, "TypedBaseItems", "ChannelId", "Text");
            _connection.AddColumn(_logger, "TypedBaseItems", "IsMovie", "BIT");
            _connection.AddColumn(_logger, "TypedBaseItems", "IsSports", "BIT");
            _connection.AddColumn(_logger, "TypedBaseItems", "IsKids", "BIT");
            _connection.AddColumn(_logger, "TypedBaseItems", "CommunityRating", "Float");
            _connection.AddColumn(_logger, "TypedBaseItems", "CustomRating", "Text");
            _connection.AddColumn(_logger, "TypedBaseItems", "IndexNumber", "INT");
            _connection.AddColumn(_logger, "TypedBaseItems", "IsLocked", "BIT");
            _connection.AddColumn(_logger, "TypedBaseItems", "Name", "Text");
            _connection.AddColumn(_logger, "TypedBaseItems", "OfficialRating", "Text");

            PrepareStatements();

            _mediaStreamsRepository.Initialize();
            _chapterRepository.Initialize();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "fileorganization.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists FileOrganizerResults (ResultId GUID PRIMARY KEY, OriginalPath TEXT, TargetPath TEXT, FileLength INT, OrganizationDate datetime, Status TEXT, OrganizationType TEXT, StatusMessage TEXT, ExtractedName TEXT, ExtractedYear int null, ExtractedSeasonNumber int null, ExtractedEpisodeNumber int null, ExtractedEndingEpisodeNumber, DuplicatePaths TEXT int null)",
                "create index if not exists idx_FileOrganizerResults on FileOrganizerResults(ResultId)",

                //pragmas
                "pragma temp_store = memory",

                "pragma shrink_memory"
            };

            _connection.RunQueries(queries, Logger);

            PrepareStatements();
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "refreshinfo.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile, Logger).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists MetadataStatus (ItemId GUID PRIMARY KEY, ItemName TEXT, ItemType TEXT, SeriesName TEXT, DateLastMetadataRefresh datetime, DateLastImagesRefresh datetime, LastStatus TEXT, LastErrorMessage TEXT, MetadataProvidersRefreshed TEXT, ImageProvidersRefreshed TEXT, ItemDateModified DateTimeNull)",
                "create index if not exists idx_MetadataStatus on MetadataStatus(ItemId)",

                //pragmas
                "pragma temp_store = memory",

                "pragma shrink_memory"
            };

            _connection.RunQueries(queries, Logger);

            AddItemDateModifiedCommand();

            PrepareStatements();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
        /// </summary>
        /// <param name="appPaths">The app paths.</param>
        /// <param name="jsonSerializer">The json serializer.</param>
        /// <param name="logManager">The log manager.</param>
        /// <exception cref="System.ArgumentNullException">
        /// appPaths
        /// or
        /// jsonSerializer
        /// </exception>
        public SqliteItemRepository(IApplicationPaths appPaths, IJsonSerializer jsonSerializer, ILogManager logManager)
        {
            if (appPaths == null)
            {
                throw new ArgumentNullException("appPaths");
            }
            if (jsonSerializer == null)
            {
                throw new ArgumentNullException("jsonSerializer");
            }

            _appPaths       = appPaths;
            _jsonSerializer = jsonSerializer;

            _criticReviewsPath = Path.Combine(_appPaths.DataPath, "critic-reviews");

            _logger = logManager.GetLogger(GetType().Name);

            var chapterDbFile = Path.Combine(_appPaths.DataPath, "chapters.db");

            var chapterConnection = SqliteExtensions.ConnectToDb(chapterDbFile).Result;

            _chapterRepository = new SqliteChapterRepository(chapterConnection, logManager);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Opens the connection to the database
        /// </summary>
        /// <returns>Task.</returns>
        public async Task Initialize()
        {
            var dbFile = Path.Combine(_appPaths.DataPath, "library.db");

            _connection = await SqliteExtensions.ConnectToDb(dbFile).ConfigureAwait(false);

            string[] queries =
            {
                "create table if not exists TypedBaseItems (guid GUID primary key, type TEXT, data BLOB)",
                "create index if not exists idx_TypedBaseItems on TypedBaseItems(guid)",

                "create table if not exists ChildrenIds (ParentId GUID, ItemId GUID, PRIMARY KEY (ParentId, ItemId))",
                "create index if not exists idx_ChildrenIds on ChildrenIds(ParentId,ItemId)",

                //pragmas
                "pragma temp_store = memory"
            };

            _connection.RunQueries(queries, _logger);

            PrepareStatements();

            _chapterRepository.Initialize();
        }