Пример #1
0
        /// <summary>
        /// get a chunk of matches
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="tagGroup"></param>
        /// <param name="tagName"></param>
        /// <param name="sort"></param>
        /// <returns></returns>
        internal static MatchesResult GetTagMatches(string searcherName, string tagGroup, string tagName, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName);
            var tagQuery  = new TagQuery();                                                 // setting a tag query, means only items that have tags will be returned

            if (!string.IsNullOrWhiteSpace(tagGroup) && string.IsNullOrWhiteSpace(tagName)) // only have the group to query
            {
                // TODO: add a new field into the lucene index (would avoid additional query to first look up the tags in this group)
                var tagsInGroup = QueryService.GetTags(searcherName, tagGroup).Select(x => x.Key).ToArray();

                tagQuery.HasAny = tagsInGroup;
            }
            else if (!string.IsNullOrWhiteSpace(tagName)) // we have a specifc tag
            {
                tagQuery.Has = new LookTag(tagGroup, tagName);
            }

            lookQuery.TagQuery = tagQuery;

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .SkipMatches(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="sort"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        internal static MatchesResult GetNodeTypeMatches(string searcherName, PublishedItemType nodeType, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName);

            lookQuery.NodeQuery = new NodeQuery()
            {
                Type = nodeType
            };

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .Matches
                                           .Skip(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }
Пример #3
0
        /// <summary>
        /// Get matches by culture - all content has a culture set in Umbraco
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="lcid"></param>
        /// <param name="sort"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        internal static MatchesResult GetCultureMatches(string searcherName, int?lcid, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName)
            {
                NodeQuery = new NodeQuery()
            };

            if (lcid.HasValue)
            {
                lookQuery.NodeQuery.Culture = new CultureInfo(lcid.Value);
            }
            else // no culture suppled, so get all content
            {
                lookQuery.NodeQuery.Type = PublishedItemType.Content;
            }

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .Matches
                                           .Skip(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }
Пример #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="sort"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        internal static MatchesResult GetLocationMatches(string searcherName, string filter, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName);

            lookQuery.LocationQuery = new LocationQuery();

            if (!string.IsNullOrWhiteSpace(filter))
            {
                lookQuery.NodeQuery = new NodeQuery()
                {
                    Alias = filter
                };
            }

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .Matches
                                           .Skip(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="nodeType"></param>
        /// <param name="sort"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        internal static MatchesResult GetDetachedMatches(string searcherName, PublishedItemType nodeType, string filter, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName)
            {
                NodeQuery = new NodeQuery()
                {
                    Type          = nodeType,
                    Alias         = !string.IsNullOrWhiteSpace(filter) ? filter : null,
                    DetachedQuery = DetachedQuery.OnlyDetached
                }
            };

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .Matches
                                           .Skip(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }
Пример #6
0
        public static List <MatchesResult> GetBetResult(int database)
        {
            var redis        = new Redis(database);
            var keys         = redis.GetAllKeys();
            var participants = new List <Participant>();

            keys.Sort();
            var ordered = keys.OrderBy(x => x.Length);

            foreach (var key in ordered)
            {
                var p = redis.GetRedisValue <Participant>(key);
                participants.Add(p);
            }
            var firstPart     = participants.First();
            var orderdMatches = firstPart.Matches
                                .Where(x => x.MatchStart > DateTime.Now.AddHours(-5))
                                .OrderBy(x => x.MatchStart < DateTime.Now).ToList();

            var matches = new List <MatchesResult>();

            foreach (var match in orderdMatches)
            {
                var matchesResult = new MatchesResult
                {
                    MatchStart     = match.MatchStart,
                    HomeTeam       = match.HomeTeam,
                    AwayTeam       = match.AwayTeam,
                    BettingResults = new List <BettingResult>()
                };
                participants.ForEach(x =>
                {
                    var bet = new BettingResult
                    {
                        Name   = x.Name,
                        Points = x.Points
                    };

                    var partMatch = x.Matches.First(u => u.HomeTeam.Equals(match.HomeTeam) &&
                                                    u.AwayTeam.Equals(match.AwayTeam) &&
                                                    u.MatchStart == match.MatchStart);
                    bet.Bet = partMatch.Result;

                    matchesResult.BettingResults.Add(bet);
                });
                matches.Add(matchesResult);
            }

            return(matches.ToList());
        }
        public MatchesResult DoesCurCHSetFileHashMatchFileInDir(ChangeSetC chSet, string rootDir, string file, string hash)
        {
            MatchesResult result            = MatchesResult.matches_none;
            string        changesetFilename = chSet.filename.ToLower().Replace("nightfiresource/", "");
            string        path = rootDir + changesetFilename;

            if (Path.GetFullPath(file.ToLower()) == Path.GetFullPath(path.ToLower()))
            {
                result |= MatchesResult.matches_filename;
                if (chSet.hash == hash)
                {
                    result |= MatchesResult.matches_hash;
                }
            }
            return(result);
        }
        public MatchesResult DoesFileHashMatch(CHANGESET_TYPES type, string file, string hash)
        {
            MatchesResult result = MatchesResult.matches_none;

            foreach (ChangeSetC chSet in getAppropriateListForType(type))
            {
                if (Path.GetFullPath(file.ToLower()) == Path.GetFullPath(chSet.filename.ToLower()))
                {
                    result |= MatchesResult.matches_filename;
                    if (chSet.hash == hash)
                    {
                        result |= MatchesResult.matches_hash;
                        break;
                    }
                }
            }
            return(result);
        }
Пример #9
0
        /// <summary>
        /// get a chunk of matches
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="tagGroup"></param>
        /// <param name="tagName"></param>
        /// <param name="sort"></param>
        /// <returns></returns>
        internal static MatchesResult GetTagMatches(string searcherName, string tagGroup, string tagName, string filter, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName)
            {
                TagQuery = new TagQuery()
            };

            if (!string.IsNullOrWhiteSpace(tagGroup) && string.IsNullOrWhiteSpace(tagName)) // only have the group to query
            {
                //use raw query looking for newly indexed field(in look 0.33.0)
                // TODO: update look to handle tags like "colour:*"
                lookQuery.RawQuery = "Look_TagGroup_" + tagGroup + ":1";
            }
            else if (!string.IsNullOrWhiteSpace(tagName)) // we have a specifc tag
            {
                lookQuery.TagQuery.Has = new LookTag(tagGroup, tagName);
            }

            if (!string.IsNullOrWhiteSpace(filter))
            {
                lookQuery.NodeQuery = new NodeQuery()
                {
                    Alias = filter
                };
            }

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .SkipMatches(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }
Пример #10
0
        /// <summary>
        /// get a chunk of matches
        /// </summary>
        /// <param name="tagName"></param>
        /// <param name="sort"></param>
        /// <returns></returns>
        internal static MatchesResult GetMatches(string searcherName, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName);

            lookQuery.NodeQuery = new NodeQuery();

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .SkipMatches(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x) // convert match to model for serialization
                                           .ToArray();

            return(matchesResult);
        }
Пример #11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="searcherName"></param>
        /// <param name="sort"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        internal static MatchesResult GetLocationMatches(string searcherName, string sort, int skip, int take)
        {
            var matchesResult = new MatchesResult();

            var lookQuery = new LookQuery(searcherName);

            lookQuery.LocationQuery = new LocationQuery();

            QueryService.SetSort(lookQuery, sort);

            var lookResult = lookQuery.Search();

            matchesResult.TotalItemCount = lookResult.TotalItemCount;
            matchesResult.Matches        = lookResult
                                           .Matches
                                           .Skip(skip)
                                           .Take(take)
                                           .Select(x => (MatchesResult.Match)x)
                                           .ToArray();

            return(matchesResult);
        }