Exemplo n.º 1
0
        public void Load()
        {
            _playlists.Clear();

            using (var cmd = new SQLiteCommand(string.Format("SELECT * FROM {0}", TabsterDatabaseHelper.TablePlaylists), _databaseHelper.GetConnection()))
            {
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var id       = long.Parse(reader["id"].ToString());
                        var name     = reader["name"].ToString();
                        var created  = reader["created"].ToString();
                        var playlist = new TablaturePlaylist(name)
                        {
                            Id = id, Created = TabsterDatabaseHelper.UnixTimestampToDateTime(int.Parse(created))
                        };
                        _playlists.Add(playlist);
                    }
                }
            }

            foreach (var playlist in _playlists)
            {
                using (var cmd = new SQLiteCommand(string.Format("SELECT * FROM {0} WHERE playlist_id=@playlist_id", TabsterDatabaseHelper.TablePlaylistItems), _databaseHelper.GetConnection()))
                {
                    cmd.Parameters.Add(new SQLiteParameter("@playlist_id", playlist.Id));

                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id       = long.Parse(reader["id"].ToString());
                            var filename = reader["filename"].ToString();

                            var file = _fileProcessor.Load(filename);

                            if (file != null)
                            {
                                var fileInfo = new FileInfo(filename);
                                var item     = new TablaturePlaylistItem(file, fileInfo);
                                playlist.Add(item);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void Load(bool useFileSystem)
        {
            if (useFileSystem)
            {
                LoadTablatureFiles();
            }

            else
            {
                using (var cmd = new SQLiteCommand(string.Format("SELECT * FROM {0}", TabsterDatabaseHelper.TableLibraryItems), _databaseHelper.GetConnection()))
                {
                    using (var reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var id       = long.Parse(reader["id"].ToString());
                            var filename = reader["filename"].ToString();
                            var favorite = bool.Parse(reader["favorite"].ToString());
                            var views    = int.Parse(reader["views"].ToString());
                            var rating   = TablatureRatingUtilities.FromString(reader["rating"].ToString());

                            var file = _fileProcessor.Load(filename);

                            if (file != null)
                            {
                                var fileInfo = new FileInfo(filename);
                                var item     = new TablatureLibraryItem <TablatureFile>(file, fileInfo)
                                {
                                    Id        = id,
                                    Favorited = favorite,
                                    Views     = views,
                                    Rating    = rating
                                };

                                base.Add(item);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Load()
        {
            _items.Clear();

            using (var cmd = new SQLiteCommand(string.Format("SELECT * FROM {0} ORDER BY id DESC", TabsterDatabaseHelper.TableRecentFiles), _databaseHelper.GetConnection()))
            {
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        var filename = reader["filename"].ToString();

                        var file = _fileProcessor.Load(filename);

                        if (file != null)
                        {
                            var r = new RecentFile(file, new FileInfo(filename));
                            _items.Add(r);
                        }
                    }
                }
            }
        }