Skip Ribbon Commands
Skip to main content

Blog

:

Quick Launch

Home
Blog of Mike Moser, containing my thoughts, comments and questions.
December 04
Silverlight 1.0: A Dynamic Control (Part I)

If you're trying to create a control in Silverlight 1.0, Tim Heuer's blog entry Implementing Silverlight Controls in 1.0 is a must and will give a great guide to how my control is laid out.  

Below I have an example of a SL 1.0 control in the very early stages of development. 

I decided to start writing what I call the "wheel" control.  My vision of this control was to replace the GridView's "next page" approach to page navigation with the wheel's "grab and spin" approach.  As my colleague Boon said, while first explaining the idea on the whiteboard, "it's like the wheel on the Price is Right".

Ok, it's actually more like the wheel on the iPhone's Timer, however in it's current version it's not as pretty or sophisticated.

Apple's version:

image

My version 1 control:

Here is a page containing many instances of the control with different settings.

image 

The control can be configured with:

  1. NumberOfRows
  2. Width
  3. ItemHeight
  4. Speed
  5. CanvasLeft
  6. CanvasTop

What I like and don't like:

I like how the instance management of the control is done.  I think this represents the best way to create a true control in SL 1.0.  Remember the test of a true control is to have many instances on the page with different settings, like I have done here.

I like that you can configure the control with speed and number of items and eventually I can make this much more sophisticated.  I find a lot of SL examples are not configurable and reusable controls.

What I don't like is how I have generated Dynamic XAML.  I don't like concatenating SQL and I don't like concatenating XAML.  The XAML should be static and declarative.  This can be accomplished by a better breakdown of control granularity and composition.  I will show this technique in Part II of this post.

What is the control composed of?

  1. The wheel shaped canvas
  2. The two lists (SideA and SideB)
    1. Side A
    2. Side B
  3. The animations
    1. Spin Side A
    2. Spin Side B

The main canvas has a Canvas.Clip with a RectangleGeometry and the appropriate RadiusX and RadiusY are given to give a sense of the wheel's curve.

The two lists are simply a series of canvases stacked one on top if the other.  For this version they have some hard coded text to show movement.

There are two animations and the control knows which list is currently visible.  When the user clicks the wheel, the visible list slides down and the other list slides in view from top to bottom at the same rate the other list slides out of view.  Giving the effect of a spin.

The control's source.

The source can be downloaded here.

The control currently supports the following:

  • Two "sides" of data
  • Click to spin
    • Toggle of sides
      • Side A -> B
      • Side B -> A
  • Settings
    • Number of rows
    • Height of rows
    • Speed of spin
    • Width
    • Position on canvas

Future features:

  • Selected Item Support
  • Data bound (AJAX)
    • Read ahead to cover for asynchronous nature of AJAX calls.
  • Spin both directions
    • Based on mouse movement
  • Spin stops based on data set EOF and BOF
  • Acceleration of spin based mouse movement
  • Events
December 03
Linq and Extension Methods

I am working on making Video.Show a more traditional 3-Tier app.  The architectural approach I am using looks like:

image

*Please note the goal of this project is to keep the application simple and approachable.  This is not a recommendation of an architecture that meets every software project.  This approach meets the goals of this project.

The data layer does not return Linq objects to the other tiers, only model objects are passed between tiers.  So in this type of architecture, you will need mappers, to translate the data objects to your model objects.  Since I want to keep my app simple.  I have decided to take advantage of extension methods, to keep the project and and syntax clean.

So my data object may have a method that looks like this:

image

Notice the "ToModel()" method.  The Linq object that's returned from the query does not by default have this method.  I have mappers for each type I want to convert to my model objects.  That class looks like:

  image

*Note:  The Mapper class needs to be in the same namespace as the Linq object.

October 30
Remote Deployment of 2005 Database Projects

 

I like to use the 2005 Database Project when developing applications. 

image

*note which database project type I selected, there is a difference.

It's great for shops with localized development environments, which include a local database.  Once you are ready to deploy the database to QA, Staging, Production or any server other then local, you will quickly find that the IDE does not support this.

The build process will generate a .sql file in the configured location.

image

Take this file and place it on the target server.  You can then use the sqlcmd utility to execute the file.  You may wonder why you can't just run the sql manually.  The Database Project uses some syntax and features that require this type of execution.  I won't go into detail in this post, however here is an example of some of the syntax.

image

Now go to the local server and run the sqlcmd utility for the file:

image

October 01
Vista and Crystal Reports Server

It seems that NTLMSSP is no longer supported on Windows Vista or Server 2008.  I realized this while installing a copy of Crystal Report Server on my Vista workstation when none of the services would start.

clip_image002

If you look at the service’s dependencies (from Crystal’s utility) you will see:

clip_image004

Here (pages 16-17) is a listing of the workarounds and known issues with BusinessObjects Enterprise XI R2 on Windows Vista:

To get the services to start, you: To use the Central Configuration Manager’s "Browse for computer" functionality on a Windows Vista-based operating system, you must turn on "Network Discovery". To access this setting, navigate to the Control Panel, select Network and Internet, and then Network and Sharing Center.”

However it sounds as though the server components are not supported on Vista: For Business Objects purposes, Windows Vista is considered a client operating system, and, therefore, will only support client tools; such as Crystal Reports, rich and client applications. Windows Vista will not support BusinessObjects Enterprise XI or XIR2 server components or deployments.”

September 28
Data Dictionary Creator and Database Projects

"Data Dictionary Creator (DDC) is a simple application which helps you document SQL Server databases. It stores all the information in Extended Properties, so it's easier to keep the documentation in sync with the database as it changes.”

When it comes to documenting database schema, I like this tool. Trying to manage the extended properties from Management Studio is more cumbersome. It’s especially nice if you are using a Database Project to manage your database development and schema version, since it will manage the extended properties as well (they are just more schema!). Did I mention its open source too! Let’s run through a quick example.

-Open Visual Studio 2005
-Create a new project using SQL Server 2005 Wizard template
-Name it SampleDatabase
image 
-Follow the steps in the New Database Project Wizard, using default settings and Import Database Schema for the database you wish to manage. I have created a database on my local server called Sample, so I created a New Connection to that database and clicked Finish.
clip_image002
-Now run DDC
-Fill out your proper connection string and Connect
clip_image004
-Once you have connected and see the green message, go to Document Database
-Select the table you are interested in documenting, I have selected the Customer table.
clip_image006
-Now that we have done some documentation, let see it integrate into our Database Projects.
-Go back to your project in Visual Studio 2005
-From the main menu, go to Data->Schema Compare->New Schema Comparison
-Select your database, and click OK
clip_image008
-You can see below that the changes are seen and can be reverse integrated back into our Database Project and naturally back into your source control.
image

September 11
Crystal Reports and .Net (My First Day)

I have never worked with Crystal Reports and plan to explore the product from a .Net development perspective. Below is a quote from Crystal Reports .Net Developer Documentation:

"You can host your report in either a Web or Windows application with one of the Crystal Reports viewer controls, or use the extensive API to interact with the report programmatically at runtime."

I plan to focus not on the creation of reports, but the consumption of existing reports defined within Crystal and attempt to expose and interact with them from a .Net Platform.

Create a simple report in Crystal Reports.
Expose the report with an interactive control from ASP.Net.
Stream a PDF version of the report from an ASP.Net using the Crystal API

Before we get started, my environment is:

Windows Vista (IIS 7)
Visual Studio 2005 Team Suite
SQL Server 2005
Crystal Reports XI R2

 

Create a simple report in Crystal Reports

We first need a report to work with. So let's create a very simple report.

Open Crystal Reports

Go to File->New->Standard Report

In the Standard Report Creation Wizard window, select Create New Connection->OLE DB (ADO)

In the OLE DB (ADO) window, select SQL Native Client provider.

Click Next

Server for this example is "." Which represents the my local Sql Server 2005 instance, you should fill out your specific server information and credentials.

Select the Adventure Works database.

Select Integrated Security if it applies.

Click Next

Select Current Connections->Adventure Works->Human Resources->Tables->Employee

Click the Right Arrow Button to add to Selected Tables

Click Next

Add some fields for the report

Click Next

Don't add anything for Grouping, just click Next

Don't add anything for Record Selection, just click Next

Let's add a little color, select Block (Blue)

Click Finish

You should now see the below screen

Go to File->Save

I saved the report to c:\reports\SampleReport.rpt, select your location and remember for later use.

Click Save

 

Make this report available on an ASP.Net site

Now that we have a sample report, we need to get it to the users of our ASP.Net web application.

Open Visual Studio 2005

Create a new ASP.Net Web Application

*I have decided to do this in C#, but of course either language will work.

In your Toolbox, you of you have Crystal Reports Developer Edition installed, you should see tools for Crystal Reports

Select the Design view for Default.asp

Drag and Drop the CrystalReportViewer to the design surface

Uncheck Enable Toolbar

Uncheck Enable Group Tree

In the Choose Report Source drop down, select new report source

Leave the name as CrystalReportSource1

For the CrystalReportSource select Browse

Navigate to the report we created earlier (c:\reports\SampleReport.rpt) and click Open

You should now see your report in the design surface.

Run the web site by clicking the green Start Debugging button.

And there is your report!

 Note: This blog entry is not diving deep into the CrystalReportViewer control, this is just an example to get you started.

 

Stream a PDF version of the report from an ASP.Net site using the Crystal API

Now that we have successfully used the built-in control, let's try using the .Net API provided by Crystal Reports.

First let's add a new Web Form called PDFReport.aspx.

*Add a Reference to CrystalDecisions.CrystalReports.Engine

*Add a Reference to CrystalDecisions.CrystalReports.Shared

Add the code below to our code behind for PDFReport.aspx.cs

 

The ReportDocument is the key to working with the report.

Right Click on PDFReport.aspx and Set as Start Page

Run the web site by clicking the green Start Debugging button.

You should see your report embedded in the browser window!

If you want, you can set the third parameter on ExportToHttpResponse to make the report open as an attachment, which gives the user the ability to Open or Save the report.

 

*note that you may have two options. I am using .Net 2.0 so I will choose the one with "dotnet2" in the path.

 

Conclusion

 

After only a few hours of working with Crystal Reports, it is clear that it is a robust and enterprise solution for report development and delivery with good integration into a .Net development environment. This post is a simple Hello World and the world is huge!

 

Additional Comments

 

As doing this novice research, I noticed a lot of people complaining about a "Logon Failed Error" and I ran across a blog that describes how to fix it on Code Project, this may save someone a lot of research time.

http://www.codeproject.com/aspnet/crCode.asp