예제 #1
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);

            PrepareStatements();

            _mediaStreamsRepository.Initialize();
            _chapterRepository.Initialize();

            _shrinkMemoryTimer = new SqliteShrinkMemoryTimer(_connection, _writeLock, _logger);
        }
예제 #2
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)",

                "create table if not exists People (ItemId GUID, Name TEXT NOT NULL, Role TEXT, PersonType TEXT, SortOrder int, ListOrder int)",

                //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");

            _connection.AddColumn(_logger, "TypedBaseItems", "MediaType", "Text");
            _connection.AddColumn(_logger, "TypedBaseItems", "Overview", "Text");
            _connection.AddColumn(_logger, "TypedBaseItems", "ParentIndexNumber", "INT");
            _connection.AddColumn(_logger, "TypedBaseItems", "PremiereDate", "DATETIME");
            _connection.AddColumn(_logger, "TypedBaseItems", "ProductionYear", "INT");
            _connection.AddColumn(_logger, "TypedBaseItems", "ParentId", "GUID");

            PrepareStatements();

            _mediaStreamsRepository.Initialize();
            _chapterRepository.Initialize();
        }