1: private void RenderReportToClient()
2: { 3: //set credentials
4: RSExecuteProxy.ReportExecutionService rs = new RSExecuteProxy.ReportExecutionService();
5: rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
6:
7: RSProxy.ReportingService2005 rsInfo = new RSProxy.ReportingService2005();
8: rsInfo.Credentials = System.Net.CredentialCache.DefaultCredentials;
9:
10: // init render args
11: byte[] result = null;
12: string reportPath = rptViewer.ServerReport.ReportPath;
13: string format = "PDF";
14: string historyId = null;
15:
16: string encoding;
17: string mimeType;
18: string extension;
19: RSExecuteProxy.Warning[] warnings = null;
20: string[] streamIDs = null;
21:
22: //init exec info
23: RSExecuteProxy.ExecutionInfo execInfo = new RSExecuteProxy.ExecutionInfo();
24: RSExecuteProxy.ExecutionHeader execHeader = new RSExecuteProxy.ExecutionHeader();
25:
26: rs.ExecutionHeaderValue = execHeader;
27:
28: //get report
29: execInfo = rs.LoadReport(reportPath, historyId);
30:
31: String SessionId = rs.ExecutionHeaderValue.ExecutionID;
32:
33: //get parameter info
34: ReportParameterInfoCollection parameters = rptViewer.ServerReport.GetParameters();
35:
36: //figure out how many parameters we will have
37: //those with multi-value will need there own ParameterValue in the array
38: int paramCount = 0;
39:
40: foreach (ReportParameterInfo pramInfo in parameters)
41: { 42: paramCount += pramInfo.Values.Count;
43: }
44:
45:
46: RSExecuteProxy.ParameterValue[] prams = new SSRSWeb.RSExecuteProxy.ParameterValue[paramCount];
47:
48: int currentPramPosition = 0;
49:
50: //set pram values
51: foreach (ReportParameterInfo pramInfo in parameters)
52: { 53: foreach (string pramValue in pramInfo.Values)
54: { 55: prams[currentPramPosition] = new SSRSWeb.RSExecuteProxy.ParameterValue();
56: prams[currentPramPosition].Label = pramInfo.Name;
57: prams[currentPramPosition].Name = pramInfo.Name;
58: prams[currentPramPosition].Value = pramValue;
59: currentPramPosition++;
60: }
61: }
62:
63: rs.SetExecutionParameters(prams, "en-US");
64:
65: //build the device settings (A4 8.3 × 11.7)
66: string deviceInfo = string.Format("<DeviceInfo><PageHeight>{0}</PageHeight><PageWidth>{1}</PageWidth></DeviceInfo>", "11.7in", "8.3in"); 67:
68: //get report bytes
69: result = rs.Render(format, deviceInfo, out extension, out encoding, out mimeType, out warnings, out streamIDs);
70:
71: Response.ClearContent();
72: Response.AppendHeader("Content-Disposition", "inline;filename=report.pdf"); 73: Response.AppendHeader("content-length", result.Length.ToString()); 74: Response.ContentType = "application/pdf";
75: Response.BinaryWrite(result);
76: Response.Flush();
77: Response.Close();
78: }