protected void btnUpload_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(txtArtist.Text) || string.IsNullOrEmpty(txtTrack.Text) || !uplTrack.HasFile) return; CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["AndrewBlob"].ConnectionString); CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve a reference to a container. CloudBlobContainer container = blobClient.GetContainerReference("mp3s"); // Create the container if it doesn't already exist. container.CreateIfNotExists(); container.SetPermissions( new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob }); string trackName = txtArtist.Text + "-" + txtTrack.Text+".mp3"; // Retrieve reference to a blob named "myblob". CloudBlockBlob blockBlob = container.GetBlockBlobReference(trackName); blockBlob.Properties.ContentType = "audio/mpeg"; blockBlob.UploadFromStream(uplTrack.PostedFile.InputStream); //DataAccess.Instance.AddNewTrack(txtTrack.Text, txtArtist.Text, blockBlob.Uri, Session["ID"].ToString()); Track uploadTrack = new Track(txtTrack.Text, txtArtist.Text, "", Convert.ToInt32(Session["ID"].ToString()), cbxShare.Checked, blockBlob.Uri.ToString()); Response.Redirect("~/Member/Member.aspx"); }
public void PlayListSyncOrder() { List<Track> holder = new List<Track>(); _orderedTracks = new List<Track>(); _playlistTrackIds = new List<int>(); Track hold = new Track(0, 0, 0); int point = 0; if (_playlistOrder == null) _playlistOrder = this.PlayListOrder; //inefficient sort loop series for ordering _playlistTrackIds & _orderedTracks for (int i = 0; i < (_playlistOrder.Count) / 3; i++) { if ((point == 0 && _playlistOrder[(i * 3) + 2] < 0) || (point == _playlistOrder[(i * 3) + 2])) { _orderedTracks.Add(new Track(_playlistOrder[i * 3], _playlistOrder[(i * 3) + 1], _playlistOrder[(i * 3) + 2])); point = _playlistOrder[i * 3]; _playlistTrackIds.Add(_playlistOrder[(i * 3) + 1]); } else holder.Add(new Track(_playlistOrder[i*3], _playlistOrder[(i*3) + 1], _playlistOrder[(i*3) + 2])); } while (_orderedTracks.Count < (_playlistOrder.Count) / 3) { hold = holder.Find(x => x.OrderPoint == point); _orderedTracks.Add(hold); point = hold.PlaylistTrackId; _playlistTrackIds.Add(_orderedTracks.Last().TrackId); holder.Remove(hold); } }