IT Software Outsourcing Business Tutorial: 3-tier ASP.NET / SSRS solution with PDF output, part 4. Report integration.
Get Adobe Flash player

IT Software Outsourcing Business Tutorial: 3-tier ASP.NET / SSRS solution with PDF output, part 4. Report integration.  

Posted by Igor Sunday, August 08, 2010 5:56:10 AM
Rate this Content 11 Votes

As you remember, from the architectural point of view we should implement 3-tier solution with the User Interface, Business Logic and Data Access Layers.

Tutorial Part 4. Report integration.

At the part 3 of our IT Software Outsourcing Business Tutorial, we implemented the business layer class which incapsulate the custom business logic but not only. Also our business class passed to the report the DataSource required:
 
thisReport.LocalReport.DataSources.Add(new ReportDataSource("SSRSTutorial_DAL_dalReport", _outList));
I should put your attention: the "SSRSTutorial_DAL_dalReport" variable is the namespace + classname of our DAL's Data Transfer Object class (with the dots been replaced by underscores) which will be reviewed later.

Let's take a look to the implementation of the Report and how we could integrate our custom DataSources inside.

The general problem of our step is to add the custom object DataSource with our SSRSTutorial.DAL.dalReport class into our Report1.rdlc report. We could implement it in a 2 ways:

1 - Add the DataSet and DataSources to the SSRS report using the XML editor.

1.1. If your Report1.rdlc report is open at the Report Designer, please, close it.
1.2. Right click the Report1.rdlc file in our Solution Explorer and choose the "Open With"->"XML Editor" and you will be able to edit the SSRS Report content in the XML form.
1.3. Add the   <DataSources> and  <DataSets> sections below the Report definition header <Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"> as you could see below:
 
<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <DataSources>
    <DataSource Name="DummyDataSource">
      <rd:DataSourceID>ef8c7980-eec3-4d64-9c8b-2ae743abc1cc</rd:DataSourceID>
      <ConnectionProperties>
        <DataProvider>SQL</DataProvider>
        <ConnectString />
      </ConnectionProperties>
    </DataSource>
  </DataSources>  
  <DataSets>
    <DataSet Name="SSRSTutorial_DAL_dalReport">
      <Fields>
        <Field Name="UserId">
          <DataField>UserId</DataField>
          <rd:TypeName>System.Int32</rd:TypeName>
        </Field>
        <Field Name="UserName">
          <DataField>UserName</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
        <Field Name="UserAddress">
          <DataField>UserAddress</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
      </Fields>
      <Query>
        <DataSourceName>DummyDataSource</DataSourceName>
        <CommandText />
        <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
      </Query>
      <rd:DataSetInfo>
        <rd:DataSetName>SSRSTutorial.DAL</rd:DataSetName>
        <rd:TableName>dalReport</rd:TableName>
        <rd:ObjectDataSourceType>SSRSTutorial.DAL.dalReport, SSRSTutorial, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</rd:ObjectDataSourceType>
      </rd:DataSetInfo>
    </DataSet>
  </DataSets>
 
I should make a remark here: as usual, the SSRS report have DataSource which is SQL query or the remote Stored Procedure CALL. But in our case the Business Logic incapsulated in the custom Business Logic Class which instantiates our Report and pass one or many DataSets to our Report after it. This way we needed to use custom Object Data Sources in our Report.
 
1.4. Save and close the Report's XML definition file and open the file in usual Report Designer. Drop the Table component into the Report and voila, you will be able to use usual Value properties for the Fields : =Fields!UserId.Value which are able to reference the custom DataSet fields.
 
2. - Add theObject Data Source to the SSRS report using the BIDS Visual Studio.
If you are using BIDS then our work will be much easier because it is possible to add the Object Data Source in a usual way. It will be required only to bind the Object Data Source with our SSRSTutorial.DAL.dalReport class which is Data Transfer Object class by nature.
 
When the custom Object Data Source been added into the report it is really easy to customize the SSRS Report in a usual way.
Our report should looks like the screen shot below:
 
IT Software Outsourcing Business Tutorial: 3-tier aspnet ssrs solution development  with pdf output.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

That's all for the Report Integration part of our tutorial.

End of Part 4.

To be continued

(c) SoftPilot2000 Software Outsourcing Ukraine. All rights reserved.
Comments are closed on this post.