This is a migrated thread and some comments may be shown as answers.

2020 R1 can not get connection string from appsetting.json in my .net core application.

1 Answer 235 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Vincent
Top achievements
Rank 1
Iron
Vincent asked on 03 Mar 2020, 01:00 PM

I used to Telerik reporing for data show. It is work order. but after update 2020 R1. I can not replace the connection string. please help.

my controller:

[Route("api/reports")]
    public class ReportsController : ReportsControllerBase
    {
        string reportsPath = string.Empty;

        public ReportsController(IHostingEnvironment environment)
        {
            this.reportsPath = Path.Combine(environment.WebRootPath, "UserUpload\\Reports");
            this.ReportServiceConfiguration = new ReportServiceConfiguration
            {
                HostAppId = "Html5DemoApp",
                Storage = new FileStorage(),
                ReportResolver = new ReportTypeResolver()
                                    .AddFallbackResolver(new ReportFileResolver(this.reportsPath)),
            };
        }


        [HttpGet("reportlist")]
        public IEnumerable<string> GetReports()
        {
            return Directory
                .GetFiles(this.reportsPath)
                .Select(path =>
                    Path.GetFileName(path));
        }
    }

 

viewer code:

<script>
    function ReportRendering(e,args) {
        var info = args.deviceInfo;
        //info.set("FontEmbedding", "Full");
    }
   
    function OnLoad()
    {
        var win = window.parent.GetWindow("WdIframe");
        var report = win.reportName;
        var parameters = win.reportParam;
        var printMode = /(chrome)/.test(navigator.userAgent.toLowerCase())
            ? telerikReportViewer.PrintModes.FORCE_PDF_PLUGIN
            : telerikReportViewer.PrintModes.FORCE_PDF_FILE;


        $("#reportViewer")
            .telerik_ReportViewer({
                serviceUrl: "../api/reports/",
                reportSource: {
                    report: report,
                    parameters: parameters,
                },
                viewMode: telerikReportViewer.ViewModes.PRINT_PREVIEW,
                scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
                scale: 1.0,
                enableAccessibility: false,
                sendEmail: { enabled: false }
            });


        //$("#reportViewer").telerik_ReportViewer({
        //    serviceUrl: "../Api/reports/",
        //        reportSource: {
        //            //report: "Telerik.Reporting.Examples.CSharp.ReportCatalog, CSharp.ReportLibrary",
        //            report: report,
        //            parameters: parameters,
        //    },
        //    renderingBegin:ReportRendering,
        //    viewMode: telerikReportViewer.ViewModes.PRINT_PREVIEW,
        //    scaleMode: telerikReportViewer.ScaleModes.SPECIFIC,
        //    scale: 1.0
        //});
        if (win.mode == "Print") {
            var reportViewer = $("#reportViewer").data("telerik_ReportViewer");
            reportViewer.bind(telerikReportViewer.Events.PAGE_READY, function (e) {
                reportViewer.commands.print.exec();
            });
        }
    }
    $(document).ready(OnLoad());
</script>

 

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 06 Mar 2020, 07:18 AM

Hi Vincent,

I have reviewed the provided code snippets and it is not clear how exactly the connection string is changed for reports. You can review the approaches for changing the connection string provided in the following kb articles:

Change Connection String dynamically through a report parameter

Changing the connection string dynamically according to runtime data

In case you have additional questions let us know.

 

Regards,
Katia
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Vincent
Top achievements
Rank 1
Iron
Answers by
Katia
Telerik team
Share this question
or