Пример #1
0
        // procède à l'importation des classements ATP (et ELO)
        private void LoadAtpRanking()
        {
            string query = "select * from atp_ranking";

            using (DataTableReader reader = SqlTools.ExecuteReader(query))
            {
                while (reader.Read())
                {
                    new AtpRanking(reader.GetUint64("player_ID"), reader.GetUint32("year"), reader.GetUint32("week_no"),
                                   reader.GetUint32("week_points"), reader.GetUint32("year_calendar_points"), reader.GetUint32("year_rolling_points"),
                                   reader.GetUint16("year_calendar_ranking"), reader.GetUint16("year_rolling_ranking"), reader.GetUint16("elo"));
                }
            }
        }
Пример #2
0
        // Procède à l'importation des éditions de tournoi.
        private void LoadEditions()
        {
            string query = "select *, (select count(*) from matches where edition_ID = editions.ID) as MatchCount from editions order by tournament_ID, year";

            using (DataTableReader reader = SqlTools.ExecuteReader(query))
            {
                while (reader.Read())
                {
                    Edition edition = new Edition(reader.GetUint32("ID"),
                                                  reader.GetUint32("tournament_ID"),
                                                  reader.GetUint32("year"),
                                                  reader.GetUint16("draw_size"),
                                                  reader.GetDateTime("date_begin"),
                                                  reader.GetUint32("MatchCount") >= Edition.TWO_WEEKS_MIN_MATCH_COUNT,
                                                  reader.GetDateTime("date_end"),
                                                  reader.GetBoolean("is_indoor"),
                                                  (Level)reader.GetByte("level_ID"),
                                                  reader.GetString("name"),
                                                  reader.GetString("city"),
                                                  reader["slot_order"] == DBNull.Value ? (byte)0 : reader.GetByte("slot_order"),
                                                  (Surface)reader.GetByte("surface_ID"));

                    if (Config.GetBool(AppKey.ComputeStatisticsWhileLoading))
                    {
                        LoadEditionsStatistics(edition);
                    }

                    _dataLoadingProgressEventHandler?.Invoke(new DataLoadingProgressEvent(100 * ++_currentDataCount / _totalDataCount));
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Importe des matchs depuis la base de données selon des paramètres optionnels.
        /// </summary>
        /// <param name="editionId">Identifiant d'édition de tournoi.</param>
        /// <param name="playerId">Identifiant de joueur.</param>
        /// <returns>Les matchs importés.</returns>
        public IEnumerable <Match> LoadMatches(uint?editionId, ulong?playerId)
        {
            List <Match> matchs = new List <Match>();

            Match.SetBatchMode(true);

            string          query     = "select * from matches where 1 = 1";
            List <SqlParam> sqlParams = new List <SqlParam>();

            if (editionId.HasValue)
            {
                query += " and edition_ID = @edition";
                sqlParams.Add(new SqlParam("@edition", DbType.UInt32, editionId.Value));
            }
            if (playerId.HasValue)
            {
                query += " and (winner_ID = @player or loser_ID = @player)";
                sqlParams.Add(new SqlParam("@player", DbType.UInt32, playerId.Value));
            }

            using (DataTableReader reader = SqlTools.ExecuteReader(query, sqlParams.ToArray()))
            {
                while (reader.Read())
                {
                    Match match = new Match(reader.GetUint64("ID"),
                                            reader.GetUint32("edition_ID"),
                                            reader.GetUint16("match_num"),
                                            (Round)reader.GetByte("round_ID"),
                                            reader.GetByte("best_of"),
                                            reader.GetUint32Null("minutes"),
                                            reader.GetBoolean("unfinished"),
                                            reader.GetBoolean("retirement"),
                                            reader.GetBoolean("walkover"),
                                            reader.GetUint32("winner_ID"),
                                            reader.GetUint32Null("winner_seed"),
                                            reader.GetString("winner_entry"),
                                            reader.GetUint32Null("winner_rank"),
                                            reader.GetUint32Null("winner_rank_points"),
                                            reader.GetUint32("loser_ID"),
                                            reader.GetUint32Null("loser_seed"),
                                            reader.GetString("loser_entry"),
                                            reader.GetUint32Null("loser_rank"),
                                            reader.GetUint32Null("loser_rank_points"));
                    match.DefineStatistics(reader.ToDynamicDictionnary <uint?>(true), reader.ToDynamicDictionnary <uint?>(true));
                    for (byte i = 1; i <= 5; i++)
                    {
                        match.AddSetByNumber(i, reader.GetByteNull("w_set_" + i.ToString()), reader.GetByteNull("l_set_" + i.ToString()), reader.GetUint16Null("tb_set_" + i.ToString()));
                    }
                    matchs.Add(match);

                    if (Config.GetBool(AppKey.ComputeMatchesWhileLoading))
                    {
                        _dataLoadingProgressEventHandler?.Invoke(new DataLoadingProgressEvent(100 * ++_currentDataCount / _totalDataCount));
                    }
                }
            }

            Match.SetBatchMode(false);

            return(matchs);
        }