【发布时间】:2011-06-23 16:16:44
【问题描述】:
我正在尝试将以下 C# 代码转换为 IronPython,但我不知道如何处理强类型可变数组。该代码是用于将服务器端 SSRS 报告写入本地 PDF 的测试代码,并且在 C# 中运行良好。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.Collections.Generic;
using Microsoft.Reporting.WinForms;
namespace ConsoleBooking
{
class Program
{
static void Main(string[] args)
{
ServerReport report = new ServerReport();
report.ReportServerUrl = new Uri("http://192.168.1.29/ReportServer");
report.ReportPath = "/Report Project Media Bookings/Business";
Warning[] warnings;
string[] streamids;
string mimeType;
string encoding;
string filenameExtension;
byte[] bytes = report.Render(
"PDF", null, out mimeType, out encoding, out filenameExtension,
out streamids, out warnings);
string filename = Path.Combine(Path.GetTempPath(), "business.pdf");
using (FileStream fs = new FileStream(filename, FileMode.Create))
{
fs.Write(bytes, 0, bytes.Length);
}
}
}
}
如果我将数组设置为
streamids = Array.CreateInstance(String, 1)
所以我的电话看起来像这样
bytes = report.Render("PDF", None, mimeType, encoding, filenameExtension, streamids, warnings)
然后我得到这个相当神秘的未处理异常返回
预期StrongBox[str],得到str
我应该如何编码?
上面的报告没有带任何参数,但是在C#中这些是使用添加的
List<ReportParameter> paramList = new List<ReportParameter>();
paramList.Add(new ReportParameter("pBookingID", "6761", false));
report.SetParameters(paramList);
在相关报告中,这对我来说也很好用 - 我如何在 IronPython 中添加它?
更新:使用字节,mimeType,编码,filenameExtension,streamids,warnings = report.Render("PDF", null) 正如 Jeff Hardy 所建议的那样,可以立即调用,但它仍然会因“太多的值而崩溃”解压”错误。任意扩展数组的大小或添加额外的参数都不会改变这个错误——而且很难看出哪里出了问题。有什么想法吗?
【问题讨论】:
标签: .net reporting-services ironpython