コード例 #1
0
 public PlayerPerformance CurrentPlayer(long accountId)
 {
     using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
     {
         return(db
                .PlayersPerformance
                .FirstOrDefault(pp => pp.AccountId == accountId));
     }
 }
コード例 #2
0
        public void AddRangeJSONToDatabase(HashSet <Result> results)
        {
            using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
            {
                db
                .Results
                .AddRange(results);

                db.SaveChanges();
            }
        }
コード例 #3
0
        public void AddJSONToDatabase(Result result)
        {
            using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
            {
                db
                .Results
                .Add(result);

                db.SaveChanges();
            }
        }
コード例 #4
0
        public List <long> GetAllMatchesIds()
        {
            using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
            {
                List <long> allMatchesIds = new List <long>();

                foreach (var result in db.Results)
                {
                    allMatchesIds.Add(result.MatchId);
                }

                return(allMatchesIds);
            }
        }
コード例 #5
0
        public void UpdatePlayerPerformance(PlayerPerformance playerPerformance)
        {
            using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
            {
                if (db.PlayersPerformance.FirstOrDefault(p => p.AccountId == playerPerformance.AccountId) == null)
                {
                    db.PlayersPerformance.Add(playerPerformance);
                }
                else
                {
                    var entity = playerPerformance;
                }

                db.SaveChanges();
            }
        }
コード例 #6
0
        public long GetLastAddedMatch()
        {
            using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
            {
                var results    = db.Results;
                var matchesIds = new List <long>();

                foreach (var result in results)
                {
                    matchesIds.Add(result.MatchId);
                }
                matchesIds.Sort();

                return(matchesIds.LastOrDefault());
            }
        }
コード例 #7
0
        public List <Result> LastMonthResults()
        {
            using (MatchesHistoryDbContext db = new MatchesHistoryDbContext())
            {
                List <Result> results = new List <Result>();

                long startTime = DateTime.Now.Millisecond;

                results = db
                          .Results
                          .Where(r => r.StartTime > startTime)
                          .Include(r => r.Players)
                          .ToList();

                return(results);
            }
        }
コード例 #8
0
        public static void Main()
        {
            string json = string.Empty;

            while (true)
            {
                var line = Console.ReadLine();

                if (line == "end")
                {
                    break;
                }

                json += line;
            }

            List <Hero> heroes = JsonConvert.DeserializeObject <RootObject>(json).Heroes;

            using (var db = new MatchesHistoryDbContext())
            {
                foreach (Hero currentHero in heroes)
                {
                    string imageFull = string.Format("C:\\Users\\User\\Desktop\\DotaProject\\HeroesFull\\{0}_full.png", currentHero.Name);

                    var currentImageFull = Image.FromFile(imageFull);

                    currentHero.ImageFull = ImageToByteArray(currentImageFull);

                    string imageOver = string.Format("C:\\Users\\User\\Desktop\\DotaProject\\HeroesOver\\{0}_hphover.png", currentHero.Name);

                    var currentImageOver = Image.FromFile(imageOver);

                    currentHero.ImageOver = ImageToByteArray(currentImageOver);

                    db.Heroes.Add(currentHero);
                }

                db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT SomeDotes.dbo.Heroes ON;");
                db.SaveChanges();
                db.Database.ExecuteSqlCommand("SET IDENTITY_INSERT SomeDotes.dbo.Heroes OFF;");
            }
        }