动态设置数据源连接字符串SSRS报告

时间:2019-07-15 11:16:23

标签: c# reporting-services ssrs-2008 ssrs-2012

我有下面的代码,可以从excel,csv或pdf格式从Reporting Server下载。我想“添加一个参数连接字符串”,该字符串应动态用作数据源,以获取根据参数(来自多租户应用程序的当前设计)来自不同数据库的数据。我可以更改设计以实现结果。

我正在使用SQL Server 2014

public async Task<ApiResponse> DownloadReport(ReportProcessRequest model)
{
    var reportUrl = GetReportUrl(model);

    var httpClientHandler = new HttpClientHandler()
                            {
                                UseDefaultCredentials = true
                            };
    HttpClient httpClient = new HttpClient(httpClientHandler);

    byte[] response = httpClient.GetByteArrayAsync(ReportUrl).Result;

    if (model.ReportFormat == "csv")
        return new ApiResponse(HttpStatusCode.OK) { ResponseObject = Encoding.UTF8.GetString(response) };

    return new ApiResponse(HttpStatusCode.OK) { ResponseObject = response };
}

应该能够下载动态设置数据源的SSRS报告

0 个答案:

没有答案