Пример #1
0
        public void GetFriends()
        {
            for (int i = 0; i < users_count; i++)
            {
                if (!users_api[i].IsAuthorized)
                {
                    continue;
                }

                FriendsGetParams getParams = new FriendsGetParams();
                getParams.Fields = ProfileFields.FirstName | ProfileFields.LastName;
                getParams.Order  = FriendsOrder.Name;

                VkCollection <User> friends = null;

                try
                {
                    friends = users_api[i].Friends.Get(getParams, true);
                }
                catch (VkApiException ex)
                {
                    continue;
                }

                List <FriendsListItem> friendsItems = new List <FriendsListItem>();

                foreach (User friend in friends)
                {
                    FriendsListItem friendItem = new FriendsListItem();
                    friendItem.User              = new UserInfo();
                    friendItem.Friend            = new UserInfo();
                    friendItem.SocialNetworkName = getSocialNetworkName();
                    friendItem.Friend.Name       = String.Format("{0} {1}", friend.FirstName, friend.LastName);
                    friendItem.Friend.ID         = Convert.ToString(friend.Id);
                    friendItem.User.Name         = getUserAccountName(i);
                    friendItem.User.ID           = Convert.ToString(users_api[i].UserId);
                    friendsItems.Add(friendItem);
                }

                applicationContract.AddItemsToFriendsList(friendsItems);
            }
        }
Пример #2
0
        public void GetFriends()
        {
            foreach (SlackHelper item in users_helpers)
            {
                if (!item.IsAuthorized)
                {
                    continue;
                }

                Responses.SlackUsersListResponse slackUsersListResponse = item.Users_List();

                if (!slackUsersListResponse.Ok)
                {
                    continue;
                }

                List <Models.SlackUser> users = slackUsersListResponse.Members?.ToList();

                if (users == null)
                {
                    continue;
                }

                List <FriendsListItem> friendsItems = new List <FriendsListItem>();

                foreach (Models.SlackUser user in users)
                {
                    FriendsListItem friendItem = new FriendsListItem();
                    friendItem.User              = new UserInfo();
                    friendItem.Friend            = new UserInfo();
                    friendItem.SocialNetworkName = getSocialNetworkName();
                    friendItem.Friend.Name       = user.Profile.RealName;
                    friendItem.Friend.ID         = user.ID;
                    friendItem.User.ID           = item.User.ID;
                    friendItem.User.Name         = item.User.RealName;
                    friendsItems.Add(friendItem);
                }

                applicationContract.AddItemsToFriendsList(friendsItems);
            }
        }