コード例 #1
0
ファイル: Picasa.cs プロジェクト: Sleeckx/Jamie
        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();
            }
        }
コード例 #2
0
ファイル: JamieActions.cs プロジェクト: Sleeckx/Jamie
 // NOTE: This class is used to add the extra custom actions used in the application (http://www.vidyano.com/Documentation/custom-actions)
 public static void RefreshAll(JamieEntityModelContainer context, CustomActionArgs e)
 {
     Picasa.UpdatePhotos();
 }