I'm trying to develop a simple custom connector to Qlik, where I Get the data from a source specific, load the data in the Qlik and extract the data according own query. However, I found some problems and question, that I describe bellow:
I pass the field, tableName and data for the connection like in the bellow codes, but when I click on "Load Data", the error "Object reference not defined as an instance of an object" is shown, how if the tables in the "QvAditiConnection.Init()" had not been defined. Bellow, the codes:
public QvAditiConectorConnection(QvxConnection connection) { try { _logApp = new LogApp(); _util = new ClsUtil(); _nomeTabela = " "; _tipoConexao = " "; _connectionString = " "; _parameters = " "; if (connection != null && connection.MParameters != null && connection.MParameters.Count > 0) { this.MParameters = connection.MParameters; } GetParametersFromConnection(); if (string.IsNullOrWhiteSpace(_parameters) == false) { _connectionStringParameters = _util.RecuperaParametrosConnectionString(_parameters); _tipoConexao = _connectionStringParameters[0]; string connectionString = GetConnectionString(); if (TestarConexao(connectionString)) { _connectionString = connectionString; StartConnection(); } else { _logApp.CriarLog("ERRO na conexão com o banco de dados."); } } else { QvxLog.Log(QvxLogFacility.Audit, QvxLogSeverity.Error, "Init() Erro de conexão. Verifique os dados ou o servidor."); } Init(); } catch (Exception ex) { _logApp = new LogApp(); if (string.IsNullOrWhiteSpace(ex.Message) == false) { QvxLog.Log(QvxLogFacility.Audit, QvxLogSeverity.Error, "Init() Erro: " + ex.Message); _logApp.CriarLog("ERRO Constructor: " + ex.Message); } else { QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Notice, "Init() Erro Desconhecido"); _logApp.CriarLog("ERRO não identificado"); } } } public override void Init() { try { if (string.IsNullOrWhiteSpace(_parameters) == false) { QvxLog.SetLogLevels(true, true); QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Notice, "Init()"); List<QvxTable> tabelas = new List<QvxTable>(); DataTable schemaTables = _connectionPostGreSqlStaging.GetSchema("Tables"); foreach (DataRow row in schemaTables.Rows) { _nomeTabela = (string)row[2]; _dataTableStagingArea = new DataTable(_nomeTabela); GetDataReader(); QvxTable dadosTable = new QvxTable(); dadosTable.TableName = _nomeTabela; dadosTable.Fields = _qvxFields; dadosTable.GetRows = GetDataRowsConnector; tabelas.Add(dadosTable); } this.MTables = tabelas; } }
How can you see below, the connection is correct in this case, because the application gets and shows the tables and fields in the correct form:
But, after I click in "Insert Script" and "Load Data", The error below is shown, how if the tables in the application has not been defined:
Error on click in load data button
The "ExtractQuery" is exact how bellow, and when I debug the code and use the "Add Watch" in parameter "qvxTables", I see that he's null and not contains Tables:
public IEnumerable<QvxDataRow> GetDataRowsConnector()
{
DataTable dadosTabela = _dataTableStagingArea;
foreach (var item in dadosTabela.Rows)
{
yield return MakeEntry(item as DataRow, FindTable(_nomeTabela, MTables));
}
}
public QvxDataRow MakeEntry(DataRow item, QvxTable table)
{
try
{
var row = new QvxDataRow();
for (int i = 0; i < _dataTableStagingArea.Columns.Count; i++)
{
var field = table.Fields.Where(a => a.FieldName == _dataTableStagingArea.Columns[i].ColumnName)
.Select(b => b).FirstOrDefault();
row[field] = item[field.FieldName].ToString();
}
return row;
}
catch (Exception ex)
{
throw new Exception(ex + "MakeEntry()");
}
}
In this case, when the Method "ExtractQuery" is called, the tables some times came, but the data don't came in the communication, similar to error 1. And in this case 2, when I debug step by step and arrive in the line " dadosTable.GetRows = GetDataRowsConnector;" the debug don't enter in the"GetDataRowsConnector" or in the "MakeEntry", even when I insert breakpoints in the methods or press "F11" to use "Step Into".
- How I show the preview data in select dialog(I use the QvxSdk in this case)? Even using the getPreview, I don't get the data and don't see example in the documentation. If do you have suggestions or examples for me, I appreciate if you share. And How I edit and select the fields to show in this window(How show or not Metadada, Selection Summary etc)? And how I insert a logo in the connector, like the connectors like "Oracle", "PostGreSql" etc?
select dialog with highlighted data area preview
- When I click in the "Insert Script", I want to send a blank script to the editor, ao invés de send the script "Load [FIELD] SQL SELECT * FROM ...", and ao mesmo tempo get this script that the Qlik genereta automactilly in my backend, It's possible do this?
Remember that I use the QvxSdk for this solution, based on the "Simple Example" provided for Qlik, but I'm open for suggestion for others APIs if is the case for answer my questions. I use too the .Net Framework 4.5 to develop the connector
Thank you in advance for your attention and help.
Thanks!