The CCS is an Asp.Net Web Forms system written in C#. It is split into 3 projects:-
  • CustomerContactSystem.Core
  • CustomerContactSystem.PollingApp
  • CustomerContactSystem.WebForms

CustomerContactSystem.Core

The Core project is currently split into 4 sections, AppServices, DataAccess, Infrastructure and Model. These days in .Net development it would be normal for these 4 sections to be separate projects in their own right but in the interest of simplicity they are combined in this single project and kept in separate folders so that should it become necessary to split them out into separate projects it would be straight-forward (particularly with tools like Resharper).

The Model is a series of classes representing the entities very much in the mold of a domain model. The key entity is the Enquiry object which besides it's properties contains methods for performing the various actions that are required. e.g. AddComment, AddDocument, Close etc.

The Infrastructure sections contains base objects, interfaces and utilities for use throughout the solution.

The DataAccess contains ORM specific code and in this case it is Nhibernate, so mapping files are here too. The mapping files tell Nhibernate how to map the entities in the Models Folder to the tables in the database. There is also a generic Repository (NhibernateRepository.cs) implementation for Nhibernate. Note: Repository.cs should be ignored and will be removed as NhibernateRepository.cs super-ceded it.

The AppServices section contains implementations of interfaces defined in the infrastructure section and in one case an implementation of an interface declared in the same section (IFixYourStreetService). The project does not yet use a proper system of Dependency Injection as of yet but is planned for the next version. The basic idea of Dependency Injection is that the code of the system can make use of interfaces without caring what implementation it will eventually be using at runtime. You can decide what implementation the system will use by using if you need to override the way certain things are currently implemented. This is also vital for unit testing which again the system is currently lacking.

CustomerContactSystem.PollingApp

The polling app project is a simple windows console project that will when run call web services in the web forms website to get the latest incidents, comments and send updates to fix your street.

CustomerContactSystem.WebForms

The web forms application is the website for the CCS. It has the usual user based stuff (login, registration etc.), an administration section for managing users, customers, categories and so on, then 2 main sub-sections for customers and enquiries. Every single page on the site inherits from BasePage.cs which contains utility functions. It is in this code file that you would override things if you wanted to make any major changes. For example the ConfigSettings is a read only property that returns a concrete implementation of IApplicationSettings, specifically the WebConfigApplicationSettings object (found in the AppServices folder of core under configuration).

More importantly BasePage.cs also contains read only properties that return Repositories for the various objects in the Model. This is what is called "poor man's ioc" in that it uses a very basic and not ideal method of Dependency Injection or provision of implementations. Something at the top of the list for a fix in the next version. For now though if you need to make a change to something you'll need to make it here.

A simple example might be that you have a user system already in place that you want the CCS to plug into. The best way would be to create your own data access repository in the Core project (under DataAccess create a new folder alongside Nhibernate for your own implementation of a Repository). Say you create a MyUserRepository.cs file which implements INhibernateRepository (yes that needs to be renamed since it is not Nhibernate specific). All you need to do is update the code in the BasePage.cs to return your implementation instead of the current one. Since the return type is an interface once you have an object that implements that interface then you can use that instead.

One final aspect of the website worth noting is a simple ajax example can be seen in the AjaxService.ashx code. Using jquery an ajax call (site.js in Content\Scripts) is made to this file when a user clicks on a link in the enquiry list. It checks if the user is allowed access and informs them if they or not. This is a basic example just to demonstrate how ajax enhancements might be added to the system.

Last edited Nov 13, 2012 at 2:40 PM by SouthDublinCoCo, version 4

Comments

No comments yet.