Click here to Skip to main content
12,069,857 members (71,642 online)
Click here to Skip to main content

Stats

45.9K views
507 downloads
56 bookmarked
Posted

Event-Driven Architecture in the Clouds with Windows Azure

, , 5 Feb 2010 CPOL
To demonstrate Azure and EDA, this article will show you how to build a flight delay management system for all US airports in clouds with Windows Azure.
FlightUpdatesManager.zip
FlightUpdates.Entities
bin
Debug
FlightUpdates.Entities.csproj.user
Properties
FlightUpdates.MessageProcessor
bin
Debug
FlightUpdates.MessageProcessor.ccproj
FlightUpdates.MessageProcessor.ccproj.user
ServiceConfiguration.cscfg
ServiceDefinition.csdef
FlightUpdates.MessageProcessorService
bin
Debug
Properties
Resource Files
FlightUpdates.Service
bin
Debug
FlightUpdates.Service.csproj.user
Properties
Service References
FlightUpdates.Service.Contracts
bin
Debug
FlightUpdates.Service.Contracts.csproj.user
Properties
FlightUpdates.TraceData
Properties
FlightUpdates.TwitterMonitor
bin
Debug
FlightUpdates.MessageGenerator.ccproj
FlightUpdates.MessageGenerator.ccproj.user
ServiceConfiguration.cscfg
ServiceDefinition.csdef
FlightUpdates.TwitterMonitorService
bin
Debug
Properties
Resource Files
FlightUpdates.Utility
bin
Debug
Constants
FlightUpdates.Utility.csproj.user
Properties
FlightUpdates.WebAzure
bin
Debug
FlightUpdates.AzureWeb.ccproj
FlightUpdates.AzureWeb.ccproj.user
ServiceConfiguration.cscfg
ServiceDefinition.csdef
External Library
Microsoft.Maps.MapControl.Common.dll
Microsoft.Maps.MapControl.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
Microsoft.Practices.EnterpriseLibrary.Data.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll
Microsoft.Practices.ObjectBuilder2.dll
Microsoft.Practices.Unity.dll
TwitterooCore.dll
FlightsUpdate.SilverlightWeb
Bin
Debug
Release
Components
FlightsUpdate.SilverlightWeb.csproj.user
Properties
Service References
AirportDelayService
AirportCodeService1.wsdl
AirportMapDelay1.disco
AirportMapDelays.AirportDelayService.AirportInfo.datasource
AirportMapDelays.AirportDelayService.FlightDelayFeed.datasource
configuration.svcinfo
configuration91.svcinfo
Reference.svcmap
ServiceReferences.ClientConfig
FlightsUpdate.Web
AirportMapDelay.svc
AirportMapDelays.Web.csproj.user
App_Data
bin
ClientBin
AirportMapDelays.xap
FlightsUpdate.Web.csproj.user
Properties
Scripts
FlightUpdates.AzureHost
bin
Debug
FlightUpdates.AzureHost.ccproj
FlightUpdates.AzureHost.ccproj.user
ServiceConfiguration.cscfg
ServiceDefinition.csdef
FlightUpdates.Business
bin
Debug
FlightUpdates.Business.csproj.user
Properties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using Microsoft.Practices.EnterpriseLibrary.Data;
using FlightUpdates.Entities;
using System.Data.Common;
using FlightUpdates.Utility.Constants;
using System.Data;

namespace FlightUpdates.Business
{
    public class AirportManager : BaseManager
    {
        /// <summary>
        /// Get a list of all US airports
        /// </summary>
        public  List<AirportInfo> GetAirports()
        {
            List<AirportInfo> AirportList = new List<AirportInfo>();

            //Set StoredProc
            DbCommand dbCommand = FlightUpdateDB.GetStoredProcCommand("spAirportActive_Select");

            //Get data
            using (IDataReader reader = FlightUpdateDB.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    AirportInfo airportItem = new AirportInfo()
                    {
                        AirportCode = DataAccessUtility.GetValue<string>(reader["AirportCode"]),
                        AirportName = DataAccessUtility.GetValue<string>(reader["AirportName"]),
                        LatitudeDegree = DataAccessUtility.GetValue<double>(reader["LatitudeDeg"]),
                        LongitudeDegree = DataAccessUtility.GetValue<double>(reader["LongitudeDeg"]),
                        DelayTime = DataAccessUtility.GetValue<int>(reader["DelayTime"])
                    };

                    AirportList.Add(airportItem);
                }
            }

            return AirportList;
        }

        /// <summary>
        /// Get flight delays for an airport 
        /// </summary> 
        /// <param name="Airport">airport code</param>
        public List<FlightDelayFeed> GetFlightDelayFeed(string Airport)
        {
            List<FlightDelayFeed> FlightDelayFeedList = new List<FlightDelayFeed>();

            //Set StoredProc with paramters
            DbCommand dbCommand = FlightUpdateDB.GetStoredProcCommand("spFlightDelayFeed_Select");
            FlightUpdateDB.AddInParameter(dbCommand, "flightCity", DbType.String, Airport);

            //Get data
            using (IDataReader reader = FlightUpdateDB.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    FlightDelayFeed flightDelayFeedItem = new FlightDelayFeed()
                    {
                        DelayTime = DataAccessUtility.GetValue<int>(reader["DelayTime"]),
                        DelayExpiration = DataAccessUtility.GetValue<DateTime>(reader["DelayExpiration"]),
                        FlightCity = DataAccessUtility.GetValue<string>(reader["FlightCity"]),
                        FlightNumber = DataAccessUtility.GetValue<string>(reader["FlightNumber"]),
                        LastUpdateTime = DataAccessUtility.GetValue<DateTime>(reader["LastUpdateTime"])
                    };

                    FlightDelayFeedList.Add(flightDelayFeedItem);
                }
            }

            return FlightDelayFeedList;
        }
    }
    internal class DataAccessUtility
    {
        internal static T GetValue<T>(object obj)
        {
            if (obj != DBNull.Value)
            {
                return (T)obj;
            }
            return default(T);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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

Share

About the Authors

John Mokkosian-Kane
Other
United States United States
No Biography provided

Daniel Hsu
Software Developer
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.160208.1 | Last Updated 5 Feb 2010
Article Copyright 2010 by John Mokkosian-Kane, Daniel Hsu
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid