private void OnUpdateFeedException(object sender, FeedSource.UpdateFeedExceptionEventArgs e) { this.resultInfos.Enqueue(e.Priority, new ThreadResultInfo(sender, e)); }
/// <summary> /// Called by <see cref="FeedSource"/>, if update of a feed caused an exception /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void OnUpdateFeedException(object sender, FeedSource.UpdateFeedExceptionEventArgs e) { FeedSourceEntry entry = sourceManager.SourceOf((FeedSource)sender); InvokeOnGui(delegate { if (e.ExceptionThrown.InnerException is ClientCertificateRequiredException) { X509Certificate2 cert = CertificateHelper.SelectCertificate( String.Format(SR.Certificate_ForFeedSiteRequired_Message, e.FeedUri)); if (cert != null) { GetFeed(entry, e.FeedUri).certificateId = cert.Thumbprint; SubscriptionModified(entry, NewsFeedProperty.FeedCredentials); } } /* * if (e.ExceptionThrown.InnerException is FacebookException) * { * FacebookException fe = e.ExceptionThrown.InnerException as FacebookException; * * if (fe.ErrorCode == 102) //session key has expired * { * try * { * FeedSourceEntry fse = * this.FeedSources.Sources.SingleOrDefault(fs => fs.SourceType == FeedSourceType.Facebook); * * string FacebookAuthToken = String.Empty; * DialogResult result = DialogResult.None; * * try * { * //TODO review: how do we get this token now? * HttpWebRequest request = WebRequest.Create(FacebookConnectDialog.TokenUrl) as HttpWebRequest; * FacebookAuthToken = new StreamReader(request.GetResponse().GetResponseStream()).ReadToEnd(); * * //string fbUrl = String.Format(FacebookConnectDialog.FbLoginUrlTemplate, FacebookConnectDialog.ApiKey, FacebookAuthToken); * string fbUrl = FacebookApp.Authorization.GetLoginUrl(FacebookAuthToken); * * // login user * using (FacebookConnectDialog fcd = new FacebookConnectDialog(new Uri(fbUrl), uri => * { * return true; * })) * { * result = fcd.ShowDialog(); * } * } * catch (WebException) * { * MessageBox.Show(SR.ExceptionFacebookAuthToken, String.Empty, MessageBoxButtons.OK, MessageBoxIcon.Error); * } * * if (result != DialogResult.OK) * { * throw new Exception(SR.ExceptionFacebookLogin); * } * else * { * var fbSource = fse.Source as IFacebookFeedSource; * * fbSource.SetAuthToken(FacebookAuthToken); * fbSource.GetSessionKey(); * fse.Source.RefreshFeeds(true );// force_download * } * } * catch (Exception) * { * // SingleOrDefault throws exception if more than one Facebook feed source is found * } * } * } */ WebException webex = e.ExceptionThrown as WebException; if (webex != null) { // yes, WebException if (webex.Status == WebExceptionStatus.NameResolutionFailure || webex.Status == WebExceptionStatus.ProxyNameResolutionFailure) { // connection lost? UpdateInternetConnectionState(true); // update connect state if (!InternetAccessAllowed) { guiMain.UpdateFeed(entry, e.FeedUri, null, false); stateManager.MoveNewsHandlerStateTo(FeedSourceBusyState.RefreshOneDone); return; } } } Trace.WriteLine(e.ExceptionThrown.StackTrace); UpdateXmlFeedErrorFeed(e.ExceptionThrown, e.FeedUri, true, entry); stateManager.MoveNewsHandlerStateTo(FeedSourceBusyState.RefreshOneDone); }); }