QBO报告服务C#输出
我正在尝试了解如何阅读Quickbooks在线报告服务的结果。具体来说,我试图在标签上显示reportBS的结果,下面是我的代码:QBO报告服务C#输出,c#,api,quickbooks-online,C#,Api,Quickbooks Online,我正在尝试了解如何阅读Quickbooks在线报告服务的结果。具体来说,我试图在标签上显示reportBS的结果,下面是我的代码: OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(dictionary["accessToken"]); ServiceContext serviceContext = new ServiceContext(dictionary["realmId&quo
OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(dictionary["accessToken"]);
ServiceContext serviceContext = new ServiceContext(dictionary["realmId"], IntuitServicesType.QBO, oauthValidator);
serviceContext.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
serviceContext.IppConfiguration.MinorVersion.Qbo = "55";
ReportService reportService = new ReportService(serviceContext);
reportService.accounting_method = "Accrual";
reportService.start_date = "2020-01-01";
reportService.end_date = "2020-10-31";
reportService.summarize_column_by = "Month";
serviceContext.IppConfiguration.Message.Response.SerializationFormat = Intuit.Ipp.Core.Configuration.SerializationFormat.Json;
ReportService defaultReportService1 = new ReportService(serviceContext);
string defaultReportName = "BalanceSheet";
Report reportBS = defaultReportService1.ExecuteReport(defaultReportName);
当我运行代码并将ReportB放在标签上时得到的结果是Intuit.Ipp.Data.Report,没有其他内容。您需要将QBO报告保存为JSON或XML字符串吗?据我所知,将QBO报表对象转换为JSON或XML需要手动完成。 这是一个显示如何使用损益表的问题。(这实际上非常类似于我在第一个地方概述的文本提取方法,在您的例子中,只将结果重新组装为XML/JSON) 如果您只想将报告传递到另一个系统或存储,则报告可以满足要求
以下是基本报告示例:
private static void PrintRows(StringBuilder reportText, Row[] rows, int[] maxColumnSize, int level)
{
for (int rowIndex = 0; rowIndex < rows.Length; rowIndex++)
{
Row row = rows[rowIndex];
//Get Row Header
Header rowHeader = GetRowProperty(row, ItemsChoiceType1.Header);
//Append Row Header
if (rowHeader != null && rowHeader.ColData != null) { PrintColData(reportText, rowHeader.ColData, maxColumnSize, level); }
//Get Row ColData
ColData[] colData = GetRowProperty(row, ItemsChoiceType1.ColData);
//Append ColData
if (colData != null) { PrintColData(reportText, colData, maxColumnSize, level); }
//Get Child Rows
Rows childRows = GetRowProperty(row, ItemsChoiceType1.Rows);
//Append Child Rows
if (childRows != null) { PrintRows(reportText, childRows.Row, maxColumnSize, level + 1); }
//Get Row Summary
Summary rowSummary = GetRowProperty(row, ItemsChoiceType1.Summary);
//Append Row Summary
if (rowSummary != null && rowSummary.ColData != null) { PrintColData(reportText, rowSummary.ColData, maxColumnSize, level); }
}
}
StringBuilder reportText = new StringBuilder();
//Determine Maxmimum Text Lengths to format Report
//int[] maximumColumnTextSize = GetMaximumColumnTextSize(report);
//Append Column Headers
//PrintColumnData(reportText, report.Columns, maximumColumnTextSize, 0);
PrintRows(reportText, report.Rows, maximumColumnTextSize, 1);
private static void PrintRows(StringBuilder reportText,Row[]rows,int[]maxColumnSize,int-level)
{
对于(int-rowIndex=0;rowIndex