Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

CustomReportResolver, where are the parameters?

$
0
0

I've created a customreportresolver in my project (mvc) so that I can make changes to the connection string (and other stuff) on the fly. I'm passing a dictionary<string,object> from my mvc view with the settings for all the report's parameters.

How does that dictionary get to my customreportresolver? I'm not seeing the parameters in my report being updated from the dictionary. 

@{
    var parameters = new Dictionary<string, object>();
    parameters.Add("s1", Model.ReportGeneratorOutput.s1);
    parameters.Add("s2", Model.ReportGeneratorOutput.s2);
    parameters.Add("g1", Model.ReportGeneratorOutput.g1);
    parameters.Add("sourceflag", Model.ReportGeneratorOutput.SourceFlag);
    parameters.Add("sid", Model.ReportGeneratorOutput.Sid);
    parameters.Add("hdr1", Model.ReportGeneratorOutput.hdr1);
    parameters.Add("hdr2", Model.ReportGeneratorOutput.hdr2);
    parameters.Add("session", Model.Session);
}
<divid="reportOutput">
    @(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer")
        .ServiceUrl("/api/reports")
        .ReportSource("Report.trdx", parameters)
        .ViewMode(ViewMode.Interactive)
        .PersistSession(false)
        .ScaleMode(ScaleMode.FitPage)
    )
</div>

publicclassCustomReportResolver : Telerik.Reporting.Services.Engine.IReportResolver
    {
        publicReportSource Resolve(stringsource)
        {
            var settings = newXmlReaderSettings();
            settings.IgnoreWhitespace = true;
 
            using(var xmlreader = XmlReader.Create(Path.Combine(HttpContext.Current.Server.MapPath("~/Reports"), source), settings))
            {
                var serializer = newTelerik.Reporting.XmlSerialization.ReportXmlSerializer();
                var report = (Report)serializer.Deserialize(xmlreader);
 
                //need to set the correct connection string here
                //the parameter: session has the year
 
                //var efconnection = ConfigurationManager.ConnectionStrings[$"Connection{report.ReportParameters["session"].Value}"].ConnectionString;
                //var connection = new EntityConnectionStringBuilder(efconnection).ProviderConnectionString;
 
                //SetConnectionString(report, connection);
                 
                var instancereport = newInstanceReportSource { ReportDocument = report };
                returninstancereport;
            }
        }
}

Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>