 Sharepoint & Reporting Services)
Sharepoint & Reporting Services)I have a Report Image that I call from Reporting Services and I render it in
a Sharepoint Webpart, I need to manage the Session from reporting sevices as
when I try to manage it from the Sharepoint Web Part, Reporting Services says
it can not find the image/data, as the report session has changed, and has
new data, I need to make the Report Image Session able to maintain the prior
session.
I was wondering if there was a way to capture the session variable from
Reporting Services and keep it in the webpart? or capture it in someway to to
maintain the sessionon the data call.
Any one out there know how to capture this or have run into this problem, or
might know a solution?
If you are using the Reporting Services Web Service to retrieve the report by calling the Render method on the ReportingService object in your web part, you can capture the Report SessionId from the SessionHeaderValue.SessionId property on the ReportingSe
rvice object after the call and use it later when you are retrieving the image via the RenderStream method.
see: http://msdn.microsoft.com/library/de...ce_lz_6x0z.asp
Currently I am using a Web Part to display the report and a seperate .aspx file to render the images in the report.
I call the Render Method of the Web Service with the and set the deviceinfo for HTMLFragment(true),StreamRoot(/myVirtualDirectory/ImageRender.aspx?sessionid=&reportname=xx¶m1=y y&streamid=)
After the call the output html will contain image tags with src attribute equal StreamRoot concatinated with the streamId (i.e. streamid has to be the last item in the query string)
I populate the sessionid in the above image url with a string replace.
CODE:
public static string RetrieveReport(string reportPath, ParameterValue[] parameterValues, string sharePointHelperUrl, bool useDefaultCredentials)
{
string outputHtml=string.Empty;
ReportingService rs = new ReportingService();
rs.Credentials = GetCredentials(useDefaultCredentials);
ItemTypeEnum reportType = rs.GetItemType(reportPath);
if(reportType==ItemTypeEnum.Report)
{
// Render arguments
byte[] result = null;
// Prepare Render method's parameters.
/*
* The devInfo parameter is set to hide the tool bar, hide the parameters, return the fragment Html
* and prefix all images with the Url to our helper aspx file with the query string holding all data
* required to retrieve the correct image from the Reporting Service
* */
string imageUrl = System.Web.HttpUtility.HtmlEncode(
string.Format("{0}/getreportimages.aspx?{1}={2}&{3}={4}&{5}={6}&{7}=" ,
sharePointHelperUrl,
"RSSessionID",
"",
"ReportPath",
reportPath,
"Parameters",
getReportParametersForQueryString(parameterValues) ,
"StreamID"
)
);
string devInfo = @."<DeviceInfo><Toolbar>False</Toolbar><StreamRoot>" + imageUrl + "</StreamRoot><Parameters>False</Parameters><HTMLFragment>True</HTMLFragment></DeviceInfo>";
string format = "HTML4.0";
string historyID = null;
DataSourceCredentials[] credentials = null;
string showHideToggle = null;
string encoding;
string mimeType;
Warning[] warnings = null;
ParameterValue[] reportHistoryParameters = null;
string[] streamIDs = null;
rs.SessionHeaderValue = new SessionHeader();
result = rs.Render(reportPath, format, historyID, devInfo, parameterValues, credentials, showHideToggle, out encoding, out mimeType, out reportHistoryParameters, out warnings, out streamIDs);
outputHtml = System.Text.Encoding.UTF8.GetString(result, 0,result.Length);
/*
* The SessionHeaderValue.SessionId is not available until the Render method of the Reporting Service
* has been called. This is required when calling the RenderStream method, this method is called by the
* supporting aspx page. This page is requested by the client to render images. Replace Query String
* "RSSessionID" with "RSSessionID" and the SessionHeaderValue.SessionId for each image in the rendered
* output.
* */
outputHtml = outputHtml.Replace("RSSessionID=", "RSSessionID=" + rs.SessionHeaderValue.SessionId);
}
return outputHtml;
}
NOTE:The /myVirtualDirectory/ has to excluded from SharePoint so it is processed as a normal aspx.
************************************************** ********************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
No comments:
Post a Comment