예제 #1
0
        private DataFeed GetFeeds(IVkDataProvider dataProvider, LikeShareType type, string entityVkId, VkGroup vkGroup, ref int offsetCounter)
        {
            var sharesFeed = dataProvider.GetShares(vkGroup.Id.ToString(), entityVkId, type, offsetCounter);

            if (sharesFeed == null)
            {
                return(null);
            }

            this.log.DebugFormat("Shares feed is received: {0}", sharesFeed.Feed);
            sharesFeed.ParentObjectId = entityVkId;
            sharesFeed.LikeShareType  = (int)type;
            string newFeed = this.responseMapper.MapResponseObject(sharesFeed);

            var dataFeed = new DataFeed
            {
                ReceivedAt      = this.dateTimeHelper.GetDateTimeNow(),
                Feed            = newFeed,
                VkGroupId       = vkGroup.Id,
                RelatedObjectId = entityVkId,
                Type            = DataFeedType.MemberShares
            };

            if (sharesFeed.users[0].uid == null || sharesFeed.users[0].uid.Length == 0)
            {
                return(null);
            }

            offsetCounter += sharesFeed.users.Length;
            return(dataFeed);
        }
        public MemberShare GetShare(int groupId, string memberId, int itemId, LikeShareType itemType)
        {
            using (IDataGateway dataGateway = this.dataGatewayProvider.GetDataGateway())
            {
                var share = dataGateway.Connection.Query <MemberShare>(
                    "select * from membershare where vkmemberid = @memberid and itemid = @entityid and itemtype = @entitytype",
                    new { memberid = int.Parse(memberId), entityid = itemId, itemtype = (int)itemType }).FirstOrDefault();

                return(share);
            }
        }
예제 #3
0
        public MemberShare GetShare(int vkGroupId, string memberId, int itemId, LikeShareType itemType)
        {
            var item = this.cachingStrategy.GetItem <MemberShare>(vkGroupId.ToString(), memberId, itemType.ToString(), itemId.ToString());

            if (item != null)
            {
                return(item);
            }

            this.cachingStrategy.InitCacheIfNeeded(this.GetInitSharesCacheKey(vkGroupId), () => this.GetMemberShares(vkGroupId), this.GetShareKey);
            return(this.cachingStrategy.GetItem <MemberShare>(vkGroupId.ToString(), memberId, itemType.ToString(), itemId.ToString()));
        }
예제 #4
0
        private IEnumerable <string> GetEntityVkIds(LikeShareType type, VkGroup vkGroup, DateTime?dateLimit)
        {
            switch (type)
            {
            case LikeShareType.Post:
                return(this.listRepository.GetPostVkIds(vkGroup.Id, dateLimit));

            case LikeShareType.Comment:
                return(this.listRepository.GetPostCommentVkIds(vkGroup.Id, dateLimit));

            case LikeShareType.Photo:
                return(this.listRepository.GetPhotoVkIds(vkGroup.Id, dateLimit));

            case LikeShareType.Video:
                return(this.listRepository.GetVideoVkIds(vkGroup.Id, dateLimit));

            default:
                throw new ArgumentOutOfRangeException("type");
            }
        }
예제 #5
0
        public Responses.LikeShareFeed.response GetShares(string groupId, string relatedObjectId, LikeShareType type, int offsetCounter)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string> {
                { "owner_id", "-" + groupId }, { "item_id", relatedObjectId }, { "type", type.ToString().ToLower() }, { "filter", "copies" }, { "friends_only", "0" }, { "offset", offsetCounter.ToString() }, { "count", "1000" }
            };
            string sharesList = this.vkAccessor.ExecuteCall("likes.getList.xml", parameters);

            Ix.Palantir.Vkontakte.API.Responses.LikeShareFeed.response shares = this.responseMapper.MapResponse <Ix.Palantir.Vkontakte.API.Responses.LikeShareFeed.response>(sharesList);
            shares.Feed = sharesList;

            return(shares);
        }