Now that the end user is able to interact with the report’s prompt page we need to execute the report and display the report values to our Output.aspx page. The Output.aspx.cs logic will contain a reference to the CognosSDK.cs function named resolvePrompts(). This function is used to determine the prompt type and prompt value that was executed on the report’s prompt page. These parameter values are then used to satisfy the parameter value collection that is passed in to the executeReport().
try
{
_frmData = Request.Form;
_selectedPkg = _frmData.GetValues("hidPkgName").GetValue(0).ToString();
_selectedRpt = _frmData.GetValues("hidRptName").GetValue(0).ToString();
_path = "/content/package[@name='" + _selectedPkg + "']/report[@name='" + _selectedRpt + "']";
asynchDetail[] _paramDetail = _cogSDK.GetParams(_selectedPkg,_selectedRpt,_rptService);
asynchDetailParameters _params = (asynchDetailParameters)_paramDetail[0];
int _pCount =_params.parameters.Length;
parameterValue[] _pv = _cogSDK.resolvePrompts(_frmData, _pCount);
string[] reportFormat = {"HTML"};
strHTML = _cogSDK.executeReport(_path, _pv, _rptService, reportFormat, false);
Response.Write(strHTML);
}
catch(Exception ex)
{
_ErrMsg = ex.Message.ToString();
Response.Write(_ErrMsg);
}
return;
We have already seen that the executeReport() will return a string variable value of the report’s output. This is achieved by applying an asynchReply variable to the Report Service’s .run() method.
try
{
spSingle.Value = reportSearchPath;
asynchReply C8reply = reportService.run(spSingle, pv ,arrRunOpts);
if (C8reply != null)
{
strHTML = getOutputPage(C8reply);
return strHTML;
}
else
{
return null;
}
}
catch (SoapException exSoap)
{
ExHandler exCognos = new ExHandler(exSoap);
return _ErrMsg = exCognos.Details + " :-: " + exCognos.Message + " :-: " + exCognos.Severity + " :-: " + exCognos.ErrorCode;
}
catch (Exception ex)
{
return _ErrMsg = ex.Message.ToString();
}
Output.aspx.cs will finally pass this string value to the page’s Reponse.Write() and render the dataset to the end user.