private async Task <string> GetUsers(LoadOptions options, int[] users) { if (options.Execute) { var req = new Request <User[]> { MethodName = "execute.mfetch25a", Token = _api.CurrentToken, Parameters = new Dictionary <string, string>() }; req.Parameters.Add("fields", string.Join(",", MiscTools.GetUserFields(options.Fields))); var uids = users.Select((value, index) => new { value, index }).GroupBy(a => a.index / 1000).Select(a => a.Select(b => b.value).ToArray()).ToArray(); for (int i = 0; i < uids.Length; i++) { req.Parameters.Add("u" + i, uids[i].ToNCStringA()); } return(await _api.Executor.ExecRawAsync(req).ConfigureAwait(false)); } return(await _api.Users.Get(options.Fields, NameCase.Nom, users).ConfigureAwait(false)); }
public async Task <User[]> UsersSearchAsync(UsersSearchParams usersSearchParams) { var req = new VKRequest <User> { MethodName = "users.search", Parameters = new Dictionary <string, string> { { "q", usersSearchParams.Query }, { "sort", ((int)usersSearchParams.Sort).ToNCString() }, { "offset", MiscTools.NullableString(usersSearchParams.Offset) }, { "count", MiscTools.NullableString(usersSearchParams.Count) }, { "fields", String.Join(",", MiscTools.GetUserFields(usersSearchParams.Fields)) }, { "city", MiscTools.NullableString(usersSearchParams.CityId) }, { "country", MiscTools.NullableString(usersSearchParams.CountryId) }, { "hometown", usersSearchParams.Hometown }, { "university_country", MiscTools.NullableString(usersSearchParams.UniversityCountryId) }, { "university", MiscTools.NullableString(usersSearchParams.UniversityId) }, { "university_year", MiscTools.NullableString(usersSearchParams.UniversityYear) }, { "sex", usersSearchParams.Sex != null ? ((int)usersSearchParams.Sex).ToNCString() : "" }, { "status", MiscTools.NullableString(usersSearchParams.Relation) }, { "age_from", MiscTools.NullableString(usersSearchParams.AgeFrom) }, { "age_to", MiscTools.NullableString(usersSearchParams.AgeTo) }, { "birth_day", MiscTools.NullableString(usersSearchParams.BirthDay) }, { "birth_month", MiscTools.NullableString(usersSearchParams.BirthMonth) }, { "birth_year", MiscTools.NullableString(usersSearchParams.BirthYear) }, { "online", MiscTools.NullableString(usersSearchParams.Online.HasValue ? (uint?)(usersSearchParams.Online.Value ? 1 : 0) : null) }, { "has_photo", MiscTools.NullableString(usersSearchParams.HasPhoto.HasValue ? (uint?)(usersSearchParams.HasPhoto.Value ? 1 : 0) : null) }, { "school_country", MiscTools.NullableString(usersSearchParams.SchoolCountryId) }, { "school_city", MiscTools.NullableString(usersSearchParams.SchoolCityId) }, { "school", MiscTools.NullableString(usersSearchParams.SchoolId) }, { "school_year", MiscTools.NullableString(usersSearchParams.SchoolYear) }, { "religion", usersSearchParams.Religion }, { "interests", usersSearchParams.Interests }, { "company", usersSearchParams.Company }, { "position", usersSearchParams.Position }, { "group_id", MiscTools.NullableString(usersSearchParams.GroupId) } }, Token = IsLogged ? CurrentToken : null }; return((await _executor.ExecAsync(req)).Data); }