コード例 #1
0
        private void CreatePhotoElement(PicasaWebPhoto photo, PicasaWebAlbum album)
        {
            bool update = false;
            var  query  = from photoRow in ((DataTable)this.mDatabase.Photo).AsEnumerable()
                          where photoRow.Field <string>("ID") == photo.Id
                          select photoRow;

            foreach (PhotoDataSet.PhotoRow photoRow in query)
            {
                if (photoRow.PhotoID != Convert.ToUInt64(photo.AccessId))
                {
                    photoRow.PhotoID = Convert.ToUInt64(photo.AccessId);
                }
                if (photoRow.Title != photo.Title)
                {
                    photoRow.Title = photo.Title;
                }
                if (photoRow.Album != photo.AlbumName)
                {
                    photoRow.Album = photo.AlbumName;
                }
                if (photoRow.Height != Convert.ToUInt16(photo.Height))
                {
                    photoRow.Height = Convert.ToUInt16(photo.Height);
                }
                if (photoRow.Width != Convert.ToUInt16(photo.Width.ToString()))
                {
                    photoRow.Width = Convert.ToUInt16(photo.Width.ToString());
                }
                if (photoRow.Uploaded != photo.Uploaded)
                {
                    photoRow.Uploaded = photo.Uploaded;
                }
                if (photoRow.Location != photo.Location)
                {
                    photoRow.Location = photo.Location;
                }
                photoRow.Keep = true;
                update        = true;
            }
            if (!update)
            {
                this.mDatabase.Photo.AddPhotoRow(photo.Id, Convert.ToUInt64(photo.AccessId), photo.Title, photo.AlbumName, Convert.ToUInt16(photo.Height), Convert.ToUInt16(photo.Width.ToString()), photo.Uploaded, photo.Location, true, album.Id);
            }
        }
コード例 #2
0
        private void AddPhotos(PicasaWebAlbum album)
        {
            PicasaWebReader reader  = null;
            WebProxy        myProxy = CreateProxy();
            var             query   = from photoRow in ((DataTable)this.mDatabase.Photo).AsEnumerable()
                                      where photoRow.Field <ulong>("AlbumId") == album.Id
                                      select photoRow;

            foreach (PhotoDataSet.PhotoRow photoRow in query)
            {
                try
                {
                    photoRow.Keep = false;
                }
                catch
                {
                }
            }


            try
            {
                reader = new PicasaWebReader(this.mUserName, "WebAlbum", album.Id.ToString() /* album.AlbumName.Replace(" ", "")*/, myProxy, this.mToken);
            }
            catch (Exception e)
            {
                this.ev_ExceptionThrown(e, "Collecting photos from: " + album.AlbumName + " " + this.mUserName);
                if (reader != null)
                {
                    reader.Dispose();
                }
                reader = null;
            }
            string[] tags = this.mTag.Split(" ".ToCharArray());

            List <PicasaWebPhoto> photos = null;

            foreach (string tag in tags)
            {
                photos = reader.QueryPhoto(tag);
                try
                {
                    foreach (PicasaWebPhoto webphoto in photos)
                    {
                        this.CreatePhotoElement(webphoto, album);
                        webphoto.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    this.ev_ExceptionThrown(ex, "Adding Photos to the data file");
                    if (reader != null)
                    {
                        reader.Dispose();
                    }
                    reader = null;
                    photos.Clear();
                    photos = null;
                }
            }
            if (reader != null)
            {
                reader.Dispose();
            }
            reader = null;
            photos.Clear();
            photos = null;
        }