private async void btnStart_Click(object sender, EventArgs e) { // get data from GUI string filePath = textBoxKey.Text; string clanId = textBoxClanId.Text; // set clan id and number of previous wars statsWarLog.SetClanId(clanId); int numWars = 5; if (Int32.TryParse(textBoxNumWars.Text, out numWars)) { statsWarLog.SetNumWars(numWars); } // load key value statsWarLog.LoadKeyValue(filePath); if (statsWarLog.GetKeyVal() != null) { // request data to server string strError = await statsWarLog.RequestDataFromServer(); if (strError == null) { // create table and display data DataTable tableWarLog = statsWarLog.CreateTable(); dataGridView1.DataSource = null; dataGridView1.DataSource = tableWarLog; dataGridView1.AutoResizeColumns(); // highlight players with good and bad performance SetColorsOnTable(tableWarLog); if (checkBoxHtml.Checked) { string HtmlBody = statsWarLog.ConvertTableToHtml(tableWarLog); System.IO.File.WriteAllText(@"WarLogTable.html", HtmlBody); } } else { richTextBoxLog.AppendText(strError); richTextBoxLog.AppendText(Environment.NewLine); } } }
static async void TestWarLogOutputInHtml() { // set clan id and number of previous wars statsWarLog.SetNumWars(5); statsWarLog.SetClanId("2Y0L8VJ2"); // load key value string filePath = @"key.txt"; statsWarLog.LoadKeyValue(filePath); if (statsWarLog.GetKeyVal() != null) { // request data to server string strError = await statsWarLog.RequestDataFromServer(); if (strError == null) { // create table and convert it to html DataTable tableWarLog = statsWarLog.CreateTable(); string HtmlBody = statsWarLog.ConvertTableToHtml(tableWarLog); System.IO.File.WriteAllText(@"WarLogTable.html", HtmlBody); } } }