static private string CreateAreaTriggerInsertValue(AreaTriggerAction action, AreaTriggerTemplateInfo template, int id) { string query = "(" + template.Entry + ", " + template.SpellId + ", " + template.CustomEntry + ", " + id + ", " + action.Moment + ", " + action.ActionType + ", " + action.TargetFlags + ", " + action.ActionSpellId + ", " + action.MaxCharges + ", " + action.HasAura + ", " + action.ChargeRestoreTimer + ", " + action.MaxTargetHitted + ", " + action.DespawnAfterAction + ',' + GenerateActionComment(action) + ")"; return(query); }
public void GenerateSQL() { mainForm.AreaTrigger_SQLOutput_RichTextBox.Clear(); foreach (var item in areaTriggerActionEntries) { string SQLtext = ""; if (item.Value.Count > 0) { SQLtext = "-- " + GetSpellName(item.Key) + " \r\n"; SQLtext += "DELETE FROM `areatrigger_actions` WHERE `summon_spellId` = " + item.Key + ";\r\n"; SQLtext += "INSERT INTO `areatrigger_actions` (`entry`, `summon_spellId`, `customEntry`, `id`, `moment`, `actionType`, `targetFlags`, `spellId`, `maxCharges`, " + "`aura`, `chargeRecoveryTime`, `hitMaxCount`, `onDespawn`, `comment`) VALUES\r\n"; } uint itr = 0; AreaTriggerTemplateInfo template = GetAreaTriggerTemplateInfo(item.Key); if (!template.IsValidTemplate()) { continue; } foreach (AreaTriggerAction spellDbc in item.Value) { string query = AreaTriggerActionCreator.CreateAreaTriggerInsertValue(spellDbc, template, (int)itr); if (itr + 1 >= item.Value.Count) { query += ";\n"; } else { query += ",\n"; } SQLtext += query; itr++; } SQLtext += "\n\n"; mainForm.AreaTrigger_SQLOutput_RichTextBox.AppendText(SQLtext); } MessageBox.Show("SQL Queries Generated"); }
public void CheckAreaTriggerInfo() { uint spellId = ParseText(mainForm.AreaTrigger_SpellId_TextBox.Text); AreaTriggerTemplateInfo template = GetAreaTriggerTemplateInfo(spellId); if (!template.IsValidTemplate()) { String msg = String.Format("The AreaTrigger with SpellId: {0} doesn't exist in DB", spellId); MessageBox.Show(msg); EnableLockedItems(false); } else { EnableLockedItems(true); } }
public AreaTriggerTemplateInfo GetAreaTriggerTemplateInfo(uint spellId) { DataSet areaTriggerInfo; string areaTriggerTemplateInfoQuery = "SELECT `entry`, `spellId`, `customEntry` FROM `areatrigger_template` where `spellId` = " + spellId + ";"; areaTriggerInfo = SQLModule.DatabaseSelectQuery(areaTriggerTemplateInfoQuery); if (areaTriggerInfo.Tables["table"].Rows.Count == 0 || areaTriggerInfo.Tables["table"].Rows.Count == 0) { MessageBox.Show("AreaTrigger Template doesn't exists in your database!"); return(new AreaTriggerTemplateInfo(-1)); } AreaTriggerTemplateInfo template = new AreaTriggerTemplateInfo(); template.Entry = Convert.ToInt32(areaTriggerInfo.Tables["table"].Rows[0][0].ToString()); template.SpellId = Convert.ToInt32(areaTriggerInfo.Tables["table"].Rows[0][1].ToString()); template.CustomEntry = Convert.ToInt32(areaTriggerInfo.Tables["table"].Rows[0][2].ToString()); return(template); }