public void CreateRequest(ClaimParameters parameters, bool withUserId) { if (Provider == Providers.Empty) { return; } var requestString = new StringBuilder(); if (withUserId) { if (Provider == Providers.Mail) { //var //if (userId.Contains("@")) //{ // userId = userId.Substring(0, userId.IndexOf("@")); //} var userIdAndDomainPair = UserId.Split(new[] { '@' }); parameters.OpenidClaimedId.Value = string.Format("http://{0}.id.{1}", userIdAndDomainPair[0], userIdAndDomainPair[1]); parameters.OpenidIdentity.Value = string.Format("http://{0}.id.{1}", userIdAndDomainPair[0], userIdAndDomainPair[1]); } } requestString.Append(_providerEndPoint[Provider] + "?"); requestString.Append(parameters.OpenidMode.RequestParameter()); requestString.Append(parameters.OpenidNs.RequestParameter()); requestString.Append(parameters.OpenidReturnTo.RequestParameter()); requestString.Append(parameters.OpenidRealm.RequestParameter()); requestString.Append(parameters.OpenidClaimedId.RequestParameter()); requestString.Append(parameters.OpenidIdentity.RequestParameter()); requestString.Append(parameters.OpenidNsSreg.RequestParameter()); requestString.Append(parameters.OpenidSregRequired.RequestParameter()); requestString.Append(parameters.OpenidSregOptional.RequestParameter()); try { var request = WebRequest.Create(requestString.ToString()); var respons = (HttpWebResponse)request.GetResponse(); HttpContext.Current.Response.Redirect(respons.ResponseUri.AbsoluteUri, true); } catch (Exception ex) { if (!(ex is System.Threading.ThreadAbortException)) { Debug.LogError(ex); } } }
public void GetNewWallpaper() { NotifyIconText = "Retrieving next picture..."; NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrwait; IsNotifyFail = false; if (ApiKey.Equals(string.Empty)) { NotifyIconText = "API key missing"; NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrbad; IsNotifyFail = true; return; } FlickrNet.Flickr flickr = new FlickrNet.Flickr(); flickr.ApiKey = ApiKey; FlickrNet.PhotoCollection photos = null; switch (_settings.SearchOrFaves) { case 0: FlickrNet.PhotoSearchOptions options = new FlickrNet.PhotoSearchOptions(); if (!Tags.Trim().Equals(string.Empty)) { options.Tags = Tags; options.TagMode = GetTagMode(); } if (!UserId.Trim().Equals(string.Empty)) { FlickrNet.FoundUser fuser; string UserName = ""; string[] AllUserNames = UserId.Split(','); UserName = AllUserNames[new Random().Next(0, AllUserNames.GetUpperBound(0) + 1)]; try { // Exception handler added by CLR 2010-06-11 fuser = flickr.PeopleFindByUserName(UserName.Trim()); } catch (Exception ex) { FailWithError(ex); return; } if (!fuser.UserId.Equals(string.Empty)) { options.UserId = fuser.UserId; } } options.PrivacyFilter = FlickrNet.PrivacyFilter.PublicPhotos; options.SortOrder = GetSortOrder(); options.PerPage = 365; try { photos = flickr.PhotosSearch(options); //photos = flickr.PhotosGetRecent(); // this was me trying to do Explore stuff, but failed } catch (Exception ex) { //MessageBox.Show(ex.Message); FailWithError(ex); return; } options = null; break; case 1: try { FlickrNet.FoundUser fuser; fuser = flickr.PeopleFindByUserName(FaveUserId); photos = flickr.FavoritesGetPublicList(fuser.UserId); } catch (Exception ex) { FailWithError(ex); return; } break; case 2: // do explore try { photos = flickr.InterestingnessGetList(); } catch (Exception ex) { //MessageBox.Show(ex.Message); FailWithError(ex); return; } break; default: break; } clsWallpaper wallpaper = new clsWallpaper(); Random pn = new Random(); if (photos.Count == 0) { NotifyIconText = "Specified parameters return no photographs from Flickr"; NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrbad; IsNotifyFail = true; return; } else { int chosePhoto = pn.Next(0, photos.Count); //FlickrNet.Sizes fs = flickr.PhotosGetSizes("4570943273"); FlickrNet.SizeCollection fs; bool LoadedWallpaper = false; try { fs = flickr.PhotosGetSizes(photos[chosePhoto].PhotoId); // Load the last size (which should be "Original"). Doing all this // because photo.OriginalURL just causes an exception LoadedWallpaper = wallpaper.Load(fs[fs.Count - 1].Source, _settings, getDisplayStyle(), Application.ExecutablePath, photos[chosePhoto].WebUrl); } catch (Exception ex) // load failed with an exception { FailWithError(ex); return; } if (!LoadedWallpaper) // load failed, but didn't cause an exception { NotifyIconText = "Failed to load wallpaper"; NotifyIconIcon = WallpaperFlickr.Properties.Resources.flickrbad; IsNotifyFail = true; return; } // Get further info about the photo to display in the tooltip FlickrNet.PhotoInfo fi; try { fi = flickr.PhotosGetInfo(photos[chosePhoto].PhotoId); } catch (Exception ex) { FailWithError(ex); return; } // Set thumbnail NotifyIconIcon = TinyPictureVersion(FileSystem.MyPath() + "\\wallpaper\\_CurrentPaper.bmp"); FlickrNet.Person fuser; string notifyText = ""; fuser = flickr.PeopleGetInfo(photos[chosePhoto].UserId); notifyText = fuser.UserName + ": " + photos[chosePhoto].Title; string description = fi.Description; string location = "\n"; if (fi.Location != null) { if (fi.Location.County != null) { location += fi.Location.County.Description + ", " + fi.Location.Country.Description; } else { location += fi.Location.Country.Description; } } description = System.Web.HttpUtility.HtmlDecode(Regex.Replace(description, "<[^>]*>", "")); NotifyIconText = notifyText.Substring(0, Math.Min(63, notifyText.Length)); NotifyIconBalloonTipText = fi.DateTaken.ToLongDateString() + location + "\n" + description; NotifyIconBalloonTipTitle = photos[chosePhoto].Title; if (ShowBubbles) { NotifyPropertyChanged("PopupBalloon"); } } wallpaper = null; flickr = null; photos = null; //notifyIcon1.Icon = WallpaperFlickr.Properties.Resources.flickr; }