Esempio n. 1
0
        private void ProcessPhoto(responsePhoto photo, VkGroup group)
        {
            var savedPhoto = this.photoRepository.GetPhotoByIdInAlbum(group.Id, photo.aid, photo.pid);

            if (savedPhoto != null)
            {
                this.log.DebugFormat("Photo with VkId={0} is already in database", photo.pid);
                return;
            }

            if (this.processingStrategy.IsLimitedProcessingEnabled(group.Id, DataFeedType.Photo) &&
                photo.created.FromUnixTimestamp().AddMonths(this.processingStrategy.GetMonthLimit()) < DateTime.UtcNow)
            {
                this.log.DebugFormat("Fetched photo with VkId={0} is created more than {1} months ago. Skipping.", photo.pid, this.processingStrategy.GetMonthLimit());
                return;
            }

            savedPhoto = new Photo
            {
                VkGroupId  = group.Id,
                PostedDate = photo.created.FromUnixTimestamp(),
                VkId       = photo.pid,
                AlbumId    = photo.aid,
                Text       = photo.text
            };

            this.photoRepository.Save(savedPhoto);
            this.log.DebugFormat("Photo with VkId={0} is not found in database. Saved with Id={1}", savedPhoto.VkId, savedPhoto.Id);
        }
Esempio n. 2
0
        private void ProcessPhotoDetails(responsePhoto photo, VkGroup group)
        {
            var savedPhoto = this.photoRepository.GetPhotoByIdInAlbum(group.Id, photo.aid, photo.pid);

            if (savedPhoto == null)
            {
                this.log.DebugFormat("Photo with VkId={0} is not in database", photo.pid);
                return;
            }

            int commentsCount = int.Parse(photo.comments[0].count);
            int likesCount    = int.Parse(photo.likes[0].count);

            if (savedPhoto.CommentsCount != commentsCount || savedPhoto.LikesCount != likesCount)
            {
                savedPhoto.CommentsCount = commentsCount;
                savedPhoto.LikesCount    = likesCount;
                this.photoRepository.UpdatePhoto(savedPhoto);
                this.log.DebugFormat("Photo with VkId={0} comments and likes are updated.", savedPhoto.VkId);
            }
        }