Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public async Task<Video[]> QueryAsync(string emails, string tags, 
            int cos, int limit, string order, int viewAll, string itfc, int showTags)
        {
            try
            {
                using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
                    this.Username, this.Password, this.AccessKey, _client.InnerChannel))
                {
                    return await this._client.QueryAsync(emails, tags, cos, limit, order, viewAll, itfc, showTags)
                                     .ContinueWith(t => t.Result.QueryResult);
                }
            }
            catch (AggregateException e)
            {
                var faultException = e.InnerException as FaultException;

                if (faultException != null)
                {
                    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;
                    }
                }
            }
            throw new Exception("Error!");
        }
Exemplo n.º 3
0
        public async Task<Video[]> GetUserVideos(string email, string Interface, string order, int limit, int page)
        {
            try
            {
                using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
                    this.Username, this.Password, this.AccessKey, _client.InnerChannel))
                {
                    return await this._client.ListUserVideosAsync(email, Interface, order, limit, page)
                                     .ContinueWith(t => t.Result.ListUserVideosResult);
                }
            }
            catch (AggregateException e)
            {
                var faultException = e.InnerException as FaultException;

                if (faultException != null)
                {
                    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;
                    }
                }
            }
            throw new Exception("Error!");
        }
Exemplo n.º 4
0
 public async Task<User> GetUserAsync(string username)
 {
     using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
             this.Username, this.Password, this.AccessKey, _client.InnerChannel))
     {
         return await this._client.GetUserInfoAsync(null, username).ContinueWith(t => t.Result);
     }
 }
Exemplo n.º 5
0
 public async Task<Video> GetVideoAsync(string videoId, string email, string videoRandname, string Interface, int showComments)
 {
     using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
             this.Username, this.Password, this.AccessKey, _client.InnerChannel))
     {
         return await this._client.CheckVideoAsync(videoId, email, videoRandname, Interface, showComments)
             .ContinueWith(t => t.Result);
     }
 }
Exemplo n.º 6
0
        public async void EditVideoAsync(VideoSubmition v)
        {
            try
            {
                using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext(
                    this.Username, this.Password, this.AccessKey, _client.InnerChannel))
                {
                    await this._client.EditVideoAsync(v, null, 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;
                }
            }
        }