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

2 posts, 0 answers
  1. Vincent
    Vincent avatar
    53 posts
    Member since:
    Dec 2013

    Posted 03 Mar Link to this post

    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>

     

  2. Katia
    Admin
    Katia avatar
    714 posts

    Posted 06 Mar Link to this post

    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
Back to Top