public CommonDataTypes.SocialElements.Group GetGroup(string groupID) { List <CommonDataTypes.SocialElements.Group> groups = null; var vkGroups = Common.Api.Groups.GetById(new List <String>() { groupID }, groupID, VkNet.Enums.Filters.GroupsFields.All); if (vkGroups == null) { return(null); } if (vkGroups.Count == 0) { return(null); } var vkGroup = vkGroups.First(); CommonDataTypes.SocialElements.Group group = new CommonDataTypes.SocialElements.Group(); group.Uid = vkGroup.Id * -1; group.Name = vkGroup.Name; group.IsModerator = vkGroup.IsAdmin; group.PictureURL = vkGroup.Photo100; return(group); }
public List <CommonDataTypes.SocialElements.Group> GetGroups(CommonDataTypes.SocialElements.User user = null) { List <CommonDataTypes.SocialElements.Group> groups = null; if (user == null) { user = new CommonDataTypes.SocialElements.User() { Uid = Common.Api.UserId.Value }; } var vkGroups = Common.Api.Groups.Get(new VkNet.Model.RequestParams.GroupsGetParams() { UserId = user.Uid, Count = 1000, Extended = true }); groups = new List <CommonDataTypes.SocialElements.Group>(vkGroups.Count); ulong num = 1; ulong count = (ulong)vkGroups.Count; foreach (var vkGroup in vkGroups) { var group = new CommonDataTypes.SocialElements.Group() { Uid = vkGroup.Id * -1, Name = vkGroup.Name, IsModerator = vkGroup.IsAdmin, PictureURL = vkGroup.Photo100 }; if (GetSourcesNotificationEvent != null) { GetSourcesNotificationEvent(count, num, group); } groups.Add(group); num++; } return(groups); }
public List <CommonDataTypes.SocialElements.Post> AddInformationAboutSourceToPosts(List <CommonDataTypes.SocialElements.Post> posts, CommonDataTypes.SocialElements.User currentUser, bool loadPictures) { IGroup groups = new VKGroups(); IUser users = new VKUser(); CommonDataTypes.SocialElements.Group _group = null; CommonDataTypes.SocialElements.User _user = null; var searchCurrentUser = KnownUsers.Where(x => x.Uid == currentUser.Uid).ToList(); if (searchCurrentUser.Count == 0) { KnownUsers.Add(currentUser); } ulong count = (ulong)posts.Count, index = 0; foreach (var post in posts) { index++; try { if (post.IsRepost.Value) { if (post.SourceID < 0) { var searchGroup = KnownGroups.Where(x => x.Uid == post.SourceID || x.Uid == post.SourceID * -1).ToList(); if (searchGroup.Count > 0) { _group = searchGroup.First(); } else { _group = groups.GetGroup(((int)post.SourceID * -1).ToString()); KnownGroups.Add(_group); System.Threading.Thread.Sleep(200); } post.Source = _group; } else { var searchUser = KnownUsers.Where(x => x.Uid == post.SourceID).ToList(); if (searchUser.Count > 0) { _user = searchUser.First(); } else { _user = new CommonDataTypes.SocialElements.User() { Uid = (int)post.SourceID }; _user = users.GetUserInfo(_user); KnownUsers.Add(_user); System.Threading.Thread.Sleep(200); } post.Source = _user; } } else { post.SourceID = currentUser.Uid; post.Source = currentUser; } if (loadPictures) { post.LoadPicture(); } } catch (Exception ex) { System.Threading.Thread.Sleep(1000); } if (AddInformationAboutSourceToPostsEvent != null) { AddInformationAboutSourceToPostsEvent(count, index, post); } // if (GetGroupsNotificationEvent != null) GetGroupsNotificationEvent(count, index, post); } return(posts); }
public CommonDataTypes.SocialElements.Post FromGroupByID(CommonDataTypes.SocialElements.Group group, CommonDataTypes.SocialElements.Post IDInform) { throw new NotImplementedException(); }
public List <CommonDataTypes.SocialElements.Post> FromGroup(CommonDataTypes.SocialElements.Group group, ulong count, ulong offset) { throw new NotImplementedException(); }