コード例 #1
0
        private OverviewDetails LoadCashOverview()
        {
            OverviewDetails details = new OverviewDetails();
            IAggregateFluent <HandHistory> cashGameHands =
                handCollection.Aggregate().Match(h => h.GameDescription.PokerFormat == PokerFormat.CashGame &&
                                                 h.GameDescription.Limit.Currency != Currency.PlayMoney);

            IAggregateFluent <UnwoundHand> actions = cashGameHands
                                                     .Unwind <HandHistory, UnwoundHand>(h => h.HandActions)
                                                     .Match(h => PlayerNames.Contains(h.HandActions.PlayerName));

            if (!cashGameHands.Any())
            {
                return(details);     // Return empty result set if there are no hands available
            }
            details.Hands = cashGameHands.Count().First().Count;

            foreach (var profit in actions.Group(h => h.HandId, h => new { sum = h.Sum(h2 => h2.HandActions.Amount * h2.GameDescription.Limit.BigBlind) }).ToEnumerable())
            {
                if (profit.sum > 0)
                {
                    details.Winnings += profit.sum;
                }
                else
                {
                    details.Losses += profit.sum;
                }
            }

            return(details);
        }
コード例 #2
0
        private List <FunctionRankResult> GetResultAfterQueryExecution(IAggregateFluent <BsonDocument> finalRank)
        {
            List <FunctionRankResult> result = new List <FunctionRankResult>();

            if (finalRank.Any())
            {
                var resultList = finalRank.ToList();
                if (resultList != null)
                {
                    result = BsonSerializer.Deserialize <List <FunctionRankResult> >(resultList.ToJson());
                }
            }
            return(result);
        }
コード例 #3
0
        private PagedList <TProjection> PagedList <TProjection>(IAggregateFluent <TProjection> findFluent, int pageNumber, int pageSize)
        {
            var count = findFluent.Any() ? findFluent.Group(new BsonDocument
            {
                { "_id", "_id" },
                { "count", new BsonDocument("$sum", 1) }
            })
                        .FirstAsync().Result["count"].AsInt32 : 0;

            var items = findFluent.Skip(pageSize * (pageNumber - 1))
                        .Limit(pageSize)
                        .ToList();

            return(new PagedList <TProjection>(items, count, pageNumber, pageSize));
        }
コード例 #4
0
        private List <Object> GetResultAfterQueryExecution(IAggregateFluent <BsonDocument> finalQuery)
        {
            var result = new List <Object>();

            try
            {
                if (finalQuery.Any())
                {
                    var resultList = finalQuery.ToList();
                    foreach (var i in resultList)
                    {
                        result.Add(BsonSerializer.Deserialize <object>(i));
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }
コード例 #5
0
        private OverviewDetails LoadTournamentOverview(bool sitAndGo)
        {
            OverviewDetails details = new OverviewDetails();
            PokerFormat     format  = sitAndGo ? PokerFormat.SitAndGo : PokerFormat.MultiTableTournament;
            IAggregateFluent <HandHistory> hands = handCollection.Aggregate().Match(h => h.GameDescription.PokerFormat == format);

            if (!hands.Any())
            {
                return(details);
            }

            details.Hands = hands.Count().First().Count;
            IAggregateFluent <TournamentSummary> tournaments =
                tournamentCollection.Aggregate()
                .Match(t => t.SitAndGo == sitAndGo && t.Buyin.Currency != Currency.PlayMoney);

            details.Winnings = tournaments.Group(t => t.SitAndGo, t => new { sum = t.Sum(t2 => t2.Winnings) }).First().sum;
            details.Losses   = -tournaments.Group(t => t.SitAndGo,
                                                  t => new { sum = t.Sum(t2 => t2.Buyin.Total + t2.Rebuy.Total * t2.RebuyCount + t2.AddOn.Total) }).First().sum;
            details.Tournaments = tournaments.Count().First().Count;
            return(details);
        }