.NET CORE Web Api Json Data Active Report

Posted by: haider.ali.cspak on 2 June 2020, 7:04 pm EST

  • Posted 2 June 2020, 7:04 pm EST

    Hello, I want to test active report for creating report from external resource which will be a json file from my web api and the after making the report in the backend using my json data i want to show user report on its frontend web. i have searched the web alot since yesterday and couldnt find a satisfactory solution or guide.
    Can you please help me with my query. if this works as expected i am gonna integrate on my server to show user server side generated reports.

    Tools:
    .Net Core web api

    again i want to integrate activereport with my web api and and make report and send report to user. Thanks
  • Replied 4 June 2020, 10:20 pm EST

    Hello,

    I have created a sample for you in which json data are coming from the public API and report is previewed in JSViewer.

    Please refer the following links for JSViewer and JsonDataSource:
    https://www.grapecity.com/activereports/docs/v14/online/json-provider.html
    https://www.grapecity.com/activereports/docs/v14/online/js-viewer.html

    Hope it helps.

    Thanks,
    Mohit

    ARWeb_NetCore.zip
  • Replied 5 June 2020, 12:04 am EST

    Hey @Mohitg, thanks for your reply. i did view your example and it worked perfectly thank you for your time.
    Now the problem is i want to use parameters and there is no parametric example of reporting through code.
    i am using .net core 2.2. How can i pass report through code using parameters from code. in order words i want to pass parameters from c# to report and load report from my c# code.
    if it is not available in .net core 2.2 please make it in .net core suitable version.
    Thank you your help is highly appreciated.
  • Replied 7 June 2020, 6:35 pm EST

    Hello,

    Please refer to the following lines of code to pass the parameter through code C#. Also, it will work with 2.2 .Net Core:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
    if (env.IsDevelopment())
    {
    app.UseDeveloperExceptionPage();
    }

    app.UseReporting(settings =>
    {
    settings.UseCustomStore(GetReport);
    settings.UseCompression = true;
    });

    app.UseMvc();
    }

    private object GetReport(string arg)
    {
    GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
    rpt.Load(new System.IO.FileInfo(@"\ARWeb_NetCore\ARWeb_NetCore\reports\rdlreport1.rdlx"));
    foreach (GrapeCity.ActiveReports.PageReportModel.ReportParameter parameter in rpt.Report.ReportParameters)
    {
    if (parameter.Name == "ReportParameter1")
    {
    parameter.DefaultValue.Values.Clear();
    parameter.DefaultValue.Values.Add("Test & Test");
    }
    }
    return rpt.Report;
    }


    Hope it helps.

    Thanks,
    Mohit
  • Replied 8 June 2020, 12:49 am EST

    Hey mohitg,
    Thank you for your reply, i was implementing your solution but could not find GrapeCity.ActiveReports.PageReport in any nuget package of active report 14. i also searched the internet and this class was present in activereport7 can you please tell me which package of activereport14 contains this class.
  • Replied 8 June 2020, 12:53 am EST

    Hello,

    Please add the following NuGet package:

    "GrapeCity.ActiveReports"

    Thanks,
    Mohit
  • Replied 8 June 2020, 4:14 pm EST

    Dear Mohit,
    This package is already installed yet the class is not found. It only shows pagereportmodel.
  • Replied 8 June 2020, 4:14 pm EST



    As you can see in the image i have already installed activereports yet i am unable to access Grapecity.Activereport.Pagereport
  • Replied 8 June 2020, 3:49 pm EST

    Hello,

    Could you please confirm that package is installed in your application as shown in the attached image. Also, could you please provide the stripped-down sample so that I can replicate the issue at my end.

    Thanks,
    Mohit
  • Replied 8 June 2020, 6:15 pm EST

    Hey Mohit,
    Yes those packages are installed on my sample as shown in the below image

    and below link is the sample.

    https://we.tl/t-Ek5hu3lTyH
  • Replied 8 June 2020, 9:21 pm EST

    Hey mohit,
    after troubleshooting it. i found out that i cannot access pagereport in .net core 2.2 but i can access it in 3.1
  • Replied 9 June 2020, 6:38 pm EST

    Hello,

    I am able to replicate the issue with .Net core 2.2. I have escalated this to our development team(AR-24557) and will inform you once I get any information from them.

    Sorry for the inconvenience caused to you.

    Thanks,
    Mohit
  • Replied 9 June 2020, 8:02 pm EST

    Thanks,
    Waiting for your reply.
  • Replied 10 June 2020, 5:36 pm EST

    Hello,

    Will you try with following code:
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
    if (env.IsDevelopment())
    {
    app.UseDeveloperExceptionPage();
    }

    app.UseReporting(settings =>
    {
    settings.UseCustomStore(GetReport);
    settings.UseCompression = true;
    });

    app.UseMvc();
    }

    private object GetReport(string arg)
    {
    GrapeCity.ActiveReports.PageReportModel.Report rpt = GrapeCity.ActiveReports.Rdl.Persistence.PersistenceFilter.Load(new StreamReader("Report1.rdlx"));
    foreach (GrapeCity.ActiveReports.PageReportModel.ReportParameter parameter in rpt.ReportParameters)
    {
    if (parameter.Name == "ReportParameter1")
    {
    parameter.DefaultValue.Values.Clear();
    parameter.DefaultValue.Values.Add("Test & Test");
    }
    }
    return rpt;
    }


    Hope it helps.

    Thanks,
    Mohit

  • Replied 10 June 2020, 10:32 pm EST

    Hey mohit,
    Thanks for your reply.
    Mohit i want to know how can i iterate through json array in designer dataset query or in table or in any way in page report e.g.
    http://dummy.restapiexample.com/api/v1/employees
    here is the employees data after success property we have a data array and i want to iterate all this data and show in a table in page report i have tried different ways but didnt accepted my queries. Can you please guide me in this problem.
  • Replied 11 June 2020, 8:59 pm EST

    Hello,

    What I understood from this, you need to show the hierarchical Json data in the report. If yes, please refer to the following link:
    https://www.grapecity.com/forums/ar-dev/display-hierarchical-json

    Thanks,
    Mohit
  • Replied 11 June 2020, 9:45 pm EST

    Hey mohit,
    i have now shifted to SQL with active report and my current problem is
    e.g. i have a column name assessment and its values are "Low", "High", "Moderate"
    and i want to count the value of rows per condition
    i.e. calculate how many rows text is "Low" and how many rows Text is "High" etc
    i have tried count() function but that function does not return rows of specific condition it just returns all rows.
  • Replied 11 June 2020, 10:06 pm EST

    Hello,

    Please use the following expression:
    =AggregateIf(Fields!assessment.Value="Low", Count, Fields!assessment.Value)

    Thanks,
    Mohit
  • Replied 14 June 2020, 7:58 pm EST

    Hello,

    I think you have solved the problem as you have deleted your last question about the page break. if not, you can check the "Page break at start" property of group of the table.


    Thanks,
    Mohit
  • Replied 15 June 2020, 8:54 pm EST

    yes mohit i have solved the problem of page break, but after making the whole report when i tried to import that report in activereportjs designer it refused to pick it and on researching i got to know that activereportsjs designer only work with json data. now i am stuck again with json
  • Replied 15 June 2020, 9:41 pm EST

    As per your previous solution for json iteration, i can access array by [*] and iterate through it but thats not happening in my solution kindly check below attached files.
    In my adn temp scans table i am not getting any values from isAbntemp array you can check Loc column with iteration field.

    https://we.tl/t-1IOUGt3wLo
  • Replied 15 June 2020, 9:51 pm EST

    Hello,

    ActiveReportsJS and ActiveReports .Net both are different products. You are using the ActiveReports.Net and its both web and desktop designer support the MSSQL.

    Could you please use the ActiveReports.Net designer instead of ARJS designer,

    Thanks,
    Mohit
  • Replied 15 June 2020, 10:58 pm EST

    yes but please help me with that json iteration problem which is occuring in activereport designer i have attached the file link above
  • Replied 16 June 2020, 6:58 pm EST

    Hello,

    You can create another dataset with the following query to access the "IsAbNormal" data:
    $.[*].isAbNormal[*]


    Thanks,
    Mohit
  • Replied 16 June 2020, 9:04 pm EST

    Dear Mohit,
    I tried this query on new dataset but i still cannot access json data. Plus the project you sent on your first post ARWeb_NetCore.zip if i add my rdlx into reports folder and change viewer.open to viewer.open("Myfile") is says Myfile not found even if it is in the same folder as previous default report.
  • Replied 17 June 2020, 4:39 am EST

    Mohit, i was able to run my report in .net core 3.1 project but if i try to run it on .netcore 2.2 it says no license error and fail to render. Do you have any idea about that?
  • Replied 17 June 2020, 5:57 pm EST

    Hello,

    Could you please add the "Licenses.licx" file in your project with the following entry:
    GrapeCity.ActiveReports.SectionReport, GrapeCity.ActiveReports
    GrapeCity.ActiveReports.PageReport, GrapeCity.ActiveReports
    GrapeCity.ActiveReports.Export.Pdf.Section.PdfExport, GrapeCity.ActiveReports.Export.Pdf

    Also, please refer to the attached sample and see if the problem also exists with the attached sample.

    Thanks,
    Mohit

  • Replied 2 July 2020, 12:00 am EST

    Hey mohit, long time no see. I am having trouble with charts, i want to add charts in my report the tutorial on your site doesnt explain properly how to populate data in charts do you have a good link of video or any sample code which uses json or dataset fields to populate data in charts? i want to use column chart and bar chart Thanks waiting for your relpy.
  • Replied 2 July 2020, 9:05 pm EST

    Hello,

    Please refer to the attached report and image to know more about the chart.

    Also, please open a new case for every new query to avoid confusion in the following AR Forum:
    https://www.grapecity.com/forums/ar-dev

    Thanks,
    Mohit

    rpt_Chart.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels