private async void BtPickVideoClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;
            FileOpenPicker openPicker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.VideosLibrary
            };
            openPicker.FileTypeFilter.Add(".avi");
            openPicker.FileTypeFilter.Add(".mp4");

            StorageFile file = await openPicker.PickSingleFileAsync();
            if (file != null)
            {
                var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);
                Video video = new Video { Title = file.DisplayName, Tags = file.DisplayName, Synopse = file.DisplayName };
                this.tblock_PostVideoResult.Text = await client.CreateVideoAsync(file, video);
            }
            else
            {
                this.tblock_PostVideoResult.Text = "Error reading file";
            }

        }
        private void BtDeleteVideoClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;

            var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);

            client.DeleteVideoAsync(this.tb_VideoRandnameForDeleteVideo.Text);

            this.tblock_Result.Text = "SUCCESS";
        }
        private async void BtGetVideoClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;

            var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);

            Video v = await client.GetVideoAsync(null, null, this.tb_VideoRandnameForGetVideo.Text, null, 0);

            this.tblock_Result.Text = String.Format("Randname: {0}\nTitle: {1}\nSynopse: {2}\nURI: {3}", 
                v.Randname, v.Title, v.Synopse, v.URL);
        }
示例#4
0
        private async void BtGetUserClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;

            var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);

            User u = await client.GetUserAsync(this.tb_UserNameForGetUser.Text);

            this.tblock_Result.Text = String.Format("Username: {0}\nCreationDate: {1}\nLastLogin: {2}", 
                u.Username, u.CreationDate, u.LastLogin);
        }
        public async Task <string> CreateVideoAsync(IStorageFile file, Video v)
        {
            VideoSubmition videoSubmition = new VideoSubmition
            {
                Tags    = v.Tags,
                Title   = v.Title,
                Synopse = v.Synopse
            };

            Video createdVideo = null;

            try
            {
                using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
                           this.Username, this.Password, this.AccessKey, _client.InnerChannel))
                {
                    createdVideo = await this._client.AddVideoPostAsync(videoSubmition, null);
                }
            }
            catch (FaultException faultException)
            {
                MessageFault messageFault = faultException.CreateMessageFault();

                if (messageFault.HasDetail)
                {
                    string innerErrorXml;
                    using (var xmlReader = messageFault.GetReaderAtDetailContents())
                    {
                        innerErrorXml = xmlReader.ReadInnerXml();
                    }
                    if (innerErrorXml != null)
                    {
                        throw new Exception(innerErrorXml);
                    }
                    throw;
                }
            }

            string token = createdVideo.Token;

            BackgroundUploader uploader = new BackgroundUploader();

            UploadOperation uploadOperation =
                await VideosServiceClient.CreateUploadOperationForCreateVideo(file, token, uploader);

            await uploadOperation.StartAsync();

            return(await GetResponseMessage(uploadOperation));
        }
        private async void BtGetUserVideosClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;

            var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);
            Video[] videos = await client.GetUserVideos(null, null, null, 50, 1);

            StringBuilder sb = new StringBuilder();
            foreach (Video v in videos)
            {
                sb.AppendLine(String.Format("Randname: {0}\nTitle: {1}\nSynopse: {2}\nURI: {3}",
                                            v.Randname, v.Title, v.Synopse, v.URL));
            }

            this.tblock_Result.Text = sb.ToString();
        }
示例#7
0
        private void BtEditVideoClick(object sender, RoutedEventArgs e)
        {
            App app = Application.Current as App;

            if (app == null)
                return;

            var client = new VideosServiceClient(app.EsbUsername, app.EsbPassword, app.EsbAccessKey);


            //Title and randname are mandatory.
            VideoSubmition v = new VideoSubmition
            {
                Randname = this.tb_VideoRandnameForEditVideo.Text,
                Synopse = this.tb_VideoSynopseForEditVideo.Text,
                Title = this.tb_VideoTitleForEditVideo.Text
            };

            client.EditVideoAsync(v);

            this.tblock_Result.Text = "SUCCESS";
        }