Beispiel #1
0
        public SQLiteCollectionManager(SQLiteConnection connection, ICollectionImageHandler imageHandler)
        {
            this.connection   = connection;
            this.ImageHandler = imageHandler;

            this.bsonWriterSettings = new BsonBinaryWriterSettings()
            {
                MaxDocumentSize = 24 * 1024 * 1024
            };
            this.bsonReaderSettings = new BsonBinaryReaderSettings()
            {
                MaxDocumentSize = this.bsonWriterSettings.MaxDocumentSize
            };

            this.Operations = new CollectionManagerOperations(this);

            this.loadSettings             = this.connection.CreateCommand();
            this.loadSettings.CommandText = "SELECT * FROM settings;";

            this.saveSettings             = this.connection.CreateCommand();
            this.saveSettings.CommandText = "DELETE FROM settings; INSERT INTO settings (bson) VALUES (@bson);";
            this.saveSettings.Parameters.Add("bson", DbType.Binary);

            this.loadTrackCaches             = this.connection.CreateCommand();
            this.loadTrackCaches.CommandText = "SELECT * FROM track_info_caches;";

            this.saveTrackCache             = this.connection.CreateCommand();
            this.saveTrackCache.CommandText = "INSERT INTO track_info_caches (bson) VALUES (@bson);";
            this.saveTrackCache.Parameters.Add("bson", DbType.Binary);

            this.loadReleases             = this.connection.CreateCommand();
            this.loadReleases.CommandText = "SELECT * FROM releases;";

            this.countReleases             = this.connection.CreateCommand();
            this.countReleases.CommandText = "SELECT COUNT(*) FROM releases;";

            this.loadReleaseById             = this.connection.CreateCommand();
            this.loadReleaseById.CommandText = "SELECT * FROM releases WHERE id = @id;";
            this.loadReleaseById.Parameters.Add("id", DbType.Int64);

            this.saveRelease             = this.connection.CreateCommand();
            this.saveRelease.CommandText = "INSERT INTO releases (bson) VALUES (@bson);";
            this.saveRelease.Parameters.Add("bson", DbType.Binary);

            this.updateRelease             = this.connection.CreateCommand();
            this.updateRelease.CommandText = "UPDATE releases SET bson = @bson WHERE id = @id;";
            this.updateRelease.Parameters.Add("id", DbType.Int64);
            this.updateRelease.Parameters.Add("bson", DbType.Binary);

            this.deleteRelease             = this.connection.CreateCommand();
            this.deleteRelease.CommandText = "DELETE FROM releases WHERE id = @id;";
            this.deleteRelease.Parameters.Add("id", DbType.Int64);

            this.ReloadSettings();
        }
        public MongoCollectionManager(MongoDatabase database, ICollectionImageHandler imageHandler)
        {
            this.database = database;
            this.releasesCollection = this.database.GetCollection<Release>(ReleasesCollectionName);
            this.settingsCollection = this.database.GetCollection<CollectionSettings>(SettingsCollectionName);
            this.trackInfosCollection = this.database.GetCollection<TrackInfoCache>(TrackInfosCollectionName);

            this.ImageHandler = imageHandler;
            this.Operations = new CollectionManagerOperations(this);

            this.artistCache = new Dictionary<string, Artist>();
            this.ReloadSettings();
        }
 public MemoryCollectionManager(ICollectionImageHandler imageHandler)
 {
     this.ImageHandler = imageHandler;
     this.Operations   = new CollectionManagerOperations(this);
     this.Settings     = new CollectionSettings();
 }