protected void Page_Load(object sender, EventArgs e) { if (!X.IsAjaxRequest) { if (Session["user"] != null && Request.QueryString["album"] != null) { PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(((User)Session["user"]).Username, Request.QueryString["album"] as string)); PicasaService tmp = Session["service"] as PicasaService; PicasaFeed feed = tmp.Query(query); List <object> data = new List <object>(feed.Entries.Count); foreach (PicasaEntry entry in feed.Entries) { data.Add(new { name = entry.Title.Text, url = entry.Content.AbsoluteUri, }); } //this.Store1.T this.Store1.DataSource = data; this.Store1.DataBind(); } } }
public static IEnumerable <PicasaAlbum> GetAlbums() { var albums = new List <PicasaAlbum>(); PicasaService service = new PicasaService("PicasaUnlistedAlbums"); service.setUserCredentials(WebConfigurationManager.AppSettings["Username"], WebConfigurationManager.AppSettings["Password"]); AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); PicasaFeed feed = service.Query(query); var albumsToExclude = WebConfigurationManager.AppSettings["AlbumsToExclude"].Split(',').ToList(); foreach (var atomEntry in feed.Entries) { var entry = (PicasaEntry)atomEntry; if (albumsToExclude.Contains(entry.Title.Text) || entry.Title.Text.Contains("Hangout")) { continue; } var album = new PicasaAlbum { Title = entry.Title.Text, Thumbnail = entry.Media.Thumbnails[0].Url, Link = entry.AlternateUri.Content }; albums.Add(album); } return(albums); }
public List <string> QueryTag(PicasaWebPhoto photo) { List <string> retval = new List <string>(); this.m_tagQuery = new TagQuery(TagQuery.CreatePicasaUri(this.m_userName, this.m_albumName, photo.AccessId)); this.m_tagService = new PicasaService("Tags"); //this.m_tagService.setUserCredentials(this.m_userName, this.m_password); this.m_tagService.SetAuthenticationToken(this.mUserToken); CreateTagProxy(); try { this.m_tagFeed = this.m_tagService.Query(this.m_tagQuery); foreach (PicasaEntry entry in m_tagFeed.Entries) { retval.Add(entry.Title.Text); } } catch (Exception e) { this.m_tagQuery = null; this.m_tagService.RequestFactory = null; this.m_tagService = null; this.m_tagFeed = null; throw new Exception("Query Tag Exception", e); } this.m_tagQuery = null; this.m_tagService.RequestFactory = null; this.m_tagService = null; this.m_tagFeed = null; return(retval); }
public ActionResult About() { string user = "******"; PicasaService service = new PicasaService("PhotoBrowser"); service.setUserCredentials(user, "**********"); AlbumQuery query = new AlbumQuery(); query.Uri = new Uri(PicasaQuery.CreatePicasaUri(user)); PicasaFeed picasaFeed = service.Query(query); List <PicasaEntry> result = new List <PicasaEntry>(); if (picasaFeed != null && picasaFeed.Entries.Count > 0) { foreach (PicasaEntry entry in picasaFeed.Entries) { result.Add(entry); } } return(View(result)); }
private void GetPhotosFromAlbum(Album album) { int pageSize = 500; long pageCount = album.NumPhotos / pageSize; int currentPage = 0; int num = 0; Console.WriteLine("Album: {0} ({1})", album.Title, album.NumPhotos); while (currentPage <= pageCount) { PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.Service.Credentials.Username, album.Id)); query.NumberToRetrieve = pageSize; query.StartIndex = currentPage * pageSize; query.ExtraParameters += "imgmax=d"; PicasaFeed feed = this.Service.Query(query); string destinationFolder = Path.Combine(this.DestinationRootPath, Utils.ScrubStringForFileSystem(album.Title)); foreach (PicasaEntry entry in feed.Entries) { Console.Write("\t [{0}/{1}]", num++.ToString("D4"), album.NumPhotos.ToString("D4")); DownloadPhotoDetails(entry, this.Service, destinationFolder); } currentPage++; } }
private void DeleteFilesFromAlbum(Dictionary <string, FileInfo> sourceFiles, PicasaFeed existingAlbumPhotosFeed) { foreach (PicasaEntry albumPhotoEntry in existingAlbumPhotosFeed.Entries) { bool deleteAlbumPhoto = false; if (!this.AddOnly && this.ClearAlbumPhotosFirst) { WriteOutput(string.Format("Deleting Album File: {0} (-emptyAlbumFirst option specified)", albumPhotoEntry.Title.Text), true); deleteAlbumPhoto = true; } else if (!this.AddOnly && !sourceFiles.ContainsKey(albumPhotoEntry.Title.Text)) { WriteOutput(string.Format("Deleting Album File: {0} (does not exist in source folder)", albumPhotoEntry.Title.Text), true); deleteAlbumPhoto = true; } else if (!this.AddOnly && sourceFiles[albumPhotoEntry.Title.Text].LastWriteTime > albumPhotoEntry.Published) { WriteOutput(string.Format("Deleting Album File: {0} (updated since last upload)", albumPhotoEntry.Title.Text), true); deleteAlbumPhoto = true; } if (deleteAlbumPhoto) { albumPhotoEntry.Delete(); albumPhotoEntry.Summary.Text = ENTRY_DELETED_SUMMARY; m_fileDeleteCount++; } } }
public NewAlbumDialog(PicasaService service, PicasaFeed feed) { // // Required for Windows Form Designer support // InitializeComponent(); this.service = service; this.feed = feed; }
public void CreateFeedEntryTest() { Uri uriBase = new Uri("http://www.google.com"); IService iService = null; // TODO: Initialize to an appropriate value PicasaFeed target = new PicasaFeed(uriBase, iService); // TODO: Initialize to an appropriate value PicasaEntry expected = null; expected = target.CreateFeedEntry() as PicasaEntry; Assert.IsNotNull(expected); }
public List <PicasaWebAlbum> QueryAlbums(BackgroundWorker worker, int overallJobPercent) { // Create an authentication factory to deal with logging in. GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); authFactory.AccountType = "GOOGLE_OR_HOSTED"; this.m_albumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); this.m_albumQuery.Access = PicasaQuery.AccessLevel.AccessAll; this.m_albumService = new PicasaService(authFactory.ApplicationName); this.m_albumService.RequestFactory = authFactory; // this.m_albumService.setUserCredentials(this.m_userName, this.m_password); //string token = this.m_albumService.QueryAuthenticationToken(); this.m_albumService.SetAuthenticationToken(this.mUserToken); List <PicasaWebAlbum> retval = new List <PicasaWebAlbum>(); decimal count = ((decimal)overallJobPercent / 100) * 10; int smallCount = (int)count; try { worker.ReportProgress(0, (object)"Creating proxy"); CreateAlbumProxy(); worker.ReportProgress(smallCount, (object)"Proxy created"); worker.ReportProgress(0, (object)"Querying google"); this.m_albumFeed = this.m_albumService.Query(this.m_albumQuery); worker.ReportProgress(smallCount, (object)"Done"); } catch (Exception e) { this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; retval = null; throw new Exception("PicasaReader failed when downloading album feed for " + this.m_userName, e); } if (this.m_albumFeed.Entries.Count > 0) { int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_albumFeed.Entries.Count), 0); worker.ReportProgress(0, (object)"Processing album data"); foreach (PicasaEntry entry in this.m_albumFeed.Entries) { AlbumAccessor ac = new AlbumAccessor(entry); retval.Add(new PicasaWebAlbum(entry.Title.Text, entry.Updated, ac.NumPhotos, Convert.ToUInt64(ac.Id))); worker.ReportProgress(percent, null); } } this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; return(retval); }
public AlbumsQuery(GooglePhotosService service) { this.service = service; AlbumQuery albumsQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); albumsQuery.ExtraParameters = "imgmax=d"; PicasaFeed albumsFeed = service.PicasaService.Query(albumsQuery); picasaAlbums = albumsFeed.Entries.OfType <PicasaEntry> ().ToArray(); }
public static AlbumSummary MapPicasaAlbum(PicasaFeed feed, string albumID) { return(new AlbumSummary { ID = albumID, ThumbnailUri = null, Title = feed.Title.Text, Description = feed.Subtitle.Text, PositionDateTime = feed.Updated }); }
private void buttonGetAlbumList_Click(object sender, EventArgs e) { authenticate(); string userName = comboLogin.Text; disableItemsForRun(); Thread thr = new Thread(new ThreadStart(delegate { try { AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(userName)); PicasaFeed feed = service.Query(query); Invoke(new MethodInvoker(delegate { listAlbums.Items.Clear(); albumMap.Clear(); foreach (PicasaEntry entry in feed.Entries) { AlbumAccessor ac = new AlbumAccessor(entry); listAlbums.Items.Add(ac.AlbumTitle); albumMap[ac.AlbumTitle] = ac; } if (feed.Entries.Count > 0) { listAlbums.SelectedIndex = 0; } buttonGetAlbumList.Enabled = true; updateItems(); })); } catch (Exception ex) { Invoke(new MethodInvoker(delegate { uploadLog.Text = "Album list upload failed: " + ex.Message + "\r\n"; listAlbums.Items.Clear(); albumMap.Clear(); updateItems(); })); } })); thr.Start(); }
/// <summary> /// Gets the album list. /// </summary> /// <param name="user">The user.</param> /// <returns>Dictionary of albums.</returns> public Dictionary <string, string> GetAlbumList(string user) { Dictionary <string, string> albums = new Dictionary <string, string>(); PicasaFeed picasaFeed = this.picasaService.Query(new AlbumQuery(PicasaQuery.CreatePicasaUri(user))); foreach (AtomEntry x in picasaFeed.Entries) { albums[x.FeedUri] = x.Title.Text; } return(albums); }
public ContentQuery(GooglePhotosService service, DiscretePicasaAlbum album) { this.service = service; this.album = album; Picasa.Album picasaAlbum = new Picasa.Album(); picasaAlbum.AtomEntry = album.Entry; PhotoQuery picturesQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri("default", picasaAlbum.Id)); picturesQuery.ExtraParameters = "imgmax=d"; PicasaFeed picturesFeed = service.PicasaService.Query(picturesQuery); picasaPictures = picturesFeed.Entries.OfType <PicasaEntry> ().ToArray(); }
public void DownloadMetadata() { AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(Username)); query.ExtraParameters += "imgmax=d"; // passing this param allows us to get the original image size. PicasaFeed feed = Service.Query(query); foreach (PicasaEntry entry in feed.Entries) { Album album = GetAlbum(entry); this.Albums.Add(album); this.TotalImageCount += album.NumPhotos; } }
/// <summary> /// Syncs a local folder to an online Picasa Web Album location /// </summary> /// <param name="folderPath">The source folder to sync.</param> public void SyncFolder(string folderPath) { ResetCounters(); PicasaService session = new PicasaService("PicasaWebSync"); session.setUserCredentials(this.PicasaUsername, this.PicasaPassword); AlbumQuery query = new AlbumQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername)); try { WriteOutput("[Connecting to Picasa web service]"); //fetch all albums PicasaFeed albumFeed = session.Query(query); WriteOutput("[Starting sync]"); folderPath = folderPath.TrimEnd(new char[] { '\\' }); DirectoryInfo sourceFolder = new DirectoryInfo(folderPath); m_baseDirectoryName = sourceFolder.Name; SyncFolder(sourceFolder, null, this.AlbumAccess, this.IncludeSubFolders, session, albumFeed); } catch (GDataRequestException gdrex) { if (gdrex.ResponseString.Contains(GDATA_RESPONSE_BADAUTH)) { throw new AuthenticationException("Picasa error - username and/or password is incorrect! Check the config file values."); } else { throw new Exception(string.Format("Picasa error - {0}", gdrex.ResponseString)); } } WriteOutput("[Done]"); WriteOutput(string.Empty); WriteOutput("Summary:"); WriteOutput(string.Format(" Folders skipped: {0}", m_folderSkipCount.ToString())); WriteOutput(string.Format(" Albums created: {0}", m_albumCreateCount.ToString())); WriteOutput(string.Format(" Albums updated: {0}", m_albumUpdateCount.ToString())); WriteOutput(string.Format(" Albums deleted: {0}", m_albumDeleteCount.ToString())); WriteOutput(string.Format(" Files uploaded: {0}", m_fileCreateCount.ToString())); WriteOutput(string.Format(" Files removed: {0}", m_fileDeleteCount.ToString())); WriteOutput(string.Format(" Files skipped: {0}", m_fileSkipCount.ToString())); WriteOutput(string.Format(" Errors occured: {0}", m_errorsCount.ToString())); WriteOutput(string.Format(" Elapsed time: {0}", (DateTime.Now - m_startTime).ToString())); }
public List <string> QueryTag(PicasaWebPhoto photo, BackgroundWorker worker, int overallJobPercent) { List <string> retval = new List <string>(); this.m_tagQuery = new TagQuery(TagQuery.CreatePicasaUri(this.m_userName, this.m_albumName, photo.AccessId)); this.m_tagService = new PicasaService("Tags"); //this.m_tagService.setUserCredentials(this.m_userName, this.m_password); this.m_tagService.SetAuthenticationToken(this.mUserToken); decimal count = ((decimal)overallJobPercent / 100) * 10; int smallCount = (int)count; worker.ReportProgress(0, (object)"Creating proxy"); CreateTagProxy(); try { worker.ReportProgress(smallCount, (object)"Proxy created"); worker.ReportProgress(0, (object)"Querying google"); this.m_tagFeed = this.m_tagService.Query(this.m_tagQuery); worker.ReportProgress(smallCount, (object)"Done"); if (this.m_tagFeed.Entries.Count > 0) { int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_tagFeed.Entries.Count), 0); worker.ReportProgress(0, (object)"Processing tag data"); foreach (PicasaEntry entry in m_tagFeed.Entries) { retval.Add(entry.Title.Text); worker.ReportProgress(percent, null); } } } catch (Exception e) { this.m_tagQuery = null; this.m_tagService.RequestFactory = null; this.m_tagService = null; this.m_tagFeed = null; throw new Exception("Query Tag Exception", e); } this.m_tagQuery = null; this.m_tagService.RequestFactory = null; this.m_tagService = null; this.m_tagFeed = null; return(retval); }
private static List <PhotoMessage> GetPhotos() { List <PhotoMessage> ans = new List <PhotoMessage>(); try { string fileName; Uri uriPath; WebClient HttpClient = new WebClient(); PhotoQuery query = new PhotoQuery(); query.Uri = new Uri(PhotoQuery.CreatePicasaUri("hagit.oded", "5780002529047522017")); PicasaService service = new PicasaService("PicasaAlbumDownloader"); PicasaFeed feed = (PicasaFeed)service.Query(query); Directory.SetCurrentDirectory("C:\\Photos\\"); foreach (AtomEntry aentry in feed.Entries) { uriPath = new Uri(aentry.Content.Src.ToString()); fileName = uriPath.LocalPath.Substring(uriPath.LocalPath.LastIndexOf('/') + 1); try { Console.WriteLine("Downloading: " + fileName); HttpClient.DownloadFile(aentry.Content.Src.ToString(), fileName); ans.Add(new PhotoMessage("C:\\Photos\\" + fileName)); } catch (WebException we) { try { HttpClient.DownloadFile(aentry.Content.Src.ToString(), fileName); ans.Add(new PhotoMessage("C:\\Photos\\" + fileName)); } catch (WebException we2) { Console.WriteLine(we2.Message); } } } } catch (Exception ex) { Console.Out.WriteLine(ex.Message); System.Diagnostics.EventLog.WriteEntry("WeddApp", ex.Message, System.Diagnostics.EventLogEntryType.Error, 626); } return(ans); }
public List <PicasaWebPhoto> QueryPhoto(BackgroundWorker worker, int overallJobPercent) { List <PicasaWebPhoto> retval = new List <PicasaWebPhoto>(); this.m_photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.m_userName, this.m_albumName)); this.m_photoService = new PicasaService(this.m_serviceName); //this.m_photoService.setUserCredentials(this.m_userName, this.m_password); this.m_photoService.SetAuthenticationToken(this.mUserToken); decimal count = ((decimal)overallJobPercent / 100) * 10; int smallCount = (int)count; worker.ReportProgress(0, (object)"Creating proxy"); CreatePhotoProxy(); try { worker.ReportProgress(smallCount, (object)"Proxy created"); worker.ReportProgress(0, (object)"Querying google"); this.m_photoFeed = this.m_photoService.Query(this.m_photoQuery); worker.ReportProgress(smallCount, (object)"Done"); if (this.m_photoFeed.Entries.Count > 0) { int percent = (int)Math.Round((decimal)((overallJobPercent - (smallCount * 2)) / this.m_photoFeed.Entries.Count), 0); worker.ReportProgress(0, (object)"Processing photo data"); foreach (PicasaEntry photo in this.m_photoFeed.Entries) { retval.Add(new PicasaWebPhoto(photo, this.m_albumName)); worker.ReportProgress(percent, null); } } } catch (Exception e) { this.m_photoQuery = null; this.m_photoService.RequestFactory = null; this.m_photoService = null; this.m_photoFeed = null; throw new Exception("Query Photo Exception", e); } this.m_photoQuery = null; this.m_photoService.RequestFactory = null; this.m_photoService = null; this.m_photoFeed = null; return(retval); }
///////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// /// <summary>tries to insert a photo using MIME multipart</summary> ////////////////////////////////////////////////////////////////////// [Test] public void InsertMimePhotoTest() { Tracing.TraceMsg("Entering InsertMimePhotoTest"); AlbumQuery query = new AlbumQuery(); PicasaService service = new PicasaService("unittests"); if (this.defaultPhotosUri != null) { if (this.userName != null) { service.Credentials = new GDataCredentials(this.userName, this.passWord); } query.Uri = new Uri(this.defaultPhotosUri); PicasaFeed feed = service.Query(query); if (feed != null) { Assert.IsTrue(feed.Entries != null, "the albumfeed needs entries"); Assert.IsTrue(feed.Entries[0] != null, "the albumfeed needs at least ONE entry"); PicasaEntry album = feed.Entries[0] as PicasaEntry; PhotoEntry newPhoto = new PhotoEntry(); newPhoto.Title.Text = "this is a title"; newPhoto.Summary.Text = "A lovely shot in the ocean"; newPhoto.MediaSource = new MediaFileSource(this.resourcePath + "testnet.jpg", "image/jpeg"); Uri postUri = new Uri(album.FeedUri.ToString()); PicasaEntry entry = service.Insert(postUri, newPhoto) as PicasaEntry; Assert.IsTrue(entry.IsPhoto, "the new entry should be a photo entry"); entry.Title.Text = "This is a new Title"; entry.Summary.Text = "A lovely shot in the shade"; entry.MediaSource = new MediaFileSource(this.resourcePath + "testnet.jpg", "image/jpeg"); PicasaEntry updatedEntry = entry.Update() as PicasaEntry; Assert.IsTrue(updatedEntry.IsPhoto, "the new entry should be a photo entry"); Assert.IsTrue(updatedEntry.Title.Text == "This is a new Title", "The titles should be identical"); Assert.IsTrue(updatedEntry.Summary.Text == "A lovely shot in the shade", "The summariesa should be identical"); } } }
private static string GetAlbum(string album) { string retVal; try { var service = new PicasaService("exampleCo-exampleApp-1"); string usr = Settings.GetSingleValue("Account") + "@gmail.com"; string pwd = Settings.GetSingleValue("Password"); service.setUserCredentials(usr, pwd); var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(usr, album)); PicasaFeed feed = service.Query(query); retVal = "<ul id=\"AlbumList\">"; foreach (PicasaEntry entry in feed.Entries) { var firstThumbUrl = entry.Media.Thumbnails[0].Attributes["url"] as string; string thumGrp = "/s" + Settings.GetSingleValue("PicWidth") + "/"; if (firstThumbUrl != null) { firstThumbUrl = firstThumbUrl.Replace("/s72/", thumGrp); } var contentUrl = entry.Media.Content.Attributes["url"] as string; if (contentUrl != null) { contentUrl = contentUrl.Substring(0, contentUrl.LastIndexOf("/")); } contentUrl += "/s640/" + entry.Title.Text; retVal += string.Format(Img, firstThumbUrl, contentUrl); } retVal += "</ul>"; } catch (Exception qex) { retVal = qex.Message; } return(retVal); }
public static PicasaEntry RetrievePicasaEntry(string id) { PicasaService service = new PicasaService(Picasa_APPLICATION_NAME); service.setUserCredentials(config.Username, config.Password); PhotoQuery photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(config.Username, string.Empty, id)); photoQuery.NumberToRetrieve = 1; PicasaFeed picasaFeed = service.Query(photoQuery); if (picasaFeed.Entries.Count > 0) { return((PicasaEntry)picasaFeed.Entries[0]); } return(null); }
protected void Page_Load(object sender, EventArgs e) { GotoAuthSubLink.Visible = false; if (Session["token"] != null) { Response.Redirect("Default.aspx"); } else if (Request.QueryString["token"] != null) { User u = new User(); u.Username = "******"; u.Password = "******"; PicasaService.setUserCredentials(u.Username, u.Password); AlbumQuery albumQuery = new AlbumQuery(); albumQuery.Uri = new Uri(PicasaQuery.CreatePicasaUri(u.Username)); //albumQuery.Access = PicasaQuery.AccessLevel.AccessPublic; PicasaFeed feed = PicasaService.Query(albumQuery); Session["feed"] = feed; Session["service"] = PicasaService; Session["user"] = u; if (feed.Entries.Count > 0) { AlbumAccessor myAlbum = new AlbumAccessor((PicasaEntry)feed.Entries[0]); Response.Redirect("Default.aspx?album=" + myAlbum.Id, true); } else { Response.Redirect("Default.aspx", true); } } else //no auth data, print link { GotoAuthSubLink.Text = "Login to your Google Account"; GotoAuthSubLink.Visible = true; GotoAuthSubLink.NavigateUrl = AuthSubUtil.getRequestUrl(Request.Url.ToString(), "https://picasaweb.google.com/data/", false, true); } }
protected virtual void Dispose(bool disposing) { if (!is_disposed) // only dispose once! { if (disposing) { m_albumService = null; m_albumFeed = null; m_albumQuery = null; m_photoService = null; m_photoQuery = null; m_photoFeed = null; m_userName = null; m_serviceName = null; m_albumName = null; } } this.is_disposed = true; }
/* public string LoginToGoogle(out string token) * { * GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); * authFactory.AccountType = "GOOGLE_OR_HOSTED"; * * this.m_albumService = new PicasaService(authFactory.ApplicationName); * try * { * this.m_albumService.setUserCredentials(this.m_userName, this.m_password); * this.m_albumService.QueryAuthenticationToken(); // Authenticate the user immediately * } * catch (CaptchaRequiredException e) * { * token = e.Token; * return e.Url; * } * } * * public string LoginToGoogle(out string token, string CAPTCHAAnswer, string CAPTCHAToken) * { * GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); * authFactory.AccountType = "GOOGLE_OR_HOSTED"; * string token = string.Empty; * this.m_albumService = new PicasaService(authFactory.ApplicationName); * authFactory.CaptchaAnswer = CAPTCHAAnswer; * authFactory.CaptchaToken = CAPTCHAToken; * this.m_albumService.setUserCredentials(this.m_userName, this.m_password); * * token = this.m_albumService.QueryAuthenticationToken(); // Authenticate the user immediately * return token; * * * } */ public List <PicasaWebAlbum> QueryAlbums() { // Create an authentication factory to deal with logging in. GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); authFactory.AccountType = "GOOGLE_OR_HOSTED"; this.m_albumService = new PicasaService(authFactory.ApplicationName); this.m_albumService.RequestFactory = authFactory; this.m_albumService.SetAuthenticationToken(this.mUserToken); this.m_albumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("default")); this.m_albumQuery.Access = PicasaQuery.AccessLevel.AccessAll; List <PicasaWebAlbum> retval = new List <PicasaWebAlbum>(); try { CreateAlbumProxy(); this.m_albumFeed = this.m_albumService.Query(this.m_albumQuery); } catch (Exception e) { this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; retval = null; throw new Exception("PicasaReader failed when downloading album feed for " + this.m_userName, e); } foreach (PicasaEntry entry in this.m_albumFeed.Entries) { AlbumAccessor ac = new AlbumAccessor(entry); retval.Add(new PicasaWebAlbum(entry.Title.Text, entry.Updated, ac.NumPhotos, Convert.ToUInt64(ac.Id))); } this.m_albumQuery = null; this.m_albumService.RequestFactory = null; this.m_albumService = null; this.m_albumFeed = null; return(retval); }
public List <PicasaWebPhoto> QueryPhoto(string tags) { List <PicasaWebPhoto> retval = new List <PicasaWebPhoto>(); GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("lh2", this.m_serviceName); authFactory.AccountType = "GOOGLE_OR_HOSTED"; this.m_photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.m_userName, this.m_albumName)); this.m_photoQuery.Tags = tags; this.m_photoService = new PicasaService(authFactory.ApplicationName); this.m_photoService.RequestFactory = authFactory; //this.m_photoService.setUserCredentials(this.m_userName, this.m_password); this.m_photoService.SetAuthenticationToken(this.mUserToken); CreatePhotoProxy(); try { this.m_photoFeed = this.m_photoService.Query(this.m_photoQuery); foreach (PicasaEntry photo in this.m_photoFeed.Entries) { retval.Add(new PicasaWebPhoto(photo, this.m_albumName)); } } catch (Exception e) { throw new Exception("Query Photo Exception", e); } finally { this.m_photoQuery = null; this.m_photoService.RequestFactory = null; this.m_photoService = null; this.m_photoFeed = null; } return(retval); }
/// <summary> /// Gets the photo list. /// </summary> /// <param name="feedUri">The feed URI.</param> /// <returns>Dictionary of photos.</returns> public Dictionary <string, Tuple <string, string> > GetPhotoList(string feedUri) { const int Medium = 1; Dictionary <string, Tuple <string, string> > photos = new Dictionary <string, Tuple <string, string> >(); PhotoQuery query = new PhotoQuery(feedUri) { ExtraParameters = "imgmax=1600" }; PicasaFeed picasaFeed = this.picasaService.Query(query); foreach (PicasaEntry x in picasaFeed.Entries) { string imageUrl = x.Media.Content.Url; string thumbnailUrl = x.Media.Thumbnails[Medium].Url; string imageTitle = x.Summary.Text; Tuple <string, string> photo = new Tuple <string, string>(thumbnailUrl, imageTitle); photos[imageUrl] = photo; } return(photos); }
private Album CreateAlbum(PicasaService session, PicasaFeed albumFeed, string targetAlbumName, AlbumAccessEnum albumAccess) { //create album (doesn't exist) WriteOutput(string.Concat("Creating Album: ", targetAlbumName), true); AlbumEntry newAlbumEntry = new AlbumEntry(); newAlbumEntry.Title.Text = targetAlbumName; newAlbumEntry.Summary.Text = targetAlbumName; newAlbumEntry.Published = DateTime.Now; Album newAlbum = new Album(); newAlbum.AtomEntry = newAlbumEntry; newAlbum.Access = albumAccess.ToString().ToLower(); Uri insertAlbumFeedUri = new Uri(PicasaQuery.CreatePicasaUri(this.PicasaUsername)); newAlbum.AtomEntry = (PicasaEntry)session.Insert(insertAlbumFeedUri, newAlbumEntry); m_albumCreateCount++; return(newAlbum); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["feed"] != null) { PicasaFeed feed = Session["feed"] as PicasaFeed; foreach (PicasaEntry entry in feed.Entries) { AlbumAccessor myAlbum = new AlbumAccessor((PicasaEntry)entry); entry.Etag = myAlbum.Id; } this.Repeater1.DataSource = feed.Entries; this.Repeater1.DataBind(); } if (Session["user"] != null) { Label_user.Text = ((User)Session["user"]).Username; } } }
private void UpdateAlbumFeed() { AlbumQuery query = new AlbumQuery(); this.AlbumList.Clear(); query.Uri = new Uri(PicasaQuery.CreatePicasaUri(this.user)); this.picasaFeed = this.picasaService.Query(query); if (this.picasaFeed != null && this.picasaFeed.Entries.Count > 0) { foreach (PicasaEntry entry in this.picasaFeed.Entries) { ListViewItem item = new ListViewItem(entry.Title.Text + " (" + entry.GetPhotoExtensionValue(GPhotoNameTable.NumPhotos) + " )"); item.Tag = entry; this.AlbumList.Items.Add(item); } } this.AlbumList.Update(); }