Пример #1
0
        public FacebookPhotoAlbum CreateAlbum(string name, string description, string location)
        {
            _Verify();

            var createMap = new METHOD_MAP
            {
                { "method", "photos.createAlbum" },
                { "name", name },
            };

            if (!string.IsNullOrEmpty(description))
            {
                createMap.Add("description", description);
            }

            if (!string.IsNullOrEmpty(location))
            {
                createMap.Add("location", location);
            }

            string createAlbumResponse = Utility.FailableFunction(() => _SendRequest(createMap));

            FacebookPhotoAlbum album = _jsonSerializer.DeserializeUploadAlbumResponse(createAlbumResponse);

            album.RawPhotos = new FBMergeableCollection <FacebookPhoto>();
            return(album);
        }
Пример #2
0
        public FacebookPhotoAlbum DeserializeUploadAlbumResponse(string jsonString)
        {
            // photos.Upload returns photo data embedded in the root node.
            JSON_OBJECT        jsonAlbum = SafeParseObject(jsonString);
            FacebookPhotoAlbum album     = _DeserializeAlbum(jsonAlbum);

            return(album);
        }
Пример #3
0
        public string[] GetWordsFromPhoto(FacebookPhoto photo, FacebookPhotoAlbum album)
        {
            if (photo == null)
            {
                return(null);
            }

            return(GetWords(photo.Caption, (album.Owner != null) ? album.Owner.Name : ""));
        }
Пример #4
0
        public string[] GetWordsFromAlbum(FacebookPhotoAlbum album)
        {
            if (album == null)
            {
                return(null);
            }

            return(GetWords(album.Title, album.Description, album.Location, (album.Owner != null) ? album.Owner.Name : ""));
        }
Пример #5
0
 private void IndexPhotos(FacebookPhotoAlbum album)
 {
     if (album.RawPhotos != null)
     {
         lock (album.RawPhotos.SyncRoot)
         {
             foreach (FacebookPhoto photo in album.RawPhotos)
             {
                 string[] words = GetWordsFromPhoto(photo, album);
                 ReplaceForwardIndexItem(photo, words);
                 IndexTags(photo);
             }
         }
     }
 }
Пример #6
0
        private FacebookPhotoAlbum _DeserializeAlbum(JSON_OBJECT jsonAlbum)
        {
            Uri linkUri = _SafeGetUri(jsonAlbum, "link");

            var album = new FacebookPhotoAlbum(_service)
            {
                AlbumId      = _SafeGetId(jsonAlbum, "aid"),
                CoverPicPid  = _SafeGetId(jsonAlbum, "cover_pid"),
                OwnerId      = _SafeGetId(jsonAlbum, "owner"),
                Title        = _SafeGetString(jsonAlbum, "name"),
                Created      = _SafeGetDateTime(jsonAlbum, "created") ?? _UnixEpochTime,
                LastModified = _SafeGetDateTime(jsonAlbum, "modified") ?? _UnixEpochTime,
                Description  = _SafeGetString(jsonAlbum, "description"),
                Location     = _SafeGetString(jsonAlbum, "location"),
                Link         = linkUri,
                // Size = _SafeGetInt32(elt, "size"),
                // Visible = _SafeGetValue(elt, "visible"),
            };

            return(album);
        }
Пример #7
0
        public object[] GetRelevantFacebookObjects(object o)
        {
            List <object> objects = new List <object>();

            FacebookContact contact = o as FacebookContact;

            if (contact != null)
            {
                foreach (var post in _service.RawNewsFeed)
                {
                    if (post.ActorUserId == contact.UserId)
                    {
                        objects.Add(post);
                    }

                    foreach (var comment in post.Comments)
                    {
                        if (comment.FromUserId == contact.UserId)
                        {
                            objects.Add(comment);
                        }
                    }
                }

                foreach (var album in _service.RawPhotoAlbums)
                {
                    if (album.OwnerId == contact.UserId)
                    {
                        objects.Add(album);
                    }

                    foreach (var photo in album.Photos)
                    {
                        if (photo.OwnerId == contact.UserId)
                        {
                            objects.Add(photo);
                            continue;
                        }

                        foreach (var tag in photo.Tags)
                        {
                            if (tag.Contact != null && tag.Contact.UserId == contact.UserId)
                            {
                                objects.Add(photo);
                                goto next;
                            }
                        }

                        next :;
                    }
                }
            }

            FacebookPhoto p = o as FacebookPhoto;

            if (p != null)
            {
                objects.Add(p.Album);

                if (p.Album.Owner != null)
                {
                    objects.Add(p.Album.Owner);
                }

                foreach (var tag in p.Tags)
                {
                    if (tag.Contact != null && !objects.Contains(tag.Contact))
                    {
                        objects.Add(tag.Contact);
                    }
                }
            }

            FacebookPhotoAlbum a = o as FacebookPhotoAlbum;

            if (a != null)
            {
                if (a.Owner != null)
                {
                    objects.Add(a.Owner);
                }

                foreach (var photo in a.Photos)
                {
                    objects.Add(photo);

                    foreach (var tag in photo.Tags)
                    {
                        if (tag.Contact != null && !objects.Contains(tag.Contact))
                        {
                            objects.Add(tag.Contact);
                        }
                    }
                }
            }

            ActivityPost activityPost = o as ActivityPost;

            if (activityPost != null)
            {
                if (activityPost.Actor != null)
                {
                    objects.Add(activityPost.Actor);
                }

                if (activityPost.Target != null)
                {
                    objects.Add(activityPost.Target);
                }

                foreach (var comment in activityPost.Comments)
                {
                    objects.Add(comment);
                }
            }

            ActivityComment activityComment = o as ActivityComment;

            if (activityComment != null)
            {
                if (activityComment.FromUser != null)
                {
                    objects.Add(activityComment.FromUser);
                }
            }

            objects.Sort(new SearchResultsComparer());
            return(objects.ToArray());
        }