public override QvxDataTable ExtractQuery(string query, List <QvxTable> tables) { try { AppInstance.LoadMemory(); logger.Debug($"Parse query {query}"); var script = ScriptCode.Parse(query); if (script == null) { throw new Exception("The sql script is not valid."); } var parameter = ConnectorParameter.Create(MParameters); var qvxTable = GetData(script, parameter); var result = new QvxDataTable(qvxTable); result.Select(qvxTable.Fields); AppInstance.SaveMemory(); AppInstance.Dispose(); logger.Debug($"Send result table {qvxTable.TableName}"); return(result); } catch (Exception ex) { logger.Error(ex, "The query could not be executed."); LogManager.Flush(); return(new QvxDataTable(new QvxTable() { TableName = "Error" })); } }
public override string HandleJsonRequest(string method, string[] userParameters, QvxConnection connection) { try { QvDataContractResponse response; AppInstance.LoadMemory(); var parameter = ConnectorParameter.Create(connection?.MParameters); logger.Trace($"HandleJsonRequest {method}"); switch (method) { case "getVersion": response = new Info { qMessage = GitVersionInformation.InformationalVersion }; break; case "getUsername": response = new Info { qMessage = parameter.UserName }; break; case "getDatabases": response = GetDatabases(parameter); break; case "getTables": response = GetTables(parameter, userParameters[0]); break; case "getFields": response = GetFields(parameter, userParameters[0], userParameters[1]); break; case "getPreview": response = GetPreview(parameter, userParameters[0], userParameters[1]); break; default: response = new Info { qMessage = "Unknown command" }; break; } AppInstance.SaveMemory(); AppInstance.Dispose(); return(ToJson(response)); } catch (Exception ex) { logger.Error(ex); return(ToJson(new Info { qMessage = "Error " + ex.ToString() })); } }