Example #1
0
        private QvDataContractResponse GetFields(UserParameter parameter, string appId, string objectId)
        {
            q2gconhypercubemain.Connection connection = null;

            using (MappedDiagnosticsLogicalContext.SetScoped("connectionId", connection?.ConnId))
            {
                try
                {
                    var oId = GetObjectId(objectId);
                    if (String.IsNullOrEmpty(oId))
                    {
                        throw new Exception("no object id for field table found.");
                    }
                    var script  = ScriptCode.Create(appId, oId);
                    var config  = QlikApp.CreateConfig(parameter, appId);
                    var qlikApp = new QlikApp(parameter);
                    connection = qlikApp.CreateNewConnection(config);
                    var resultTable = tableFunctions.GetTableInfosFromApp("FieldTable", script, connection.CurrentApp);
                    if (resultTable == null)
                    {
                        throw new Exception("no field table found.");
                    }
                    var qvxTable = TableUtilities.ConvertTable(resultTable.QvxTable);
                    return(new QvDataContractFieldListResponse {
                        qFields = qvxTable.Fields
                    });
                }
                catch (Exception ex)
                {
                    logger.Error(ex, $"fields from app {appId} and table {objectId} not loaded.");
                    return(new QvDataContractFieldListResponse {
                        qFields = new QvxField[0]
                    });
                }
                finally
                {
                    connection?.Close();
                }
            }
        }