Thursday, March 22, 2012

Detecting the render method using an expression

Is there a way of detecting (in an expression in the report) the render
method that is being used to render the report?
Scenario
I have created a custom assembly that sits in the footer of a report and
writes the total number of pages to a database table. However, the total
number of pages varies depending on the render method used, and I need to
capture this render method along with the total pages.
I can't pass the render method into the report as a parameter because, even
when rendering with a single render format such as PDF the report seems to
render twice:
string format = "PDF";
results = viewer.ServerReport.Render(format, deviceInfo, out mimeType, out
encoding, out fileNameExtension, out streamIDs, out warnings);
The above code inserts two records into the database table (once as either
XML or HTML and then as PDF). The first record reflects the total pages
displayed in the viewer, and the second record reflects totalPages as if
exported into PDF.
If we could detect which format was being used at render time then we could
get around this double rendering problem.Hello Stu,
I undertstand that you want to pass the render type in the expression.
Well you could not pass the render type in the expression.
Could you please let me know how your custom code to insert the total page
information?
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Hi Wei Lu,
The expression in the report is:
--
="Page "&Globals!PageNumber & " of "
&LogAttributes.CommonFunctions.LogReportDetails(Globals!ReportName,
Globals!TotalPages, Globals!PageNumber, Parameters!SnapshotID.Value,
Parameters!SchemaName.Value,
Parameters!Database.Value,Parameters!UserID.Value,Parameters!Password.Value,
Parameters!Server.Value)
--
And the code in the custom assembly is:
--
public static int LogReportDetails(string reportName, int
totalNumberOfPages, int currentPage, int snapShotID, string schema,
string database, string userID, string password, string server)
{
bool testRun = false;
if (currentPage == totalNumberOfPages) { testRun = true; } else
{ testRun = false; }
if (testRun)
{
int totalNumPages;
bool ok = true;
TableOfContents toc = new TableOfContents();
toc.Description = reportName;
toc.TotalNumberOfPages = totalNumberOfPages;
toc.CurrentPage = currentPage;
toc.SnapshotID = snapShotID;
toc.SchemaName = schema;
toc.Database = database;
toc.UserID = userID;
toc.Password = password;
toc.Server = server;
SqlTOCDalc dalc = new SqlTOCDalc();
totalNumPages = dalc.InsertTocRow(toc, ok);
return totalNumPages;
}
else
{
return totalNumberOfPages;
}
}
--
Thanks
Stu
"Wei Lu [MSFT]" wrote:
> Hello Stu,
> I undertstand that you want to pass the render type in the expression.
> Well you could not pass the render type in the expression.
> Could you please let me know how your custom code to insert the total page
> information?
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no rights.
>|||Hello Stu,
Well, unfortunately, you could not refer the render method in the custom
code. And the only workaround I thought is that you may need to add the
custom application to call the report instead of the access the report via
the web browser.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment