在自定义ReportResolver中获取ReportSource参数

时间:2015-10-16 09:52:24

标签: asp.net-mvc telerik-reporting

我目前尝试在index.cshtml上使用asp .net mvc报告创建简单的telerik报告

@(Html.TelerikReporting().ReportViewer()
        .Id("reportViewer1")
        .ServiceUrl(Url.Content("~/api/reports/"))
        .TemplateUrl(Url.Content("~/ReportViewer/templates/telerikReportViewerTemplate-9.2.15.930.html"))
        .ReportSource(typeof(MyReport).AssemblyQualifiedName, new Dictionary<string, object>() { {"Id", 123} })
        .ViewMode(ViewMode.Interactive)
        .ScaleMode(ScaleMode.Specific)
        .Scale(1.0)
        .Deferred())

我还处理了自己的ReportResolver

class ReportResolverWithFallBack : IReportResolver
{
    readonly IReportResolver parentResolver;

    public ReportResolverWithFallBack(IReportResolver parentResolver)
    {
        this.parentResolver = parentResolver;
    }

    public ReportSource Resolve(string report)
    {
        ReportSource reportDocument = null;
        reportDocument = this.CustomReportResolver(report);

        if (null == reportDocument && null != this.parentResolver)
        {
            reportDocument = this.parentResolver.Resolve(report);
        }

        return reportDocument;
    }

    public ReportSource CustomReportResolver(string report)
    {
        var type = Type.GetType(report);
        ConstructorInfo ctor = type.GetConstructor(Type.EmptyTypes);
        var reportInstance = (Report)ctor.Invoke(new object[] { });

        InstanceReportSource instanceReportSource = new InstanceReportSource
        {
            ReportDocument = reportInstance
        };

        return instanceReportSource;
    }
}

如何在Resolve方法中获取ReportSource中的指定参数,或者可能还有其他方法,所以我可以在NeedDataSource类中的MyReport事件中获取它们?

0 个答案:

没有答案