0% found this document useful (0 votes)
171 views

Advanced Dotnet Tutorial

Implementing and embedding Crystal Reports in the.Net environment is extremely easy to do. Once the tools are downloaded from the businessobject website creating and editing reports from Visual Studio is a breeze. We are going to be covering the caching functionality that the Crystal Report framework provides through the ICachedReport interface.

Uploaded by

Sachdeva Ashu
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views

Advanced Dotnet Tutorial

Implementing and embedding Crystal Reports in the.Net environment is extremely easy to do. Once the tools are downloaded from the businessobject website creating and editing reports from Visual Studio is a breeze. We are going to be covering the caching functionality that the Crystal Report framework provides through the ICachedReport interface.

Uploaded by

Sachdeva Ashu
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Advanced Dotnet Tutorial

Type here

Home Asp .Net C# Visual Basic Java Silverlight

Subscribe via email


Enter your email address:

Followers Subscribe This Blog


Posts Comments

Other Tech Posts


Create Thumbnail Images using PHP PHP: Export Database Schema as XML Get the Current Page URL Using PHP Passing JavaScript variables to PHP Create CAPTCHA Protection using PHP and AJAX Encrypt Passwords in the Database Blocking access to the login page after three unsuccessful login attempts DSN and DSN-less connections Connect to MS SQL Server database Creating New Directories

Optimizing Crystal Reports for Asp.Net


0 comments Implementing and embedding Crystal Reports in the .Net environment is extremely easy to do. Once the tools are downloaded from the businessobject website creating and editing reports from Visual Studio is a breeze. We are going to be covering the caching functionality that the Crystal Report framework provides through the ICachedReport interface.
What you will learn

What is the ICachedReport interface. System generated classes and when to modify them. Adding extensions to support ConnectionInfo binding. Putting it all together.

ICachedReport Interface The ICachedReport interface will work like a flag to signal the Crystal Report framework that the report should be cache. It works by creating a layer ontop of the Asp.net Cache object to accommodate the needs of the report. The interface is found in the CrystalDecisions.ReportSource namespace. System Generated Classes (Benefits of embedding) Using Visual Studio to add a report as a new item will generate a report wrapper class with the name of the report. The second class will be the management class named Cached[ReportName]. Visual Studio will generate

both classes in the same file (ReportName.cs). Below you will see an example of a generated class for a report called SalesDirectory. For the most part this class will expose everything needed to work with the report without any changes. In some cases when using the Cached class properties will need to be added to support parameters.
namespace Optimized.Reports { using System; using System.ComponentModel;

using CrystalDecisions.Shared; using CrystalDecisions.ReportSource;

using CrystalDecisions.CrystalReports.Engine; public class SalesDirectory : ReportClass {} [System.Drawing.ToolboxBitmapAttribute(typeof(CrystalDecisions.Shared.ExportOptions) ,


}

"report.bmp")] public class CachedSalesDirectory : Component, IcachedReport {}

Extension Methods for Report


What you will often find is that if the report is not properly authenticated, it will prompt the user everytime the report is loaded. What we will do here is leverage the ConnectionInfo object and create an extension method for the Tables inside the report.
using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared; namespace Core.Util { public static class Extensions { /// <summary> /// Set Crystal Report ConnectionInfo. /// </summary> /// <param name="tables">CrystalDecisions.CrystalReports.Engine.Tables</param> public static void SetLocation(this Tables tables) { ConnectionInfo connectionInfo = new ConnectionInfo(); connectionInfo.ServerName = ConfigurationManager.AppSettings["CrystalServerName"].ToString(); connectionInfo.DatabaseName = ConfigurationManager.AppSettings["CrystalDatabaseName"].ToString(); connectionInfo.UserID = ConfigurationManager.AppSettings["CrystalUserID"].ToString(); connectionInfo.Password = ConfigurationManager.AppSettings["CrystalPassword"].ToString(); connectionInfo.IntegratedSecurity = Convert.ToBoolean( ConfigurationManager.AppSettings["CrystalIntegratedSecurity"]); foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables) { TableLogOnInfo tableLogOnInfo = table.LogOnInfo; tableLogOnInfo.ConnectionInfo = connectionInfo;

table.ApplyLogOnInfo(tableLogOnInfo); } }
} }

In the example the values are kept in the WebConfig, but it is not a requirement. If the namespace for the Extension class and the pages that have the controls are not the same-it must be added in order for the method to show. Putting It Together Now that we have our SalesDirectory report with the wrapper and utility class, we are going to create a page to hold a report viewer. Below is the code listing for adding the directive to the page and immediately after the declaration for the control.
<%@ Register assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" namespace="CrystalDecisions.Web" tagprefix="CR" %> <CR:CrystalReportViewer ID="CrystalReportViewer" runat="server" AutoDataBind="true" Visible="true" />

With the report viewer in place the last thing we need to do is create and bind the report to the viewer. READ MORE >> http://www.c-sharpcorner.com/UploadFile/felipe9875/5533/ Email ThisBlogThis!Share to TwitterShare to Facebook Posted under : Asp .net If you like this post then consider sharing it with others.

0 comments: Post a Comment Newer Post Older Post Subscribe to: Post Comments (Atom)

Blog Archive

2011 (110)

o o o o

May (10) April (18) March (21) February (30) Paging for First, Next, Previous and Last in gridv... Insert HINDI Font from ASP.NET web page to SQL Ser... Get Child window values to parent using javascript... How to go back to the same position in a given vie... How to apply/change CSS dynamically HTTP Post from SilverLight application to a REST S... Using the AnyButton to Create Dynamic Image Button... Nested Repeater : Display hierarchal data in web f... ASP.Net Page Navigation using Workflow 4.0 How to show Alert and Confirmation Message box in ... Working with CSS Manage Ads with AdRotator Control in ASP.NET 2.0 Outlook with .NET 2.0 On-line Address Book in ASP.NET 2.0 Calling WCF Duplex service in Silverlight ImageMap control in ASP.net and Defining Hot Spots... Read All Notepad Files in a folder and merge all n... Optimizing Crystal Reports for Asp.Net Extension Methods in C# Adding Cloud Service project to existing ASP.Net W... How to Access/Manipulate HTML Elements/Javascript ... How to Create Excel file in ASP.NET C# How to Show PDF file in C# Understanding Isolated Storage in Silverlight Working with Isolated Storage in Silverlight Working with Routed Event in Silverlight Importance of TimeZoneInfo class in ASP.NET JavaScript and CSS Minifier Applying Custom Filtering with AutoCompleteTextbox... Silverlight OOB Application Installer January (31)

2010 (53)

2010 Advanced Dotnet Tutorial | 27,400

You might also like