我只想将两份SSRS报告合并到单个报告中。 下面的代码执行没有任何错误,但它只写入第一个URL报告内容 新文件里面不是两个。 有人可以建议我在这段代码中做错了吗?
string newFile = "NewFile.pdf";
string sTargetURL = "http://xxx/ReportServer_SQLEXPRESS?/Reports&rs:Embed=true&rc:Parameters=false&GroupBy1:isnull=true&GroupBy2:isnull=true&GroupBy3:isnull=true&GroupBy4:isnull=true&Show_Detail=False&Report_Id=d80589ea-324d-41ff-af53-58f009b5497c&rs:ParameterLanguage=en-us&rc:Toolbar=true&rs:Format=pdf";
string sTargetURL1 = "http://xxx/ReportServer_SQLEXPRESS?/Reports&rs:Embed=true&rc:Parameters=false&GroupBy1:isnull=true&GroupBy2:isnull=true&GroupBy3:isnull=true&GroupBy4:isnull=true&Show_Detail=False&Report_Id=b4d79d69-57fe-4ccf-9beb-a4bbffdd87fb&rs:ParameterLanguage=en-us&rc:Toolbar=true&rs:Format=pdf";
using (FileStream fs = new FileStream(NewFile, FileMode.Create, FileAccess.Write))
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sTargetURL);
req.UseDefaultCredentials = true;
req.PreAuthenticate = true;
req.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse HttpWResp = (HttpWebResponse)req.GetResponse();
fStream = HttpWResp.GetResponseStream();
var fileBytes = ReadFully(fStream);
HttpWebRequest req1 = (HttpWebRequest)WebRequest.Create(sTargetURL1);
req1.UseDefaultCredentials = true;
req1.PreAuthenticate = true;
req1.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse HttpWResp1 = (HttpWebResponse)req1.GetResponse();
fStream = HttpWResp1.GetResponseStream();
var fileBytes1 = ReadFully(fStream);
var fileBytes2 = Combine(fileBytes, fileBytes1);
fs.Write(fileBytes2, 0, fileBytes2.Length);
}
private byte[] Combine(byte[] a, byte[] b)
{
byte[] c = new byte[a.Length + b.Length];
System.Buffer.BlockCopy(a, 0, c, 0, a.Length);
System.Buffer.BlockCopy(b, 0, c, a.Length, b.Length);
return c;
}