This a technical document about the Crystalizer application, you can also find a functional overview describing how-to’s and the main features of Crystalizer.

The big idea

Crystalizer architecture

Client side

On a high level Crystalizer has a Silverlight application which is hosted either in a website or inside a WinForm. In the Webhost version there is a standard html or aspx page which contains the Silverlight control inside which the Crystalizer applet is called. In the Winhost version the winform has a webbrowser control in which some fixed html is rendered and which also calls the Silverlight application.

Server side

In the winhost version the WCF service which delivers data to the Silverlight application acts also as a webserver. Technically it amounts to a service with two interfaces and two endpoints, both delivering data through HTTP. This situation is possible because the WCF service is a RESTful service and data is requested by means of URLs like http://localhost:8000/dataservice/Person.

In the webhost version the webserver serves HTML but the CrystalService.svc serves the data. The webserver can be either the development server of VisualStudio or IIS.

It’s important to note that in either hosting solution the Silverlight applet doesn’t need cross-site data access. While it’s possible to host the WCF service and the HTML webserver on different addresses/ports, in practice it’s a cumbersome operation.

Visual Studio solution

VS organization

The organization of the Visual Studio solution consists of four main parts; the Silverlight application (Crystalizer.One), the data access layer (Crystalizer.Data), the website hosting version (Crystalizer.OneWeb) and the WinForms hosting version (Crystalizer.WinHost).

On a file level there is directory called ‘assemblies’ which contains all the necessary assemblies for the various projects.

Crystalizer assemblies

Crystalizer WCF reference

Inside the Crystalizer Silverlight project there is a WCF reference which can generated by either the win or the web project. The WCF services in both projects are identical, so if you want to re-generate the proxy you can use either one. If you set the web project as start-up project Visual Studio will automatically start the development webserver and you can browse to the WCF service via http://localhost:5940/CrystalService.svc. Note that the port is set to fixed 5940 in the properties of the project. You can change this port but note that it’s par of various settings (more about it below). If you run the WinHost version the WCF service will be hosted (so-called ’self-hosted’ WCF service) and is accessible via http://localhost:8000/dataservice/

Configuration details

Crystalizer Silverlight application

The applet doesn’t need any configuration, it accesses the necessary initialization by means of its host (see below).

The Webhost

In the website the following places contain configuration settings: the web.config, the Crystalizer.OneTestPage.html and the Crystalizer.OneTestPage.aspx.

In the web.config you will find a section entitled ‘Crystalizer.OneWeb.Properties.Settings‘. This section actually corresponds to the Properties.Settings class in the Properties folder of the project. These settings define how the CrystalService.svc connects to the database. Note that they do not set how the Silverlight application connects to the WCF service, these settings are part of the web pages.

The settings below should be set depending on whether you wish to use MySQL or SQL Server to serve the data.

  • DataServer: this can be either MsSQL or MySQL and sets the database to be used.
  • MySqlServer: the name of the MySQL server
  • MySqlDatabase: the name of the MySQL database
  • MySQLUser: the user which will be used to connect to MySQL
  • MySQLPassword, the password for the MySQLUser
  • MsIntegratedSecurity: true/false, whether to use integrated security to connect to MsSQL
  • MsSQLServer: the name of the SQL Server
  • MsSQLDatabase: the name of the database on SQL Server
  • MsSQLUser: the SQL Server user
  • MsSQLPassword: the password for the MsSQLUser

If you look at the code of the CrystalService.svc.cs file you will easily recognize how these settings are use to build up a connection string. Obviously, you can alter things in function of your needs (e.g. an additional non-standard port number to SQL Server might be necessary).

The Silverlight application knows how to connect to the WCF service via the initial paramters of the Silverlight control. In bot the HTML and the ASPX page you will find the InitParameters:

InitParameters="serviceurl=localhost:5940/CrystalService.svc, startatom=..."

The serviceurl specifies the url (without a final ‘/’ and the ‘http://’ prefix) to the data WCF service. The startatom is the identifier to the initial node which will be loaded. If the startatom is left blank the application will start with and empty diagramming surface.

The WinHost

The WinForm application hosts both the webserver and the data service in the same WCF service. This service can listens by default to port 8000. This setting can be changed in the app.config file while the other settings are similar to the ones described above for the webhost.

If the Silverlight application doesn’t serve data one should in the first place check whether the service is responding. The data service can be called at http://localhost:8000/dataservice and it should reply with the following

 
    Default
 
      Bindings
 
 
      Document
 
 
      Person
 
 
      Structon
 
 
      DocumentView
 
 
      PersonView

In addition, the WCF data service can be interrogated in a RESTful fashion and the request http://localhost:5940/CrystalService.svc/Person should be answered with something like the following:
Sample WCF data service response on a low level.

The database

You can use either MySQL or SQL server as a RDBMS backend for Crystalizer. In the Crystalizer.Data project you will find a directory which contains scripts for both systems. These scripts contain both structure and sample data, but the sample data insertions can be easily removed from the script if you prefer to start with a blank database. To test the setup it’s however advice to launch the database initially with data included.

The data access layer

The data access layer is implemented by means of Microsoft’s ADO.Net’s Data Services (formerly called ‘Astoria’). This mechanism allows one to easily implement a RESTful WCF service on top of the Entity Framework.
In the Crystalizer.Data project you will find two EF implementations, one for MySQL and one for MsSQL. Of course, if you only need one of the two it’s quite OK to delete the other one.

EF surface to the database.

Unless you start changing/adding tables to the database, the EF need no configuration. You should in particular remark that the connection string which the EF needs to connect to the database is not in the Crystalizer.Data project and not in the EF design sureface. It’s build dynamically in the WCF service and handed over to the EF at runtime (see the C# implementation code of the CrystalService.svc service).