Exemple #1
0
        private static void DCNewTeams(Class1 d2Dm)
        {
            // Check if System Config permits this method call.
            SystemConfig systemConfig = new SystemConfig();
            systemConfig.GetByKey("GetNewTeams");

            if (!systemConfig.RecordExists || systemConfig.IsActive)
            {
                return;
            }

            string[] files = Directory.GetFiles(".", "GetTeamInfo*.xml");

            for (int i = 0; i < files.Length; i++)
            {
                files[i] = files[0].Substring(files[0].LastIndexOf("\\") + 1);

                XmlDocument response = new XmlDocument();
                response.Load(files[i]);
                string teamID = files[i].Substring("GetTeamInfo".Length, files[i].IndexOf('(') - "GetTeamInfo".Length);
                d2Dm.GetTeams(response, Convert.ToInt32(teamID));
            }

            systemConfig.IsActive = true;
            systemConfig.InsertOrUpdate();
        }
Exemple #2
0
        public bool UpdateTeam(int? teamID, int count, SystemConfig systemConfig)
        {
            XmlDocument response = new XmlDocument();

            string request = @"https://api.steampowered.com/IDOTA2Match_570/GetTeamInfoByTeamID/v001/?key=" + steamAPIKey;

            request += "&format=xml";

            if (teamID != null)
                request += @"&start_at_team_id=" + teamID;

            request += "&teams_requested=" + count;

            response = MakeRequest("UpdateTeams", request, systemConfig);
            if (response != null)
            {
                response.Save("GetTeamInfo" + (teamID != null ? teamID.ToString() : "") + "(" +
                              DateTime.Now.ToString("ddMMyyyy") + ").xml");

                GetTeams(response, teamID);
                return checkIfTeamsFound(response);
            }
            else
            {
                return false;
            }
        }
Exemple #3
0
        private static bool GetOlderMatchesPerPlayer(long steamID64)
        {
            Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1();

            PlayersList playersList = new PlayersList();
            int matchID = 0;
            // Make sure there is older matches to find.
            if (playersList.LastMatchFound(steamID64, out matchID))
                return false;

            // Check for and Recover Local Data.
            d2Dm.GetMatchPerPlayerLocalData(steamID64, matchID);

            // Check if System Config permits this method call.
            SystemConfig systemConfig = new SystemConfig();
            systemConfig.GetByKey("GetOlderMatchesPerPlayer");

            if (systemConfig.RecordExists)
            {
                if (DateTime.Now < Convert.ToDateTime(systemConfig.SCValue).AddSeconds(1))
                    return true;
            }
            else
            {
                systemConfig.SCKey = "GetOlderMatchesPerPlayer";
            }

            // Get or Create SteamRequest
            SteamRequests steamRequests;
            GetSteamRequest(out steamRequests);

            // Check if API can be used else return
            if (DateTime.Now < steamRequests.LastUpdated.AddSeconds(1))
                return true;

            // Increment the Steam Request Counter
            Console.WriteLine("Steam request number : " + steamRequests.RequestNumber + " - Get Older Matches Per Player");
            steamRequests.RequestNumber++;
            steamRequests.LastUpdated = DateTime.Now;
            steamRequests.InsertOrUpdate();

            Players player = new Players();

            // Get Live Data.
            try
            {
                if (!d2Dm.GetMatchPerPlayer(steamID64, matchID, "GetOlderMatchesPerPlayer", systemConfig))
                {
                    if (!QuiteMode)
                        Console.WriteLine("Oldest Player match found.");

                    player.GetBySteamID64(steamID64);
                    player.OldestMatchFound = true;
                    player.Update();
                }

                systemConfig.SCValue = DateTime.Now.ToString();
                systemConfig.InsertOrUpdate();
            }
            catch (Exception)
            {
                steamRequests.RequestNumber--;
                steamRequests.InsertOrUpdate();
            }

            if (player.RecordExists && player.OldestMatchFound)
                return false;
            else
                return true;
        }
Exemple #4
0
        private static void GetPlayerSummaries()
        {
            Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1();

            PlayersList players = new PlayersList();

            // Get Top 100 Unprocessed Players
            players.GetUnprocessedPlayers(Dota2DataMiner.Class1.PlayerSummariesLimiter);

            // Check for and Recover Local Data.
            d2Dm.GetNewPlayerSummariesRecoverLocalData(players);

            // Get Top 100 Unprocessed Players
            players.GetUnprocessedPlayers(Dota2DataMiner.Class1.PlayerSummariesLimiter);

            // Check if System Config permits this method call.
            SystemConfig systemConfig = new SystemConfig();
            systemConfig.GetByKey("GetPlayerSummaries");

            if (systemConfig.RecordExists)
            {
                if (DateTime.Now < Convert.ToDateTime(systemConfig.SCValue).AddSeconds(1))
                    return;
            }
            else
                systemConfig.SCKey = "GetPlayerSummaries";

            // Get or Create And Increment SteamRequest
            SteamRequests steamRequests;
            GetSteamRequest(out steamRequests);

            // Check if API can be used else return
            if (DateTime.Now < steamRequests.LastUpdated.AddSeconds(1))
                return;

            // Increment the Steam Request Counter
            Console.WriteLine("Steam request number : " + steamRequests.RequestNumber + " - Get Player Summaries");
            steamRequests.RequestNumber++;
            steamRequests.LastUpdated = DateTime.Now;
            steamRequests.InsertOrUpdate();

            // Get Live Data.
            if (d2Dm.GetNewPlayerSummaries(players, systemConfig))
            {
                // New Data Found, sleep for 1 seconds as steam requests before continuing.
                systemConfig.SCValue = DateTime.Now.ToString();
            }
            else
            {
                // No New Data Found, sleep for 60 seconds to save daily requests.
                if (!QuiteMode)
                    Console.WriteLine("No New Players Found.");
                systemConfig.SCValue = DateTime.Now.AddMinutes(1).ToString();
            }

            systemConfig.InsertOrUpdate();
        }
Exemple #5
0
        //private static void GetTeams()
        //{
        //    Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1();

        //    TeamsList teams = new TeamsList();

        //    // Get latest Team.
        //    int? teamID = teams.GetMaxTeamID();

        //    // Check for and Recover Local Data.
        //    d2Dm.GetNewTeamsRecoverLocalData(teamID);

        //    // Get latest Team.
        //    teamID = teams.GetMaxTeamID();

        //    // Check if System Config permits this method call.
        //    SystemConfig systemConfig = new SystemConfig();
        //    systemConfig.GetByKey("GetNewTeams");

        //    if (systemConfig.RecordExists)
        //    {
        //        if (DateTime.Now < Convert.ToDateTime(systemConfig.SCValue).AddSeconds(1))
        //            return;
        //    }
        //    else
        //    {
        //        systemConfig.SCKey = "GetNewTeams";
        //    }

        //    // Get or Create And Increment SteamRequest
        //    SteamRequests steamRequests;
        //    GetSteamRequest(out steamRequests);

        //    // Check if API can be used else return
        //    if (DateTime.Now < steamRequests.LastUpdated.AddSeconds(1))
        //        return;

        //    // Increment the Steam Request Counter
        //    Console.WriteLine("Steam request number : " + steamRequests.RequestNumber + " - GetTeams");
        //    steamRequests.RequestNumber++;
        //    steamRequests.LastUpdated = DateTime.Now;
        //    steamRequests.InsertOrUpdate();

        //    // Get Live Data.
        //    if (d2Dm.GetNewTeams(teamID, 100))
        //    {
        //        // New Data Found, sleep for 1 seconds as steam requests before continuing.
        //        systemConfig.SCValue = DateTime.Now.ToString();
        //    }
        //    else
        //    {
        //        // No New Data Found, sleep for 60 seconds to save daily requests.
        //        if (!QuiteMode)
        //            Console.WriteLine("No New Teams Found.");
        //        systemConfig.SCValue = DateTime.Now.AddMinutes(30).ToString();
        //    }

        //    systemConfig.InsertOrUpdate();
        //}

        private static void UpdateTeams()
        {
            Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1();

            TeamsList teams = new TeamsList();

            // Get latest Team.
            int? teamID = teams.GetMinTeamIDForUpdate();

            // Check for and Recover Local Data.
            d2Dm.GetNewTeamsRecoverLocalData(teamID);

            // Get latest Team.
            teamID = teams.GetMinTeamIDForUpdate();

            // Check if System Config permits this method call.
            SystemConfig systemConfig = new SystemConfig();
            systemConfig.GetByKey("UpdateTeams");

            if (systemConfig.RecordExists)
            {
                if (DateTime.Now < Convert.ToDateTime(systemConfig.SCValue).AddSeconds(1))
                    return;
            }
            else
            {
                systemConfig.SCKey = "UpdateTeams";
            }

            // Get or Create And Increment SteamRequest
            SteamRequests steamRequests;
            GetSteamRequest(out steamRequests);

            // Check if API can be used else return
            if (DateTime.Now < steamRequests.LastUpdated.AddSeconds(1))
                return;

            // Increment the Steam Request Counter
            Console.WriteLine("Steam request number : " + steamRequests.RequestNumber + " - UpdateTeams");
            steamRequests.RequestNumber++;
            steamRequests.LastUpdated = DateTime.Now;
            steamRequests.InsertOrUpdate();

            // Get Live Data.
            if (!d2Dm.UpdateTeam(teamID, 100, systemConfig))
            {
                // No New Data Found, sleep for 60 seconds to save daily requests.
                if (!QuiteMode)
                    Console.WriteLine("No New Teams Found.");
                systemConfig.SCValue = DateTime.Now.AddMinutes(1).ToString();
            }

            systemConfig.InsertOrUpdate();
        }
Exemple #6
0
        private static void GetMatchesPerUndocumentedPlayer()
        {
            Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1();

            PlayersList playersList = new PlayersList();

            // Get latest Team.
            long steamID64 = playersList.GetPlayerWithNoMatchRecords();

            // If nothing new to find, return
            if (steamID64 == -1)
                return;

            // Check for and Recover Local Data.
            d2Dm.GetMatchPerPlayerLocalData(steamID64, 0);

            // Get latest Team.
            steamID64 = playersList.GetPlayerWithNoMatchRecords();

            // If nothing new to find, return
            if (steamID64 == -1)
                return;

            // Check if System Config permits this method call.
            SystemConfig systemConfig = new SystemConfig();
            systemConfig.GetByKey("GetMatchesPerUndocumentedPlayer");

            if (systemConfig.RecordExists)
            {
                if (DateTime.Now < Convert.ToDateTime(systemConfig.SCValue).AddSeconds(1))
                    return;
            }
            else
            {
                systemConfig.SCKey = "GetMatchesPerUndocumentedPlayer";
            }

            // Get or Create SteamRequest
            SteamRequests steamRequests;
            GetSteamRequest(out steamRequests);

            // Check if API can be used else return
            if (DateTime.Now < steamRequests.LastUpdated.AddSeconds(1))
                return;

            // Increment the Steam Request Counter
            Console.WriteLine("Steam request number : " + steamRequests.RequestNumber + " - Get Matches Per Undocumented Player");
            steamRequests.RequestNumber++;
            steamRequests.LastUpdated = DateTime.Now;
            steamRequests.InsertOrUpdate();

            // Get Live Data.
            if (d2Dm.GetMatchPerPlayer(steamID64, 0, "GetMatchesPerUndocumentedPlayer", systemConfig))
            {
                // New Data Found, sleep for 1 seconds as steam requests before continuing.
                systemConfig.SCValue = DateTime.Now.ToString();
            }
            else
            {
                // No New Data Found, sleep for 60 seconds to save daily requests.
                if (!QuiteMode)
                    Console.WriteLine("No Match Per Player Found.");
                systemConfig.SCValue = DateTime.Now.AddMinutes(1).ToString();
            }

            systemConfig.InsertOrUpdate();
        }
Exemple #7
0
        public bool GetMatchPerPlayer(long steamId64, int matchID, string requestType, SystemConfig systemConfig)
        {
            XmlDocument response = new XmlDocument();
            string request = @"https://api.steampowered.com/IDOTA2Match_570/GetMatchHistory/V001/?key=" + steamAPIKey;

            request += "&format=xml";

            request += @"&account_id=" + steamId64;

            if (matchID != 0)
                request += "&start_at_match_id=" + matchID;

            response = MakeRequest(requestType, request, systemConfig);
            if (response != null)
            {
                response.Save("GetMatchPerPlayer" + steamId64.ToString() + (matchID != 0 ? matchID.ToString() : "") + "(" +
                              DateTime.Now.ToString("ddMMyyyy") + ").xml");

                return GetMatchs(response, steamId64, matchID);
            }
            else
            {
                return false;
            }
        }
Exemple #8
0
        public bool GetNewPlayerSummaries(PlayersList players, SystemConfig systemConfig)
        {
            if (players == null || players.Count == 0)
                return false;

            XmlDocument response = new XmlDocument();

            string request = @"http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" + steamAPIKey;

            request += "&format=xml";

            request += @"&SteamIDs=";

            for (int i = 0; i < players.Count; i++)
            {
                if (i != 0)
                    request += ",";
                request += (players[i].SteamID + 76561197960265728).ToString();
            }

            response = MakeRequest("GetPlayerSummaries", request, systemConfig);

            if (response == null)
            {
                if (players.Count == 1 && PlayerSummariesLimiter == 1)
                {
                    players[0].PersonaName = "BROKEN";
                    players[0].LastUpdated = new DateTime(2020, 1, 1);

                    PlayerSummariesLimiter = 100;
                    players[0].InsertOrUpdate();
                }
                return true;
            }
            else
            {
                response.Save("PlayerSummaryInfo" + players[0].SteamID + "(" + DateTime.Now.ToString("ddMMyyyy") + ").xml");

                return GetPlayers(response, players);
            }
        }
Exemple #9
0
        public static XmlDocument MakeRequest(string requestType, string requestUrl, SystemConfig systemConfig)
        {
            try
            {
                // Track every request made.
                RequestTracking requestTracking = new RequestTracking();
                requestTracking.Request = requestUrl;
                requestTracking.Date = DateTime.Now;
                requestTracking.InsertOrUpdate();

                HttpWebRequest request = WebRequest.Create(requestUrl) as HttpWebRequest;
                HttpWebResponse response = request.GetResponse() as HttpWebResponse;

                if (systemConfig == null)
                    systemConfig = new SystemConfig();

                if (!systemConfig.RecordExists)
                    systemConfig.SCKey = requestType;
                systemConfig.SCValue = DateTime.Now.ToString();
                systemConfig.InsertOrUpdate();

                XmlDocument xmlDoc = new XmlDocument();
                xmlDoc.Load(response.GetResponseStream());
                return (xmlDoc);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);

                PlayerSummariesLimiter = 1;

                return null;
            }
        }