private bool DoesModpackWithSameVersionExistInDatabase(Modpack modpack) { try { using (MySqlConnection connection = Database.GetConnectionString()) { connection.Open(); using (MySqlCommand selectId = new MySqlCommand("SELECT IFNULL(MAX(id), 0) FROM modpackupdates WHERE (version) = (@version)", connection)) { selectId.Parameters.AddWithValue("version", modpack.Version); if (Convert.ToInt32(selectId.ExecuteScalar()) == 0) { return(false); } return(true); } } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
private bool HasModpackBeenUpdatedInPast(Modpack modpack) { try { if (AnnouncedModpackIdList.Contains(modpack.Id)) { return(true); } return(false); } catch (Exception e) { Console.WriteLine(e); throw; } }
public void CreateConnection() { Modpack modpack = new Modpack(); try { foreach (int modpackId in modpack.ModpackIds) { try { string url = "http://curse.nikky.moe/api/addon/" + modpackId + "/files"; string json = GetModpackContent(url); dynamic modpackData = JsonConvert.DeserializeObject(json); dynamic modpackMetaData = GetModpackMeta(modpackId); ModpackName = modpackMetaData["name"].ToString(); ChangelogUrl = modpackMetaData["webSiteURL"].ToString() + "/changes"; foreach (var modpackFile in modpackData) { Modpack modpk = new Modpack(ModpackName, modpackId, modpackFile["fileName"].ToString(), modpackFile["releaseType"].ToString(), ChangelogUrl); modpack.ModpackList.Add(modpk); } } catch (Exception) { Console.WriteLine("Something went wrong trying to get the modpack data from: " + modpackId); } } CheckForReleaseTypeAsync(modpack.ModpackList); } catch (Exception e) { Console.WriteLine(e); throw; } }
private void AddModpackToDatabase(Modpack modpack, bool removePreviousEntry) { try { using (MySqlConnection connection = Database.GetConnectionString()) { connection.Open(); if (removePreviousEntry) { using (MySqlCommand removeModpack = new MySqlCommand("DELETE FROM modpackupdates WHERE (id) = (@id)", connection)) { removeModpack.Parameters.AddWithValue("id", modpack.Id); removeModpack.ExecuteNonQuery(); } } using (MySqlCommand insertModpack = new MySqlCommand( "INSERT INTO modpackupdates (id, version, name, changelogurl) VALUES (@id, @version, @name, @changelogurl)", connection)) { insertModpack.Parameters.AddWithValue("id", modpack.Id); insertModpack.Parameters.AddWithValue("version", modpack.Version); insertModpack.Parameters.AddWithValue("name", modpack.Name); insertModpack.Parameters.AddWithValue("changelogUrl", modpack.ChangelogUrl); Console.WriteLine(modpack.Id + " " + modpack.Version + " was added to the database"); insertModpack.ExecuteNonQuery(); } } } catch (Exception exception) { Console.WriteLine(exception); throw; } }
public async Task CreateAnnouncement(Modpack modpack) { await Bot.Announce(modpack.Name, modpack.Version, modpack.ChangelogUrl, true, 225347404197658624); await Bot.Announce(modpack.Name, modpack.Version, modpack.ChangelogUrl, false, 241556187752038401); }