public override string InvokeAsync(string args, int maxResultSize, CancellationToken token)
{
//if we haven't setup the database connection and such yet, this will do it
Startup.StartupConnection();
IList<object> arguments;
if (Format.TrySqfAsCollection(args, out arguments) && arguments.Count == 2 && arguments[0] != null && arguments[1] != null)
{
string database = arguments[0] as string;
string mysql_command = arguments[1] as string;
Logger.addMessage(Logger.LogType.Info, "Received - Database: " + database + " SQL Query: " + mysql_command.ToString());
if (SQL.dbs.SQLProviderExists(database))
{
IEnumerable<string[][]> returned = SQL.dbs.getSQLProvider(database).RunCommand(mysql_command, maxResultSize);
//the following is needed because we need to return something even if there is nothing to return
//for example, an SQL DELETE call will go off and return ""
//however, because on the SQF side, we check for this in a while loop so we know the database process has completed, we can
//just return an empty array
if (returned.ToString() == "")
return Format.ObjectAsSqf("[]");
return Format.ObjectAsSqf(returned);
}
else
{
Logger.addMessage(Logger.LogType.Warning, "The database: " + database + " is not loaded in through the Databases.txt file.");
}
//Logger.addMessage(Logger.LogType.Info, "Returning false object");
return Format.ObjectAsSqf(false);
}
else
{
Logger.addMessage(Logger.LogType.Error, "The number and/or format of the arguments passed in doesn't match.");
throw new ArgumentException();
}
}