Lech Kulikowski wrote: ↑Thu Oct 01, 2020 3:36 pm
Hello,
Please try to add the Synchronize() method:
report.Dictionary.SynchronizeBusinessObjects(nestedlevels);
Thank you.
I already tried that solution a time ago. But I get an error.
Could you explain how to fix it?
Engine version 2020.3.2 and 2020.4.2, .Net Core 3.1 on Linux
Code: Select all
Object reference not set to an instance of an object. StackTrace: at Stimulsoft.Report.Dictionary.StiBusinessObjectHelper.GetValueFromITypedList(ITypedList typedList, String name)
at Stimulsoft.Report.Dictionary.StiBusinessObjectHelper.GetElementFromObject(Object value, String name, Boolean isColumnsRetrieve)
at Stimulsoft.Report.Dictionary.StiBusinessObject.GetBusinessObjectData(Boolean isColumnsRetrieve)
at Stimulsoft.Report.Dictionary.StiDictionary.Synchronize(StiBusinessObjectsCollection businessObjects)
at Stimulsoft.Report.Dictionary.StiDictionary.SynchronizeBusinessObjects()
at Stimulsoft.Report.Dictionary.StiDictionary.Synchronize()
at Stimulsoft.Report.Dictionary.StiDictionary.<SynchronizeAsync>b__104_0()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.<>c.<.cctor>b__274_0(Object obj)
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location where exception was thrown ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location where exception was thrown ---
at Stimulsoft.Report.Dictionary.StiDictionary.SynchronizeAsync()
Full code
Code: Select all
using var report = new StiReport();
report.Load(templateBody); // body as byte[]
report.CacheAllData = false;
var jsonObject = StimulsoftJToken.Parse(json); // json
report.RegBusinessObject(category: dataObject.Category, name: dataObject.Name, alias: dataObject.Alias, value: jsonObject);
// sync data & render
await report.Dictionary.SynchronizeAsync();
await report.RenderAsync(new StiRenderState(false));
Json data
Code: Select all
[{
"Payment": {
"Name": "123",
"rub": "123",
"penny": "123",
"rubCom": "123",
"pennyCom": "123",
"rubTotal": "123",
"pennyTotal": "123",
"day": "1",
"month": "1",
"year": "2020"
},
"Payer": {
"firstName": "PayerName1",
"lastName": "PayerName2",
"middleName": "qwe",
"address": "qwe"
},
"Name": "qwe",
"inn": "123123",
"bankAccount": "123123",
"bankName": "qwe",
"bic": "123123",
"bankCorrAccount": "123123"
}]
Report file was attached