1 | Page DNN UserGroup - Mar 11 2009 Meeting Topic: Linq and DNN Reporting Presentation Part 3 Speaker: Paul Chu ( Senior Web Consultant ) Contact: [email protected]Last Time, we saw how to utilize our Linq DAL layer containing our RSVP tables Data Model. We showed diagrams to show how the Microsoft ReportViewer control can be used to Host Local Reports ( .rdlc ) files. SHOW DIAGRAMS We showed how the Presentation Layer can request data from our Business Layer Method which access the Linq DAL layer. We showed how to create reports but did not finish. Future Meetings : 4/??/09 – asked Lynn Langit to speak on DNN project for Ministry of Health ( Government) in Zambia, Africa. Report Viewer Tip: http://www.gotreportviewer.com/ Bummer: You cannot use the VS 2008 BI Server Report Project generated RDL reports as local reports ( .RDLC )
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
It may be possible to tweak the XML of the RDL to convert to
RDLC compatible ( but BI 2008 has Tablix and other features )
that are NOT in the VS 2005 / ReportViewer Control based .RDLC
file.
3 | P a g e
Mar 11, 2009 - Presentation Goals – DNN Reporting Part 3
This time, we continue our discussion to cover:
1. Review of the RSVP Reporting Module DNN Package which
can be installed on a DNN website.
a. Demo RSVP Module again !
b. Demo installing the Module on a clean DNN 4.9.2
website
2. This module is the reporting component only and does NOT
have the RSVP Form page and Admin Pages.
3. Create the Master/Detail Report / Sub Reports from Scratch.
4. Show off more Linq queries.
5. How to do a Master Detail with ListViews and Linq
Q. When installing our DNN RSVP Reporting Module that has
DLLs ( such as our Linq DLL and Business Layer DLL ) how are
they deployed ?
Q. What is the DNN Manifest File ( .dnn ) ?
This file is created by DNN when you “Create a Module Definition”
in the Admin page
This XML file contains a list of “objects/Files” used by the Module.
SHOW .dnn file EXAMPLE IN APPENDIX
Q. Module Installation: How do we install the initial RSVP Tables
and populate with Data ?
4 | P a g e
SHOW Provider file EXAMPLE IN APPENDIX
Q. What are the pre-requisites for the DNN Reporting Module ?
A. Uses MS ReportViewer control which must be install on the
Hosting DNN Website. This means that the GAC has the RV dlls.
B. The DNN website web.config must also reference the RV dlls
and have the Asp.Net 3.5 references to Linq.
Attach sample web.config.sample to download
5 | P a g e
Testing RSVP Report Module 1.18 zip file on new DNN 501
website
Download 501 install zip
Install – update SiteSqlServer in Web.config
Create Database DNN501
Create Virdir to DNN501 to install folder
Create page: ReportViewerTest.aspx
Drag ReportViewer control to update web.config
Open website with VS 2008
Say yes to upgrade the Project to Asp.Net 3.5 to put Linq dlls
etc in web.config
Install RSVP Report Module but putting it on a page fails.
Error: RSVPReport is currently unavailable. DotNetNuke.Services.Exceptions.ModuleLoadException: c:\DNN4\DotNetNuke_Community_05.00.01_Install\DesktopModules\RSVPReport\View.ascx.cs(22): error CS0246: The type or namespace name 'RSVPBLL' could not be found (are you missing a using directive or an assembly reference?) ---> System.Web.HttpCompileException: c:\DNN4\DotNetNuke_Community_05.00.01_Install\DesktopModules\RSVPReport\View.ascx.cs(22): error CS0246: The type or namespace name 'RSVPBLL' could not be found (are you missing a using directive or an assembly reference?) at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at DotNetNuke.UI.ControlUtilites.LoadControl[T](TemplateControl containerControl, String ControlSrc) at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
Open Internet Information Services (IIS) Manager and select your Web application.
Under IIS area, double-click on Handler Mappings icon. At the Action pane on your right, click on Add Managed Handler.
14 | P a g e
At the Add Managed Handler dialog, enter the following: Request path: Reserved.ReportViewerWebControl.axd Type: Microsoft.Reporting.WebForms.HttpHandler Name: Reserved-ReportViewerWebControl-axd
Click OK.
Fixed Report Module pages references to
Using RSVP; to Using RSVPReport;
RSVP.RSVPUtil .xxx to RSVPReport.RSVPUtil.xxx
+ Drill Down Report – Image is missing
Fix: change Image Path to
DesktopModules\RSVPReport\Img\Plug.png or minus.png
+ Send RSVP Module Package for Testing
DNN 5.01 RSVP Module Testing Completed !
Sat –
Review Practice pages in Demo folder
Review main RSVP report
Review Nested ListView
Review Nested GridView
d. DNN Report with ReportViewer Deployment to Hosted
Website
i. Install ReportViewer.exe
ii. Update Web.Config
15 | P a g e
iii. Setup IIS 7 Security
iv. Install DNN Report Module ( uses ReportViewer )
3. Business Layer with static methods using Linq Queries to the
DAL layer.
4. UI Layer ( DNN Module ) making calls to methods on the
Business Layer and databinding to our Reports.
5. Create a Simple Report using Visual Studio 2008 Report
template
6. Create a DataSource: DataSet
7. Demo the use of Images in Reports ( Dilbert Example ) –
embedded , url
8. Demo use of Linq queries in Business Layer and use of
IQueryable object to return data to the UI Layer
9. Linq Queries
a. Linq Group By query
b. Linq Left outer join
10. SSRS Report
a. SubReport ( nested in a Main Report )
b. Images
c. Formatting using VB.Net Expresssions
i. Footer – page x of y
ii. Show Date without time
iii. Alternate color
16 | P a g e
11. SSRS Reporting Example
a. Show accessing Linq query methods in Business Layer
b. Code to Bind to Report in ReportViewer
c. Code to Bind to SubReports in Report
Sample Report using Images / Background Image with Linq
17 | P a g e
N-Tier design with ReportViewer Benefits:
1. The UI Layer does NOT access the Database directly and
uses the Business Layer to get data.
2. Business Layer is reusable and can be accessed from
Winforms / WebServices etc.
3. Business Layer can be Unit Tested independent of UI Layer.
4. SSRS LocalReports don’t require Reporting Services
website. You can host these reports in your website.
5. It can provide a web based reporting presence with the
ability to export to PDF and Excel.
Disadvantages:
1. Building LocalReports is more difficult than using the
Business Intelligence Report Visual Studio Template which
creates Reporting Server Deployable reports .rdl instead
of .rdlc.
2. When Authoring a Report you do NOT have the PREVIEW
tab like in BI development mode. You must build a Page
with a Report Viewer and attach the Report and optionally
do data retrieval to populate the report.
18 | P a g e
RSVP Attendance Report using Nested ListViews
++ The Outer ListView is built from this part of the Linq Query
select new { EventDate = g.Key.EventDate, EventName
Remember in LinqPad we need to have reference the Linq…DLL
in order to use our own DataContext !
Refer to Linq example:
RSVPTest3Statements.Linq
21 | P a g e
LinqPad supports intellisense on REFERENCED dlls !
22 | P a g e
RSVP Report Module – Host > Module Definitions
23 | P a g e
+ Left Outer Join Example – when you want to include all
rows from the main table and join to the second table if
there are any rows found.
The Left Outer Join syntax in Linq is not very intuitive but
here is an example ( I don’t know how to use the
GroupJoin yet) –
… join … on … into … from … in …DefaultIfEmpty()
var v1 = (
from x in CRISII_FundingSources
join y in CRISII_Funding_Slots
on x.FundingID equals y.FundingID
into xy
from x2 in xy.DefaultIfEmpty() orderby x.FundingDescription
select new { x.FundingDescription, SlotCount =
xy.Count() }
).Distinct();
v1.Dump();
NOTICE: no Group By in the generated Sql
SELECT DISTINCT [t3].[FundingDescription], [t3].[value] AS [SlotCount] FROM ( SELECT [t0].[FundingDescription], ( SELECT COUNT(*) FROM [CRISII_Funding_Slot] AS [t2] WHERE [t0].[FundingID] = [t2].[FundingID] ) AS [value] FROM [CRISII_FundingSource] AS [t0]
24 | P a g e
LEFT OUTER JOIN [CRISII_Funding_Slot] AS [t1] ON [t0].[FundingID] = [t1].[FundingID] ) AS [t3] -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel