public List <CommonDataTypes.SocialElements.User> GetAllUsersFriends(CommonDataTypes.SocialElements.User user) { var vkUser = new Connectors.VK.VKUser(); vkUser.GetSourcesNotificationEvent += Sources_GetSourceNotificationEvent; List <CommonDataTypes.SocialElements.User> friends = vkUser.GetUsers(user); var UnknownUsers = friends.Where(x => KnownUsers.Where(y => y.Uid == x.Uid).Count() == 0); if (UnknownUsers.Count() > 0) { KnownUsers.AddRange(UnknownUsers.ToList()); } return(friends); }
public List <CommonDataTypes.SocialElements.User> GetUsers(CommonDataTypes.SocialElements.User user = null) { List <CommonDataTypes.SocialElements.User> users = null; if (user == null) { user = new CommonDataTypes.SocialElements.User() { Uid = Common.Api.UserId.Value }; } var vkUsers = Common.Api.Friends.Get(new VkNet.Model.RequestParams.FriendsGetParams() { UserId = user.Id, Fields = VkNet.Enums.Filters.ProfileFields.FirstName | VkNet.Enums.Filters.ProfileFields.LastName | VkNet.Enums.Filters.ProfileFields.Nickname | VkNet.Enums.Filters.ProfileFields.Photo100 | VkNet.Enums.Filters.ProfileFields.Contacts | VkNet.Enums.Filters.ProfileFields.BirthDate }); users = new List <CommonDataTypes.SocialElements.User>(vkUsers.Count); ulong num = 1; ulong count = (ulong)vkUsers.Count; foreach (var vkUser in vkUsers) { CommonDataTypes.SocialElements.User newUser = new CommonDataTypes.SocialElements.User(); newUser.Uid = vkUser.Id; newUser.Name = vkUser.FirstName; newUser.SurName = vkUser.LastName; newUser.NickName = vkUser.Nickname; newUser.PictureURL = vkUser.Photo100; newUser.HomePhone = vkUser.HomePhone; newUser.MobilePhone = vkUser.MobilePhone; newUser.BirthDate = vkUser.BirthDate; if (GetSourcesNotificationEvent != null) { GetSourcesNotificationEvent(count, num, newUser); } users.Add(newUser); num++; } return(users); }
public List <CommonDataTypes.SocialElements.Group> GetAllUsersGroups(CommonDataTypes.SocialElements.User user) { var vkGroups = new Connectors.VK.VKGroups(); vkGroups.GetSourcesNotificationEvent += Sources_GetSourceNotificationEvent; List <CommonDataTypes.SocialElements.Group> groups = vkGroups.GetGroups(user); var UnknownGroups = groups.Where(x => KnownGroups.Where(y => y.Uid == x.Uid).Count() == 0); if (UnknownGroups.Count() > 0) { KnownGroups.AddRange(UnknownGroups.ToList()); } return(groups); }
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 CommonDataTypes.SocialElements.User GetUserInfo(CommonDataTypes.SocialElements.User idInfo = null) { if (idInfo == null) { idInfo = new CommonDataTypes.SocialElements.User() { Uid = VK.Common.Api.UserId.Value }; } var userInfos = VK.Common.Api.Users.Get(new List <long>() { idInfo.Uid }, VkNet.Enums.Filters.ProfileFields.All); if (userInfos == null) { return(null); } if (userInfos.Count == 0) { return(null); } var userInfo = userInfos.First(); idInfo.Name = userInfo.FirstName; idInfo.SurName = userInfo.LastName; idInfo.NickName = userInfo.Nickname; idInfo.PictureURL = userInfo.Photo100; idInfo.HomePhone = userInfo.HomePhone; idInfo.MobilePhone = userInfo.MobilePhone; idInfo.BirthDate = userInfo.BirthDate; if (userInfo.Occupation != null) { idInfo.Occupation = userInfo.Occupation.Name; } return(idInfo); }
public List <CommonDataTypes.SocialElements.Post> GetAllPosts(CommonDataTypes.SocialElements.User user, long limit = 0) { if (limit <= 0) { limit = long.MaxValue; } IPosts posts = new VKPosts(); if (user == null) { user = new CommonDataTypes.SocialElements.User() { Uid = Common.Api.UserId.Value }; } posts.GetPostNotificationEvent += Posts_GetPostNotificationEvent; List <CommonDataTypes.SocialElements.Post> allPosts = new List <CommonDataTypes.SocialElements.Post>(100000); List <CommonDataTypes.SocialElements.Post> currentPosts = null; ulong offset = 0; try { do { currentPosts = posts.FromUser(user, 100, offset); offset += 100; allPosts.AddRange(currentPosts); System.Threading.Thread.Sleep(200); } while (currentPosts != null && currentPosts.Count > 0 && allPosts.Count < limit); } catch (Exception ex) { } return(allPosts); }
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 List <CommonDataTypes.SocialElements.Post> FromUser(CommonDataTypes.SocialElements.User user, ulong count, ulong offset) { List <CommonDataTypes.SocialElements.Post> posts = null; if (user == null) { user = new CommonDataTypes.SocialElements.User() { Uid = Common.Api.UserId.Value }; } var vkPosts = Common.Api.Wall.Get(new VkNet.Model.RequestParams.WallGetParams() { Count = count, Offset = offset, OwnerId = user.Uid }); posts = new List <CommonDataTypes.SocialElements.Post>(vkPosts.WallPosts.Count); ulong index = 0; foreach (var vkPost in vkPosts.WallPosts) { index++; var post = new CommonDataTypes.SocialElements.Post() { Uid = vkPost.Id.Value, Text = vkPost.Text, Date = vkPost.Date.Value.ToString("dd.MM.yyyy hh:mm:ss"), IsRepost = (vkPost.CopyHistory != null && vkPost.CopyHistory.Count > 0) ? true : false, OwnerID = vkPost.OwnerId.Value }; try { LoadPictureIfNull(post, vkPost); if (post.IsRepost.Value) { post.SourceID = vkPost.CopyHistory.First().FromId.Value; post.SourcePostUID = vkPost.CopyHistory.First().Id.Value; foreach (var copyHistoryPart in vkPost.CopyHistory) { LoadPictureIfNull(post, copyHistoryPart); post.Text = String.Format("{0}\n\n+++\n\n{1}", post.Text, copyHistoryPart.Text); } } } catch (Exception ex) { } posts.Add(post); if (GetPostNotificationEvent != null) { GetPostNotificationEvent(offset + count, offset + index, post); } } return(posts); }
public CommonDataTypes.SocialElements.Post FromUserByID(CommonDataTypes.SocialElements.User user, CommonDataTypes.SocialElements.Post IDInform) { throw new NotImplementedException(); }