diff --git a/src/Huxley/App_Start/NinjectWebCommon.cs b/src/Huxley/App_Start/NinjectWebCommon.cs
new file mode 100644
index 0000000..0571018
--- /dev/null
+++ b/src/Huxley/App_Start/NinjectWebCommon.cs
@@ -0,0 +1,50 @@
+using Huxley.ldbServiceReference;
+
+[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(Huxley.App_Start.NinjectWebCommon), "Start")]
+[assembly: WebActivatorEx.ApplicationShutdownMethodAttribute(typeof(Huxley.App_Start.NinjectWebCommon), "Stop")]
+
+namespace Huxley.App_Start {
+ using System;
+ using System.Web;
+ using Microsoft.Web.Infrastructure.DynamicModuleHelper;
+ using Ninject;
+ using Ninject.Web.Common;
+
+ public static class NinjectWebCommon {
+ private static readonly Bootstrapper Bootstrapper = new Bootstrapper();
+
+ ///
+ /// Starts the application
+ ///
+ public static void Start() {
+ DynamicModuleUtility.RegisterModule(typeof(OnePerRequestHttpModule));
+ DynamicModuleUtility.RegisterModule(typeof(NinjectHttpModule));
+ Bootstrapper.Initialize(CreateKernel);
+ }
+
+ ///
+ /// Stops the application.
+ ///
+ public static void Stop() {
+ Bootstrapper.ShutDown();
+ }
+
+ ///
+ /// Creates the kernel that will manage your application.
+ ///
+ /// The created kernel.
+ private static IKernel CreateKernel() {
+ var kernel = new StandardKernel();
+ try {
+ kernel.Bind>().ToMethod(ctx => () => new Bootstrapper().Kernel);
+ kernel.Bind().To();
+ kernel.Bind().To().InRequestScope();
+ kernel.Bind().To().InRequestScope();
+ return kernel;
+ } catch {
+ kernel.Dispose();
+ throw;
+ }
+ }
+ }
+}
diff --git a/src/Huxley/Controllers/CrsController.cs b/src/Huxley/Controllers/CrsController.cs
index 46a0cba..8c40f41 100644
--- a/src/Huxley/Controllers/CrsController.cs
+++ b/src/Huxley/Controllers/CrsController.cs
@@ -32,6 +32,9 @@ public IEnumerable Get() {
// GET /crs/{query}
public IEnumerable Get(string query) {
+ if (query.Equals("London Terminals", StringComparison.InvariantCultureIgnoreCase)) {
+ return HuxleyApi.LondonTerminals;
+ }
// Could use a RegEx here but putting user input into a RegEx can be dangerous
var results = HuxleyApi.CrsCodes.Where(c => c.StationName.IndexOf(query, StringComparison.InvariantCultureIgnoreCase) >= 0);
return results;
diff --git a/src/Huxley/Controllers/DelaysController.cs b/src/Huxley/Controllers/DelaysController.cs
index c00d3d5..3152df2 100644
--- a/src/Huxley/Controllers/DelaysController.cs
+++ b/src/Huxley/Controllers/DelaysController.cs
@@ -22,14 +22,18 @@ You should have received a copy of the GNU Affero General Public License
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
-using System.ServiceModel;
using System.Threading.Tasks;
using System.Web.Http;
using Huxley.Models;
using Huxley.ldbServiceReference;
namespace Huxley.Controllers {
- public class DelaysController : BaseController {
+ public class DelaysController : LdbController {
+
+ public DelaysController(ILdbClient client)
+ : base(client) {
+ }
+
// GET /delays/{crs}/{filtertype}/{filtercrs}/{numrows}/{stds}?accessToken=[your token]
public async Task Get([FromUri] StationBoardRequest request) {
@@ -61,121 +65,81 @@ public async Task Get([FromUri] StationBoardRequest request) {
}
}
- // https://en.wikipedia.org/wiki/London_station_group
- // Farringdon [ZFD] is not a London Terminal but it probably should be (maybe when Crossrail opens it will be)
- var londonTerminals = new List {
- "BFR", // Blackfriars
- "CST", // Cannon Street
- "CHX", // Charing Cross
- "CTX", // City Thameslink
- "EUS", // Euston
- "FST", // Fenchurch Street
- "KGX", // King's Cross
- "LST", // Liverpool Street
- "LBG", // London Bridge
- "MYB", // Marylebone
- "MOG", // Moorgate
- "OLD", // Old Street
- "PAD", // Paddington
- "STP", // St. Pancras
- "VXH", // Vauxhall
- "VIC", // Victoria
- "WAT", // Waterloo
- "WAE", // Waterloo East
- };
-
- var client = new LDBServiceSoapClient();
+ var totalDelayMinutes = 0;
+ var delayedTrains = new List();
- // Avoiding Problems with the Using Statement in WCF clients
- // https://msdn.microsoft.com/en-us/library/aa355056.aspx
- try {
- var totalDelayMinutes = 0;
- var delayedTrains = new List();
+ var token = MakeAccessToken(request.AccessToken);
- var token = MakeAccessToken(request.AccessToken);
+ var filterCrs = request.FilterCrs;
+ if (request.FilterCrs.Equals("LON", StringComparison.InvariantCultureIgnoreCase) ||
+ request.FilterCrs.Equals("London", StringComparison.InvariantCultureIgnoreCase)) {
+ filterCrs = null;
+ }
- var filterCrs = request.FilterCrs;
- if (request.FilterCrs.Equals("LON", StringComparison.InvariantCultureIgnoreCase) ||
- request.FilterCrs.Equals("London", StringComparison.InvariantCultureIgnoreCase)) {
- filterCrs = null;
- }
-
- var board = await client.GetDepartureBoardAsync(token, request.NumRows, request.Crs, filterCrs, request.FilterType, 0, 0);
-
- var response = board.GetStationBoardResult;
- var filterLocationName = response.filterLocationName;
-
- var trainServices = response.trainServices ?? new ServiceItem[0];
- var railReplacement = null != response.busServices && !trainServices.Any() && response.busServices.Any();
- var messagesPresent = null != response.nrccMessages && response.nrccMessages.Any();
-
- if (null == filterCrs) {
- // This only finds trains terminating at London terminals. BFR/STP etc. won't be picked up if called at en-route.
- // Could query for every terminal or get service for every train and check calling points. Very chatty either way.
- switch (request.FilterType) {
- case FilterType.to:
- trainServices = trainServices.Where(ts => ts.destination.Any(d => londonTerminals.Contains(d.crs.ToUpperInvariant()))).ToArray();
- break;
- case FilterType.from:
- trainServices = trainServices.Where(ts => ts.origin.Any(d => londonTerminals.Contains(d.crs.ToUpperInvariant()))).ToArray();
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
- filterCrs = "LON";
- filterLocationName = "London";
+ var board = await Client.GetDepartureBoardAsync(token, request.NumRows, request.Crs, filterCrs, request.FilterType, 0, 0);
+
+ var response = board.GetStationBoardResult;
+ var filterLocationName = response.filterLocationName;
+
+ var trainServices = response.trainServices ?? new ServiceItem[0];
+ var railReplacement = null != response.busServices && !trainServices.Any() && response.busServices.Any();
+ var messagesPresent = null != response.nrccMessages && response.nrccMessages.Any();
+
+ if (null == filterCrs) {
+ // This only finds trains terminating at London terminals. BFR/STP etc. won't be picked up if called at en-route.
+ // Could query for every terminal or get service for every train and check calling points. Very chatty either way.
+ switch (request.FilterType) {
+ case FilterType.to:
+ trainServices = trainServices.Where(ts => ts.destination.Any(d => HuxleyApi.LondonTerminals.Any(lt => lt.CrsCode == d.crs.ToUpperInvariant()))).ToArray();
+ break;
+ case FilterType.from:
+ trainServices = trainServices.Where(ts => ts.origin.Any(o => HuxleyApi.LondonTerminals.Any(lt => lt.CrsCode == o.crs.ToUpperInvariant()))).ToArray();
+ break;
+ default:
+ throw new ArgumentOutOfRangeException();
}
+ filterCrs = "LON";
+ filterLocationName = "London";
+ }
- // If STDs are provided then select only the train(s) matching them
- if (stds.Count > 0) {
- trainServices = trainServices.Where(ts => stds.Contains(ts.std.Replace(":", ""))).ToArray();
- }
+ // If STDs are provided then select only the train(s) matching them
+ if (stds.Count > 0) {
+ trainServices = trainServices.Where(ts => stds.Contains(ts.std.Replace(":", ""))).ToArray();
+ }
- // Parse the response from the web service.
- foreach (var si in trainServices.Where(si => !si.etd.Equals("On time", StringComparison.InvariantCultureIgnoreCase))) {
- if (si.etd.Equals("Delayed", StringComparison.InvariantCultureIgnoreCase) ||
- si.etd.Equals("Cancelled", StringComparison.InvariantCultureIgnoreCase)) {
- delayedTrains.Add(si);
- } else {
- DateTime etd;
- // Could be "Starts Here", "No Report" or contain a * (report overdue)
- if (DateTime.TryParse(si.etd.Replace("*", ""), out etd)) {
- DateTime std;
- if (DateTime.TryParse(si.std, out std)) {
- var late = etd.Subtract(std);
- totalDelayMinutes += (int)late.TotalMinutes;
- if (late.TotalMinutes > HuxleyApi.Settings.DelayMinutesThreshold) {
- delayedTrains.Add(si);
- }
+ // Parse the response from the web service.
+ foreach (var si in trainServices.Where(si => !si.etd.Equals("On time", StringComparison.InvariantCultureIgnoreCase))) {
+ if (si.etd.Equals("Delayed", StringComparison.InvariantCultureIgnoreCase) ||
+ si.etd.Equals("Cancelled", StringComparison.InvariantCultureIgnoreCase)) {
+ delayedTrains.Add(si);
+ } else {
+ DateTime etd;
+ // Could be "Starts Here", "No Report" or contain a * (report overdue)
+ if (DateTime.TryParse(si.etd.Replace("*", ""), out etd)) {
+ DateTime std;
+ if (DateTime.TryParse(si.std, out std)) {
+ var late = etd.Subtract(std);
+ totalDelayMinutes += (int)late.TotalMinutes;
+ if (late.TotalMinutes > HuxleyApi.Settings.DelayMinutesThreshold) {
+ delayedTrains.Add(si);
}
}
}
}
-
- return new DelaysResponse {
- GeneratedAt = response.generatedAt,
- Crs = response.crs,
- LocationName = response.locationName,
- Filtercrs = filterCrs,
- FilterLocationName = filterLocationName,
- Delays = delayedTrains.Count > 0 || railReplacement || messagesPresent,
- TotalTrainsDelayed = delayedTrains.Count,
- TotalDelayMinutes = totalDelayMinutes,
- TotalTrains = trainServices.Length,
- DelayedTrains = delayedTrains,
- };
-
- } catch (CommunicationException) {
- client.Abort();
- } catch (TimeoutException) {
- client.Abort();
- } catch (Exception) {
- client.Abort();
- throw;
- } finally {
- client.Close();
}
- return new DelaysResponse();
+
+ return new DelaysResponse {
+ GeneratedAt = response.generatedAt,
+ Crs = response.crs,
+ LocationName = response.locationName,
+ Filtercrs = filterCrs,
+ FilterLocationName = filterLocationName,
+ Delays = delayedTrains.Count > 0 || railReplacement || messagesPresent,
+ TotalTrainsDelayed = delayedTrains.Count,
+ TotalDelayMinutes = totalDelayMinutes,
+ TotalTrains = trainServices.Length,
+ DelayedTrains = delayedTrains,
+ };
}
}
}
\ No newline at end of file
diff --git a/src/Huxley/Controllers/BaseController.cs b/src/Huxley/Controllers/LdbController.cs
similarity index 91%
rename from src/Huxley/Controllers/BaseController.cs
rename to src/Huxley/Controllers/LdbController.cs
index b4592af..d806ead 100644
--- a/src/Huxley/Controllers/BaseController.cs
+++ b/src/Huxley/Controllers/LdbController.cs
@@ -24,7 +24,14 @@ You should have received a copy of the GNU Affero General Public License
using Huxley.ldbServiceReference;
namespace Huxley.Controllers {
- public class BaseController : ApiController {
+ public class LdbController : ApiController {
+
+ protected readonly ILdbClient Client;
+
+ public LdbController(ILdbClient client) {
+ Client = client;
+ }
+
protected static AccessToken MakeAccessToken(Guid accessToken) {
// If ClientAccessToken is an empty GUID then no token is required in the Huxley URL.
// If ClientAccessToken matches the token in the URL then the DarwinAccessToken will be used instead in the SOAP call.
diff --git a/src/Huxley/Controllers/ServiceController.cs b/src/Huxley/Controllers/ServiceController.cs
index 4993595..3a201ec 100644
--- a/src/Huxley/Controllers/ServiceController.cs
+++ b/src/Huxley/Controllers/ServiceController.cs
@@ -19,42 +19,27 @@ You should have received a copy of the GNU Affero General Public License
*/
using System;
-using System.ServiceModel;
using System.Threading.Tasks;
using System.Web.Http;
using Huxley.Models;
using Huxley.ldbServiceReference;
namespace Huxley.Controllers {
- public class ServiceController : BaseController {
+ public class ServiceController : LdbController {
+
+ public ServiceController(ILdbClient client)
+ : base(client) {
+ }
+
// GET /service/ID?accessToken=[your token]
public async Task Get([FromUri] ServiceRequest request) {
-
Guid sid;
if (Guid.TryParse(request.ServiceId, out sid)) {
request.ServiceId = Convert.ToBase64String(sid.ToByteArray());
}
-
- var client = new LDBServiceSoapClient();
-
- // Avoiding Problems with the Using Statement in WCF clients
- // https://msdn.microsoft.com/en-us/library/aa355056.aspx
- try {
- var token = MakeAccessToken(request.AccessToken);
-
- var service = await client.GetServiceDetailsAsync(token, request.ServiceId);
- return service.GetServiceDetailsResult;
- } catch (CommunicationException) {
- client.Abort();
- } catch (TimeoutException) {
- client.Abort();
- } catch (Exception) {
- client.Abort();
- throw;
- } finally {
- client.Close();
- }
- return new ServiceDetails();
+ var token = MakeAccessToken(request.AccessToken);
+ var service = await Client.GetServiceDetailsAsync(token, request.ServiceId);
+ return service.GetServiceDetailsResult;
}
}
}
\ No newline at end of file
diff --git a/src/Huxley/Controllers/StationController.cs b/src/Huxley/Controllers/StationController.cs
index f761cac..096c272 100644
--- a/src/Huxley/Controllers/StationController.cs
+++ b/src/Huxley/Controllers/StationController.cs
@@ -18,15 +18,18 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
-using System;
-using System.ServiceModel;
using System.Threading.Tasks;
using System.Web.Http;
using Huxley.Models;
using Huxley.ldbServiceReference;
namespace Huxley.Controllers {
- public class StationController : BaseController {
+ public class StationController : LdbController {
+
+ public StationController(ILdbClient client)
+ : base(client) {
+ }
+
// GET /{board}/CRS?accessToken=[your token]
public async Task Get([FromUri] StationBoardRequest request) {
@@ -34,37 +37,21 @@ public async Task Get([FromUri] StationBoardRequest request) {
request.Crs = MakeCrsCode(request.Crs);
request.FilterCrs = MakeCrsCode(request.FilterCrs);
- var client = new LDBServiceSoapClient();
-
- // Avoiding Problems with the Using Statement in WCF clients
- // https://msdn.microsoft.com/en-us/library/aa355056.aspx
- try {
- var token = MakeAccessToken(request.AccessToken);
+ var token = MakeAccessToken(request.AccessToken);
- if (Board.Departures == request.Board) {
- var departures = await client.GetDepartureBoardAsync(token, request.NumRows, request.Crs, request.FilterCrs, request.FilterType, 0, 0);
- return departures.GetStationBoardResult;
- }
- if (Board.Arrivals == request.Board) {
- var arrivals = await client.GetArrivalBoardAsync(token, request.NumRows, request.Crs, request.FilterCrs, request.FilterType, 0, 0);
- return arrivals.GetStationBoardResult;
- }
-
- // Default all (departures and arrivals board)
- var board = await client.GetArrivalDepartureBoardAsync(token, request.NumRows, request.Crs, request.FilterCrs, request.FilterType, 0, 0);
- return board.GetStationBoardResult;
+ if (Board.Departures == request.Board) {
+ var departures = await Client.GetDepartureBoardAsync(token, request.NumRows, request.Crs, request.FilterCrs, request.FilterType, 0, 0);
+ return departures.GetStationBoardResult;
+ }
- } catch (CommunicationException) {
- client.Abort();
- } catch (TimeoutException) {
- client.Abort();
- } catch (Exception) {
- client.Abort();
- throw;
- } finally {
- client.Close();
+ if (Board.Arrivals == request.Board) {
+ var arrivals = await Client.GetArrivalBoardAsync(token, request.NumRows, request.Crs, request.FilterCrs, request.FilterType, 0, 0);
+ return arrivals.GetStationBoardResult;
}
- return new StationBoard();
+
+ // Default all (departures and arrivals board)
+ var board = await Client.GetArrivalDepartureBoardAsync(token, request.NumRows, request.Crs, request.FilterCrs, request.FilterType, 0, 0);
+ return board.GetStationBoardResult;
}
}
}
\ No newline at end of file
diff --git a/src/Huxley/Global.asax.cs b/src/Huxley/Global.asax.cs
index ca71002..0f72c5f 100644
--- a/src/Huxley/Global.asax.cs
+++ b/src/Huxley/Global.asax.cs
@@ -37,6 +37,9 @@ public class HuxleyApi : HttpApplication {
// Singleton to store the station name to CRS lookup
public static IList CrsCodes { get; private set; }
+ // Singleton to store the London Terminals CRS lookup
+ public static IList LondonTerminals { get; private set; }
+
// Singleton to store the Huxley settings
public static HuxleySettings Settings { get; private set; }
@@ -59,6 +62,29 @@ protected void Application_Start() {
// Set the CRS dictionary passing in embedded CRS path
CrsCodes = GetCrsCodes(Server.MapPath("~/RailReferences.csv")).Result;
+
+ // https://en.wikipedia.org/wiki/London_station_group
+ // Farringdon [ZFD] is not a London Terminal but it probably should be (maybe when Crossrail opens it will be)
+ LondonTerminals = new List {
+ new CrsRecord {CrsCode = "BFR", StationName = "London Blackfriars",},
+ new CrsRecord {CrsCode = "CST", StationName = "London Cannon Street",},
+ new CrsRecord {CrsCode = "CHX", StationName = "London Charing Cross",},
+ new CrsRecord {CrsCode = "CTX", StationName = "City Thameslink",},
+ new CrsRecord {CrsCode = "EUS", StationName = "London Euston",},
+ new CrsRecord {CrsCode = "FST", StationName = "London Fenchurch Street",},
+ new CrsRecord {CrsCode = "KGX", StationName = "London Kings Cross",},
+ new CrsRecord {CrsCode = "LST", StationName = "London Liverpool Street",},
+ new CrsRecord {CrsCode = "LBG", StationName = "London Bridge",},
+ new CrsRecord {CrsCode = "MYB", StationName = "London Marylebone",},
+ new CrsRecord {CrsCode = "MOG", StationName = "Moorgate",},
+ new CrsRecord {CrsCode = "OLD", StationName = "Old Street",},
+ new CrsRecord {CrsCode = "PAD", StationName = "London Paddington",},
+ new CrsRecord {CrsCode = "STP", StationName = "London St Pancras International",},
+ new CrsRecord {CrsCode = "VXH", StationName = "Vauxhall",},
+ new CrsRecord {CrsCode = "VIC", StationName = "London Victoria",},
+ new CrsRecord {CrsCode = "WAT", StationName = "London Waterloo",},
+ new CrsRecord {CrsCode = "WAE", StationName = "London Waterloo East",},
+ };
}
protected void Application_BeginRequest(object sender, EventArgs e) {
diff --git a/src/Huxley/Huxley.csproj b/src/Huxley/Huxley.csproj
index 4316f94..b7ef8d7 100644
--- a/src/Huxley/Huxley.csproj
+++ b/src/Huxley/Huxley.csproj
@@ -50,10 +50,30 @@
True
+
+ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll
+ True
+
False
..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll
+
+ ..\packages\Ninject.3.2.0.0\lib\net45-full\Ninject.dll
+ True
+
+
+ ..\packages\Ninject.Web.Common.3.2.0.0\lib\net45-full\Ninject.Web.Common.dll
+ True
+
+
+ ..\packages\Ninject.Web.WebApi.3.2.4.0\lib\net45-full\Ninject.Web.WebApi.dll
+ True
+
+
+ ..\packages\Ninject.Web.WebApi.WebHost.3.2.4.0\lib\net45-full\Ninject.Web.WebApi.WebHost.dll
+ True
+
@@ -87,15 +107,22 @@
+
+ ..\packages\WebActivatorEx.2.0\lib\net40\WebActivatorEx.dll
+ True
+
+
-
+
+
+
@@ -114,9 +141,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -147,6 +200,7 @@
+
Designer
diff --git a/src/Huxley/ILdbClient.cs b/src/Huxley/ILdbClient.cs
new file mode 100644
index 0000000..d8843e5
--- /dev/null
+++ b/src/Huxley/ILdbClient.cs
@@ -0,0 +1,31 @@
+/*
+Huxley - a JSON proxy for the UK National Rail Live Departure Board SOAP API
+Copyright (C) 2015 James Singleton
+ * http://huxley.unop.uk
+ * https://github.com/jpsingleton/Huxley
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+using System.Threading.Tasks;
+using Huxley.ldbServiceReference;
+
+namespace Huxley {
+ public interface ILdbClient {
+ Task GetDepartureBoardAsync(AccessToken accessToken, ushort numRows, string crs, string filterCrs, FilterType filterType, int timeOffset, int timeWindow);
+ Task GetArrivalBoardAsync(AccessToken accessToken, ushort numRows, string crs, string filterCrs, FilterType filterType, int timeOffset, int timeWindow);
+ Task GetArrivalDepartureBoardAsync(AccessToken accessToken, ushort numRows, string crs, string filterCrs, FilterType filterType, int timeOffset, int timeWindow);
+ Task GetServiceDetailsAsync(AccessToken accessToken, string serviceId);
+ }
+}
diff --git a/src/Huxley/LdbClient.cs b/src/Huxley/LdbClient.cs
new file mode 100644
index 0000000..964dbb3
--- /dev/null
+++ b/src/Huxley/LdbClient.cs
@@ -0,0 +1,66 @@
+/*
+Huxley - a JSON proxy for the UK National Rail Live Departure Board SOAP API
+Copyright (C) 2015 James Singleton
+ * http://huxley.unop.uk
+ * https://github.com/jpsingleton/Huxley
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU Affero General Public License as published
+by the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU Affero General Public License for more details.
+
+You should have received a copy of the GNU Affero General Public License
+along with this program. If not, see .
+*/
+
+using System;
+using System.Threading.Tasks;
+using Huxley.ldbServiceReference;
+
+namespace Huxley {
+ public class LdbClient : ILdbClient {
+
+ private readonly LDBServiceSoapClient client;
+
+ public LdbClient(LDBServiceSoapClient client) {
+ this.client = client;
+ }
+
+ public async Task GetDepartureBoardAsync(AccessToken accessToken, ushort numRows, string crs, string filterCrs,
+ FilterType filterType, int timeOffset, int timeWindow) {
+ return await Execute(() => client.GetDepartureBoardAsync(accessToken, numRows, crs, filterCrs, filterType, timeOffset, timeWindow));
+
+ }
+
+ public async Task GetArrivalBoardAsync(AccessToken accessToken, ushort numRows, string crs, string filterCrs,
+ FilterType filterType, int timeOffset, int timeWindow) {
+ return await Execute(() => client.GetArrivalBoardAsync(accessToken, numRows, crs, filterCrs, filterType, timeOffset, timeWindow));
+ }
+
+ public async Task GetArrivalDepartureBoardAsync(AccessToken accessToken, ushort numRows, string crs, string filterCrs,
+ FilterType filterType, int timeOffset, int timeWindow) {
+ return await Execute(() => client.GetArrivalDepartureBoardAsync(accessToken, numRows, crs, filterCrs, filterType, timeOffset, timeWindow));
+ }
+
+ public async Task GetServiceDetailsAsync(AccessToken accessToken, string serviceId) {
+ return await Execute(() => client.GetServiceDetailsAsync(accessToken, serviceId));
+ }
+
+ private T Execute(Func func) {
+ // Avoiding Problems with the Using Statement in WCF clients
+ try {
+ return func();
+ } catch (Exception) {
+ client.Abort();
+ throw;
+ } finally {
+ client.Close();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Huxley/Properties/AssemblyInfo.cs b/src/Huxley/Properties/AssemblyInfo.cs
index 2930384..57deecc 100644
--- a/src/Huxley/Properties/AssemblyInfo.cs
+++ b/src/Huxley/Properties/AssemblyInfo.cs
@@ -34,5 +34,5 @@
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
-[assembly: AssemblyVersion("1.2.0.0")]
-[assembly: AssemblyFileVersion("1.2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("1.3.0.0")]
+[assembly: AssemblyFileVersion("1.3.0.0")]
\ No newline at end of file
diff --git a/src/Huxley/Web.config b/src/Huxley/Web.config
index 263bfdf..110002d 100644
--- a/src/Huxley/Web.config
+++ b/src/Huxley/Web.config
@@ -1,4 +1,4 @@
-
+