public async void GetPhotoInfoAsync(string photoId, string OwnerId, bool isUploadedPhoto) { if (infoQueue.Contains(photoId)) return; infoQueue.Add(photoId); string timestamp = DateTimeUtils.GetTimestamp(); string nonce = Guid.NewGuid().ToString().Replace("-", null); Dictionary<string, string> paramDict = new Dictionary<string, string>(); paramDict["method"] = "flickr.photos.getInfo"; paramDict["format"] = "json"; paramDict["nojsoncallback"] = "1"; paramDict["oauth_consumer_key"] = consumerKey; paramDict["oauth_nonce"] = nonce; paramDict["oauth_signature_method"] = "HMAC-SHA1"; paramDict["oauth_timestamp"] = timestamp; paramDict["oauth_token"] = AccessToken; paramDict["oauth_version"] = "1.0"; paramDict["photo_id"] = photoId; string paramString = GenerateParamString(paramDict); string signature = GenerateSignature("GET", AccessTokenSecret, "https://api.flickr.com/services/rest", paramString); string requestUrl = "https://api.flickr.com/services/rest?" + paramString + "&oauth_signature=" + signature; HttpWebResponse response = await DispatchRequest("GET", requestUrl, null).ConfigureAwait(false); using (StreamReader reader = new StreamReader(response.GetResponseStream())) { if (infoQueue.Contains(photoId)) infoQueue.Remove(photoId); GetPhotoInfoExceptionEventArgs exceptionArgs = null; if (response.StatusCode != HttpStatusCode.OK) { exceptionArgs = new GetPhotoInfoExceptionEventArgs(); exceptionArgs.PhotoId = photoId; PhotoInfoException.DispatchEvent(this, exceptionArgs); return; } string jsonString = await reader.ReadToEndAsync().ConfigureAwait(false); if (!IsResponseSuccess(jsonString)) { exceptionArgs = new GetPhotoInfoExceptionEventArgs(); exceptionArgs.PhotoId = photoId; PhotoInfoException.DispatchEvent(this, exceptionArgs); return; } GetPhotoInfoEventArgs args = new GetPhotoInfoEventArgs(); args.PhotoId = photoId; args.Response = jsonString; args.OwnerId = OwnerId; args.IsUploadedPhoto = isUploadedPhoto; PhotoInfoReturned.DispatchEvent(this, args); } }
private void OnPhotoInfoException(object sender, GetPhotoInfoExceptionEventArgs e) { Dispatcher.BeginInvoke(() => { if (e.PhotoId != PhotoSource.ResourceId) return; ProgressView.Visibility = Visibility.Collapsed; StatusLabel.Text = AppResources.DetailPageRetrievePhotoInfoErrorText; doneButton.IsEnabled = true; }); }
private void OnPhotoInfoException(object sender, GetPhotoInfoExceptionEventArgs e) { Dispatcher.BeginInvoke(() => { if (e.PhotoId != photoId) return; if (statusView == null) return; ShowCompleteStatus("Photo is uploaded, but cannot retrieve from server"); }); }