Page 1 of 2

API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Fri May 28, 2021 7:20 pm
by Mateus Garrido Kern
Hi, I downloaded the example project that the publish page offers me using the following options:
Screenshot_1.png
Screenshot_1.png (26.55 KiB) Viewed 11104 times
And it worked really well.

But I have a .NET Core API and a SPA application in Angular that work separately, where the back end team works in the visual studio with the API and the front end team works in the visual code with the SPA.

So, we put this code below in our controller:

Code: Select all

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Stimulsoft.Report;
using Stimulsoft.Report.Angular;
using Stimulsoft.Report.Web;
using System;

namespace Digibyte.API.Controllers.Relatorio
{
    [Route("v1/reports")]
    [ApiController]
    [Authorize]
    public class RelatorioStimulsoftController : Controller
    {
        public RelatorioStimulsoftController()
        {
            Stimulsoft.Base.StiLicense.Key =
                "stimulsoft key";
        }

        [HttpPost("open-report")]
        public IActionResult OpenReport()
        {
            var requestParams = StiAngularViewer.GetRequestParams(this);
            var options = new StiAngularViewerOptions();
            options.Actions.GetReport = "GetReport";
            options.Actions.ViewerEvent = "ViewerEvent";
            options.Appearance.ScrollbarsMode = true;
            options.Appearance.FullScreenMode = true;
            options.Toolbar.DisplayMode = StiToolbarDisplayMode.Separated;
            options.Localization = StiAngularHelper.MapPath(this, "Localization/pt-BR.xml");

            return StiAngularViewer.ViewerDataResult(requestParams, options);
        }

        [HttpPost("GetReport")]
        public IActionResult GetReport()
        {
            var report = StiReport.CreateNewReport();
            var path = StiAngularHelper.MapPath(this, "Reports/Report.mrt");
            report.Load(path);

            report.Dictionary.Databases.Clear();
            var obj = GetBusinessObject();
            report.RegBusinessObject("data", obj);

            return StiAngularViewer.GetReportResult(this, report);
        }

        [HttpPost("ViewerEvent")]
        public IActionResult ViewerEvent()
        {
            return StiAngularViewer.ViewerEventResult(this);
        }
    }
}

And, we put this code below in our SPA:
Screenshot_2.png
Screenshot_2.png (17.88 KiB) Viewed 11104 times
But the page opens blank like this:
Screenshot_3.png
Screenshot_3.png (83.46 KiB) Viewed 11104 times
After the request to the GetReport () method, nothing else comes, and I needed to make a request in the ViewerEvent () method, but it is done after about 1 minute and a half to 2 minutes, and even then, the screen remains blank:
Screenshot_4.png
Screenshot_4.png (49.21 KiB) Viewed 11104 times
Can anyone tell me what may be happening?

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Thu Jun 03, 2021 9:35 pm
by Lech Kulikowski
Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Fri Jun 04, 2021 12:16 pm
by Vadim
Hello.

We can't reproduce problem, maybe CORS the reason ?

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Mon Jun 07, 2021 2:40 pm
by Mateus Garrido Kern
I believe it's not CORS, there's just a delay to access the ViewerEvent() end-point.

Look how long it takes to make the request in the ViewerEvent() end-point:
Screenshot_5.png
Screenshot_5.png (77.79 KiB) Viewed 9818 times

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Tue Jun 08, 2021 7:45 am
by Vadim
Hello.

Please in method OpenReport() instead of return StiAngularViewer.ViewerDataResult(requestParams, options); use StiAngularViewer.ProcessRequestResult(this);

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Thu Jun 17, 2021 7:22 pm
by Mateus Garrido Kern
Hello,

I found out that the problem is in our SPA project, we use a readymade Metronic theme, but I can't figure out where the problem is that is affecting the API calls.

Could you give me a contact to send the sample projects?

Thanks.

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Fri Jun 18, 2021 9:52 am
by Lech Kulikowski
Hello,

Please send us a sample project that reproduces the issue for analysis on support@stimulsoft.com

Thank you.

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Fri Jun 18, 2021 6:06 pm
by Mateus Garrido Kern
Hi Lech Kulikowski,

I sent an email with the subject to "API with .NET Core and SPA with Angular, report viewer dosen't work, by Mateus Garrido Kern" to support@stimulsoft.com and generated the request 3169830.

Thank you.

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Sat Jun 19, 2021 7:56 am
by Lech Kulikowski
Hello,

Ok. We will check it and will reply to you by email.

Thank you.

Re: API with .NET Core and SPA with Angular, report viewer dosen't work

Posted: Thu Aug 05, 2021 6:26 pm
by Mateus Garrido Kern
Unfortunately my problem has not been resolved, I cannot share the Metronic project as it is data that cannot be shared.

I took as much of the project as I could to share with you how stimulsoft was behaving, but unfortunately the error didn't occur when you tested it.

I will have to continue using Stimulsoft JS leaving the angular project build very heavy.

Thanks for your attention and have a great day.