private void RefreshMusicArtistsLibrary()
        {
            Logger.Instance().Log("Yatse2","Start Refresh : MusicArtists");
            var res = _remote.AudioLibrary.GetArtists();
            Logger.Instance().Log("Yatse2","Remote MusicArtists : " + res.Count);

            var oldData = _database.GetAudioArtistFavorites(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteAudioArtist(_remoteInfo.Id);
            foreach (var apiMusicArtist in res)
            {
                long oldFavorite = 0;
                foreach (var oartist in oldData)
                {
                    if (oartist.IdArtist == apiMusicArtist.IdArtist)
                        oldFavorite = oartist.IsFavorite;
                }
                var musicArtist = new Yatse2AudioArtist(apiMusicArtist) { IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite };
                _database.InsertAudioArtist(musicArtist);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("Yatse2","End Refresh : MusicArtists");
        }
Exemple #2
0
 private Collection<Yatse2AudioArtist> QueryAudioArtist(SQLiteCommand query)
 {
     var audioartists = new Collection<Yatse2AudioArtist>();
     if (!_connected) return audioartists;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var audioArtist = new Yatse2AudioArtist
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 IdArtist = GetLong(sqldReader, "IdArtist"),
                 Name = GetString(sqldReader, "Name"),
                 Biography = GetString(sqldReader, "Biography"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Fanart"),
                 Hash = GetString(sqldReader, "Hash"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite")
             };
             audioartists.Add(audioArtist);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return audioartists;
 }
Exemple #3
0
        public long InsertAudioArtist(Yatse2AudioArtist audioArtist)
        {
            if (audioArtist == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `AudioArtists` ( IdRemote ,IdArtist, Name, Thumb, Fanart, Hash, IsFavorite, Biography )
                  VALUES (?, ? ,? ,? ,? ,?, ?, ?);";
            sqlCmd.Parameters.AddWithValue("a1", audioArtist.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", audioArtist.IdArtist);
            sqlCmd.Parameters.AddWithValue("a3", audioArtist.Name);
            sqlCmd.Parameters.AddWithValue("a4", audioArtist.Thumb);
            sqlCmd.Parameters.AddWithValue("a5", audioArtist.Fanart);
            sqlCmd.Parameters.AddWithValue("a6", audioArtist.Hash);
            sqlCmd.Parameters.AddWithValue("a7", audioArtist.IsFavorite);
            sqlCmd.Parameters.AddWithValue("a8", audioArtist.Biography);

            return QueryInsert(sqlCmd);
        }
Exemple #4
0
        public bool UpdateAudioArtist(Yatse2AudioArtist audioArtist)
        {
            if (audioArtist == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `AudioArtists` SET IdRemote = ?,IdArtist = ?, Name = ?, Thumb = ?, Fanart = ?, Hash = ?, IsFavorite = ?, Biography = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", audioArtist.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", audioArtist.IdArtist);
            sqlCmd.Parameters.AddWithValue("a3", audioArtist.Name);
            sqlCmd.Parameters.AddWithValue("a4", audioArtist.Thumb);
            sqlCmd.Parameters.AddWithValue("a5", audioArtist.Fanart);
            sqlCmd.Parameters.AddWithValue("a6", audioArtist.Hash);
            sqlCmd.Parameters.AddWithValue("a7", audioArtist.IsFavorite);
            sqlCmd.Parameters.AddWithValue("a8", audioArtist.Biography);
            sqlCmd.Parameters.AddWithValue("@Id", audioArtist.Id);

            return Query(sqlCmd);
        }