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);}<div id="reportOutput"> @(Html.TelerikReporting().ReportViewer() .Id("reportViewer") .ServiceUrl("/api/reports") .ReportSource("Report.trdx", parameters) .ViewMode(ViewMode.Interactive) .PersistSession(false) .ScaleMode(ScaleMode.FitPage) )</div>
public class CustomReportResolver : Telerik.Reporting.Services.Engine.IReportResolver { public ReportSource Resolve(string source) { var settings = new XmlReaderSettings(); settings.IgnoreWhitespace = true; using (var xmlreader = XmlReader.Create(Path.Combine(HttpContext.Current.Server.MapPath("~/Reports"), source), settings)) { var serializer = new Telerik.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 = new InstanceReportSource { ReportDocument = report }; return instancereport; } }}