Click here to Skip to main content
Click here to Skip to main content

The Health and Safety Management System - Created with LightSwitch

, 20 Dec 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
A LightSwitch created Health and Safety Management System

Hello all! As part of the ever growing number of LightSwitch Star contest participants, here is my submission of an example of what is possible with LightSwitch. Hope you find some useful information here, or at least get inspired to give LightSwitch a try yourself.

Enjoy...

Health & Safety Management System

A solution created with Microsoft Visual Studio LightSwitch.

Sample Image - maximum width is 600 pixels

Introduction

What does your application/extension do? What business problem does it solve?

The Health and Safety Management System is an application that is used to help organizations better manage and mitigate health and safety statistics and KPIs. The solution is designed to empower users with a tool that can be used to capture and report on finely grained health and safety performance metrics.

Workplace safety is serving an ever increasing role with many organizations. Companies are now being held accountable to, not just their own internal stakeholders such as employees and shareholders, but also other external stakeholders such as customers, vendors, and suppliers. Whether it is for internal corporate health and safety concerns, or performance metrics such as KPIs, organizations are putting more and more visibility into health and safety concerns.

Companies are now asking for health and safety accountability from their partners, often before engaging in a relationship. For example, large energy industry companies make it a prerequisite that their vendors have a health and safety program in place with proper record keeping and reporting. Often these relationships include contractual obligations which require the vendor to provide regular health and safety reporting; especially when performing work on a customer work-site.

The Health and Safety Management System has been designed to provide an organization with the means to capture and report on key health and safety metrics. The key value propositions for the Health and Safety Management System include:

  • Granular health and safety information gathering, such as:
    • Observations - capturing data that identifies health and safety threats and opportunities,
    • Near Miss Incidents - incidents that occur and do not result in an injury or time loss, and
    • Injury and Time Loss Incidents - managing details about injuries and time loss.
  • Flexible and intuitive user configurable reporting, including:
    • Several "canned" and built-in reports that can be optionally printed or exported to various formats such as Excel or PDF.
    • Powerful OLAP analytics that are highly customizable.
    • Flexible user defined querying that can optionally be saved, reloaded, printed, or exported.
  • Highly configurable, and is easily customizable for each customer.
  • Can be quickly integrated with existing organization systems; such as legacy customer or human resources ERP systems.
  • Can be deployed to either the desktop, web, or the cloud.

How many screens and entities does this application have?

Currently, the Health and Safety Management System has:

  • 19 screens that provide standard data entry interfaces as well as for various administration tasks such as lookup or reference tables, reporting and analytics, and security, and
  • 23 entities (tables)

Did LightSwitch save your business money? How?

LightSwitch provided the means to build the solution very quickly. The quality of the solution matches that of an enterprise class solution that would have taken a great deal of more time and effort to create using other, more common, technologies.

Getting to market quickly is key, as is the quality of the offering. With LightSwitch, a solution can be created using technologies and proven software development best practices. The quality of the solution is something that is automatically applied when using LightSwitch. Enabling the scenarios and requirements was easy using the template based tasks.

Would this application still be built if you didn’t have LightSwitch? If yes, with what?

The solution concept was already on-the-table well before any consideration was being made regarding the technology to use for it. Consideration was made for using one or more technologies, including; ASP.Net MVC, HTML5/JSON, SQL Server, and WCF.

Again, as mentioned earlier, LightSwitch makes for a much faster turnaround in delivery time. Using relatively traditional development technologies would result in much more time before delivering on requirements.

How many users does this application support?

As many as required. There are no known constraints to suggest that the solution could not be deployed in a large enterprise.

How long did this application take to actually build using LightSwitch?

As of the time of this writing, the solution took only a few days to build. It is estimated that the actual total hours of effort would be 18.

Does this application use any LightSwitch extensions? If so, which ones? Did you write any of these extensions yourself? If so, is it available to the public? Where?

The Health and Safety Management System uses a number of extensions and custom controls. These include:

A key success factor of the development of this solution is to utilize existing extensions and tools whenever possible. The goal was to deliver on requirements as quickly as possible. Using existing tools offered the opportunity to enable scenarios without having to "reinvent the wheel".

How did LightSwitch make your developer life better? Was it faster to build compared to other options you considered?

LightSwitch made a remarkable impact on the developer experience when using LightSwitch for this solution. The investment in effort and time was considerably less than what it would have taken using the other considered technologies.

Links, Screenshots, Videos

Links

Screenshot(s)

Home Page

The Health and Safety Management Home Page

Observations

New Observation entry

Injury and Time Loss

Injury and Time Loss

Reporting

An example report

Analytics

Some very flexible data mining features...

Analytics

...with visualizations!

User Defined Queries

Intuitive user defined queries that can be saved and loaded for later use.

Scheduling

Scheduling capabilities, such as tailgate safety meetings.

As far as coding and techniques go, here are a few useful tips and tricks that you might find helpful for your own LightSwitch projects...

Images and Icons

Applying images and icons to the application added some UX appeal to the overall look and feel of the application. The process used to add images to headers of each of the screens in the application included;

  1. Create appropriately sized .png images for screen header images.
  2. Open the Solution Explorer File View.
  3. Add the images as an Embedded Resource in the Resources folder of the Client project.

    Screen Header Images

  4. Add the image control to the screen element tree. In this application, the element is a SilverLight Image control, so that the element would be borderless...

    Screen Header Images

  5. A class named MyImageHelper was created in the UserCode folder of the Client project (open Solution Explorer in File View). This was used to provide a small bit of infrastructure to use the embedded resource image files.
    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using System.IO;
    using System.Reflection;
    using System.Windows.Media.Imaging;
    
    namespace LightSwitchApplication
    {
        public class MyImageHelper
        {
            public static byte[] GetImageByName(string fileName)
            {
                Assembly currentAssembly = Assembly.GetExecutingAssembly();
                Stream stream = currentAssembly.GetManifestResourceStream
                ("LightSwitchApplication.Resources." + fileName);
                return GetStreamAsByteArray(stream);
            }
    
            public static BitmapImage GetBitmapImageByName(string fileName)
            {
                Assembly currentAssembly = Assembly.GetExecutingAssembly();
                Stream stream = currentAssembly.GetManifestResourceStream
                ("LightSwitchApplication.Resources." + fileName);
                return GetBitmapImage(GetStreamAsByteArray(stream));
            }
    
            private static byte[] GetStreamAsByteArray(System.IO.Stream stream)
            {
                if (stream != null)
                {
                    int streamLength = Convert.ToInt32(stream.Length);
                    byte[] fileData = new byte[streamLength];
                    stream.Read(fileData, 0, streamLength);
                    stream.Close();
                    return fileData;
                }
                else
                {
                    return null;
                }
            }
    
            private static BitmapImage GetBitmapImage(byte[] bytes)
            {
                // Create a BitmapImage from a byte[];
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    var bi = new BitmapImage();
                    bi.SetSource(ms);
                    return bi;
                }
            }
        }
    }
  6. Then back in the home page screen, code was implemented to retrieve and use the image on the screen...
    partial void AllIncidents_InitializeDataWorkspace(List<idataservice> saveChangesTo)
       {
           IContentItemProxy logo = this.FindControl("HomeHeaderLogo");
           logo.ControlAvailable += new EventHandler
        <controlavailableeventargs>(HomeHeaderLogo_ControlAvailable);
       }
    
    void HomeHeaderLogo_ControlAvailable(object sender, ControlAvailableEventArgs e)
       {
           // Set image source to PNG logo.
           var img = e.Control as Image;
           if (img != null)
             img.Source = MyImageHelper.GetBitmapImageByName("HealthAndSafetyLogo.png");
       }</controlavailableeventargs> </idataservice>
  7. ...the image is applied when the application opens the screen...

    Screen Header Images

Other Techniques

A couple of other techniques applied to this solution include:

  • Intermediate, or "Dummy", screen - Observations, Near Misses, and Injury Incidents are actually each of a type of Incident entity. When clicking on the hyperlink for any of the incidents in the home page listing, logic was applied so that depending on the type of incident selected, the application would open the appropriate incident type screen.
  • One Detail Screen for Add or Edit - A single screen is used for both adding and editing entities. This is achieved by adding a parameter to the screen, usually an integer parameter representing the id of the entity. Logic on the screen would then interpret whether the application is opening the screen for a new or existing record. For example...
    partial void InjuryIncidentScreen_InitializeDataWorkspace
        (List<idataservice> saveChangesTo)
    {
    
      Incident incident;
      if (!this.IncidentID.HasValue)
      {
       incident = new Incident();
    
      IncidentType incidentType = (from it in DataWorkspace.ApplicationData.IncidentTypes
                                    where it.IncidentTypeName == "Injury"
                                    select it).FirstOrDefault();
    
       incident.IncidentType = incidentType;
       incident.HoursLost = 0;
    
       this.IncidentProperty = incident;
    
      }
      else
      {
        int incidentId = (int)this.IncidentID;
    
        incident = (from i in DataWorkspace.ApplicationData.Incidents
                    where i.Id == incidentId
                    select i).FirstOrDefault();
    
                    this.IncidentProperty = incident;
       }
    
    }</idataservice>

Hope you all find this helpful and useful. Cheers!

Post a link to this contest entry on our Facebook wall and let people know they should rate this submission! And don’t forget to follow us on Twitter for contest updates! Good luck!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

No Biography provided

Comments and Discussions

 
QuestionMy vote of 5 PinmemberDelordson Kallon20-Dec-11 9:20 
AnswerRe: My vote of 5 PinmemberPaulSPatterson20-Dec-11 9:42 

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 | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 20 Dec 2011
Article Copyright 2011 by PaulSPatterson
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid