Пример #1
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (VideoUpload.HasFiles & Page.IsValid)
            {
                ChannelPerformingRepository<Media> mediaRepository = new ChannelPerformingRepository<Media>();
                ChannelPerformingRepository<Tag> tagRepository = new ChannelPerformingRepository<Tag>();

                string uniqueBobName = string.Format("{0}/ShowVideo_{1}{2}", Utils.CloudBlobKey, Guid.NewGuid().ToString(), Path.GetExtension(VideoUpload.FileName));
                CloudBlockBlob blob = blobClient.GetBlockBlobReference(uniqueBobName);
                blob.Properties.ContentType = VideoUpload.PostedFile.ContentType;
                blob.UploadFromStream(VideoUpload.FileContent);

                Media media = new Media
                {
                    Description = TextBoxVideoDescription.Text,
                    Title = TextBoxVideoName.Text
                };

                string[] tagArray = TextBoxTags.Text.Split(';');
                foreach (string t in tagArray)
                {
                    if (!string.IsNullOrEmpty(t))
                    {
                        Tag tag = new Tag
                        {
                            TagName = t,
                            MediaPartitionKey = media.PartitionKey,
                            MediaRowKey = media.RowKey,
                            RecordDate = DateTime.Now
                        };

                        tagRepository.Create(tag);
                        tagRepository.SubmitChange();
                    }
                }

                media.MediaProgressStateType = Utils.MediaProgressStateTypeWait;
                mediaRepository.Create(media);
                mediaRepository.SubmitChange();

                CloudQueue queue = queueClient.GetQueueReference(Utils.CloudQueueKey);
                CloudQueueMessage message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri, media.PartitionKey, media.RowKey));
                queue.AddMessage(message);

                LabelResult.Text = "Video Uploaded";
                Response.Redirect("/Manager/VideoProgressListPage.aspx");
            }
        }