c# - 我可以在利用 ReportExecutionService 执行我的 SSRS 脚本方面获得一些帮助吗
问题描述
这是我的控制台应用程序代码:
private static void CreateSSRSPDF()
{
string FullFilePath = "C:\\NewIbidReport";
ReportExecutionService rs = new ReportExecutionService();
string format = "PDF";
string reportPath = "http://bushssrs02dev/ReportServer/Sam%20"+"-"+"%20Student%20Reports/IBid%20Audit%20Analysis.rdl";
string mimeType = "application/pdf";
ParameterValue[] parameters = new ParameterValue[1];
parameters[0] = new ParameterValue();
parameters[0].Name = "StudentStatus";
parameters[0].Value = "Active";
byte[] results = RenderReport(rs, format, mimeType, reportPath, parameters);
WriteFile(results, FullFilePath);
}
private static byte[] RenderReport(ReportExecutionService rs, string format, string mimeType, string reportPath, ParameterValue[] parameters)
{
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
//Prepare Render arguments
string historyID = null;
string deviceInfo = String.Empty;
string extension = String.Empty;
string encoding = String.Empty;
Warning[] warnings = null;
string[] streamIDs = null;
byte[] results = null;
rs.LoadReport(reportPath, historyID);
rs.SetExecutionParameters(parameters, "en-us");
results = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);
return results;
}
rs.LoadRedport 行抛出错误:
System.Web.Services.Protocols.SoapException
HResult=0x80131501
Message=The path of the item 'http://bushssrs02dev/ReportServer/Sam%20-%20Student%20Reports/IBid%20Audit%20Analysis.rdl' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidItemPathException: The path of the item 'http://bushssrs02dev/ReportServer/Sam%20-%20Student%20Reports/IBid%20Audit%20Analysis.rdl' is not valid. The full path must be less than 260 characters long; other restrictions apply. If the report server is in native mode, the path must start with slash.
Source=System.Web.Services
StackTrace:
at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at MyServices.MyReportSerivce.ReportExecutionService.LoadReport(String Report, String HistoryID) in c:\users\prykiel\source\repos\Factodo399\MyServices\Web References\MyReportSerivce\Reference.cs:line 287
at Factodo399.Program.RenderReport(ReportExecutionService rs, String format, String mimeType, String reportPath, ParameterValue[] parameters) in c:\users\prykiel\source\repos\Factodo399\Factodo399\Program.cs:line 53
at Factodo399.Program.CreateSSRSPDF() in c:\users\prykiel\source\repos\Factodo399\Factodo399\Program.cs:line 36
at Factodo399.Program.Main(String[] args) in c:\users\prykiel\source\repos\Factodo399\Factodo399\Program.cs:line 16
我可以在浏览器中为报告路径键入此 URL 并执行 SSRS 报告,但我想从控制台应用程序执行它。
解决方案
推荐阅读
- javascript - 从给定的选项卡和数据中形成类似字典的结构
- flutter - 如何在颤动中创建带有下一个和上一个按钮的可滚动选项卡
- azure-functions - Azure Functions:消耗计划中插槽之间的内存和 CPU 分配
- python - 获取当前索引号 QStackedWidget
- python - Python:图形用户界面和后端
- javascript - 编译失败 - 反应
- html - 将图像添加到离子选择选项(离子选择)
- python - 运行 python 脚本写入文件的 Windows 任务计划程序
- javascript - How to use emojionearea library in webpack
- javascript - json-server 未显示 JSON 数据的 URL