Ejemplo n.º 1
0
        /// <summary>
        /// Sync Local DB with Server DB
        /// </summary>
        public static void SyncLocalDbWithServerDb()
        {
            // Delete all local tables
            AlbumsManager.db_Delete_All();
            ArtistsManager.db_Delete_All();
            PlaylistsManager.db_Delete_All();

            //Get all server tables
            List <Album>    albums    = AlbumsNwManager.GetAlbums();
            List <Artist>   artists   = ArtistsNwManager.GetArtists();
            List <Playlist> playlists = PlaylistsNwManager.GetPlaylists();
            List <Track>    tracks    = TracksNwManager.GetTracks();


            // < sync local tables with server tables >
            foreach (var item in albums)
            {
                AlbumsManager.db_Add_Update_Record(item);
            }
            foreach (var item in artists)
            {
                ArtistsManager.db_Add_Update_Record(item);
            }
            foreach (var item in playlists)
            {
                PlaylistsManager.db_Add_Update_Record(item);
            }
            foreach (var item in tracks)
            {
                TracksManager.db_Add_Update_Record(item);
            }
            // </ sync local tables with server tables >

            // < Add relations to local db >
            foreach (Album album in albums)
            {
                foreach (string artistId in album.artists)
                {
                    AlbumFromArtistManager.db_Add_Update_Record((int)album.id, Convert.ToInt32(artistId));
                }
            }

            foreach (Artist artist in artists)
            {
                foreach (string trackId in artist.songs)
                {
                    TrackFromArtistManager.db_Add_Update_Record(Convert.ToInt32(trackId), (int)artist.id);
                }
            }
            // </ Add relations to local db >
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sync edited metadata
 /// </summary>
 /// <param name="track"></param>
 public static void SyncNewMetadata(Track track)
 {
     TracksNwManager.PutAudio(track);
 }