Introducing ImageAbsolutePath Feature in SqlReportViewer

The recently released service pack includes a number of enhancements to the SqlReportViewer control. One of the enhancements is the addition of ImageAbsolutePath property. This property is introduced for use in scenario involving multiple server environment.

In the initial release, ImageAbsolutePath is inferred from ImageVirtualPath. In this case, the control always assume that the SqlReportViewer and SQL Reporting Service is located on the same server. However, based on customer feedback, scenarios involving multiple server location is common in enterprise application deployment.

For example, the SqlReportViewer service is hosted on ssrs-1 server while the SqlReportingService is located on web-1. The scenario requires user to set both the ImageVirtualPath and ImageAbsolutePath properties, because the inferred absolute path from a remote location will not return a correct result. A code snippet to address such scenario would be:

<Intersoft:SqlReportViewer x:Name="ReportViewer1"
	ReportProxyHandler="http://web-1/SqlReportViewerHandler.ashx"
	ReportName="/Northwind Reports/SalesOrderInvoice"
	ReportServer="http://ssrs-1/ReportServer"
	ImageVirtualPath="http://ssrs-1/TempImages/"
	ImageAbsolutePath="C:\inetpub\wwwroot\TempImages" />

The above code snippet assumes that the report images will be stored to the C:\inetpub\wwwroot\TempImages folder on the ssrs-1 server and virtually hosted on http://ssrs-1/TempImages. In this case, you need to configure ssrs-1 as the image server by creating the TempImages virtual directory.

If opening up the SQL report server as public web server is not option, simply set the ImageVirtualPath property to the web-1 server. Everything else should remain the same. In this case, you need to configure the IIS in the web-1 server by creating a virtual directory and map it to the network path in the ssrs-1 server.

I hope this post gives you insights on the new ImageAbsolutePath feature and how it can be used along with other properties to achieve advanced deployment scenarios. Any questions or feedback are welcomed.

For the complete list of enhancements and fixes in the latest ClientUI release, please visit our support page.

Regards,
Glenn Layaar

Posted in 2011 R2, Development, Tips and Tricks | Tagged , , , , , , | Leave a comment

Working with SqlReportViewer Parameter

The latest ClientUI release comes up with a host of new amazing controls that have been awaited by many developers. One of the new controls is SqlReportViewer, which is used to display SQL Reporting Service reports in Silverlight or WPF applications.

In this blog post, I will share how to work with the report parameter features in SqlReportViewer, e.g. fill the parameter with default value, hide some parameters, and use custom validation to validate the inserted parameter value.

Consider this scenario, we have a holiday request form that a user needs to fill. The report by default requires these parameters to be filled:

  • Company Name
  • Username
  • First Name
  • Last Name
  • Start Date
  • End Date
  • Holiday Name

In this scenario, the Silverlight application will retrieve the Company Name, Username, First Name, and Last Name based on the user login information. Since these information are already predefined, SqlReportViewer has the capabilities to hide and automatically fill these parameters value.

As shown in the above image, Company Name, Username, First Name, and Last Name by default has been set programmatically. Company Name and Username is hidden as well, since we would like the value not to be modified by the user.

In order to achieve this behavior, you need to bind the ReportParameters property to a ObservableCollection<ISqlParameterMetadata> using TwoWay mode.

<Intersoft:SqlReportViewer ReportParameters="{Binding ReportParameters, Mode=TwoWay}"
x:Name="ReportViewer1" />

The default value and Visible property is modified during ObservableCollection<ISqlParameterMetadata> collection changed event, see the code snippet below.

void _reportParameters_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
    if (e.NewItems != null)
    {
        foreach (object paramObj in e.NewItems)
        {
            SqlReportParameterMetadata sqlParamObj = paramObj as SqlReportParameterMetadata;
            if (sqlParamObj != null)
            {
                switch(sqlParamObj.Name)
                {
                    case "CompanyName":
                        sqlParamObj.Value = this._companyName;
                        sqlParamObj.Visible = Visibility.Collapsed;
                        break;
                    case "Username":
                        sqlParamObj.Value = this._userName;
                        sqlParamObj.Visible = Visibility.Collapsed;
                        break;
                    case "FirstName":
                        sqlParamObj.Value = this._firstName;
                        break;
                    case "LastName":
                        sqlParamObj.Value = this._lastName;
                        break;
                }
            }
        }
    }

    OnPropertyChanged("ReportParameters");
}

public ObservableCollection<ISqlParameterMetadata> ReportParameters
{
    set
    {
        if (_reportParameters != value)
        {
            _reportParameters = value;
            _reportParameters.CollectionChanged += new System.Collections.Specialized.
                NotifyCollectionChangedEventHandler(_reportParameters_CollectionChanged);
            OnPropertyChanged("ReportParameters");
        }
    }
    get
    {
        return _reportParameters;
    }
}

For simplicity, the sample is using a static value to retrieve the default parameter value.

this._companyName = "Intersoft Solutions";
this._userName = "jdoe@intersoft.com";
this._firstName = "John";
this._lastName = "Doe";

A custom validation which does not allow StartDate earlier than EndDate has also been provided.

This behavior is achieved by using a custom SubmitParameterCommand and binding IsReportParameterError property to a boolean property with TwoWay mode. Setting IsReportParameter property to False aborts the report execution to the reporting services.

<Intersoft:SqlReportViewer Intersoft:DockPanel.IsFillElement="True" x:Name="ReportViewer1"
    IsReportParameterError="{Binding IsReportParameterError, Mode=TwoWay}"
    SubmitParameterCommand="{Binding SubmitParameterCommand}" />

During command execution, the code below will validate if the EndDate is later than StartDate. It will also set the IsReportParameter to False if the validation fail.

public ReportSampleViewModel()
{
    _submitParameterCommand = new DelegateCommand(ExecuteSubmitParameter, CanSubmitParameter);
}

public DelegateCommand SubmitParameterCommand
{
    get { return _submitParameterCommand; }
}

private bool CanSubmitParameter(object parameter)
{
    return true;
}

private void ExecuteSubmitParameter(object parameter)
{
    ObservableCollection<ISqlParameterMetadata> sqlParams = parameter as ObservableCollection<ISqlParameterMetadata>;

    if (sqlParams != null)
    {
        ISqlParameterMetadata sqlStartParam = sqlParams.Where(x => x.Name == "StartDate").FirstOrDefault();
        ISqlParameterMetadata sqlEndParam = sqlParams.Where(x => x.Name == "EndDate").FirstOrDefault();

        if (sqlStartParam != null && sqlStartParam.Value != null &&
            sqlEndParam != null && sqlEndParam.Value != null)
        {

            DateTime startDate = (DateTime)sqlStartParam.Value;
            DateTime endDate = (DateTime)sqlEndParam.Value;

            if (endDate.CompareTo(startDate) > 0)
            {
                this.IsReportParameterError = false;
                sqlStartParam.ClearError("Value");
            }
            else
            {
                this.IsReportParameterError = true;
                sqlStartParam.SetError("Value", "Start date must be earlier than End date");
            }
        }
    }
}

Here is the link to the sample project and the link to the RDL used in this sample.

Conclusion

In this post, I have discussed the report parameter feature in SqlReportViewer. The feature allows you to insert default parameters value, hide parameters, and use custom validation to validate the parameter. If you would like to learn more about SqlReportViewer, please see SqlReportViewer Overview.

As an extra note, hiding parameter feature is an enhancement in the latest SqlReportViewer build and requires the latest ClientUI hotfix.

SqlReportViewer is available in the latest 2011 R2 release which you can download here. If you have questions or feedback regarding SqlReportViewer or other ClientUI controls, feel free to post them to our community forum.

Regards,
Glenn Layaar

Posted in 2011 R2, Development, Products, Tips and Tricks | Tagged , , , , , , | Leave a comment

Native Silverlight 5 Support and 100+ Enhancements

Just a month ago, the Silverlight team has finally released the long awaited Silverlight 5. The latest Silverlight release simply signals that the technology is still of interest by huge number of developers. With dozens of exciting features in Silverlight 5 such as full trust support for in-browser apps, vector printing support, 64 bit support and hundreds more, it’s obvious that Silverlight will still be the preferred line-of-business application platform for many years to come.

Ever since Silverlight 5 was released, we’ve been bombarded with emails and forum posts asking when we will upgrade our tools to support it. And I’m pleased to answer that the day is today. You can download WebUI Studio 2011 R2 Service Pack 1 here which is a free upgrade for all existing subscribers.

Speaking about Silverlight 5 support, we shipped not only about “compatibility” support with the Silverlight 5 runtime, but to the extent of “native” Silverlight 5 support where we improved many areas of our components to leverage the new features introduced in Silverlight 5. Once you installed the service pack, noticed that ClientUI assemblies for Silverlight 5 are now available in the separate folder.

Among the most significant enhancements is the vector printing support. All document viewer lineup in ClientUI – such as Fixed Document Viewer, XPS Document Viewer, Flow Document Viewer, and SQL Report Viewer – now automatically leverage vector printing by default, and fallback to the bitmap printing if unsupported by the printer.

The Flow Document Viewer has been significantly enhanced to support the improved graphic stack introduced in Silverlight 5 which enables the images to dynamically loaded in different UI thread while at the same time maintaining the layout consistency.

Upgrading your existing project to Silverlight 5 is as easy as few clicks away – thanks to the seamless integration to the Silverlight 5 developer tools. Simply bring up the project properties and change the Silverlight target version to Silverlight 5. Once you ok’ed the changes, Visual Studio will refresh the project’s references and automatically pick up the Silverlight 5 version of ClientUI assemblies. To ensure that your project is now upgraded, select a ClientUI assembly and press F4 to see the assembly properties, as shown in the following figure.

Silverlight 5 assembly

Note that ClientUI supports side-by-side development with Silverlight 3, Silverlight 4 and Silverlight 5 – by far the industry’s most comprehensive toolset for Silverlight development.

Another major effort that our team have put in this latest release is a brand-new wizard for Silverlight and WPF templates. Previously, some ClientUI templates depend on the installed Silverlight version. Several templates also have to be made separately to target different version of WCF RIA Services (i.e., RTM, SP1 and SP2). In this latest release, the ClientUI project templates no longer depend on the Silverlight version. A single project template now works flawlessly regardless of the WCF RIA Services, see the shot below.

Enhanced ClientUI project templates

For data-driven project templates, you can now choose the target Silverlight version when creating a new project, see the shot below.

Silverlight version target

In addition, the service pack also throws in nearly 100+ enhancements and fixes across all Silverlight, WPF and ASP.NET controls. To see the complete list, please download the release notes here.

So what’re you waiting for? Kick-off the new year with this exciting release, and build some amazing apps fast.

Note: Existing customers can also download the service pack from Intersoft Developer Network, under My Components link.

Best,
Jimmy Petrus

Posted in Development, Products, 2011 R2 | Tagged , , , , , , | 1 Comment

Intersoft Holiday Offers Extended!

First of all, Happy New Year 2012 to all of you! We wish you peace, happiness, and abundant good health in the New Year.

To start off the New Year, we’re pleased to extend our holiday offers until the end of January 2012. Take an action now to get this opportunity before the offers end! Click here for more information about these great offers.

Visit our online store to get your copy along with the free second copy gift today, or feel free to contact me at martin@intersoftpt.com for any questions.

Thank you and we look forward to serving you in 2012!

Regards,
Martin

Posted in General, Misc, Products | Tagged | Leave a comment

Intersoft 2011 Holiday Offers Start Today

Great news for all of you! During this holiday season, I’m very excited to announce that our most popular holiday offer is back. An interesting offer – Purchase a 1-year full subscription of any WebUI Studio editions, and you’ll get another subscription – free of charge. Of course you can use this moment to send the gift to someone you care the most – your colleagues, friends or relatives – or reserve it for a new team member for the next projects.

This great offer is not forever, means that it is limited only until 31st December 2011. So Hurry up! Don’t miss out this great opportunity! Time to save your money – take advantage of this special holiday offer and get two subscription licenses for the price of one. For more information about this promo, click here.

Visit our online store to get your copy along with the free second copy gift today, or feel free to contact me at martin@intersoftpt.com for any questions.

Thank you and happy holiday!

Regards,
Martin

Posted in 2011 R2, Development, General, Misc, Products | Leave a comment