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; } } }
public IAsyncOperation <string> DummyEchoAsync(string echoStr) { try { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(_client .DummyEchoAsync(echoStr) .ContinueWith(t => t.Result.DummyEchoResult) .AsAsyncOperation()); } } 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; } } throw new Exception("Request cannot be fulfilled"); }
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)); } }
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)); } }
public async Task <string[]> GetUserTags() { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(await this._client .UserGetTagsAsync(null, null) .ContinueWith(t => t.Result.tags)); } }
public async Task <Image[]> GetUserImageList() { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(await this._client .ImageGetListByUserAsync(0, null) .ContinueWith(t => t.Result.images)); } }
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)); }
//Tested providing username public async Task <User> GetUserDetailsAsync(string username) { User user = new User { username = username, }; try { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(await this._client .UserDetailsAsync(user, new Format()) .ContinueWith(t => { if (t.Result.result.ok) { return t.Result.user; } throw new Exception("Server returned error"); })); } } 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; } } throw new Exception("Request cannot be fulfilled"); }
//ImageAddToAlbumAsync requires not only the Album::id but also Album::idSpecified public async Task <bool> AddImageToAlbums(string imageId, int[] albunsIds) { Image img = new Image { uid = imageId, albums = new Album[albunsIds.Length] }; for (int i = 0; i < img.albums.Length; i++) { img.albums[i] = new Album { id = albunsIds[i], idSpecified = true }; } try { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(await this._client .ImageAddToAlbumAsync(img, PhotosServiceClient.FotosSapoPtInterface) .ContinueWith(t => t.Result.result.ok)); } } 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; } } throw new Exception("Request cannot be fulfilled"); }
public async Task <bool> DeleteImageAsync(string imageUid) { Image img = new Image { uid = imageUid }; try { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(await this._client.ImageDeleteAsync(img).ContinueWith(t => { if (t.Result.ok) { return t.Result.ok; } throw new Exception("Server returned error"); })); } } 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; } } throw new Exception("Request cannot be fulfilled"); }
public async Task <Album[]> GetUserAlbumsList() { User user = new User() { username = "******", }; try { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { return(await this._client .AlbumGetListByUserAsync(user, 0, null, FotosSapoPtInterface) .ContinueWith(t => t.Result.albums)); } } 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; } } throw new Exception("Request cannot be fulfilled"); }
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!"); }
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!"); }
public async Task <CreateImageResult> CreateImageAsync(IStorageFile file, Image img) { ImageCreateResult res = null; try { using (EnsureCredentialsUseContext context = new EnsureCredentialsUseContext( this.Username, this.Password, this.Accesskey, _client.InnerChannel)) { res = await this._client.ImageCreateAsync(img, FotosSapoPtInterface); } } 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; } } if (res != null && res.result.ok) { BackgroundUploader uploader = new BackgroundUploader(); //Default HTTP Method is POST (http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.networking.backgroundtransfer.backgrounduploader.method.aspx) //uploader.Method = "POST"; UploadOperation uploadOperation = await PhotosServiceClient.CreateUploadOperationForCreateImage(file, res.token, uploader); await uploadOperation.StartAsync(); ResponseInformation responseInformation = uploadOperation.GetResponseInformation(); uint contentLength = Convert.ToUInt32(responseInformation.Headers["Content-Length"]); uint statusCode = responseInformation.StatusCode; IInputStream resultStreamAt = uploadOperation.GetResultStreamAt(0); IBuffer result = await resultStreamAt.ReadAsync( new Windows.Storage.Streams.Buffer(contentLength), contentLength, InputStreamOptions.None); Stream responseStream = result.AsStream(); XDocument xDocument = XDocument.Load(responseStream); /* * * Bug!! Root element ("Upload") as diferent cases in error and in success responses * * Must ask SAPO Photos Team about the latency at User creation * * How can an application post photos for a user not being that user? Seems to be possible. * * Return usefull information * */ string resultCode = xDocument .Descendants("uploadPost") .Select(e => e.Element("Result").Value) .SingleOrDefault(); return(new CreateImageResult(res.image, resultCode)); } throw new Exception("Request cannot be fulfilled"); }