Click here to Skip to main content
Click here to Skip to main content
Go to top

Genesis Hybrid Smart Client Framework part V

, 19 Jun 2009
Rate this:
Please Sign up or sign in to vote.
This is part V of a VII part series. This article covers the programming concepts that are involved in writing code for the Genesis Smart Client Framework
Download the latest source code for this article on Code Project (opens in new window)

Download the latest release from Code Plex (opens in new window)

Introduction - Programming Concepts

I've been waiting all weekend to get to this article. This article is going to explain the programming that has to be done in order to utilize the Genesis Smart Client Framework. I've tried to keep it simple as much as possible. Attached to this article you will find a solution combining both the back-end code and the Windows client code in one. This is because of the local file system web server that ships with Microsoft Visual Studio.

If you run the Genesis.Host project in the solution the database script will deploy the database and all of the database artifacts, the 3 local file system web servers would start, and your logon screen would be displayed.

In this article I am going to explain the process of writing a module for the Genesis Smart Client Framework by developing a management system to control the Genesis Smart Client Framework. I will attempt to explain each step in detail, and provide as many code samples and screenshots as possible.

This article is part V of VII. Go to part I to see the index.

Please refer to our web site www.bluemarble.co.za for the most up to date information about the Genesis Smart Client Framework or any of our newsfeeds.
News feed
Development feed
View our blog
Follow our tweets

In order to pursue our active interest in releasing this version of the Genesis Smart Client Framework as an open source product, we've created a profile on www.codeplex.com where we maintain the most recent copy of the source code. If you want the latest version of the Genesis Smart Client Framework source code go to our code plex profile or download the latest release from Code Plex.

Module

A module is a collection of libraries, web services, web sites and databases that makes up a client application. These resources are kept on the Genesis Smart Client Framework server where the Windows clients can access them. When a user signs into an application, the most up to date version of the resources are downloaded.

By implementing the Genesis Smart Client Framework API, a developer can enable his/her class library to be hosted inside of the Smart Client application. The Genesis Smart Client Framework API has classes and interfaces that enable you to implement User Controls that will be hosted inside of the host form, dialogs, navigation, generic web service access. The developer can also create an entire Smart Client application by implementing the correct interfaces.

Most code inside of the Module (client or server side) will only be executed through a command. This is because the host form will only activate the module if the user clicks the correct menu button, or through the logon script, or through XML script. This does not mean the command has to be complex code, but simply that you cannot show the form unless a user clicks the menu button, which launches the command which creates and shows the form. The Genesis Smart Client Framework is very command driven, it is how user access is enforced, and how we enable the XML scripting.

Command

A Command is a unit of code that is executed on the Smart Client application with the user access profile applied. A command can accept parameters, and return results like any function in any modern programming language. Commands can be executed by placing a button in the ribbon, by executing code from your own code, through the XML script and by specially formatted hyperlinks in web pages viewed with the browser that ships with the Smart Client.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Genesis.Management.Commands.Module
{
    [Genesis.Common.Attributes.CommandCode("Genesis.Management.Commands.Module.File.Search")]
    [Genesis.Common.Attributes.CommandDescription("Search for a file")]
    [Genesis.Common.Attributes.CommandName("File Search")]
    public class ShowFileSearch : Genesis.Common.Classes.CommandBase, Genesis.Common.Interfaces.ICommand
    {
        #region ICommand Members

        void Genesis.Common.Interfaces.ICommand.Execute()
        {
            Genesis.Client.Common.Forms.WebBrowser webBrowser = 
                new Genesis.Client.Common.Forms.WebBrowser();

            webBrowser.Host = this.host;

            webBrowser.PageProperties.Add(
                new Genesis.Common.Classes.PageProperty(
                    "Url", 
                    "http://localhost:2147/genesis.management.web/Module/FileSearch.aspx"));

            webBrowser.Navigate();
            base.host.CreateWindow(webBrowser);
        }

        #endregion
    }
}

Samples of how to execute a command from your own code

this.Host.ExecuteCommand("Genesis.Management.Commands.Module.File.Search");
this.Host.ExecuteCommand("Genesis.Management.Files.Module.File.Search",
        new Genesis.Common.Classes.CommandParameter[] {
            new Genesis.Common.Classes.CommandParameter("Parameter1", "Value1"),
            new Genesis.Common.Classes.CommandParameter("Parameter2", "Value2") });
this.Host.ExecuteCommandUrl("genesis://Genesis.Management.Commands.Module.File.Search");
this.Host.ExecuteCommandUrl("genesis://Genesis.Management.Commands.Module.File.Search?Parameter1=Value1&Parameter2=Value2");

Samples of how to execute a command through the XML script

<?xml version="1.0" encoding="utf-8" ?> 
<script> 
    <Job name="SearchModuleFile" command="genesis://Genesis.Management.Files.Module.File.Search" /> 
    <Job name="SearchModuleFileWithParameter" command="genesis://Genesis.Management.Files.Module.File.Search?Parameter1=Value1&Parameter2=Value2" /> 
</script>

Samples of how to execute a command through a special formatted hyperlink on a web page

genesis://Genesis.Management.Files.Module.File.Search
genesis://Genesis.Management.Files.Module.File.Search?Parameter1=Value1&Parameter2=Value2

The web page that is being opened in this sample is a standard ASP.NET web page. No fancy trickery is required to operate the page within the Smart Client.

Web Service Proxy Client

Most of the time when using complex classes with Web Services, developers experience type casting problems in the client code when referencing their Web Service. The Web Service Proxy Client is simply a type safe client implementation of the Web Service reference generated by Microsoft Visual Studio. It also resets the Web Service address before the SOAP requests are sent to ensure that the client is communicating with the correct Web Service as defined in the Meta-Data.

By implementing the Web Service Proxy Client interface, the developer also opens up his/her code in a usable API for reuse either by themselves or other developers. Developers do not have to implement the Web Service Proxy Client when developing modules for the Genesis Smart Client Framework, however it is recommended to ensure a consistant end-user experience. No one wants to deploy their code and left some hard-coded development server address.

Web Service reference code generated by Microsoft Visual Studio

/// <remarks/>
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://genesis.bluemarble.co.za/GetApplicationRibbons", RequestNamespace="http://genesis.bluemarble.co.za/", ResponseNamespace="http://genesis.bluemarble.co.za/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public System.Data.DataTable GetApplicationRibbons(System.Guid SessionGuid) {
    object[] results = this.Invoke("GetApplicationRibbons", new object[] {
                SessionGuid});
    return ((System.Data.DataTable)(results[0]));
}

Default constructor for a Web Service Proxy Client class.

public class ModuleProvider : Genesis.Client.Common.Classes.ServiceProviderBase, Genesis.Common.Interfaces.IServiceProvider
{
    public ModuleProvider()
    {
        try
        {
            base.WebService = new Genesis.Client.Module.WebService.Module.Module();
            base.WebService.Url = base.ServerAddress + "Module.ASMX";

            base.setWebServiceProxy();
        }
        catch (System.Exception exception)
        {
            Genesis.Client.Common.Classes.ExceptionHandler.HandleException(exception);
        }
    }

Method specific type-safe wrapper code

public DataTable GetApplicationRibbons()
{
    DataTable resultValue = null;

    try
    {
        resultValue = ((Genesis.Client.Module.WebService.Module.Module)base.WebService).GetApplicationRibbons(base.sessionGuid);
    }
    catch (System.Exception exception)
    {
        Genesis.Client.Common.Classes.ExceptionHandler.HandleException(exception);
    }

    return resultValue;
}

Included Samples

Some samples are included to demonstrate application development using the Genesis Smart Client Framework.

Genesis Management System

026.png
041.png

The included sample application is the the Management System solution folder inside of the solution. The sample illustrates how to develop a module for the Genesis Smart Client Framework and how to hook into the API. It is also designed to be the default management interface for the Genesis Smart Client Framework.

The sample contains a class library which contains Commands to be executed from the Ribbon Bar. These Commands launch web sites in a seperate ASP.NET Web site. The web pages will allow the user to search for users, roles, modules, commands, files and to update the detail records of each of these.

The Management System is configured to display on the user interface and to allow user interaction through commands exactly like any application would require when being delivered through the Genesis Smart Client Framework. This sample also illustrates the minimun requirement for any application to implement if it were to be hosted through the Genesis Smart Client Framework.

The Management System is made up of two parts. The first part is the Genesis.Management.Web project. This is a web project with some web pages that allow standard interaction as you would expect from an ASP.NET web site. The second part is the Genesis.Management library, which contains some basic Commands. These commands simply link up to the menu structure provided by the Smart Client application. In this sample the commands open the built-in web browser and navigates to the appropriate web form in the Genesis.Management.Web project.

The Genesis.Management.Web project implements the Genesis.Client.Common.Security and Genesis.Client.Common.Module API libraries to interact with the Genesis Smart Client Framework.

Custom Smart Client Application

056.png
057.png
058.png
059.png

The Custom Smart Client application demonstrates how to implement your own Windows Application to connect to the Genesis Smart Client Framework back-end. It also does not have a dependency on a 3rd party library for user interface features.

049.png
050.png

Application Template

051.png
054.png

If you want to create your own hosted application, simply implement the included template solution. This sample illustrates the minimum implementation requirements for any hosted application for the Genesis Smart Client Framework. Open the Template Solution solution to access the source code. The template project is called Genesis.Application and can be found in the Hosted Application solution folder.

IMPORTANT: Make sure that you have the latest database script run (v1.40.1024.0). This script also demonstrates the required management setup which can be viewed using the Genesis Management System.

Further Reading

This article is part V of VII. Go to part VI to read about managing the Genesis Smart Client Framework.

Other information

Blue Marble is proud to be a Microsoft BizSpark startup company.

DISCLAIMER

The Genesis Smart Client Framework is a commercial closed source application. It is being provided on Code Project with all of the benefits that articles on Code Project grant its users (ie. Free and Fair use), however it must be noted that some modules contain a 3rd party control that we are unable to license via Code Project. Once all of the articles are uploaded, the code will be extracted to a seperate obfusicated library to protect our vendor's Intellectual Property. The full source code will be provided for this library, excluding the few lines that could compromise our License. An alternative will also be provided for developers who wish to use a completely free version.

DISCLAIMER UPDATE

An implementation of a standard Microsoft.NET controls user interface has been created and is available on Code Plex as of release 1.30.1024.0. This release complies with all of the Code Project article publishing terms and conditions.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

Share

About the Author

Stephan Johnson
Blue Marble
South Africa South Africa
No Biography provided

Comments and Discussions

 
Generaleasy to use PinmemberCraziChix24-Jun-09 3:37 
GeneralRe: easy to use PinmemberStephan Johnson24-Jun-09 6:18 
Questionit need a .net 3.0 WPF? Pinmemberivanchain@hotmail.com22-Jun-09 22:34 
AnswerRe: it need a .net 3.0 WPF? PinmemberStephan Johnson23-Jun-09 0:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 19 Jun 2009
Article Copyright 2009 by Stephan Johnson
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid