private void searchReviewsToolStripMenuItem_Click(object sender, EventArgs e) { selectedTable = DBAccessor.selectAllTable("ReviewView"); CurrentTable = "ReviewView"; dataGridView1.DataSource = new BindingSource(selectedTable, null); }
private void SearchButton_Click(object sender, EventArgs e) { DataTable search; search = DBAccessor.selectSearchTable("PlaylistView", this.SearchBox.Text); this.AllMediaDataGrid.DataSource = new BindingSource(search, null); }
private void searchSongsToolStripMenuItem_Click(object sender, EventArgs e) { selectedTable = DBAccessor.selectAllTable("SongView"); CurrentTable = "SongView"; dataGridView1.DataSource = new BindingSource(selectedTable, null); dataGridView1.Columns["Filepath"].Visible = false; }
private void SearchButton_Click(object sender, EventArgs e) { //TODO search through all media for keywords selectedTable = DBAccessor.selectSearchTable(selectedTable.TableName, this.SearchBar.Text); dataGridView1.DataSource = new BindingSource(selectedTable, null); dataGridView1.Columns["Filepath"].Visible = false; }
public void Register(String username) { if (ssh == null) { try { ssh = new SshClient("137.112.128.188", "mpd", "mpd"); ssh.Connect(); } catch (Exception ex) { System.Console.WriteLine("Problems connecting to music server, try registering later!"); DBAccessor.deleteEntry("Users", "Username = "******"cat port"); String portnum = cmd1.Execute(); int portnumnum = int.Parse(portnum); int streamPort = portnumnum + 1; SshCommand command = ssh.CreateCommand("echo 'user \"mpd\"\nport \"" + portnumnum + "\"\nrestore_paused \"no\"\npid_file \"/run/mpd/" + username + ".pid\"\ndb_file \"/var/lib/mpd/mpd.db\"\nstate_file \"/var/lib/mpd/userstates/" + username + ".mpdstate\"\nplaylist_directory \"/var/lib/mpd/playlists\"\nmusic_directory \"/var/lib/mpd/music\"\naudio_output {\n\ttype\t\"httpd\"\n\tbind_to_address\t\"137.112.128.188\"\n\tname\t\"My HTTP Stream\"\n\tencoder\t\"lame\"\n\tport\t\"" + streamPort + "\" \n\tbitrate\t\"320\"\n\tformat\t\"44100:16:1\"\n}' > userconfs/" + username + ".conf"); command.Execute(); //StreamPort = portnumnum; portnumnum += 2; SshCommand cmd2 = ssh.CreateCommand("echo \"" + portnumnum + "\" > port"); cmd2.Execute(); // ssh.Disconnect(); }
private void writeReviewToolStripMenuItem_Click(object sender, EventArgs e) { if (GetSelectedMediaName() == null) { return; } ReviewEditor re = new ReviewEditor(GetSelectedMediaName()); int reviewType = DBAccessor.CheckReviewValidity(this.CurrentUser, this.GetSelectedMediaFilepath()); //rating and content are both null, so no special case if (reviewType == 0) { re.ShowDialog(); if (re.submit) { DBAccessor.AddReview(this.CurrentUser, this.GetSelectedMediaFilepath(), re.Rating, re.Content); } } //rating is not null but content is, so this review needs to be updated, not inserted else if (reviewType == 1) { re.RatingBar.Value = DBAccessor.GetCurrentRating(this.CurrentUser, this.GetSelectedMediaFilepath()); re.ShowDialog(); if (re.submit) { DBAccessor.UpdateReview(this.CurrentUser, this.GetSelectedMediaFilepath(), this.GetSelectedReviewRating(), re.Content); } } //item has already been reviewed, so it can't be reviewed again else if (reviewType == 2) { MessageBox.Show("You have already reviewed this item!"); } }
private void followPlaylistToolStripMenuItem_Click(object sender, EventArgs e) { string author = (string)this.dataGridView1.Rows[GetSelectedRowNumber()].Cells["Author"].Value; DateTime date = (DateTime)this.dataGridView1.Rows[GetSelectedRowNumber()].Cells["DateCreated"].Value; DBAccessor.follow(this.CurrentUser, author, date); }
private void selectFollowed() { selectedTable = DBAccessor.selectAllWhere("Follows Join Playlist on Follows.PlaylistAuthor = Playlist.Author" + " AND Follows.PlaylistDateCreated = Playlist.DateCreated", "Follows.Username", this.CurrentUser); dataGridView1.DataSource = new BindingSource(selectedTable, null); dataGridView1.Columns["PlaylistAuthor"].Visible = false; dataGridView1.Columns["PlaylistDateCreated"].Visible = false; }
private void addFavoriteToolStripMenuItem_Click(object sender, EventArgs e) { string fp = (string)dataGridView1.Rows[GetSelectedRowNumber()].Cells["Filepath"].Value; if (fp != null) { DBAccessor.addFavorite(this.CurrentUser, fp); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { ComboBox cmb = (ComboBox)(sender); String text = cmb.Text; Console.WriteLine(text); //GetSelectedRowNumber(); selectedTable = DBAccessor.selectAllTable(text); dataGridView1.DataSource = new BindingSource(selectedTable, null); }
private void UpdateTables() { DataTable dt = DBAccessor.selectAllWhere("PlaylistView", "[Playlist Name]", PlaylistName); CurrentTable = dt; this.CurrentPlaylistDataGrid.DataSource = new BindingSource(dt, null); dt = DBAccessor.selectAllTable("MediaView"); this.AllMediaDataGrid.DataSource = new BindingSource(dt, null); }
private void RemoveButton_Click(object sender, EventArgs e) { int firstRow = this.CurrentPlaylistDataGrid.Rows.GetFirstRow(DataGridViewElementStates.Selected); if (firstRow == -1) { return; } DBAccessor.deleteEntry("Belongs_To", "MediaFilepath = '" + (string)CurrentPlaylistDataGrid.Rows[firstRow].Cells["MediaFilepath"].Value + "' and PlaylistAuthor = '" + this.Username + "'"); UpdateTables(); }
public void ConfirmRegistration(object sender, EventArgs e) { if (PasswordTextbox.Text == RepeatPasswordTextbox.Text) { username = UsernameTextbox.Text; DBAccessor.insertEntry("'" + UsernameTextbox.Text + "'|'" + Math.Abs(PasswordTextbox.Text.GetHashCode() + username.GetHashCode()) + "'", "Users"); confirmed = true; this.Close(); } }
private void removeFavoriteToolStripMenuItem_Click(object sender, EventArgs e) { int index = GetSelectedRowNumber(); if (index == -1) { return; } DBAccessor.deleteEntry("Likes", "Username = '******' and MediaFilepath = '" + (string)this.dataGridView1.Rows[index].Cells["MediaFilepath"].Value + "'"); selectFavorites(); }
private void unFollowPlaylistToolStripMenuItem_Click(object sender, EventArgs e) { int index = GetSelectedRowNumber(); if (index == -1) { return; } DBAccessor.deleteEntry("Follows", "Username = '******' and PlaylistDateCreated = '" + (DateTime)this.dataGridView1.Rows[index].Cells["DateCreated"].Value + "' and PlaylistAuthor = '" + (string)this.dataGridView1.Rows[index].Cells["Author"].Value + "'"); selectFollowed(); }
private void AddButton_Click(object sender, EventArgs e) { int firstRow = AllMediaDataGrid.Rows.GetFirstRow(DataGridViewElementStates.Selected); if (firstRow == -1) { return; } Console.WriteLine(this.PlaylistName); DBAccessor.insertEntry("'" + AllMediaDataGrid.Rows[firstRow].Cells["Filepath"].Value + "'|'" + this.PlaylistName + "'|'" + this.Username + "'|" + (this.PlaylistSize++), "Belongs_To"); UpdateTables(); }
private void expandPlaylistToolStripMenuItem_Click_1(object sender, EventArgs e) { int index = GetSelectedRowNumber(); if (index == -1) { return; } selectedTable = DBAccessor.selectAllWhere("PlaylistView", "Author = '" + this.CurrentUser + "' and [Playlist Name]", (string)this.dataGridView1.Rows[index].Cells["Name"].Value); dataGridView1.DataSource = new BindingSource(selectedTable, null); dataGridView1.Columns["MediaFilepath"].Visible = false; }
public static void LoginButton_Click(object sender, EventArgs e) { if (!DBAccessor.verifyLoginInfo(mm.UsernameTextbox.Text, mm.PasswordTextbox.Text)) { MessageBox.Show("Invalid User Information. Try again."); return; } DisplayWindow dw = new DisplayWindow(); dw.SetUser(mm.UsernameTextbox.Text); HideMainMenu(); dw.ShowDialog(); }
public DisplayWindow() { InitializeComponent(); this.Text = "Maestro: Guest User"; Manager = new MediaManager(); CurrentTable = "SongView"; selectedTable = DBAccessor.selectAllTable(CurrentTable); dataGridView1.DataSource = new BindingSource(selectedTable, null); dataGridView1.Columns["Filepath"].Visible = false; // byte[] address = { 137, 112, 128, 188 }; // streamer = new MediaStreamer(new System.Net.IPAddress(address), 6600, 8000); // streamer.Play(); }
public void SetPlaylist(string PlaylistName) { this.PlaylistName = PlaylistName; this.PlaylistNameBox.Text = PlaylistName; DataTable dt = DBAccessor.selectAllWhere("PlaylistView", "[Playlist Name]", PlaylistName); foreach (DataRow dr in dt.Rows) { if (((int)dr["PlaylistIndex"]) > this.PlaylistSize) { this.PlaylistSize = (int)dr["PlaylistIndex"]; } } UpdateTables(); }
public PlaylistEditor(string username, Boolean isCreation = false) { this.Username = username; InitializeComponent(); if (isCreation) { this.PlaylistName = Interaction.InputBox("Enter playlist name:", "Playlist Editor", ""); this.PlaylistNameBox.Text = this.PlaylistName; CreatePlaylist(); UpdateTables(); DataTable dt = DBAccessor.selectAllWhere("PlaylistView", "[Playlist Name]", PlaylistName); foreach (DataRow dr in dt.Rows) { if (((int)dr["PlaylistIndex"]) > this.PlaylistSize) { this.PlaylistSize = (int)dr["PlaylistIndex"]; } } } }
private void showCurrentPlayQueueToolStripMenuItem_Click(object sender, EventArgs e) { String[] playlist = Manager.streamer.GetInternalPlaylist(); if (playlist == null) { return; } String attributes = ""; for (int i = 0; i < playlist.Length; i++) { attributes += "Filepath='" + playlist[i] + "'"; if (i < playlist.Length - 1) { attributes += " OR "; } } DataTable table = DBAccessor.selectCurrentPlaylist(attributes); table.Columns.Add("Order"); //table.PrimaryKey = new DataColumn[]{table.Columns[0]}; int ind = -1; for (int i = 0; i < playlist.Length; i++) { for (int j = 0; j < table.Rows.Count; j++) { System.Console.WriteLine(table.Rows[j].Field <String>(0)); if (table.Rows[j].Field <String>(0) == playlist[i]) { ind = j; break; } } //int ind = table.Rows.IndexOf(table.Rows.Find(playlist[i])); table.Rows[ind].SetField <int>(table.Columns[table.Columns.Count - 1], i + 1); } table.Columns.Remove("Filepath"); dataGridView1.DataSource = new BindingSource(table, null); }
public void UploadSong(String songFilepath, String artist, String album, String name, String genre, int releaseDate, int length, String username, int track_no) { if (songFilepath == "") { return; } System.Console.WriteLine("In Uploadsong"); SftpClient sftpClient = new SftpClient("137.112.128.188", "mpd", "mpd"); SshClient ssh = new SshClient("137.112.128.188", "mpd", "mpd"); ssh.Connect(); SshCommand cmd = ssh.CreateCommand("mkdir -p " + "'/var/lib/mpd/music/" + artist + "/" + album + "'"); cmd.Execute(); ssh.Disconnect(); sftpClient.Connect(); char[] split = { '\\', '\\' }; String[] path = songFilepath.Split(split); System.IO.FileStream file = new System.IO.FileStream(songFilepath, System.IO.FileMode.Open); //TagLib.File tagFile = TagLib.File.Create(songFilepath); //System.Console.WriteLine(tagFile.Tag.Year); String uploadFilepath = artist + "/" + album + "/" + path[path.Length - 1]; //uploadFilepath.Replace(" ", "\\ "); DBAccessor.uploadSong(uploadFilepath + "|" + name + "|" + artist + "|" + length + "|" + genre + "|" + username + "|" + releaseDate + "|" + artist + "/" + album + "|" + track_no + "|" + album); try { sftpClient.UploadFile(file, "/var/lib/mpd/music/" + uploadFilepath); } catch (Renci.SshNet.Common.SshException sshe) { System.Console.WriteLine(sshe.Message); } file.Close(); sftpClient.Disconnect(); //this.Close(); }
private void selectFavorites() { selectedTable = DBAccessor.getFavorites(this.CurrentUser); dataGridView1.DataSource = new BindingSource(selectedTable, null); dataGridView1.Columns["MediaFilepath"].Visible = false; }
private void CreatePlaylist() { //Console.WriteLine("DATE FOR NOW: " + DateTime.Now); DBAccessor.AddPlaylist(this.Username, this.PlaylistName); }
private void myReviewsToolStripMenuItem_Click(object sender, EventArgs e) { this.selectedTable = DBAccessor.selectAllWhere("Reviews", "Username", this.CurrentUser); dataGridView1.DataSource = new BindingSource(selectedTable, null); }
private void searchAllPlaylistsToolStripMenuItem_Click(object sender, EventArgs e) { selectedTable = DBAccessor.selectAllTable("Playlist"); dataGridView1.DataSource = new BindingSource(selectedTable, null); }
/* * public void UploadAlbum(String songFilepath) * { * SftpClient sftpClient = new SftpClient("137.112.128.188", "mpd", "mpd"); * SshClient ssh = new SshClient("137.112.128.188", "mpd", "mpd"); * ssh.Connect(); * SshCommand cmd = ssh.CreateCommand("mkdir -p " + "'/var/lib/mpd/music/" + this.ArtistTextbox.Text + "/" + this.albumTextBox.Text + "'"); * cmd.Execute(); * ssh.Disconnect(); * sftpClient.Connect(); * char[] split = { '\\', '\\' }; * String[] path = songFilepath.Split(split); * System.IO.FileStream file = new System.IO.FileStream(songFilepath, System.IO.FileMode.Open); * String uploadFilepath = this.ArtistTextbox.Text + "/" + this.albumTextBox.Text + "/" + path[path.Length - 1]; * //uploadFilepath.Replace(" ", "\\ "); * DBAccessor.insertEntry("'" + uploadFilepath + "'|'" + this.NameTextBox.Text + "'|'" + this.ArtistTextbox.Text + "'|NULL|'" + GenreTextBox.Text + "'|'" + TypeBox.Text + "'|'" + 300 + "'|" + ReleaseDateBox.Text, "Media"); * try * { * sftpClient.UploadFile(file, "/var/lib/mpd/music/" + uploadFilepath); * } * catch (Renci.SshNet.Common.SshException sshe) * { * System.Console.WriteLine(sshe.Message); * } * file.Close(); * sftpClient.Disconnect(); * }*/ public void Unregister(String username) { DBAccessor.deleteEntry("Users", "Username = '******'"); }
private void myPlaylistsToolStripMenuItem_Click(object sender, EventArgs e) { selectedTable = DBAccessor.getMyPlaylists(this.CurrentUser); dataGridView1.DataSource = new BindingSource(selectedTable, null); }