Esempio n. 1
0
        private void RefreshMusicSongsLibrary()
        {
            Logger.Instance().Log("Yatse2","Start Refresh : MusicSongs");
            var res = _remote.AudioLibrary.GetSongs();
            Logger.Instance().Log("Yatse2","Remote MusicSongs : " + res.Count);
            var oldData = _database.GetAudioSongFavorites(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteAudioSong(_remoteInfo.Id);
            foreach (var apiMusicSong in res)
            {
                long oldFavorite = 0;
                foreach (var osong in oldData)
                {
                    if (osong.IdSong == apiMusicSong.IdSong)
                        oldFavorite = osong.IsFavorite;
                }
                var musicSong = new Yatse2AudioSong(apiMusicSong) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertAudioSong(musicSong);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("Yatse2","End Refresh : MusicSongs");
        }
Esempio n. 2
0
 private Collection<Yatse2AudioSong> QueryAudioSong(SQLiteCommand query)
 {
     var audioSongs = new Collection<Yatse2AudioSong>();
     if (!_connected) return audioSongs;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var audioSong = new Yatse2AudioSong
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 IdSong = GetLong(sqldReader, "IdSong"),
                 Title = GetString(sqldReader, "Title"),
                 Track = GetLong(sqldReader, "Track"),
                 Duration = GetLong(sqldReader, "Duration"),
                 Year = GetLong(sqldReader, "Year"),
                 FileName = GetString(sqldReader, "FileName"),
                 IdAlbum = GetLong(sqldReader, "IdAlbum"),
                 IdArtist = GetLong(sqldReader, "IdArtist"),
                 Artist = GetString(sqldReader, "Artist"),
                 Genre = GetString(sqldReader, "Genre"),
                 IdGenre = GetLong(sqldReader, "IdGenre"),
                 Album = GetString(sqldReader, "Album"),
                 Path = GetString(sqldReader, "Path"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Thumb"),
                 Hash = GetString(sqldReader, "Hash"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite")
             };
             audioSongs.Add(audioSong);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return audioSongs;
 }
Esempio n. 3
0
        public long InsertAudioSong(Yatse2AudioSong audioSong)
        {
            if (audioSong == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `AudioSongs` ( IdRemote ,IdSong,Title,Track,Duration,Year,FileName,IdAlbum,Album,Path,IdArtist,Artist,IdGenre,Genre,Thumb,Fanart,Hash, IsFavorite)
                  VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
            sqlCmd.Parameters.AddWithValue("a1", audioSong.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", audioSong.IdSong);
            sqlCmd.Parameters.AddWithValue("a3", audioSong.Title);
            sqlCmd.Parameters.AddWithValue("a4", audioSong.Track);
            sqlCmd.Parameters.AddWithValue("a5", audioSong.Duration);
            sqlCmd.Parameters.AddWithValue("a6", audioSong.Year);
            sqlCmd.Parameters.AddWithValue("a7", audioSong.FileName);
            sqlCmd.Parameters.AddWithValue("a8", audioSong.IdAlbum);
            sqlCmd.Parameters.AddWithValue("a9", audioSong.Album);
            sqlCmd.Parameters.AddWithValue("a10", audioSong.Path);
            sqlCmd.Parameters.AddWithValue("a11", audioSong.IdArtist);
            sqlCmd.Parameters.AddWithValue("a12", audioSong.Artist);
            sqlCmd.Parameters.AddWithValue("a13", audioSong.IdGenre);
            sqlCmd.Parameters.AddWithValue("a14", audioSong.Genre);
            sqlCmd.Parameters.AddWithValue("a15", audioSong.Thumb);
            sqlCmd.Parameters.AddWithValue("a16", audioSong.Fanart);
            sqlCmd.Parameters.AddWithValue("a17", audioSong.Hash);
            sqlCmd.Parameters.AddWithValue("a18", audioSong.IsFavorite);

            return QueryInsert(sqlCmd);
        }
Esempio n. 4
0
        public bool UpdateAudioSong(Yatse2AudioSong audioSong)
        {
            if (audioSong == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `AudioSongs` SET IdRemote = ?,IdSong = ?,Title = ?,Track = ?,Duration = ?,Year = ?,FileName = ?,IdAlbum = ?,Album = ?,Path = ?,IdArtist = ?,Artist = ?,IdGenre = ?,Genre = ?,Thumb = ?,Fanart = ?,Hash = ?,IsFavorite = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", audioSong.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", audioSong.IdSong);
            sqlCmd.Parameters.AddWithValue("a3", audioSong.Title);
            sqlCmd.Parameters.AddWithValue("a4", audioSong.Track);
            sqlCmd.Parameters.AddWithValue("a5", audioSong.Duration);
            sqlCmd.Parameters.AddWithValue("a6", audioSong.Year);
            sqlCmd.Parameters.AddWithValue("a7", audioSong.FileName);
            sqlCmd.Parameters.AddWithValue("a8", audioSong.IdAlbum);
            sqlCmd.Parameters.AddWithValue("a9", audioSong.Album);
            sqlCmd.Parameters.AddWithValue("a10", audioSong.Path);
            sqlCmd.Parameters.AddWithValue("a11", audioSong.IdArtist);
            sqlCmd.Parameters.AddWithValue("a12", audioSong.Artist);
            sqlCmd.Parameters.AddWithValue("a13", audioSong.IdGenre);
            sqlCmd.Parameters.AddWithValue("a14", audioSong.Genre);
            sqlCmd.Parameters.AddWithValue("a15", audioSong.Thumb);
            sqlCmd.Parameters.AddWithValue("a16", audioSong.Fanart);
            sqlCmd.Parameters.AddWithValue("a17", audioSong.Hash);
            sqlCmd.Parameters.AddWithValue("a18", audioSong.IsFavorite);
            sqlCmd.Parameters.AddWithValue("@Id", audioSong.Id);

            return Query(sqlCmd);
        }