Пример #1
0
        private void RefreshMusicGenreLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Refresh : MusicGenres");
            var res = _remote.AudioLibrary.GetGenres();
            Logger.Instance().Log("FrontView+","Remote MusicGenres : " + res.Count);
            var oldData = _database.GetAudioGenreFavorites(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteAudioGenre(_remoteInfo.Id);
            foreach (var apiMusicGenre in res)
            {
                long oldFavorite = 0;
                foreach (var ogenre in oldData)
                {
                    if (ogenre.IdGenre == apiMusicGenre.IdGenre)
                        oldFavorite = ogenre.IsFavorite;
                }
                var musicGenre = new Yatse2AudioGenre(apiMusicGenre) { IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite };
                _database.InsertAudioGenre(musicGenre);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+","End Refresh : MusicGenres");
        }
Пример #2
0
        public long InsertAudioGenre(Yatse2AudioGenre audioGenre)
        {
            if (audioGenre == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `AudioGenres` ( IdRemote ,Name,IdGenre,Thumb,Fanart,AlbumCount, IsFavorite ) 
                  VALUES (?, ? ,? ,? ,? ,? ,?);";
            sqlCmd.Parameters.AddWithValue("a1", audioGenre.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", audioGenre.Name);
            sqlCmd.Parameters.AddWithValue("a3", audioGenre.IdGenre);
            sqlCmd.Parameters.AddWithValue("a4", audioGenre.Thumb);
            sqlCmd.Parameters.AddWithValue("a5", audioGenre.Fanart);
            sqlCmd.Parameters.AddWithValue("a6", audioGenre.AlbumCount);
            sqlCmd.Parameters.AddWithValue("a7", audioGenre.IsFavorite);

            return QueryInsert(sqlCmd);
        }
Пример #3
0
        public bool UpdateAudioGenre(Yatse2AudioGenre audioGenre)
        {
            if (audioGenre == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `AudioGenres` SET IdRemote = ? ,Name = ? ,IdGenre = ? ,Thumb = ? ,Fanart = ? ,AlbumCount = ? , IsFavorite = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", audioGenre.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", audioGenre.Name);
            sqlCmd.Parameters.AddWithValue("a3", audioGenre.IdGenre);
            sqlCmd.Parameters.AddWithValue("a4", audioGenre.Thumb);
            sqlCmd.Parameters.AddWithValue("a5", audioGenre.Fanart);
            sqlCmd.Parameters.AddWithValue("a6", audioGenre.AlbumCount);
            sqlCmd.Parameters.AddWithValue("a7", audioGenre.IsFavorite);
            sqlCmd.Parameters.AddWithValue("@Id", audioGenre.Id);

            return Query(sqlCmd);
        }
Пример #4
0
 private Collection<Yatse2AudioGenre> QueryAudioGenre(SQLiteCommand query)
 {
     var audiogenres = new Collection<Yatse2AudioGenre>();
     if (!_connected) return audiogenres;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var audioGenre = new Yatse2AudioGenre
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 Name = GetString(sqldReader, "Name"),
                 IdGenre = GetLong(sqldReader, "IdGenre"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Fanart"),
                 AlbumCount = GetLong(sqldReader, "AlbumCount"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite")
             };
             audiogenres.Add(audioGenre);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return audiogenres;
 }