Exemple #1
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 #2
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();
        }