/// <summary> /// Returns a matching user Google Test /// </summary> /// <param name="guid"></param> /// <param name="database"></param> /// <returns></returns> public GoogleTest GetGoogleUserTests(Guid guid, Database database) { database.CheckConnection(); GoogleTest gt = null; try { MySqlCommand command = new MySqlCommand("GetGoogleUserTests", database.Connection); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@guid", guid); //Run stored procedure to get the event dates in asc order of the current month MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { gt = new GoogleTest { score = reader.GetInt32("score"), category = reader.GetString("category"), resources = reader.GetInt32("resources"), hosts = reader.GetInt32("hosts"), bytes = reader.GetInt64("bytes"), htmlBytes = reader.GetInt64("html_bytes"), cssBytes = reader.GetInt64("css_bytes"), imageBytes = reader.GetInt64("image_bytes"), webspeed = (decimal)reader.GetDouble("webspeed") }; } reader.Close(); } catch (MySqlException) { Debug.WriteLine("Stored Procedure: Cannot perform GetGoogleUserTests."); } _complete = true; return(gt); }
/// <summary> /// Get crowdsourcing tests (google specific) /// </summary> /// <param name="city"></param> /// <param name="state"></param> /// <param name="browser"></param> /// <param name="website"></param> /// <param name="ordering"></param> /// <param name="database"></param> /// <returns></returns> public List <GoogleTest> GetGoogleTests(string city, string state, string browser, string website, bool ordering, Database database) { database.CheckConnection(); List <GoogleTest> tests = new List <GoogleTest>(); try { MySqlCommand command = new MySqlCommand("GetGoogleTests", database.Connection); command.CommandType = CommandType.StoredProcedure; if (String.IsNullOrEmpty(city)) { city = "null"; } if (String.IsNullOrEmpty(state)) { state = "null"; } if (String.IsNullOrEmpty(browser)) { browser = "null"; } if (String.IsNullOrEmpty(website)) { website = "null"; } command.Parameters.AddWithValue("@ucity", city); command.Parameters.AddWithValue("@ustate", state); command.Parameters.AddWithValue("@ubrowser", browser); command.Parameters.AddWithValue("@uwebsite", website); if (ordering) { command.Parameters.AddWithValue("@ordering", true); } else { command.Parameters.AddWithValue("@ordering", false); } //Run stored procedure to get the event dates in asc order of the current month MySqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { GoogleTest gt = new GoogleTest { date = reader.GetDateTime("tstamp"), website = website, score = reader.GetInt32("score"), category = reader.GetString("category"), resources = reader.GetInt32("resources"), hosts = reader.GetInt32("hosts"), bytes = reader.GetInt64("bytes"), htmlBytes = reader.GetInt64("html_bytes"), cssBytes = reader.GetInt64("css_bytes"), imageBytes = reader.GetInt64("image_bytes"), webspeed = (decimal)reader.GetDouble("webspeed"), }; tests.Add(gt); } reader.Close(); } catch (MySqlException) { Debug.WriteLine("Stored Procedure: Cannot perform GetGoogleTests."); } return(tests); }