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

Stimulsoft Reports.ANGULAR discussion
Mateus Garrido Kern
Posts: 45
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

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

Post 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 10826 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 10826 times
But the page opens blank like this:
Screenshot_3.png
Screenshot_3.png (83.46 KiB) Viewed 10826 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 10826 times
Can anyone tell me what may be happening?
Mateus Garrido Kern
Email: mateus.kern@digibyte.com.br
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

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

Post by Lech Kulikowski »

Hello,

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

Thank you.
Vadim
Posts: 362
Joined: Tue Apr 23, 2013 11:23 am

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

Post by Vadim »

Hello.

We can't reproduce problem, maybe CORS the reason ?
Mateus Garrido Kern
Posts: 45
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

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

Post 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 9540 times
Mateus Garrido Kern
Email: mateus.kern@digibyte.com.br
Vadim
Posts: 362
Joined: Tue Apr 23, 2013 11:23 am

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

Post by Vadim »

Hello.

Please in method OpenReport() instead of return StiAngularViewer.ViewerDataResult(requestParams, options); use StiAngularViewer.ProcessRequestResult(this);
Mateus Garrido Kern
Posts: 45
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

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

Post 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.
Mateus Garrido Kern
Email: mateus.kern@digibyte.com.br
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

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

Post by Lech Kulikowski »

Hello,

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

Thank you.
Mateus Garrido Kern
Posts: 45
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

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

Post 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.
Mateus Garrido Kern
Email: mateus.kern@digibyte.com.br
Lech Kulikowski
Posts: 6196
Joined: Tue Mar 20, 2018 5:34 am

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

Post by Lech Kulikowski »

Hello,

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

Thank you.
Mateus Garrido Kern
Posts: 45
Joined: Wed Sep 04, 2019 5:19 pm
Location: Curitiba/PR (Brazil)

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

Post 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.
Mateus Garrido Kern
Email: mateus.kern@digibyte.com.br
Post Reply