public string ExportAlbum(string albumFeedUri, string template, int previewMaxWidth, int previewMaxHeight)
        {
            PhotoQuery query = new PhotoQuery(albumFeedUri);
            PicasaFeed feed = this.Service.Query(query);

            photoCounter = 0;
            this.previewWidth = previewMaxWidth;
            this.previewHeight = previewMaxHeight;

            StringBuilder result = new StringBuilder();

            foreach (PicasaEntry photo in feed.Entries)
            {
                string html = template;

                foreach (var valueGetter in this.valueGetters)
                {
                    html = html.Replace(valueGetter.Key, valueGetter.Value(photo));
                }

                result.AppendLine(html);
            }

            string output = result.ToString();

            return output;
        }
Beispiel #2
0
        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();
                }
            }
        }
		private void AuthenticatePicasaButton_Click(object sender, RoutedEventArgs e)
		{
		    authenticatePicasaButton.IsEnabled = false;
		    authenticatePicasaLabel.Content = "";
			try
			{
			    var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(DataModel.Element.PicasaUsername));
			    query.NumberToRetrieve = 1;

			    var picasaService = new PicasaService(DataModel.Element.ApplicationName);
			    picasaService.setUserCredentials(DataModel.Element.GoogleUsername, DataModel.Element.GooglePassword);

			    var feed = picasaService.Query(query);

			    authenticatePicasaLabel.Content = "Authentication Successful";
			}
			catch (Exception exception)
			{
			    authenticatePicasaLabel.Content = "Authentication Failure";
			}
			finally
			{
                authenticatePicasaButton.IsEnabled = true;
			}
		}
Beispiel #4
0
 public void PhotoQueryConstructorTest()
 {
     string queryUri = "http://www.google.com/test";
     string expected = "http://www.google.com/test?kind=photo"; 
     PhotoQuery target = new PhotoQuery(queryUri);
     Assert.AreEqual(new Uri(expected), target.Uri);
 }
 public PicasaEntry GetPhoto(string albumId, string photoTitle)
 {
     PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(GetGUsername(), albumId));
     query.ExtraParameters = "imgmax=576";
     query.KindParameter = "";
     PicasaFeed feed = service.Query(query);
     var entry = feed.Entries.Where(d => d.Title.Text.ToLower() == photoTitle.ToLower()).FirstOrDefault();
     return (PicasaEntry)entry;
 }
Beispiel #6
0
        public static void UpdatePhotos()
        {
            using (var ctx = new JamieEntityModelContainer())
            {
                foreach (var owner in ctx.Owners)
                {
                    var service = GetService(owner);
                    if (ctx.Albums.Count() > 0)
                    {
                        owner.Albums.Run(album =>
                        {
                            var googleAlbum = GetAlbum(service, album.Id);
                            if (googleAlbum.Updated != album.LastUpdated)
                            {
                                var query = new PhotoQuery(PicasaQuery.CreatePicasaUri(owner.Name, album.Id)) { ExtraParameters = "imgmax=1280" };
                                var googlePhotos = service.Query(query).Entries.Select(entry => new Google.Picasa.Photo { AtomEntry = entry }).ToArray();
                                var albumPhotos = album.Photos.ToArray();

                                albumPhotos.Run(photo =>
                                {
                                    if (googlePhotos.FirstOrDefault(gPhoto => gPhoto.Id == photo.Id) != null)
                                        return;

                                    album.Photos.Remove(photo);
                                    ctx.Photos.DeleteObject(photo);
                                });

                                googlePhotos.Run(photo =>
                                {
                                    if (albumPhotos.FirstOrDefault(p => p.Id == photo.Id) != null || ctx.Photos.FirstOrDefault(p => p.Id == photo.Id) != null)
                                        return;

                                    var newPhoto = new Photo
                                    {
                                        Id = photo.Id,
                                        TimeTaken = FromUnixTimeStamp(photo.Timestamp),
                                        ThumbUri = ((PicasaEntry)photo.AtomEntry).Media.Thumbnails.Last().Url,
                                        FullUri = photo.AtomEntry.Content.AbsoluteUri
                                    };

                                    album.Photos.Add(newPhoto);
                                });

                                album.LastUpdated = googleAlbum.Updated;
                            }
                        });
                    }
                }

                ctx.SaveChanges();
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            DbUtils.OpenDbContext(db =>
            {
                // clear Db
                db.Database.ExecuteSqlCommand("DELETE FROM [Album]");
                //
                PicasaService service = new PicasaService("");
                var feed = default(PicasaFeed);
                // add albums
                {

                    AlbumQuery albumQuery = new AlbumQuery(PicasaQuery.CreatePicasaUri("109913968155621160630"));
                    feed = service.Query(albumQuery);
                    foreach (PicasaEntry entry in feed.Entries)
                    {
                        var apiAlbum = new AlbumAccessor(entry);
                        db.Albums.Add(new Album
                        {
                            ExternalId = apiAlbum.Id,
                            Name = apiAlbum.AlbumTitle,
                            CoverPath = entry.Media.Thumbnails[0].Url,
                            IsActive = false
                        });
                    }
                    db.SaveChanges();
                }
                // add images to albums
                {
                    foreach (var dbAlbum in db.Albums)
                    {
                        PhotoQuery photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri("109913968155621160630", dbAlbum.ExternalId));
                        feed = service.Query(photoQuery);
                        foreach (PicasaEntry entry in feed.Entries)
                        {
                            dbAlbum.AlbumImages.Add(new AlbumImage
                            {
                                Name = entry.Title.Text,
                                Path = entry.Media.Contents[0].Url,
                                Thumbnail = entry.Media.Thumbnails[entry.Media.Thumbnails.Count - 1].Url,
                                Description = entry.Media.Description.Value
                            });
                        }
                    }
                    db.SaveChanges();
                }
            });
        }
        public 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;
        }
        /// <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;
        }
Beispiel #10
0
        public IList<PicasaEntry> findPhotosByAlbum(string albumId)
        {
            PhotoQuery query = new PhotoQuery("http://picasaweb.google.com/data/feed/api/user/default/albumid/" + albumId + "?thumbsize=144u,640");
            //query.Thumbsize = "144u, 800u";

            PicasaFeed feed = Service.Query(query);

            IList<PicasaEntry> photos = new List<PicasaEntry>();

            foreach (PicasaEntry entry in feed.Entries)
            {
                PicasaEntry photo = entry;
                photos.Add(photo);
            }

            Google.GData.Photos.PicasaFeed tagFeed = Service.Query(new Google.GData.Photos.TagQuery(TagQuery.CreatePicasaUri("default")));

            foreach (PicasaEntry tag in tagFeed.Entries) {
                TagEntry tagEntry = (TagEntry) tag;
            }

            return photos;
        }
        private void LoadAlbumBackground(object sender, DoWorkEventArgs e)
        {
            //albums = new List<PicasaEntry>();
              //albumIndex = -1;

              // Prepare for contact query
              string applicationName = "DigitalFrame";
              string username = settings.Username;
              string password = settings.Password;

              RequestSettings contactRequestSettings = new RequestSettings(applicationName, username, password);
              ContactsRequest contactRequest = new ContactsRequest(contactRequestSettings);

              // Request all groups of the auth user.
              //var allGroups = contactRequest.GetGroups();
              //foreach (var item in allGroups.Entries) {
              //  Debug.Write(item.Id + " - " + item.Title);
              //}

              // Get Family group entry.
              Group familyGroup;
              StringBuilder gs = new StringBuilder(GroupsQuery.CreateGroupsUri("default"));
              gs.Append("/");
              gs.Append("e"); // Family

              try {
            Feed<Group> gf = contactRequest.Get<Group>(new Uri(gs.ToString()));
            familyGroup = gf.Entries.First();
              }
              catch (AuthenticationException) {
            // We fail to get the group which means the login failed.
            return;
              }
              catch (GDataRequestException) {
            return;
              }

              // Get all contacts in Family group.
              ContactsQuery contactQuery = new ContactsQuery(ContactsQuery.CreateContactsUri("default"));
              contactQuery.Group = familyGroup.Id;
              Feed<Contact> friends = contactRequest.Get<Contact>(contactQuery);

              // Prepare for picasa query
              service = new PicasaService(applicationName);
              service.setUserCredentials(username, password);
              service.SetAuthenticationToken(service.QueryAuthenticationToken());

              allPhotos = new List<PicasaEntry>();

              foreach (var contact in friends.Entries) {
            try {
              string friendUsername = ParseUserName(contact);
              if (!string.IsNullOrEmpty(friendUsername)) {
            AlbumQuery query = new AlbumQuery();
            query.Uri = new Uri(PicasaQuery.CreatePicasaUri(friendUsername));

            PicasaFeed picasaFeed = service.Query(query);
            if (picasaFeed != null && picasaFeed.Entries.Count > 0) {
              foreach (PicasaEntry albumEntry in picasaFeed.Entries) {
                PhotoQuery photosQuery = new PhotoQuery(albumEntry.FeedUri);
                var photosFeed = (PicasaFeed)service.Query(photosQuery);
                foreach (PicasaEntry photoEntry in photosFeed.Entries) {
                  allPhotos.Add(photoEntry);
                }
              }
            }
              }
            }
            catch (LoggedException) {
              // Ignore the exception and continue.
            }
              }
        }
 public AtomEntryCollection GetAllPhotos(string id)
 {
     PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(GetGUsername(), id) + "?imgmax=576");
     PicasaFeed feed = service.Query(query);
     return feed.Entries;
 }
        /// <summary>
        /// Syncs a local folder to an online Picasa Web Album location
        /// </summary>
        /// <param name="sourceFolder">The source folder to sync.</param>
        /// <param name="albumNamePrefix">A prefix to prepend to the album name.</param>
        /// <param name="includeSubFolders">Indicated whether to sync all subfolders recursively.</param>
        /// <param name="session">The current authenticated Picasa session.</param>
        /// <param name="albumFeed">A feed listing all existing Picass Web Albums in the Picasa account.</param>
        private void SyncFolder(DirectoryInfo sourceFolder, string albumNamePrefix, AlbumAccessEnum targetAlbumAccess, bool includeSubFolders, PicasaService session, PicasaFeed albumFeed)
        {
            if (!sourceFolder.Exists)
            {
                throw new DirectoryNotFoundException(string.Format("Folder '{0}' cannot be located.", sourceFolder.FullName));
            }

            string targetAlbumName = GetTargetAlbumName(sourceFolder, albumNamePrefix);
            Dictionary<string, FileInfo> sourceFiles = GetSourceFiles(sourceFolder);
            bool excludeFolder = ShouldExcludeFolder(sourceFolder, sourceFiles);
            PicasaEntry existingAlbumEntry = albumFeed.Entries.FirstOrDefault(a => a.Title.Text == targetAlbumName) as PicasaEntry;

            if (excludeFolder)
            {
                if (existingAlbumEntry != null && !this.AddOnly)
                {
                    //album needs to be removed
                    WriteOutput(string.Format("Removing Album: {0} (excluded but already exists)", targetAlbumName));
                    existingAlbumEntry.Delete();
                    existingAlbumEntry.Summary.Text = ENTRY_DELETED_SUMMARY;
                    m_albumDeleteCount++;
                }
                else
                {
                    m_folderSkipCount++;
                }
            }
            else
            {
                WriteOutput(string.Format("Syncing Folder: {0} to Album: {1}", sourceFolder.FullName, targetAlbumName), true);

                try
                {
                    targetAlbumAccess = DetermineAlbumAccess(sourceFolder, targetAlbumAccess);

                    if (sourceFiles.Count > 0)
                    {
                        Album targetAlbum = new Album();
                        if (existingAlbumEntry != null)
                        {
                            targetAlbum.AtomEntry = existingAlbumEntry;
                            if (targetAlbum.Access != targetAlbumAccess.ToString().ToLower())
                            {
                                UpdateAlbumAccess(session, targetAlbum, targetAlbumAccess);
                            }
                        }
                        else
                        {
                            targetAlbum = CreateAlbum(session, albumFeed, targetAlbumName, targetAlbumAccess);
                        }

                        PhotoQuery existingAlbumPhotosQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.PicasaUsername, targetAlbum.Id));
                        PicasaFeed existingAlbumPhotosFeed = session.Query(existingAlbumPhotosQuery);

                        //sync folder files
                        DeleteFilesFromAlbum(sourceFiles, existingAlbumPhotosFeed);

                        foreach (KeyValuePair<string, FileInfo> file in sourceFiles.OrderBy(f => f.Value.LastWriteTime))
                        {
                            AddFileToAlbum(file.Value, targetAlbum, existingAlbumPhotosFeed, session);
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteOutput(string.Format("Skipping Folder: {0} (Error - {1})", sourceFolder.Name, ex.Message), true);
                }

                if (includeSubFolders)
                {
                    DirectoryInfo[] subfolders = sourceFolder.GetDirectories().OrderBy(d => d.CreationTime).ToArray();
                    if (subfolders.Length > 0)
                    {
                        foreach (DirectoryInfo folder in subfolders)
                        {
                            SyncFolder(folder, targetAlbumName, targetAlbumAccess, includeSubFolders, session, albumFeed);
                        }
                    }
                }
            }
        }
        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;
        }
Beispiel #15
0
        private PicasaEntry FindFileByTitle(string title)
        {
            if (String.IsNullOrEmpty(title))
                throw new ArgumentNullException(title);

            PhotoQuery photoQuery = new PhotoQuery(PicasaQuery.CreatePicasaUri(_picasaService.Credentials.Username, Id));
            var results = from photo in _picasaService.Query(photoQuery).Entries
                          where photo.Title.Text == title
                          select photo;
            if (results.Count() > 0)
                return (PicasaEntry)results.First();

            return null;
        }
Beispiel #16
0
 public void PhotoQueryConstructorTest1()
 {
     PhotoQuery target = new PhotoQuery();
     Assert.IsNotNull(target);
 }
Beispiel #17
0
        private bool checkFileExists(string fileName, string albumName)
        {
            bool fileExists = false;
            
            PhotoQuery query = new PhotoQuery(PicasaQuery.CreatePicasaUri(this.user, albumName));
            PicasaFeed feed =null;

            try
            {
                feed = picasaService.Query(query);
            }
            catch (Exception)
            {
                return true;
            }

            foreach (PicasaEntry entry in feed.Entries)
            {
                if(entry.Title.Text.Equals(fileName)) fileExists = true;
            }
            return fileExists;
        }
Beispiel #18
0
 private void OnBrowseAlbum(object sender, System.EventArgs e)
 {
     foreach (ListViewItem item in this.AlbumList.SelectedItems) 
     {
         PicasaEntry entry = item.Tag as PicasaEntry;
         string photoUri = entry.FeedUri; 
         if (photoUri != null) 
         {
             PhotoQuery query = new PhotoQuery(photoUri);
             this.Cursor = Cursors.WaitCursor;
             PicasaFeed photoFeed = this.picasaService.Query(query);
             this.Cursor = Cursors.Default;
             PictureBrowser b = new PictureBrowser(this.picasaService, photoFeed, entry.Title.Text);
             b.Show();
         }
     }
 }
        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 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;
        }
Beispiel #21
0
        private void SaveAlbum_Click(object sender, System.EventArgs e)
        {
            foreach (ListViewItem item in this.AlbumList.SelectedItems) 
            {
                PicasaEntry entry = item.Tag as PicasaEntry;
                string photoUri = entry.FeedUri; 

                // Show the FolderBrowserDialog.
                DialogResult result = folderBrowserDialog.ShowDialog();
              
                if( result == DialogResult.OK )
                {
                    string folderName = folderBrowserDialog.SelectedPath;
                    this.Cursor = Cursors.WaitCursor;
        
                    if (photoUri != null) 
                    {
                        PhotoQuery query = new PhotoQuery(photoUri);
                        this.Cursor = Cursors.WaitCursor;
                        PicasaFeed photoFeed = this.picasaService.Query(query);
                 
                        int i=1;

                        foreach (PicasaEntry photo in photoFeed.Entries)
                        {
                            string filename = folderName + "\\image" + i.ToString() + ".jpg";
                            i++;
                            PictureBrowser.saveImageFile(photo, filename, this.picasaService);
                        }
                        
                        this.Cursor = Cursors.Default;
                    }
                }
            }
        }
        private List<PicasaEntry> GetItems(string uri, PicasaQuery.Kinds kind, string searchText = null)
        {
            var service = GetPicasaService();
            KindQuery query;
            switch (kind)
            {
                case PicasaQuery.Kinds.album:
                    query = new AlbumQuery(uri);
                    break;
                case PicasaQuery.Kinds.photo:
                    query = new PhotoQuery(uri);
                    if (!String.IsNullOrWhiteSpace(searchText))
                        query.Query = searchText;
                    break;
                default:
                    throw new NotImplementedException("Unknown kind");
            }

            query.NumberToRetrieve = 1000;



            PicasaFeed feed;
            try
            {
                feed = service.Query(query);
            }
            catch
            {
                //If a first error. Try recreate service 
                service = GetPicasaService(true);
                feed = service.Query(query);
            }
                        
            var result = new List<PicasaEntry>();
            while (feed.Entries!=null)
            {
                foreach (PicasaEntry entry in feed.Entries)
                    result.Add(entry);

                if (String.IsNullOrWhiteSpace(feed.NextChunk))
                    break;

                switch (kind)
                {
                    case PicasaQuery.Kinds.album:
                        query = new AlbumQuery(feed.NextChunk);
                        break;
                    case PicasaQuery.Kinds.photo:
                        query = new PhotoQuery(feed.NextChunk);
                        break;
                    default:
                        throw new NotImplementedException("Unknown kind");
                }
                try
                {
                    feed = service.Query(query);
                }
                catch
                {
                    //If a first error. Try recreate service 
                    service = GetPicasaService(true);
                    feed = service.Query(query);
                }
            }
            return result;
       }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Title = "Danh Sách Album";

            service.setUserCredentials("*****@*****.**", "doantruong");
            feed = service.Query(query);
            foreach (PicasaEntry entry in feed.Entries)
            {
                AlbumAccessor ac = new AlbumAccessor(entry);
                listAlbum.Add(ac);
            }
            if (!IsPostBack)
            {
                int soDong = LoadAlbum();
                FilterSTT(soDong, 0, 10);
            }
            this.GridViewPicasa.HeaderStyle.CssClass = "headerstyle";

            //photos

            string maAlbum = null;
            List<SPHOTO> listPhotos = new List<SPHOTO>();
            if(Request.QueryString["id"] != null)
            {
                maAlbum = Request.QueryString["id"].ToString();
            }
            if(maAlbum != null)
            {
                PhotoQuery Pquery = new PhotoQuery(PicasaQuery.CreatePicasaUri("*****@*****.**",maAlbum));
                feed = service.Query(Pquery);
                foreach (PicasaEntry entry in feed.Entries)
                {
                    SPHOTO temp = new SPHOTO();

                    temp.title = entry.Title.Text;
                    temp.thumbURL = entry.Media.Thumbnails[1].Attributes["url"] as string;
                    listPhotos.Add(temp);

                }
                ListViewPhotos.DataSource = listPhotos;
                ListViewPhotos.DataBind();
            }
            if (maAlbum != null)
            {
                //lay ma

                //lay thong tin va load len cac textbox
                for (int i = 0; i < listAlbum.Count; i++)
                {
                    if (listAlbum[i].Id == maAlbum)
                    {
                        currentAlbum = listAlbum[i];
                        break;
                    }
                }
                switch (currentAlbum.Access)
                {
                    case "public":
                        DropDownListAccess.SelectedIndex = 0;
                        break;

                    case "private":
                        DropDownListAccess.SelectedIndex = 1;
                        break;
                    case "protected":
                        DropDownListAccess.SelectedIndex = 2;
                        break;

                }
                txtalbumtitle.Text = currentAlbum.AlbumTitle;
                txtmieuta.Text = currentAlbum.AlbumSummary;
            }
        }
        public static List<PicasaPhoto> GetAlbumContent(string album)
        {
            List<PicasaPhoto> retVal = new List<PicasaPhoto>();
            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);

                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.Add(new PicasaPhoto() { Title = entry.Summary.Text, ImageSrc = contentUrl, Url = firstThumbUrl });
                }
            }
            catch
            {
                retVal = null;
            }
            return retVal;
        }
        /////////////////////////////////////////////////////////////////////////////

        //////////////////////////////////////////////////////////////////////
        /// <summary>runs an authentication test, iterates all entries</summary> 
        //////////////////////////////////////////////////////////////////////
        [Test] public void QueryPhotosTest()
        {
            Tracing.TraceMsg("Entering PhotosQueryPhotosTest");

            PhotoQuery query = new PhotoQuery();
            PicasaService service = new PicasaService("unittests");
           
            if (this.defaultPhotosUri != null)
            {
                if (this.userName != null)
                {
                    service.Credentials = new GDataCredentials(this.userName, this.passWord);
                }

                GDataLoggingRequestFactory factory = (GDataLoggingRequestFactory) this.factory;
                factory.MethodOverride = true;
                service.RequestFactory = this.factory; 

                query.Uri = new Uri(this.defaultPhotosUri);
                PicasaFeed feed = service.Query(query);

                ObjectModelHelper.DumpAtomObject(feed,CreateDumpFileName("PhotoAuthTest")); 
     
                if (feed != null && feed.Entries.Count > 0)
                {
                    Tracing.TraceMsg("Found a Feed " + feed.ToString());
                    DisplayExtensions(feed);

                    foreach (PicasaEntry entry in feed.Entries)
                    {
                        Tracing.TraceMsg("Found an entry " + entry.ToString());
                        DisplayExtensions(entry);

                        GeoRssWhere w = entry.Location;
                        if (w != null)
                        {
                            Tracing.TraceMsg("Found an location " + w.Latitude + w.Longitude);
                        }

                        ExifTags tags = entry.Exif;
                        if (tags != null)
                        {
                            Tracing.TraceMsg("Found an exif block ");
                        }

                        MediaGroup group = entry.Media;
                        if (group != null)
                        {
                            Tracing.TraceMsg("Found a media Group");
                            if (group.Title != null)
                            {
                                Tracing.TraceMsg(group.Title.Value);
                            }
                            if (group.Keywords != null)
                            {
                                Tracing.TraceMsg(group.Keywords.Value);
                            }
                            if (group.Credit != null)
                            {
                                Tracing.TraceMsg(group.Credit.Value);
                            }
                            if (group.Description != null)
                            {
                                Tracing.TraceMsg(group.Description.Value);
                            }
                        }


                        PhotoAccessor photo = new PhotoAccessor(entry);

                        Assert.IsTrue(entry.IsPhoto, "this is a photo entry, it should have the kind set");
                        Assert.IsTrue(photo != null, "this is a photo entry, it should convert to PhotoEntry");

                        Assert.IsTrue(photo.AlbumId != null);
                        Assert.IsTrue(photo.Height > 0);
                        Assert.IsTrue(photo.Width > 0);
                    }
                }

                factory.MethodOverride = false;
            }
        }
        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;
        }