private IEnumerable <QvxDataRow> GetData(QvxConnection connection, QvxFieldsWrapper fields, string reportID)
        {
            IEnumerable <QvxDataRow> rows = EndpointCalls.GetReportData(connection, fields, reportID);

            if (rows.Count() == 0)
            {
                QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Notice, "No rows were returned for report ID: '" + reportID + "'.");
            }
            return(rows);
        }
        private QvxTable BuildSingleTable(QvxConnection connection, string tableID, string tableName)
        {
            QvxFieldsWrapper fields = GetFields(connection, tableID);

            if (fields.GetLength() == 0)
            {
                QvxLog.Log(QvxLogFacility.Application, QvxLogSeverity.Notice, "No fields were found for table '" + tableName + "'.");
                return(null);
            }
            QvxTable.GetRowsHandler handler = () => { return(GetData(connection, fields, tableID)); };
            return(new QvxTable()
            {
                TableName = tableName,
                Fields = fields.Fields,
                GetRows = handler
            });
        }
        private QvxFieldsWrapper GetFields(QvxConnection connection, string tableID)
        {
            IDictionary <string, SalesforceDataType> fields = EndpointCalls.GetFieldsFromReport(connection, tableID);

            if (fields == default(IDictionary <string, Type>))
            {
                return(new QvxFieldsWrapper(0));
            }

            QvxFieldsWrapper qvxFields = new QvxFieldsWrapper(fields.Count);

            for (int i = 0; i < fields.Count; i++)
            {
                if (fields.ElementAt(i).Value == SalesforceDataType.String)
                {
                    qvxFields.SetFieldValue(i, new QvxField(fields.ElementAt(i).Key, QvxFieldType.QVX_TEXT, QvxNullRepresentation.QVX_NULL_FLAG_SUPPRESS_DATA, FieldAttrType.ASCII), fields.ElementAt(i).Value);
                }
                else if (fields.ElementAt(i).Value == SalesforceDataType.Integer || fields.ElementAt(i).Value == SalesforceDataType.Boolean)
                {
                    qvxFields.SetFieldValue(i, new QvxField(fields.ElementAt(i).Key, QvxFieldType.QVX_SIGNED_INTEGER, QvxNullRepresentation.QVX_NULL_FLAG_SUPPRESS_DATA, FieldAttrType.INTEGER), fields.ElementAt(i).Value);
                }
                else if (fields.ElementAt(i).Value == SalesforceDataType.Double || fields.ElementAt(i).Value == SalesforceDataType.Currency || fields.ElementAt(i).Value == SalesforceDataType.Percent)
                {
                    qvxFields.SetFieldValue(i, new QvxField(fields.ElementAt(i).Key, QvxFieldType.QVX_IEEE_REAL, QvxNullRepresentation.QVX_NULL_FLAG_SUPPRESS_DATA, FieldAttrType.REAL), fields.ElementAt(i).Value);
                }
                else if (fields.ElementAt(i).Value == SalesforceDataType.Date)
                {
                    qvxFields.SetFieldValue(i, new QvxField(fields.ElementAt(i).Key, QvxFieldType.QVX_IEEE_REAL, QvxNullRepresentation.QVX_NULL_FLAG_SUPPRESS_DATA, FieldAttrType.DATE), fields.ElementAt(i).Value);
                }
                else if (fields.ElementAt(i).Value == SalesforceDataType.DateTime)
                {
                    qvxFields.SetFieldValue(i, new QvxField(fields.ElementAt(i).Key, QvxFieldType.QVX_IEEE_REAL, QvxNullRepresentation.QVX_NULL_FLAG_SUPPRESS_DATA, FieldAttrType.TIMESTAMP), fields.ElementAt(i).Value);
                }
                else
                {
                    qvxFields.SetFieldValue(i, new QvxField(fields.ElementAt(i).Key, QvxFieldType.QVX_TEXT, QvxNullRepresentation.QVX_NULL_FLAG_WITH_UNDEFINED_DATA, FieldAttrType.ASCII), fields.ElementAt(i).Value);
                }
            }

            return(qvxFields);
        }
        private List <QvxTable> BuildTablesSync(QvxConnection connection, IDictionary <string, string> tableDictionary)
        {
            List <QvxTable> newTables = new List <QvxTable>(tableDictionary.Select(table =>
            {
                QvxFieldsWrapper fields = GetFields(connection, table.Key);
                if (fields.GetLength() == 0)
                {
                    return(null);
                }
                QvxTable.GetRowsHandler handler = () => { return(GetData(connection, fields, table.Key)); };
                return(new QvxTable()
                {
                    TableName = table.Value,
                    Fields = fields.Fields,
                    GetRows = handler
                });
            }).Where(t => t != null && t.Fields.Length != 0)
                                                            );

            return(newTables);
        }