Entries by David Abrahams (31)

Friday
Jun262009

ASP.NET MVC Membership Management (Users and Roles)

Here at kmsystems we have really been diving into ASP.NET MVC with everyone in the team doing loads of learning, setting up some new projects using MVC and converting over some old ones. Not to be left out of all the MVC fun :) I've decided to dive in and port over a simple team management app we built called "Whos Doin Wot" from the Morfik 2.0 RIA Tool which I put together a while ago now.

The new release of Whos Doin Wot isn't quite ready for use yet however I want to share some of the work I have done setting up user and role management. I'm a big fan of buy borrow, beg, steal before you build or role your own (just can't see the benefit of re-inventing the wheel if a great wheel already exists) so I started my search and found the following:

ASP.Net MVC Membership Starter Kit which is a really promising membership management tool and would have been exactly what I was looking for, unfortunately the current release does not work on MVC Release 1.0

ASP.NET MVC Membership Management Roni Schuetz which also looks great but costs 30 euros (around $50 Australian dollars) and given that it was just a blog post with no comments I wasn't too sure if I was just kissing my $50 goodbye (maybe I'll give it a go later).

As the options to buy, beg, borrow or steal were not that appealing and with the goal of learning more about MVC I decided to (god forbid) roll my own membership management. Anyway it wasn't going into a full blown management tool I wanted to keep it simple and light to just cover off the very basics.

If you are interested I have uploaded the source code for you to download modify and use in your own projects. This code is jsut a very basic base to start from and extend to meet your requirements. It would be great if you could share any improvements back here with us.

The code covers:

- List all users

- Add a new user

- Edit a user

- Delete a user

- View the roles associated to a user

- Remove a role from a user

- Add a role to a user

- List all roles

- Create a role

- Lists users in a role

- Delete a role

The code I created is based on using ASP.NET Membership in a SQL server database by default MVC points to a SQL Express database named "ASPNETDB.MDF"; under the application's "App_Data" directory. If you would like to use a different SQL server or dataabase update the "ApplicationServices"; connection string within the web.config file. You can run the "aspnet_regsql.exe" utility within the \Windows\Microsoft.NET\Framework\v2.0.50727\ directory to add membership and the other ASP.NET application services to any database.

Tuesday
Jun022009

Waterfall charts in SQL Reporting Services

Recently we completed a project to build a KPI dashboard for a large Australian organisation to show certain performance measures for each business unit. The challenge was that the client wanted a very specific kind of chart,  basically a waterfall chart which displays the end target/goal as the final column. Using the Dundas charts control this task would not be that difficult as we could have used a chart similar to this and made a few tweaks.

However due to the clients Reporting Services Architecture the costs of Dundas licenses was not feasible so we needed to come up with a way to produce a similar chart using the native Reporting Services chart control.

Here's what we learned:

  • The chart type to use is a Stacked Column Chart
  • You need to add a data value the represent the data value you want to appear in the waterfall. In our case we added the KPI actuals eg:(Fields!KPIActual.Value)
  • Then you need to add the same data as a second data value to the stacked series as a running total and subtract the individual first data value at each point. We added the same KPI actual data as a second data value which would be stacked below the first but this time using a running total less each KPI actual eg:RunningValue(Fields!KPIActual.Value, Sum, "chart1_SeriesGroupKPI_Measures")-(Fields!KPIActual.Value). We also set the background colour fill for this series to white so that it would blend into the background of the chart an could not be seen 

 The final result was a nice clean waterfall chart that shows progress towards an end target

Monday
Jun012009

Greenhouse and Energy Reporting NGERS

We have been working with one of Australia's largest logistics companies, building various web applications to help improve some of their current business processes. One of the areas we discussed was their environmental impact and reporting requirements under the National Greenhouse and Energy Reporting Act 2007(the NGER Act). In short the Australian Government has passed an Act that requires organisations to report on greenhouse gas emissions, energy consumption and production.

After doing some research into the NGERS guidelines and requirements we have decided to build an application that will:

  • Make it easier for organisations to capture and track information regarding their greenhouse gas emissions, energy consumption and production
  • Provide some value back to the business for going to the effort in capturing this information. Such as a better understanding of environmental expenses and possible areas for improvement/reduction

Currently we are in the process of designing and developing the application. If you and your company need to report under NGERS and would like to talk to us about what could make your life easier in this area. Or if you would be interested in using this tool to make NGERS reporting easier then please contact us

I will add another post soon when we have a beta version ready for people to try out.

Friday
May292009

Manifesto for Agile Software Development

At kmsystems we have build a lot of software and in most cases the time frame and budget we have to work with is tight, very tight. The challenge is to not only to meet tight deadlines and budget constraints but above all deliver something of value. The output or result of what we develop must add value to our clients existing processes and business otherwise there is no point in building the solution in the first place. I'm talking about not just solving a problem but solving it in the best possible way that adds the most possible value. Let's face it problems can be solved in a lot of different ways for example you can implement a manual process good old pen and paper, use Excel, create a simple Access database, the list goes on. We build software and its our job to ensure that the software solution we provide adds the most value over all options.

To achieve this we have found agile development methodologies to be an effective way to keep costs and time overheads low yet deliver something that the client will use and get maximum value from.

As part of our agile development practises we try to follow the "Manifesto for Agile Software Development"

We are uncovering better ways of developing
software by doing it and helping others do it.
Through this work we have come to value:

Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan


That is, while there is value in the items on
the right, we value the items on the left more.

http://agilemanifesto.org/

and we try to up hold these 12 principles which sit behind the manifesto:

  1. Our highest priority is to satisfy the customer through early and continuous delivery of valuable software.
  2. Welcome changing requirements, even late in development. Agile processes harness change for the customer's competitive advantage.
  3. Deliver working software frequently, from a couple of weeks to a couple of months, with a preference to the shorter timescale.
  4. Business people and developers must work together daily throughout the project.
  5. Build projects around motivated individuals. Give them the environment and support they need, and trust them to get the job done.
  6. The most efficient and effective method of conveying information to and within a development team is face-to-face conversation.
  7. Working software is the primary measure of progress.
  8. Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely.
  9. Continuous attention to technical excellence and good design enhances agility.
  10. Simplicity--the art of maximizing the amount of work not done--is essential.
  11. The best architectures, requirements, and designs emerge from self-organizing teams.
  12. At regular intervals, the team reflects on how to become more effective, then tunes and adjusts its behavior accordingly.

It has taken us some time to grow and adopt agile development but I think as a team kmsystems has been able to work fairly closely to these principles and deliver some great software especially on a few recent projects. As a leader I trust my teams to get the job done, however one of the obstacles we face over and over again is engaging the customer in the agile process and keeping them engaged for the length of the project. The agile process does require a higher level of commitment from both parties but the output end result is a far better product. Unfortunately this is not easy to demonstrate up front. I think that open honest communication about the process will give your client and you a good start that will carry you through to being able to demonstrate the value. Remember deliver fast and review often.

 

Saturday
Jan102009

Linq to SQL basic list/grid view and form view

Lately I've been getting more and more into using Linq to SQL and think it rocks, Linq takes care of all the hard back end database functions so that you can focus on the interesting business logic of fun design and styling. I've been doing some research on the basics of Linq and found that most tutorials only show the List/GridView. However there was not many tutorials on working with Forms. So I have put together this basic tutorial to get you started. I have to give a lot of credit to aDefWebserver for this tutorial http://www.adefwebserver.com/DotNetNukeHELP/LinqTutorial2/LinqTutorial2_3.htm which although it specific to DotNetNuke a lot of the concepts can be learned here.

I have created a very basic database called "Contacts" with a table called "MyContacts", here is a screenshot of this table.

I prefer to set up a new database user now for this specific application so that when it comes to deploying the application your ready to go.

 

Now I will create a New Web Site in Visual Web Developer 2008 Express Edition called "MyContacts"

 In the Database Explorer right button click on the Data Connections root and select Add Connection

Add a new Linq to SQL Classes item called "My_Contacts_DataClass.dbml" under the App_Code folder

Once the My_Contacts_DataClass opens drag the "MyContacts" table onto the data class from the Database Explorer

 

Add a new web form called "List_MyContacts.aspx" for the list/grid view

Add a LinqDataSource from the Data section in the Toolbox to your new List_Mycontacts page and select Configure Data Source

Select the My_contacts_DataClassDataContext object and click next

Click the "Advanced" button and select which options you want to allow from the list/grid view. In this case I only want to allow Delete

Add a GridView from the Data section in the Toolbox to your new List_Mycontacts page and select the LinqDataSource1 as the Data source. Then check Enable Deleting and Selection so that the user can either delete the record directly from the list or select it to view it in the form view mode.

Select the GridView control and open the properties and click on the lightning bolt to see the events. Double click on the SelectedIndexChanged event and enter the following line of code within this SelectedIndexChanged procedure. This code will open the update page with the selected record in the form view.

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

    {

        Response.Redirect("Update_MyContacts.aspx?ContactId=" + Convert.ToInt32(GridView1.SelectedDataKey.Value) + "");

    }

 

Add a new web form called "Update_MyContacts.aspx" for the form view

Add a LinqDataSource from the Data section in the Toolbox to your new Update_Mycontacts page and select Configure Data Source

Select the My_contacts_DataClassDataContext object and click next

Click the "Advanced" button and select which options you want to allow from the list/grid view. Here I want to allow Insert, Update and Delete

Also click on the Where button and select the Contact_Id is equal to the a parameter passed via the query string so that when a user selects an item on the list/grid view page the update form will know which item the user wants to edit. Add the where clause

 

Add a FormView from the Data section in the Toolbox to your new Update_Mycontacts page and select the LinqDataSource1 as the Data source.

That's it now you can open your browser and browse the application. Here is the first page the list/grid view

When you click on the Select link in the grid view the page redirects to the Update page to display the form view in read only mode

 

Now when the user clicks on the Edit link the form will automatically switch into update mode so they can update the data and save it

Now that all of the data access functionality has been automatically created by Linq all you need to focus on is design and logic.