0

我正在尝试通过使用循环用 C# 编写的 SSIS 包运行许多 SSRS 报告。问题是下面的代码仅根据传递的初始参数生成 1 个文件。我认为问题是 ConnectionManager 和 HttpClientConnection 被重用。还有其他方法吗?

        for (int i = 0; i <= cust.GetUpperBound(0); i++)
        {
            string varDate = System.DateTime.Now.ToString("dd/MM/yyyy");
            string d1ThisMOnth = System.DateTime.Today.AddDays(-(DateTime.Today.Day - 1)).ToString();
            var today = DateTime.Today;
            var month = new DateTime(today.Year, today.Month, 1);
            var first = month.AddMonths(-1);
            var last = month.AddDays(-1);
            string reportfilename = @"D:\Reports\AllActiveAccounts_" + month.ToString("MMyyyy") + "_" + cust[0, 0] + "." + cust[0, 4];
            string url = @"http://" + cust[i, 5] + "/ReportServer?/" + cust[i, 0] + "/Report&rs:Command=Render&location=" + cust[i, 1] + "&clityp=" + cust[i, 2] + "&acctyp=" + cust[i, 3] + "&startdate=" + first.ToString("MM/dd/yyyy") + "&enddate=" + last.ToString("MM/dd/yyyy") + "&rs:Format=" + cust[i, 4] + "&rc:Toolbar=False";
            ConnectionManager httpConn = Dts.Connections["ReportServer"];
            HttpClientConnection clientConn = new HttpClientConnection(httpConn.AcquireConnection(null));
            clientConn.ServerURL = url;
            clientConn.DownloadFile(reportfilename, true);
        }
4

1 回答 1

2

这有点猜测,但如果我这样做的话。我会说这是因为您没有在 reportfilename 参数中使用循环计数器。尝试将文件名行更改为以下内容。

string reportfilename = @"D:\Reports\AllActiveAccounts_" + month.ToString("MMyyyy") + "_" + cust[i, 0] + "." + cust[i, 4];
于 2013-08-13T16:42:32.273 回答