public override string Invoke(string args, int maxResultSize)
{
//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 procedure = arguments[1] as string;
string parameters = arguments[2] as string;
//strip out [] characters at the beginning and end
if (parameters[0].ToString() == "[" && parameters[parameters.Length - 1].ToString() == "]")
{
parameters = parameters.Substring(1, parameters.Length - 2);
}
List<string> split = new List<string>();
if (parameters != null)
{
split = parameters.Split(',').ToList<string>();
}
Logger.addMessage(Logger.LogType.Info, "Received - Database: " + database + " Procedure: " + procedure + " Parameters: " + parameters.ToString());
if (SQL.dbs.SQLProviderExists(database))
{
IEnumerable<string[][]> returned = SQL.dbs.getSQLProvider(database).RunProcedure(procedure, split.ToArray(), maxResultSize);
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();
}
}