private static bool GetDecision(UInt32 ID, Case caseData) { while (true) { try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://na.leagueoflegends.com/tribunal/en/case/" + ID); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); string data = reader.ReadToEnd(); reader.Close(); response.Close(); if (data.Contains("Unable to locate specified case.")) return false; string punishment = ""; for (int i = data.IndexOf("verdict-stat") + 14; data[i] != '<'; i++) punishment += data[i]; caseData.Punishment = punishment; string agreement = ""; for (int i = data.IndexOf("verdict-stat agreement") + 24; data[i] != '<'; i++) agreement += data[i]; caseData.Agreement = agreement; string decision = ""; for (int i = data.LastIndexOf("verdict-stat") + 14; data[i] != '<'; i++) decision += data[i]; caseData.Decision = decision; break; } catch (Exception) { } } return true; }
private static void UpdateDecision(UInt32 ID, Case caseData) { while (true) { try { conn.Open(); using (MySqlCommand cmd = new MySqlCommand("UPDATE cases SET Decision='" + caseData.Decision + "', Agreement='" + caseData.Agreement + "', Punishment='" + caseData.Punishment + "', Decided=1 WHERE ID='" + ID + "';", conn)) { cmd.ExecuteNonQuery(); conn.Close(); break; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); conn.Close(); } } }
public static void Insert(Case data, MySqlConnection conn) { while (true) { try { conn.Open(); using (MySqlCommand cmd = new MySqlCommand("INSERT INTO cases (ID, Games, Reports, Ally, Enemy, OFFENSIVE_LANGUAGE, VERBAL_ABUSE, INTENTIONAL_FEEDING, ASSISTING_ENEMY, UNSKILLED_PLAYER, NO_COMMUNICATION_WITH_TEAM, LEAVING_AFK, NEGATIVE_ATTITUDE, INAPPROPRIATE_NAME, SPAMMING, Decision, Agreement, Punishment, Decided) VALUES (@ID, @Games, @Reports, @Ally, @Enemy, @OFFENSIVE_LANGUAGE, @VERBAL_ABUSE, @INTENTIONAL_FEEDING, @ASSISTING_ENEMY, @UNSKILLED_PLAYER, @NO_COMMUNICATION_WITH_TEAM, @LEAVING_AFK, @NEGATIVE_ATTITUDE, @INAPPROPRIATE_NAME, @SPAMMING, @Decision, @Agreement, @Punishment, @Decided);", conn)) { cmd.Parameters.Add("@ID", MySqlDbType.UInt32).Value = data.ID; cmd.Parameters.Add("@Games", MySqlDbType.UByte).Value = data.Games; cmd.Parameters.Add("@Reports", MySqlDbType.UByte).Value = data.Reports; cmd.Parameters.Add("@Ally", MySqlDbType.UByte).Value = data.Ally; cmd.Parameters.Add("@Enemy", MySqlDbType.UByte).Value = data.Enemy; cmd.Parameters.Add("@OFFENSIVE_LANGUAGE", MySqlDbType.UByte).Value = data.OFFENSIVE_LANGUAGE; cmd.Parameters.Add("@VERBAL_ABUSE", MySqlDbType.UByte).Value = data.VERBAL_ABUSE; cmd.Parameters.Add("@INTENTIONAL_FEEDING", MySqlDbType.UByte).Value = data.INTENTIONAL_FEEDING; cmd.Parameters.Add("@ASSISTING_ENEMY", MySqlDbType.UByte).Value = data.ASSISTING_ENEMY; cmd.Parameters.Add("@UNSKILLED_PLAYER", MySqlDbType.UByte).Value = data.UNSKILLED_PLAYER; cmd.Parameters.Add("@NO_COMMUNICATION_WITH_TEAM", MySqlDbType.UByte).Value = data.NO_COMMUNICATION_WITH_TEAM; cmd.Parameters.Add("@LEAVING_AFK", MySqlDbType.UByte).Value = data.LEAVING_AFK; cmd.Parameters.Add("@NEGATIVE_ATTITUDE", MySqlDbType.UByte).Value = data.NEGATIVE_ATTITUDE; cmd.Parameters.Add("@INAPPROPRIATE_NAME", MySqlDbType.UByte).Value = data.INAPPROPRIATE_NAME; cmd.Parameters.Add("@SPAMMING", MySqlDbType.UByte).Value = data.SPAMMING; cmd.Parameters.Add("@Decision", MySqlDbType.TinyText).Value = data.Decision; cmd.Parameters.Add("@Agreement", MySqlDbType.TinyText).Value = data.Agreement; cmd.Parameters.Add("@Punishment", MySqlDbType.TinyText).Value = data.Punishment; cmd.Parameters.Add("@Decided", MySqlDbType.Bit).Value = data.Decided; cmd.ExecuteNonQuery(); conn.Close(); break; } } catch (Exception ex) { Console.WriteLine(ex.ToString()); conn.Close(); } } }
private static void Run() { while (true) { PopulateList(); int count = cases.Count; for (int i = 0; i < count; i++) { if (run) { if (GetGameData(cases[i], 1) == null) { Case decision = new Case(cases[i]); if (GetDecision(cases[i], decision)) { UpdateDecision(decision.ID, decision); } UpdateFix(decision.ID); } } else { Console.WriteLine("Worker terminated"); return; } } } }
public void ParseGame(UInt32 ID) { Console.Title = "Case: " + ID + " - Key: " + KeyID; if (LoLKeep.Check(ID, conn)) { Case caseData = new Case(ID); for (int game = 1; game <= 5; game++) { GameRecord gameData; Tribunal tribunalData = new Tribunal(); caseData.Games++; if ((gameData = GetGame(ID, game)) != null) { if (gameData.game_mode == "Classic" && gameData.game_mode_raw == "Classic" && gameData.players.Count == 10) { for (int n = 0; n < 10; n++) { Record recordData = new Record(); Player temp = gameData.players[n]; recordData.Champion = temp.champion_name; recordData.Team = temp.team != "Team1"; recordData.ReportedTeam = temp.association_to_offender != "enemy"; recordData.Offender = temp.association_to_offender == "offender"; switch (temp.outcome) { case "Win": recordData.Outcome = 0; break; case "Loss": recordData.Outcome = 1; break; case "Leave": recordData.Outcome = 2; break; } recordData.Time = temp.time_played; recordData.K = temp.scores.kills; recordData.D = temp.scores.deaths; recordData.A = temp.scores.assists; recordData.G = temp.gold_earned; LoLKeep.Insert(recordData, conn); if (recordData.Offender) tribunalData.Record(recordData); if (recordData.ReportedTeam) tribunalData.AddKDA(recordData); } tribunalData.Report = gameData.most_common_report_reason; LoLKeep.Insert(tribunalData, conn); } caseData.Ally += gameData.allied_report_count; caseData.Enemy += gameData.enemy_report_count; int count = gameData.reports.Count; for (int n = 0; n < count; n++) { switch (gameData.reports[n].offense) { case "OFFENSIVE_LANGUAGE": caseData.OFFENSIVE_LANGUAGE++; break; case "VERBAL_ABUSE": caseData.VERBAL_ABUSE++; break; case "INTENTIONAL_FEEDING": caseData.INTENTIONAL_FEEDING++; break; case "ASSISTING_ENEMY": caseData.ASSISTING_ENEMY++; break; case "UNSKILLED_PLAYER": caseData.UNSKILLED_PLAYER++; break; case "NO_COMMUNICATION_WITH_TEAM": caseData.NO_COMMUNICATION_WITH_TEAM++; break; case "LEAVING_AFK": caseData.LEAVING_AFK++; break; case "NEGATIVE_ATTITUDE": caseData.NEGATIVE_ATTITUDE++; break; case "INAPPROPRIATE_NAME": caseData.INAPPROPRIATE_NAME++; break; case "SPAMMING": caseData.SPAMMING++; break; } } } else if (game > 1) break; else { Console.WriteLine("Key: " + KeyID + " - Ended at " + ID); LoLKeep.TerminateKey(KeyID); return; } } if (GetDecision(ID, caseData)) caseData.Decided = true; caseData.Reports = (byte)(caseData.Ally + caseData.Enemy); LoLKeep.Insert(caseData, conn); } }