mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Flags attribute * empty statement * Fix Formatting * Fix OrderBy -> ThenBy * use OfType * Replace with asingle call to Count(...) * Replace with a single call to FirstOrDefault * Merge cast with type check * use String.IsNullOrEmpty * use collections count property * use format specifier (results in shorter loc) * use Any() instead of Count() > 0 * revert ThenBy with comment
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System.IO;
|
|
|
|
using ACE.Database.Models.World;
|
|
|
|
namespace ACE.Database.SQLFormatters.World
|
|
{
|
|
public class QuestSQLWriter : SQLWriter
|
|
{
|
|
/// <summary>
|
|
/// Default is formed from: input.Name
|
|
/// </summary>
|
|
public string GetDefaultFileName(Quest input)
|
|
{
|
|
string fileName = input.Name;
|
|
fileName = IllegalInFileName.Replace(fileName, "_");
|
|
fileName += ".sql";
|
|
|
|
return fileName;
|
|
}
|
|
|
|
public void CreateSQLDELETEStatement(Quest input, StreamWriter writer)
|
|
{
|
|
writer.WriteLine($"DELETE FROM `quest` WHERE `name` = {GetSQLString(input.Name)};");
|
|
}
|
|
|
|
public void CreateSQLINSERTStatement(Quest input, StreamWriter writer)
|
|
{
|
|
writer.WriteLine("INSERT INTO `quest` (`name`, `min_Delta`, `max_Solves`, `message`, `last_Modified`)");
|
|
|
|
var output = $"VALUES ({GetSQLString(input.Name)}, {input.MinDelta}, {input.MaxSolves}, {GetSQLString(input.Message)}, '{input.LastModified:yyyy-MM-dd HH:mm:ss}');";
|
|
|
|
output = FixNullFields(output);
|
|
|
|
writer.WriteLine(output);
|
|
}
|
|
}
|
|
}
|