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(); }
static void Main(string[] args) { Dota2DataMiner.Class1.PlayerSummariesLimiter = 100; QuiteMode = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings.Get("QuiteMode")); BackgroundWorker _bgWorker = new BackgroundWorker(); _bgWorker.DoWork += delegate { Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1(); do { DCNewTeams(d2Dm); } while (true); }; _bgWorker.RunWorkerAsync(); do { // If their are special requests do one and restart the loop else do normal routine. if (GetSpecialRequest()) continue; GetTeams(); GetPlayerSummaries(); UpdateTeams(); GetMatchesPerUndocumentedPlayer(); } while (true); }
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; }
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(); }
//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(); }
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(); }