我正在尝试通过使用循环用 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);
}