public StatsEntry(EndOfGameStats game, PlayerStatsSummary stats)
 {
     GameMode = game.GameMode;
     GameType = game.GameType;
     Summary = stats;
     TimeStamp = game.TimeStamp;
 }
Exemple #2
0
 void StatsRead(EndOfGameStats game)
 {
     Task.Factory.StartNew(() => CommitGame(game));
 }
Exemple #3
0
        public EndOfGameStats RecordGame(EndOfGameStats game)
        {
            if (game == null)
                throw new ArgumentNullException("game");

            var match = Database.Query<EndOfGameStats>().FirstOrDefault(m => m.GameId == game.GameId);
            if (match != null)
            {
                //If the object read is older then don't bother adding it.
                //However it may have new player information so don't return.
                if (game.TimeStamp > match.TimeStamp)
                {
                    Database.Delete(match);
                    Database.Store(game.CloneT());
                }
            }
            else
            {
                Database.Store(game.CloneT());
            }

            //No reason to record players here?
            //We should have gotten them all in the GameDTO

            //var statslist = game.TeamPlayerStats.Union(game.OtherTeamPlayerStats).ToList();
            //for (int i = 0; i < statslist.Count; i++)
            //{
            //    var entry = GetPlayer(statslist[i].UserId);
            //    if (entry == null)
            //    {
            //        entry = new PlayerEntry(statslist[i]);
            //        RecordPlayer(entry, false);
            //    }
            //}

            return match;
        }
Exemple #4
0
        public void CommitGame(EndOfGameStats game)
        {
            Stopwatch sw;
            lock (DatabaseLock)
            {
                sw = Stopwatch.StartNew();

                RecordGame(game);
                Database.Commit();
            }
            sw.Stop();
            StaticLogger.Debug(string.Format("EndOfGameStats committed in {0}ms", sw.ElapsedMilliseconds));
        }
		void StatsRead(EndOfGameStats game)
		{
            Task.Factory.StartNew(() => CommitGame(game), TaskCreationOptions.LongRunning);
		}