Ejemplo n.º 1
0
 public UsersSearchParams(string query      = "", SearchSortOrder sort  = SearchSortOrder.ByRating,
                          ushort?offset     = null, ushort?count        = null, UserFields fields = UserFields.None,
                          uint?cityId       = null, uint?countryId      = null, string hometown   = "", uint?universityCountryId = null,
                          uint?universityId = null, uint?universityYear = null, Sex?sex           = null, Relation?relation      = null,
                          byte?ageFrom      = null, byte?ageTo    = null, byte?birthDay           = null, byte?birthMonth        = null,
                          ushort?birthYear  = null, bool?online   = null, bool?hasPhoto           = null, uint?schoolCountryId   = null,
                          uint?schoolCityId = null, uint?schoolId = null, uint?schoolYear         = null, string religion        = "",
                          string interests  = "", string company  = "", string position           = "", uint?groupId             = null)
 {
     Query               = query;
     Sort                = sort;
     Offset              = offset;
     Count               = count;
     Fields              = fields;
     CityId              = cityId;
     CountryId           = countryId;
     Hometown            = hometown;
     UniversityCountryId = universityCountryId;
     UniversityId        = universityId;
     UniversityYear      = universityYear;
     Sex             = sex;
     Relation        = relation;
     AgeFrom         = ageFrom;
     AgeTo           = ageTo;
     BirthDay        = birthDay;
     BirthMonth      = birthMonth;
     BirthYear       = birthYear;
     Online          = online;
     HasPhoto        = hasPhoto;
     SchoolCountryId = schoolCountryId;
     SchoolCityId    = schoolCityId;
     SchoolId        = schoolId;
     SchoolYear      = schoolYear;
     Religion        = religion;
     Interests       = interests;
     Company         = company;
     Position        = position;
     GroupId         = groupId;
 }
Ejemplo n.º 2
0
 public UsersSearchParams( string query = "", SearchSortOrder sort = SearchSortOrder.ByRating,
                           ushort? offset = null, ushort? count = null, UserFields fields = UserFields.None,
                           uint? cityId = null, uint? countryId = null, string hometown = "", uint? universityCountryId = null,
                           uint? universityId = null, uint? universityYear = null, Sex? sex = null, Relation? relation = null,
                           byte? ageFrom = null, byte? ageTo = null, byte? birthDay = null, byte? birthMonth = null,
                           ushort? birthYear = null, bool? online = null, bool? hasPhoto = null, uint? schoolCountryId = null,
                           uint? schoolCityId = null, uint? schoolId = null, uint? schoolYear = null, string religion = "",
                           string interests = "", string company = "", string position = "", uint? groupId = null ) {
     Query = query;
     Sort = sort;
     Offset = offset;
     Count = count;
     Fields = fields;
     CityId = cityId;
     CountryId = countryId;
     Hometown = hometown;
     UniversityCountryId = universityCountryId;
     UniversityId = universityId;
     UniversityYear = universityYear;
     Sex = sex;
     Relation = relation;
     AgeFrom = ageFrom;
     AgeTo = ageTo;
     BirthDay = birthDay;
     BirthMonth = birthMonth;
     BirthYear = birthYear;
     Online = online;
     HasPhoto = hasPhoto;
     SchoolCountryId = schoolCountryId;
     SchoolCityId = schoolCityId;
     SchoolId = schoolId;
     SchoolYear = schoolYear;
     Religion = religion;
     Interests = interests;
     Company = company;
     Position = position;
     GroupId = groupId;
 }
Ejemplo n.º 3
0
     ///<summary>
     ///        Возвращает список пользователей в соответствии с заданным критерием поиска
     ///      
     ///</summary>
     ///<param name="q">строка поискового запроса</param>
     ///<param name="sort">порядок сортировки</param>
     ///<param name="fields">список дополнительных полей профилей, которые необходимо вернуть</param>
     ///<param name="city">идентификатор города</param>
     ///<param name="country">идентификатор страны</param>
     ///<param name="hometown">название города строкой</param>
     ///<param name="universityCountry">идентификатор страны, в которой пользователи закончили ВУЗ</param>
     ///<param name="university">идентификатор ВУЗа</param>
     ///<param name="universityYear">год окончания ВУЗа</param>
     ///<param name="universityFaculty">идентификатор факультета</param>
     ///<param name="universityChair">идентификатор кафедры</param>
     ///<param name="sex">пол</param>
     ///<param name="status">семейное положение</param>
     ///<param name="ageFrom">начиная с какого возраста</param>
     ///<param name="ageTo">до какого возраста</param>
     ///<param name="birthDay">день рождения</param>
     ///<param name="birthMonth">месяц рождения</param>
     ///<param name="birthYear">год рождения</param>
     ///<param name="online">только в сети</param>
     ///<param name="hasPhoto">только с фотографией</param>
     ///<param name="schoolCountry">идентификатор страны, в которой пользователи закончили школу</param>
     ///<param name="schoolCity">идентификатор города, в котором пользователи закончили школу</param>
     ///<param name="schoolClass"></param>
     ///<param name="school">идентификатор школы, которую закончили пользователи</param>
     ///<param name="schoolYear">год окончания школы</param>
     ///<param name="religion">религиозные взгляды</param>
     ///<param name="interests">интересы</param>
     ///<param name="company">название компании, в которой работают пользователи</param>
     ///<param name="position">название должности</param>
     ///<param name="groupId">идентификатор группы, среди пользователей которой необходимо проводить поиск</param>
     ///<param name="fromList">Разделы среди которых нужно осуществить поиск</param>
 ///<param name="offset">Оффсет для возврата результатов</param>
 ///<param name="count">Количество записей, которые необходимо вернуть</param>
     public EntityList<User> SearchSync(
         string q = "", SearchSortOrder sort = SearchSortOrder.ByRating, UserFields fields = UserFields.None, int? city = null, int? country = null, string hometown = "", int? universityCountry = null, int? university = null, int? universityYear = null, int? universityFaculty = null, int? universityChair = null, Sex? sex = null, Relation? status = null, byte? ageFrom = null, byte? ageTo = null, byte? birthDay = null, byte? birthMonth = null, ushort? birthYear = null, bool? online = null, bool? hasPhoto = null, int? schoolCountry = null, int? schoolCity = null, int? schoolClass = null, int? school = null, int? schoolYear = null, string religion = "", string interests = "", string company = "", string position = "", int? groupId = null,  FriendshipType? fromList = null, int? offset = null, int? count = 100
     ) {
         var task = _parent.Executor.ExecAsync(
                 _parent._reqapi.Users.Search(
                     q,sort,fields,city,country,hometown,universityCountry,university,universityYear,universityFaculty,universityChair,sex,status,ageFrom,ageTo,birthDay,birthMonth,birthYear,online,hasPhoto,schoolCountry,schoolCity,schoolClass,school,schoolYear,religion,interests,company,position,groupId,fromList,offset, count
                 )
             );
         task.Wait();
         return task.Result.Response;
     }
Ejemplo n.º 4
0
            ///<summary>
            ///        Возвращает список пользователей в соответствии с заданным критерием поиска
            ///      
            ///</summary>
            ///<param name="q">строка поискового запроса</param>
            ///<param name="sort">порядок сортировки</param>
            ///<param name="fields">список дополнительных полей профилей, которые необходимо вернуть</param>
            ///<param name="city">идентификатор города</param>
            ///<param name="country">идентификатор страны</param>
            ///<param name="hometown">название города строкой</param>
            ///<param name="universityCountry">идентификатор страны, в которой пользователи закончили ВУЗ</param>
            ///<param name="university">идентификатор ВУЗа</param>
            ///<param name="universityYear">год окончания ВУЗа</param>
            ///<param name="universityFaculty">идентификатор факультета</param>
            ///<param name="universityChair">идентификатор кафедры</param>
            ///<param name="sex">пол</param>
            ///<param name="status">семейное положение</param>
            ///<param name="ageFrom">начиная с какого возраста</param>
            ///<param name="ageTo">до какого возраста</param>
            ///<param name="birthDay">день рождения</param>
            ///<param name="birthMonth">месяц рождения</param>
            ///<param name="birthYear">год рождения</param>
            ///<param name="online">только в сети</param>
            ///<param name="hasPhoto">только с фотографией</param>
            ///<param name="schoolCountry">идентификатор страны, в которой пользователи закончили школу</param>
            ///<param name="schoolCity">идентификатор города, в котором пользователи закончили школу</param>
            ///<param name="schoolClass"></param>
            ///<param name="school">идентификатор школы, которую закончили пользователи</param>
            ///<param name="schoolYear">год окончания школы</param>
            ///<param name="religion">религиозные взгляды</param>
            ///<param name="interests">интересы</param>
            ///<param name="company">название компании, в которой работают пользователи</param>
            ///<param name="position">название должности</param>
            ///<param name="groupId">идентификатор группы, среди пользователей которой необходимо проводить поиск</param>
            ///<param name="fromList">Разделы среди которых нужно осуществить поиск</param>
            ///<param name="offset">Оффсет для возврата результатов</param>
            ///<param name="count">Количество записей, которые необходимо вернуть</param>
            public Request<EntityList<User>> Search(
                string q = "", SearchSortOrder sort = SearchSortOrder.ByRating, UserFields fields = UserFields.None, int? city = null, int? country = null, string hometown = "", int? universityCountry = null, int? university = null, int? universityYear = null, int? universityFaculty = null, int? universityChair = null, Sex? sex = null, Relation? status = null, byte? ageFrom = null, byte? ageTo = null, byte? birthDay = null, byte? birthMonth = null, ushort? birthYear = null, bool? online = null, bool? hasPhoto = null, int? schoolCountry = null, int? schoolCity = null, int? schoolClass = null, int? school = null, int? schoolYear = null, string religion = "", string interests = "", string company = "", string position = "", int? groupId = null,  FriendshipType? fromList = null, int? offset = null, int? count = 100
            ) {
                var req = new Request<EntityList<User>>{
                    MethodName = "users.search",
                    Parameters = new Dictionary<string, string> {

                        { "q", q},
                        { "sort", ((int)sort).ToNCString()},
                        { "fields", String.Join( ",", MiscTools.GetUserFields( fields ) )},
                        { "city", MiscTools.NullableString(city)},
                        { "country", MiscTools.NullableString(country)},
                        { "hometown", hometown},
                        { "university_country", MiscTools.NullableString(universityCountry)},
                        { "university", MiscTools.NullableString(university)},
                        { "university_year", MiscTools.NullableString(universityYear)},
                        { "university_faculty", MiscTools.NullableString(universityFaculty)},
                        { "university_chair", MiscTools.NullableString(universityChair)},
                        { "sex", MiscTools.NullableString( (int?)sex )},
                        { "status", MiscTools.NullableString( (int?)status )},
                        { "age_from", MiscTools.NullableString(ageFrom)},
                        { "age_to", MiscTools.NullableString(ageTo)},
                        { "birth_day", MiscTools.NullableString(birthDay)},
                        { "birth_month", MiscTools.NullableString(birthMonth)},
                        { "birth_year", MiscTools.NullableString(birthYear)},
                        { "online", (online != null ? ( online.Value ? 1 : 0 ).ToNCString() : "")},
                        { "has_photo", (hasPhoto != null ? ( hasPhoto.Value ? 1 : 0 ).ToNCString() : "")},
                        { "school_country", MiscTools.NullableString(schoolCountry)},
                        { "school_city", MiscTools.NullableString(schoolCity)},
                        { "school_class", MiscTools.NullableString(schoolClass)},
                        { "school", MiscTools.NullableString(school)},
                        { "school_year", MiscTools.NullableString(schoolYear)},
                        { "religion", religion},
                        { "interests", interests},
                        { "company", company},
                        { "position", position},
                        { "group_id", MiscTools.NullableString(groupId)},
                        { "from_list", fromList?.ToNCString()?.ToSnake()??""},
                        { "offset", offset.NullableString() },
                        { "count", count.NullableString() },

                    }
                };
                    req.Token = _parent.CurrentToken;
                return req;
            }
Ejemplo n.º 5
0
        public static async Task<List<article>> SearchArticle(string query, SearchSortOrder order = SearchSortOrder.ByRelevance, int page = 0)
        {
            var req = new RestRequest();
            req.Resource = "/search/article";
            req.Method = Method.GET;
            req.Parameters.Add(new Parameter() { Name = "wd", Value = query, Type = ParameterType.GetOrPost });
            req.Parameters.Add(new Parameter() { Name = "Accept-Encoding", Value = "gzip", Type = ParameterType.HttpHeader });
            req.Parameters.Add(new Parameter() { Name = "sort", Value = (order == SearchSortOrder.ByRelevance ? "" : "date"), Type = ParameterType.GetOrPost });
            if (page > 0)
                req.Parameters.Add(new Parameter() { Name = "page", Value = page + 1, Type = ParameterType.GetOrPost });

            var resp = await RestSharpAsync.RestSharpExecuteAsyncTask(WwwClient, req);
            ProcessError(resp);

            var htmldoc = new HtmlDocument();
            htmldoc.LoadHtml(resp.Content);
            var items = htmldoc.DocumentNode.SelectNodes(@"//li[@class=""items-post""]");
            if (items == null || items.Count == 0)
                return new List<article>();

            var result = items.Select((i) => new article()
            {
                Abstract = "..." + i.SelectSingleNode(i.XPath + @"/p[1]").InnerText + "...",
                title = i.SelectSingleNode(i.XPath + @"/h2/a").InnerText,
                minisite_name = i.SelectSingleNode(i.XPath + @"/p[2]/a").InnerText,
                id = Convert.ToInt64(Regex.Match(i.SelectSingleNode(i.XPath + @"/h2/a").Attributes["href"].Value, @"\d+").Groups[0].Value),
                posted_dt = Regex.Match(i.SelectSingleNode(i.XPath + @"/p[2]/text()[2]").InnerText, @"\d{4}-\d{1,2}-\d{1,2}").Groups[0].Value,
            });
            return result.ToList();
        }
Ejemplo n.º 6
0
        public static IQueryOver <T, T> ApplySorting <T>(this IQueryOver <T, T> query, SearchSortOrder sortOrder, bool sortAscending) where T : ISortable
        {
            IQueryOverOrderBuilder <T, T> orderBuilder = null;

            if (sortOrder == SearchSortOrder.Newest)
            {
                orderBuilder = query.OrderBy(x => x.CreationDate);
            }
            else if (sortOrder == SearchSortOrder.HighestRating)
            {
                orderBuilder = query.OrderBy(x => x.Rating);
            }
            else
            {
                orderBuilder = query.OrderBy(x => x.Name);
            }

            if (sortAscending)
            {
                query = orderBuilder.Asc;
            }
            else
            {
                query = orderBuilder.Desc;
            }
            return(query);
        }