Download as PDF:
Configuring Reporting Engine.pdf
The purpose of this tutorial is to cover the basic steps of
of the class which implements the server part. This server part is necessary
for the use of SharpShooter Reports.Web. This step-by-step tutorial provides
minimum required skills necessary for work with the component, such as:
- addition of a class to a project,
- class configuration,
- addition of Dataset,
- addition of “ReportManager”,
- addition of a data source,
- a report creation.
Let’s examine the creation of a class on the basis of the “ASP.NET Empty
Web Application” project.
The steps described in this application are similar for such projects as:
- ASP.NET Web Application
- ASP.NET MVC Web Application
1. Creation of a project
Create “ASP.NET Empty Web Application”. Select File|New|Project…
in the Visual Studio menu.
Select “ASP.NET Empty Web Application” in the list of projects.
Enter “ReportingEngine” in the “Name” field.
2. Adding references to the assemblies
Add the references to the following assemblies to the project:
Select the “ReportingEngine” project in the “Solution Explorer”.
Select “Add Reference” in the context menu.
Select the PerpetuumSoft.Reporting.WebViewer.Model.dll,
and System.ServiceModel.dll files.
Step 3. Adding reporting engine class
Add a class to the project. The class implements the logic of the server part work.
Select “Add\New Item…” inthe context menu of the “ReportingEngine”
project in the “Solution Explorer”.
Select “Class” in the list of elements. Enter “ServiceClass” in the “Name” field
and click the “Add” button.
Open the added class. To do this, double click on the “ServiceClass.cs”
element in “Solution Explorer”.
Add the “System.ServiceModel.Activation”, “System.Data” and
namespaces to the “ServiceClass”. To do this, use the using directive:
Inherit the added class from the “ReportServiceBase” class. Thus, you get ready
implementation and ability to change standard behavior.
You should mark the service class with
After this the service will have access to ASP.NET context during the realization
of the server part. The ASP.NET context caches document’s data if other
cache mechanism is not implemented.
Add the “InitializeComponent” function and the constructor,
which invokes this function, to the “ServiceClass” class.
public class ServiceClass : ReportServiceBase
private void InitializeComponent()
4. Adding data source
Open the designer for the “ServiceClass”. Select the “View Designer” item
in the “Solution Explorer” in the context menu of the “ServiceClass.cs” file.
Firstly, create data source structure. Add “Dataset” from the “Toolbox”
(double click on the Dataset in Toolbox).
And select the Untyped dataset.
After that the dataset node (dataSet1) will appear in the designer.
Open Tables Collection Editor (click button in property Tables).
Add Customers table to the dataSet1 (click “Add” button
and set TableName property value to “Customers”, set Name property
value to “customers”). After that open Columns Collection Editor
(click button in property grid of Tables Collection Editor)
Add two columns by clicking “Add” button and setting ColumnName property
value to “Name” and “Phone”.
5. Adding data to a data source
Data structure is defined, and it’s necessary to fill Customers Table with the data.
To view source code right-click on designer area and click “View Code”
item in contextual menu.
You should fill data sources with the values via overriding OnLoadData method
of the ServiceClass class.
protected override void OnLoadData(IDictionary<string, object>
parameters, string reportName,
base.OnLoadData(parameters, reportName, reportSlot);
DataRow row = customers.NewRow();
row["Name"] = "Johnson Leslie";
row["Phone"] = "613-442-7654";
row = customers.NewRow();
row["Name"] = "Fisher Pete";
row["Phone"] = "401-609-7623";
row = customers.NewRow();
row["Name"] = "Brown Kelly";
row["Phone"] = "803-438-2771";
6. Adding slot for a report
Now add the ReportManager component (double click on “ReportManager”
in ToolBox); this component is responsible for report generation.
After that the ReportManager node (reportManager1) will appear in the designer.
Set the ReportManager property of the ServiceClass class. In order to do that,
open ServiceClass properties in the Properties window.
Select reportManager1 from the list:
Run Report Manager Editor by right-click on reportManager1 and
choosing Run Editor
Before you start creating report template add a data source by which
the report will be generated. Add Customers table to the Data binding list
located on the “Data sources” tab (click “Add” button, in appeared form
“Edit object name” set Name value to Customers,
select dataSet1.Customers in the combo box list).
In the “Reports” tab, add a new object – “InlineReportSlot” by clicking the “Add” button.
Set the ReportName property value to CustomersReport. Afterwards you
will get the required document from the Report Manager exactly by that name.
Then press the “Run Designer” button to launch report designer.
7. Creation of a report with Wizard
Select the File\New menu item, and the form shown on the
screen below will appear.
Select Standard Report in the list under the “New” tab and press OK.
The Standard Wizard window will appear on the screen.
Set document parameters as shown in the following figure.
Add data source using the “Add” button ( ).
Click button, in appeared tree view select “Customers” by double click.
Select fields you want to output in the report (you should move
both fields Name and Phone):
8. Setting up a report
The template is created.
Set the “RepeatEveryPage” property to True for the header1 element in
the “Properties” window.
Set the “NewPageAfter” property to True for the detail1 element
in the “Properties” window.
9. Adding navigation
Let’s add navigation to a report. Bookmarks tree will be used
for navigation through the report. Select “Bindings” for the
detail1_Customers_phone element in the “Properties” window.
Open the script editor (the button) for “Bookmark” property.
Enter “#” + in the script editor. Expand the “Customer” data
source in the “Data Source” tab. Double click on the “Name” element
in order to add the script code which will get customer name.
Now you should save the template and close designer.
If you have any questions regarding the integration with
SharpShooter Reports.Web don’t hesitate to
contact us at email@example.com