コード例 #1
0
ファイル: ReportService.cs プロジェクト: Mnuzz/dsmm_web
        public async Task Save(MMgameNG game)
        {
            // /**
            foreach (var pl in game.GetPlayers())
            {
                if (pl.Name.StartsWith("Random") || pl.Name.StartsWith("Dummy"))
                {
                    continue;
                }
                var dbpl = _db.MMdbPlayers.Where(x => x.Name == pl.Name).FirstOrDefault();
                if (dbpl != null)
                {
                    var dbrat = _db.MMdbRatings.Where(x => x.MMdbPlayerId == dbpl.MMdbPlayerId && x.Lobby == game.Lobby).FirstOrDefault();
                    if (dbrat == null)
                    {
                        dbrat = new MMdbRating();
                    }
                    var rat = pl.Rating[game.Lobby];
                    dbrat.EXP          = rat.EXP;
                    dbrat.Games        = rat.Games;
                    dbrat.Lobby        = game.Lobby;
                    dbrat.MU           = rat.MU;
                    dbrat.SIGMA        = rat.SIGMA;
                    dbrat.MMdbPlayerId = dbpl.MMdbPlayerId;
                    dbrat.MMdbPlayer   = dbpl;

                    if (dbrat.MMdbRatingId == null)
                    {
                        dbpl.MMdbRatings.Add(dbrat);
                    }
                    //_db.MMdbRatings.Add(dbrat);
                    else
                    {
                        _db.MMdbRatings.Update(dbrat);
                    }
                }
            }
            await _db.SaveChangesAsync();

            // **/
            string output = Program.workdir + "/games/" + game.ID + "_report.json";

            if (!File.Exists(output))
            {
                using (FileStream fs = File.Create(output))
                {
                    await JsonSerializer.SerializeAsync(fs, game);
                }
            }
        }
コード例 #2
0
ファイル: StartUp.cs プロジェクト: Mnuzz/dsmm_web
        public async Task Save(MMgameNG game)
        {
            // /**
            using (var _db = new MMdb(_mmdb))
            {
                foreach (var pl in game.GetPlayers())
                {
                    if (pl.Name.StartsWith("Random") || pl.Name.StartsWith("Dummy"))
                    {
                        continue;
                    }
                    var dbpl = _db.MMdbPlayers.Where(x => x.Name == pl.Name).FirstOrDefault();
                    if (dbpl != null)
                    {
                        var dbrat = _db.MMdbRatings.Where(x => x.MMdbPlayerId == dbpl.MMdbPlayerId && x.Lobby == game.Lobby).FirstOrDefault();
                        if (dbrat == null)
                        {
                            dbrat = new MMdbRating();
                        }
                        var rat = pl.Rating[game.Lobby];
                        dbrat.EXP          = rat.EXP;
                        dbrat.Games        = rat.Games;
                        dbrat.Lobby        = game.Lobby;
                        dbrat.MU           = rat.MU;
                        dbrat.SIGMA        = rat.SIGMA;
                        dbrat.MMdbPlayerId = dbpl.MMdbPlayerId;
                        dbrat.MMdbPlayer   = dbpl;

                        if (dbrat.MMdbRatingId == null)
                        {
                            dbpl.MMdbRatings.Add(dbrat);
                        }
                        //_db.MMdbRatings.Add(dbrat);
                        else
                        {
                            _db.MMdbRatings.Update(dbrat);
                        }
                    }
                }
                await _db.SaveChangesAsync();
            }
            // **/
        }
コード例 #3
0
        public async Task Save(MMgameNG game)
        {
            // /**
            foreach (var pl in game.GetPlayers())
            {
                if (pl.Name.StartsWith("Random") || pl.Name.StartsWith("Dummy"))
                {
                    continue;
                }
                var dbpl = _startUp._db.MMdbPlayers.Where(x => x.Name == pl.Name).FirstOrDefault();
                if (dbpl != null)
                {
                    foreach (var rat in pl.Rating[game.Lobby].Where(x => x.Db == false).OrderBy(o => o.Time).ToArray())
                    {
                        MMdbRating dbrat = new MMdbRating();
                        dbrat.EXP          = rat.EXP;
                        dbrat.Games        = rat.Games;
                        dbrat.Lobby        = game.Lobby;
                        dbrat.MU           = rat.MU;
                        dbrat.SIGMA        = rat.SIGMA;
                        dbrat.MMdbPlayerId = dbpl.MMdbPlayerId;
                        dbrat.MMdbPlayer   = dbpl;
                        rat.Db             = true;
                        _startUp._db.MMdbRatings.Add(dbrat);
                    }
                }
            }
            await _startUp._db.SaveChangesAsync();

            // **/
            string output = Program.workdir + "/games/" + game.ID + "_report.json";

            if (!File.Exists(output))
            {
                using (FileStream fs = File.Create(output))
                {
                    await JsonSerializer.SerializeAsync(fs, game);
                }
            }
        }
コード例 #4
0
 public async Task Save(MMgameNG game)
 {
     // /**
     using (var _db = new MMdb(_mmdb))
     {
         foreach (var pl in game.GetPlayers())
         {
             if (pl.Name.StartsWith("Random") || pl.Name.StartsWith("Dummy"))
             {
                 continue;
             }
             var dbpl = _db.MMdbPlayers.Where(x => x.Name == pl.Name).FirstOrDefault();
             if (dbpl != null)
             {
                 foreach (var rat in pl.Rating[game.Lobby].Where(x => x.Db == false).OrderBy(o => o.Games).ToArray())
                 {
                     MMdbRating dbrat;
                     dbrat              = new MMdbRating();
                     dbrat.EXP          = rat.EXP;
                     dbrat.Games        = rat.Games;
                     dbrat.Lobby        = game.Lobby;
                     dbrat.MU           = rat.MU;
                     dbrat.SIGMA        = rat.SIGMA;
                     dbrat.MMdbPlayerId = dbpl.MMdbPlayerId;
                     dbrat.MMdbPlayer   = dbpl;
                     dbrat.Time         = rat.Time;
                     rat.Db             = true;
                     _db.MMdbRatings.Add(dbrat);
                     //dbpl.MMdbRatings.Add(dbrat);
                 }
             }
         }
         await _db.SaveChangesAsync();
     }
     // **/
 }