Page 1 of 2

Errors in the async merged report

Posted: Fri Jul 10, 2020 6:01 pm
by Mateus Garrido Kern
Hi,

I'm trying some problems when I merged three reports.

Attachment Screenshot_1:
The times when the report finishes loading it displays the error "cannot read property 'pageNumbers' of null"

Attachment Screenshot_2 and Screenshot_3:
When I go to the third or fourth page of the report, the following errors appear: "Cannot read property 'name' of undefined" and Cannot read property 'sortingEnabled' of undefined

I think it has something to do with the merged report loading the pages of the other reports asynchronously.

Thank you for attention

Re: Errors in the async merged report

Posted: Tue Jul 14, 2020 11:10 am
by Lech Kulikowski
Hello,

Please send us a sample project that reproduces the issue for analysis.

Thank you.

Re: Errors in the async merged report

Posted: Wed Jul 15, 2020 1:09 pm
by Mateus Garrido Kern
Hi Lech,

I sent an email to support@stimulsoft with the project with errors and it's generated the number request 3165067.

Thank you

Re: Errors in the async merged report

Posted: Wed Jul 15, 2020 2:39 pm
by Lech Kulikowski
Hello,

Thank you. We will let you know about the result.

Re: Errors in the async merged report

Posted: Mon Jul 20, 2020 1:10 pm
by Mateus Garrido Kern
Hello, any solution to this problem?

Re: Errors in the async merged report

Posted: Thu Jul 23, 2020 7:41 am
by Lech Kulikowski
Hello,

We are working on the problem, we will let you know about the result.

Thank you.

Re: Errors in the async merged report

Posted: Fri Aug 21, 2020 7:50 pm
by Mateus Garrido Kern
Hello,

I received a response from Aleksey Andreyanov by email, written:

"When you render the reports you are using async methods but don't wait for the end of the rendering.
There are no rendered pages when you pass the report to the Viewer.
You should get the report inside the response function. "

What is the Report's response function?

Re: Errors in the async merged report

Posted: Mon Aug 24, 2020 12:38 pm
by Mateus Garrido Kern
Hello,

The answer I received is attached: "Screenshot_1.png".

It is about 3165067 request, and was answered on the August 04, 2020.

What is the Report's response function?

Thank you.

Re: Errors in the async merged report

Posted: Wed Aug 26, 2020 2:23 pm
by HighAley
Hello,

You call the renderAsync() function and try to do something with the report right after calling it.
You should do it like in this sample :

Code: Select all

report.renderAsync(function () {
     var settings = new Stimulsoft.Report.Export.StiPdfExportSettings();
     var service = new Stimulsoft.Report.Export.StiPdfExportService();
     var stream = new Stimulsoft.System.IO.MemoryStream();
     for (var index = 1; index <= report.renderedPages.count; ++index) {
          settings.pageRange = new Stimulsoft.Report.StiPagesRange(Stimulsoft.Report.StiRangeType.Pages, index.toString());
          service.exportTo(report, stream, settings);
          var data = stream.toArray();
          var fileName = index;
          Object.saveAs(data, fileName + ".pdf", "application/pdf");
     }
});
Thank you.

Re: Errors in the async merged report

Posted: Wed Aug 26, 2020 2:59 pm
by Mateus Garrido Kern
Hello,

I already use the renderAsync method, but I also use the merge between reports, where I intend to merge it only when the user wishes, follow the code:

Code: Select all

import { Component, OnInit  } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { environment } from '../../../../../environments/environment';

declare var Stimulsoft: any;

@Component({
	selector: 'app-report-cash-desk-book',
	template: `<div id="viewerContent"></div>`
})

export class ReportCashDeskBookComponent implements OnInit {
	options: any = new Stimulsoft.Viewer.StiViewerOptions();
	viewer: any = new Stimulsoft.Viewer.StiViewer(this.options, 'StiViewer', false);
	baseUrl: string;
	companyId: string;
	dateStart: string;
	dateFinish: string;
	separateByMonth: string;
	cashDeskAccount: string;
	bookNumber: string;
	dateEmission: string;
	dateCloseFiscalYear: string;
	showOpenCloseTerms: boolean;

	constructor(private activatedRoute: ActivatedRoute) { }

	ngOnInit() {
		this.baseUrl = environment.apiUrl;
		this.activatedRoute.queryParams.subscribe(params => {
			this.companyId = params['companyId'];
			this.dateStart = params['dateStart'];
			this.dateFinish = params['dateFinish'];
			this.separateByMonth = params['separateByMonth'];
			this.cashDeskAccount = params['cashDeskAccount'];
			this.bookNumber = params['bookNumber'];
			this.dateEmission = params['dateEmission'];
			this.dateCloseFiscalYear = params['dateCloseFiscalYear'];
			this.showOpenCloseTerms = params['showOpenCloseTerms'] === 'true' ? true : false;
		});

		let reportOpen;
		let reportCashDeskBook;
		let reportClose;
		let dbOpen;
		let dbCashDeskBook;
		let dbClose;

		reportCashDeskBook = Stimulsoft.Report.StiReport.createNewReport();
		reportCashDeskBook.loadFile('../../../../../assets/reports/reportCashDeskBook.mrt');
		reportCashDeskBook.isAsync = true;

		dbCashDeskBook = reportCashDeskBook.dictionary.databases.getByName('CashDeskBook');

		dbCashDeskBook.pathData = environment.apiUrl + '/v1/reports/cash-desk-book?' +
		'companyId=' + this.companyId + '&dateStart=' + this.dateStart + '&dateFinish=' +
		this.dateFinish + '&separateByMonth=' + this.separateByMonth;

		if (this.cashDeskAccount !== null && this.cashDeskAccount !== undefined) {
			dbCashDeskBook.pathData += '&cashDeskAccount=' + this.cashDeskAccount;
		}

		const reportMerge = new Stimulsoft.Report.StiReport();
		reportMerge.reportUnit = reportCashDeskBook.reportUnit;
		reportMerge.renderAsync();
		reportMerge.renderedPages.clear();

		if (this.showOpenCloseTerms) {
			reportOpen = Stimulsoft.Report.StiReport.createNewReport();
			reportOpen.loadFile('../../../../../assets/reports/ReportOpenCloseTerm.mrt');

			dbOpen = reportOpen.dictionary.databases.getByName('JSON');

			dbOpen.pathData = this.baseUrl + 'v1/reports/open-cash-desk-book-term?companyId=' +
			this.companyId + '&dateStart=' + this.dateStart + '&dateFinish=' + this.dateFinish + 
			'&separateByMonth=' + this.separateByMonth + '&bookNumber=' + this.bookNumber + '&dateEmission=' + 
			this.dateEmission + '&dateCloseFiscalYear=' + this.dateCloseFiscalYear;

			reportClose = Stimulsoft.Report.StiReport.createNewReport();
			reportClose.loadFile('../../../../../assets/reports/ReportOpenCloseTerm.mrt');

			dbClose = reportClose.dictionary.databases.getByName('JSON');

			dbClose.pathData = this.baseUrl + 'v1/reports/close-cash-desk-book-term?companyId=' +
			this.companyId + '&dateStart=' + this.dateStart + '&dateFinish=' + this.dateFinish + 
			'&separateByMonth=' + this.separateByMonth + '&bookNumber=' + this.bookNumber + '&dateEmission=' + 
			this.dateEmission + '&dateCloseFiscalYear=' + this.dateCloseFiscalYear;

			reportOpen.onBeginProcessData = function (event) {
				event.headers.push({key: 'Authorization', value: 'Bearer ' + localStorage.getItem('token')});
			};

			reportOpen.renderAsync(function () {
				for (let index = 0; index < reportOpen.renderedPages.count; ++index) {
					reportMerge.renderedPages.add(reportOpen.renderedPages.getByIndex(index));
				}
			});
		}

		reportCashDeskBook.onBeginProcessData = function (event) {
			event.headers.push({key: 'Authorization', value: 'Bearer ' + localStorage.getItem('token')});
		};

		reportCashDeskBook.renderAsync(function () {
			for (let index = 0; index < reportCashDeskBook.renderedPages.count; ++index) {
				reportMerge.renderedPages.add(reportCashDeskBook.renderedPages.getByIndex(index));
			}
		});

		if (this.showOpenCloseTerms) {
			reportClose.onBeginProcessData = function (event) {
				event.headers.push({key: 'Authorization', value: 'Bearer ' + localStorage.getItem('token')});
			};

			reportClose.renderAsync(function () {
				for (let index = 0; index < reportClose.renderedPages.count; ++index) {
					reportMerge.renderedPages.add(reportClose.renderedPages.getByIndex(index));
				}
			});
		}

		reportMerge.renderedPages.list.forEach(function(page, i, arr) {
			const pagination = page.components.getByName('Pagination');
			if (pagination) {
				pagination.text = 'Page ' + (i + 1) + ' of ' + reportMerge.renderedPages.count;
			}

			const centralText = page.components.getByName('CentralText');
			if (centralText) {
				centralText.text = centralText.text.replace(/{TotalPages}/gi, '' + reportMerge.renderedPages.count);
			}
		});

		this.options.appearance.fullScreenMode = true;
		this.options.toolbar.displayMode = Stimulsoft.Viewer.StiToolbarDisplayMode.Separated;

		this.viewer.report = reportMerge;
		this.viewer.renderHtml("viewerContent");
	}

}
And keep showing me the same mistake! Any solution for this case?