Thursday, December 25, 2008

Integrating SQL Server Reporting Services with ASP.NET 3.5

Today, I am going to discuss Basic and Simple demo on Integration of SSRS with ASP.NET 3.5, I am assuming that readers have already have installed Visual Studio 2008, SQL Server 2008 [with Reporting Features] and Report Builder 2.0

Just to have idea those who are new to SSRS, SQL Server Reporting Services 2008 are in a way unique due to their architecture, Now we have a separate block of Tablix, Tablix is combination of Table + Matrix [In short, Table + Matrix = Tablix].

Since Microsoft have great association with .NET Dundas visualization tool, so now you can implement Graphs, Gauges in your reports with ease and with much more Rich UI, which you can create using tools like Report Builder 2.0.

I am showing this example with Northwind Database. I assume you are comfortable with Report Builder 2.0 to design your report.

What I would like to discuss over here before we go for ASP.NET integration is how we can enhance performance of Report say for like getting 1 lac or more records, So We can Implement Cache for the same.

Step 1 : Cache the Report for better Performance

Start your Reporting Manager instance [ You can find URL of that in your Reporting Services Configuration], Once you add Report to your directory, Click on Report and locate “Properties” tab, Click on Properties and you will find Cache settings in “Execution” option on left hand side.

SSRS1

SSRS2

Note : You can only set Cache if and only if you provide valid credentials for “DataSources” option just above “Execution” option, else it will not allow you to implement Cache.

Once you apply Cache, Test report in Report Manager, Close the Report Manager instance and Start Visual Studio 2008

I tried from 60k to 1 lac records and it worked out very smoothly, so I personally find this feature as “Edge” over Crystal Reports.

Step 2: Integrate Report with ASP.NET 3.5 and Send parameters to Report from ASP.NET Web Application

You already have “MicrosoftReportViewer” Control in your Visual Studio 2008 under Reporting tab on Toolbox.

I am now taking one instance of ReportViewer with one TextBox to accept paramaters and one command button to submit that parameters to Report.

ASP.NET Code :

<div>
   <table>
       <tr>
           <td>Enter Customer ID: </td>
           <td><asp:TextBox Width="180" runat="server" ID="txtparam"/></td>
           <td><asp:Button Text="Show Report" ID="btnSubmit" runat="server" onclick="btnSubmit_Click" /></td>
       </tr>
   </table>  
   <rsweb:ReportViewer ID="rptvw" runat="server" Height="600px" Width="800px"></rsweb:ReportViewer>
   </div>

C# Code :

using Microsoft.Reporting.WebForms;

….

protected void btnSubmit_Click(object sender, EventArgs e)
    {
        rptvw.ProcessingMode = ProcessingMode.Remote;
        rptvw.ServerReport.ReportServerUrl = new Uri("http://localhost/reportserver");
        rptvw.ServerReport.ReportPath = "/Northwind/NewNorthwind";

        ReportParameter[] param = new ReportParameter[1];
        param[0] = new ReportParameter("CustomerID", txtparam.Text);
        rptvw.ServerReport.SetParameters(param);

        rptvw.ServerReport.Refresh();
    }

SSRSOP

Explanation of Code :

Currently, I am sending only one parameter as “CustomerID” to my Report. SSRS basically supports two Processing Modes as “Remote” and “Local”, Since there is no support available for “Local” mode, Developers are suppose to fetch reports directly from Reporting Server, So I have set mode as “Remote” and have set those paths which you can see in code.

This is most simple way to integrate SSRS with ASP.NET, some other ways are using WebService [WSDL which RS exposes], but I personally find that time consuming and bit difficult compare to this one.

Hope this will give you idea about how you can enhance performance of your report with implementation of Cache and how easy is integration with ASP.NET 3.5 Web Application.

On ending note..

SSRS now give you power to export your reports in various formats like XML,PDF,CSV,TIFF and other Standard Office document formats, Also Report Builder 2.0 now implements most of the Office features like Zooming and Ribbon Controls for design and editing etc.

Vikram.

Thursday, December 11, 2008

IIS 7 : Reports and Database Manager features.

First of sorry for so much delay in putting blogpost, I am out of my hometown for some work so hardly get time to blog and Internet access is sporadic.

Today I am going to share with you the simply amazing tool of IIS7. It is add-on to IIS7 but it is very much handy especially for those who monitor performance and into Website management. Those people along with others now can have complete Drill-down reports from IIS7 which can be export to CSV,HTML,XML etc.

Also many of the developer find hectic to log on to SQL Server instance for firing queries and modifying Table data and Schema. Now IIS 7 provides handy add-on of Database Manager, let’s discuss it one by one.

For this you need Admin Report Kit for IIS7 (ARKIIS), find it here :

http://www.iis.net/downloads/default.aspx?tabid=34&g=6&i=1782

Download and install it, it won’t ask you for any other dependency, all you need is IIS7 installed in place.

IIS Reports :

Once you installed it, you will find it like this once you start IIS7

image1

Click on IIS7 Report [Assumption : You have at least one website hosted on IIS7]

image2

You will get “Get Report” option and “Filters” to view specific reports from two specific Date intervals.You will also find Export option over here, as we discuss above, you can export it in various formats, along with that you have Pie and Line as other options of Chart, Column is default.

image3

As you can see above, This is how you will get report, drill down to date and categories like which page,script or resource had maximum hits etc. in proper grid as well as graph format. Beside this there are several options too which you can see in image below.

image4 Other details of visit you can see in Grid Format just below Chart like this.

image6

So, don’t wait, download it and start using, it is a great tool !

Database Manager : 

As we have discuss above, now Database Manager is built-in in IIS7, it is very similar to SQL management studio [Looks wise] and other hosting consoles which we get on hosting sites for Database.

image7

Here you can create Tables with Schema, Stored procedures and you can play around with it, lots of general Data Operation functionalities are provided.

image8

image9

Hope this article will encourage you to move from IIS6 to IIS7 and make use of these great tools, I will back with loads of new stuff on ASP.NET and Silverlight in coming days, so I am back here again, do let me know your suggestions and feedback.

Vikram. 

Tuesday, December 2, 2008

Silverlight 2 : Playing Multiple Videos with One Media Element

You may think that Playlist is always good option, though it is, sometimes it takes too much time to develop and test, so for small amount of video files, you can do play multiple videos by making use of Media_Ended() event.

I found many new things while doing demo of this, First surprise was that I was not able to declare “var” globally, I am researching on it why it had happened, Hashtable and ArrayList are seems to be not allowed in Silverlight though they are normal collections with .net framework, a surprise for me !

Code goes here :

public partial class Media : UserControl
    {


        int i = 1,j;
        Dictionary<int, string> temp = null;


        public Media()
        {
            InitializeComponent();

            temp = new Dictionary<int, string>();

            temp.Add(1, "http://localhost/Video1.wmv");
            temp.Add(2, "http://localhost/Video2.wmv");
            temp.Add(3, “http://localhost/Video3.wmv”);

            j = temp.Count;

            this.Loaded += new RoutedEventHandler(Media_Loaded);
            MasterMedia.MediaEnded += new RoutedEventHandler(MasterMedia_MediaEnded);
        }


        void MasterMedia_MediaEnded(object sender, RoutedEventArgs e)
        {
            if (i == j)
            {
                MasterMedia.Stop();
            }
            else
            {
                i++;
                MasterMedia.Source = new Uri(temp[i], UriKind.Absolute);            
            }
        }


        void Media_Loaded(object sender, RoutedEventArgs e)
        {
            if(i == 1)
              MasterMedia.Source = new Uri(temp[i], UriKind.Absolute);            
        }
}

As I told you that Hashtable and Arraylist was not in position so I have declare a “Dictionary” over here globally. I am adding URLs of media in it along with a key as integer so as to recognize what needs to be play. That can be track using global variables i and j.

This is the simplest way to play media in loop and you will observe the great usage of Media_Ended() event over here, how every time its getting fired. Do let me know your feedback on this if there are any more smart ways to do so.

Vikram.

Saturday, November 29, 2008

Terror attacks on Mumbai : India’s 9/11

This blog post is tribute to those 14-15 Brave Mumbai Police Cops, NSG Commandos, Army personals and Staff of Taj and Oberoi Hotel,Nariman House who lost their life, who got very deadly injuries and who lost their friends and family members in a brutal and dirty attack by Terrorist on India’s biggest Metro and Capital of Maharashtra “Mumbai”.

This I personally think was most deadly attack ever happen anywhere in the world, more worst than 9/11 happen in US.160 innocents Dead and more than 300+ injured badly, more than 50 hours of gun and grenade battle at 10 different places of Mumbai.

1 INDIA-MUMBAI/SHOOTINGS
2 4

[Photos from various Blogs and News updates on Internet]

Big loss to our nation, but Indian and local government fight it out very well and finally able to wipeout terror out of Mumbai finally on early morning today along with unforgettable contribution of Police and Army of India.

I Pray to God for all those who lost their lives to protect us,protect nation, I pray for those who lost their love ones..May God Bless !

Vikram.

Monday, November 24, 2008

DeepZoom with PhotoZoom and Silverlight.live.com

I have already wrote article on How to build DeepZoom with DeepZoom Composer, I know after that another version of DeepZoom came up, but changes are not that much to discuss,still you can see old one for reference, This is now the depolyment part or you can say extension to my old article at :

http://pendsevikram.blogspot.com/2008/07/deep-zoom-with-silverlight-2.html

First thing to note that, we are discussing first "PhotoZoom" which practically don't require any DeepZoom Composer and even those users who are not aware of DeepZoom, now even they are getting empower with PhotoZoom, so they will be also now able to create DeepZoom on fly.

What is PhotoZoom??

"PhotoZoom makes it easy for anyone to create zooming albums from their uploaded photos. It is an experimental site, developed at Microsoft, that uses the Deep Zoom technology in Silverlight 2."

PhotoZoom is FREE !! :)

Step 1: Visit http://photozoom.mslivelabs.com/ ,hope you already have Live ID, if not please get one, its worth doing so.

Step 2: Once you sign-in with your Live ID, you will get :

zoom1

Step 3: Upload Snaps/Photos using Browse button,Note on thing over here that You may need Silverlight Runtime, since I saw that Once you click on "Browse" button,it loads Silverlight File Upload app, so you may need runtime here if you don't have it.

Also PhotoZoom have provided facility to get snaps from RSS feeds/Atom, you can also Email or even Delete Album.

zoom2

Step 4: Upload all the snaps, if you wish to give title to each snap, you can simply click on any of the snap and give caption/details over there like :

zoom3

One thing to note here which I have highlighted in Red box, Can you see it creates what?? ..yes DeepZoom Image file. see extention  is 1.xml, so each images goes to collection like we have it in DeepZoom [ I don't mind to say this PhotoZoom is nothing but Web Version of DeepZoom Composer ;-) , Great job Microsoft !! :-) ] 

Step 5 : You are ready with DeepZoom, can't see that? ok, then just you need to click on "View Zooming Album" option on right side of the template and you are totally ready with DeepZoom!!

zoom4

You can see output instantly on the same page :

zoom5

This is how it looks like, Observe topmost section with "+ -"  sign for zooming and it also shows how much it has zoom with third button next to "-", If you observe bottom most red block, Yes ! you get <iframe> so you can plug and play it anywhere you want, isn't this much simpler and friendly? do let me know your feedback !

[Between, snaps which you looking at in above snaps are from my 1st Session on Silverlight at Pune Developer Conference 2008 :) ]

DeepZoom with Silverlight.live.com

Now in second section of this article as we started with Silverlight streaming and DeepZoom, so with referecne to that,here I assume that you have already followed all steps of my previous article at :

http://pendsevikram.blogspot.com/2008/07/deep-zoom-with-silverlight-2.html

So once you have set of images ready, go to Silverlight.live.com site to host that DeepZoom and to stream it across.

If you are not aware of Silverlight.live.com, you can read my old article at :

http://pendsevikram.blogspot.com/2008/10/silverlight-live-streaming.html

Here you need to follow same procedure, but this time with xap, you need to also copy "GeneratedImages" folder from DeepZoom along with one Manifest.xml file whose contents are like :

<SilverlightApp>
  <version>2.0</version>
  <source>VikramDeepZoom.xap</source>
  <width>400</width>
  <height>400</height>
  <background>gray</background>
  <isWindowless>false</isWindowless>
</SilverlightApp>

Zip this xap,xml file and GeneratedImages folder and directly upload it as Application on Silverlight.live.com, then follow the same old procedure of editing it there, again you will get scripts and iframe code generated over there, so you can plug that and you are ready with your DeepZoom Streaming application.

Hope this will be useful for you and encourage you to convert all your photos which you store on drive to a classy Online DeepZoom Album !!

Vikram.

Wednesday, November 19, 2008

Silverlight 2 : Master Pages implementation in Silverlight 2

The title of the post may be sound funny, and it was fun since many arguments did happen while whole process of this implementation.

There are several post made by several expertise and enthus on the same, Basically a big question is do we need this?? since all Silverlight application however powerful they are, they are still run under umbrella of ASP.NET. I agree on this !

But there might be some business scenarios, if not now then might be in future, so keeping this vision in mind, here I am showing you a very easy way to implement Master Page concept in Silverlight, It is not difficult code and neither we need to touch App.xaml file..here I go :

SLMasters1

This is what I want to build, You can see header part "Explore .NET with Vikram Pendse" followed by buttons [Third Party Silverlight Control may provide you good Menu bar too] and footer as "Microsoft .NET for everyone !!".

Now once I click on Home or RSS or any other button, Idea is to keep header and footer as it is and load other page contents in middle blank portion as content if we assume this page as Master page. so the required XAML code is,

XAML Code :

<Grid x:Name="LayoutRoot" Background="AliceBlue">
        <Button x:Name="btnBlog" Height="22" Width="67" Content="Blog" Margin="161.5,36,171.5,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height" Click="btnBlog_Click"/>
        <Button x:Name="btnRSS" Height="22" Width="67" Content="RSS" HorizontalAlignment="Left" Margin="94,36,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height" Click="btnRSS_Click"/>
        <Button x:Name="btnHome" Height="22" Width="67" Content="Home" HorizontalAlignment="Left" Margin="27,36,0,0" VerticalAlignment="Top" d:LayoutOverrides="Width, Height" Click="btnHome_Click"/>
        <Button x:Name="btnDownload" Height="22" Width="67" Content="Download" Margin="0,36,104,0" VerticalAlignment="Top" HorizontalAlignment="Right" d:LayoutOverrides="Width, Height" Click="btnDownload_Click"/>
        <Button x:Name="btnAbtus" Height="22" Width="67" Content="About Us" Margin="0,36,37,0" VerticalAlignment="Top" HorizontalAlignment="Right" d:LayoutOverrides="Width, Height" Click="btnAbtus_Click"/>
        <TextBlock Height="23" Margin="94,8,116,0" VerticalAlignment="Top" Text="Explore .NET with Vikram Pendse" TextWrapping="Wrap" Foreground="#FF000000"/>
        <StackPanel x:Name="stk" Width="400" Margin="0,66,0,30"/>

        <TextBlock Height="23" Margin="106,0,104,3" VerticalAlignment="Bottom" Text="Microsoft .NET for everyone!!" TextWrapping="Wrap" Foreground="#FF000000"/>
    </Grid>

Here you can see that I am using "stk" as my contentplace holder stack where I will load the other pages on each corresponding button clicks, rest of the code is just routine design.

C# Code :

namespace SL_MasterPages
{
    public partial class Page : UserControl
    {
        int var = 0;

        public Page()
        {
            InitializeComponent();
        }

        private void NavigateRequest(int w)
        {
            if(w>0)
            {
                switch(w)
                {
                    case 1:  stk.Children.Add(new RSS());
                             break;
                    case 2:  stk.Children.Add(new Home());
                             break;
                    default: this.Content = new Page();
                             break;
                }
            }
        }

     private void btnRSS_Click(object sender, RoutedEventArgs e)
        {
            stk.Children.Clear();
            var = 1;
            NavigateRequest(var);
        }

        private void btnHome_Click(object sender, RoutedEventArgs e)
        {
            stk.Children.Clear();
            var = 2;
            NavigateRequest(var);
        }
   }
}

Here I have implemented for first two buttons, I am setting and resetting flag values for each button with a global variable as "var", and I am clearing stack in each click so as to keep contents dynamic in nature.

I have written a "NavigateRequest" sub proc which takes integer value just for switching between two pages. So this is very simple way to switch between the pages from one to anothet and result will be like..

SLMasters2

SLMaster3

Now you can see messages like "You are on Home Page", "You are on RSS Page", these you will get once you click on corresponding button on Main Header and you also have observed now that header and footer are constant in all case like Master Pages in ASP.NET

Hope this will encourage you to go ahead and explore it more and apply the same in all possible business scenarios which need this kind of implementation.

Feedback and suggestions for this are most welcome, I will be more than happy to know if there are any more simple and good way to implement such things.

Vikram.

Ultimate Windows Tweaker is here : Great job by Pune MVP !!

Another landmark is set in Indian IT and a proud moment for Pune City.

City based MVP Anand Khanse did a wonderful job. A free Ultimate Windows Tweaker which is a Tweak UI Utility for tweaking and optimizing Windows Vista, 32-bit & 64-bit is now available to whole world !!

It can simply be downloaded and used as a portable application to customize your Windows Vista to meet your requirements.

This was made public in recent South Asia MVP Open Day 2008 in Goa,India in presence of 60+ MVPs across Asia and  It was made public by Howard Lo, Microsoft's Regional Team Manager (APAC), in the prescense of Abhishek Kant, South Asia – MVP Lead and Abhishek Baxi, MVP Program Specialist.

You can check here for more details and download :

http://www.winvistaclub.com/Ultimate_Windows_Tweaker.html

It is very well design,developed and tested tool, if you have Windows Vista and If you don't have this tool, then you are missing something big thing !! so don't waste time..go there and download it..convey this to your other friends in communities and Vista buddies !!

Note : WinVistaClub is simply amazing portal for all kind of information on Windows Vista and its services, so do check that portal, for this, I have already added a WinVistaClub Link/Button on right side of my blog.

Vikram.