Archive

Archive for April, 2016

Vehicle Number plate lookup API: Ireland

ie

 We’ve just updated the structure of the data returned from the API for Ireland, to provide more data, and some other under-the-hood improvements

The website has been updated to carregistrationapi.ie

Car registration plates in Ireland use the /CheckIreland endpoint and return the following information:

  • Make & Model
  • Style
  • Transmission
  • ABI Code
  • Fuel Type
  • Number of Seats

 

Sample JSON:

{“ABICode”:”95052243″,”Description”:”HYUNDAI IX35 1.7 CRDI 115HP 2WD (1685cc – 5 door) “,”RegistrationYear”:”2012″,”CarMake”:{“CurrentTextValue”:”HYUNDAI”},”CarModel”:{“CurrentTextValue”:”IX35″},”BodyStyle”:{“CurrentTextValue”:”4×4″},”Transmission”:{“CurrentTextValue”:”Manual”},”FuelType”:{“CurrentTextValue”:”Diesel”},”MakeDescription”:{“CurrentTextValue”:”HYUNDAI”},”ModelDescription”:{“CurrentTextValue”:”IX35″},”NumberOfSeats”:{“CurrentTextValue”:5}}

Categories: Uncategorized

New Zealand Car Registration lookup API

new_zealand_640Yet another country is now supported by our rapidly growing car registration lookup API, which now supports New Zealand, and can be accessed via http://carregistrationapi.nz/

Car registration plates in New Zealand use the /CheckNewZealand endpoint and return the following information:

  • Make
  • Model
  • Engine Size
  • Fuel Type
  • Body Style
  • VIN number
  • Engine Code
  • Number of seats
  • Colour
  • Country of assembly
  • Stolen indicator
  • Odometer reading (last and current)
  • Warrant of Fitness
  • Import status

Sample Json:

{“Description”:”2003 FORD ESCAPE”,”RegistrationYear”:”2003″,”CarMake”:{“CurrentTextValue”:”FORD”},”CarModel”:{“CurrentTextValue”:”ESCAPE”},”EngineSize”:{“CurrentTextValue”:”2,967cc”},”FuelType”:{“CurrentTextValue”:”Petrol”},”MakeDescription”:{“CurrentTextValue”:”FORD”},”ModelDescription”:{“CurrentTextValue”:”ESCAPE”},”BodyStyle”:{“CurrentTextValue”:”Station Wagon”},”VechileIdentificationNumber”:”JC0CU041421109337″,”EngineNumber”:”1109337″,”Colour”:”Green”,”NumberOfSeats”:{“CurrentTextValue”:”5″},”Assembly”:”Japan”,”Stolen”:”No”,”EstimatedCurrentOdometer”:”167,000 “,”LastOdometerReading”:”154,228 “,”WarrantOfFitness”:”Yes”,”PlateType”:”Standard”,”Origin”:”NZ New”,”VehiclePurpose”:”Private Passenger vehicle”,”ReasonLatestRegistration”:”New”,”FirstLocalRegistration”:”08-Jul-2003″,”Imported”:”No”}

Categories: Uncategorized

POP3 in C# with System.Net.Pop3 #bizzehdee

logo-intro

If you want to have your c# application receive email on behalf of a user, then there are plenty of solutions out there, but the one I picked had no documentation, and I had to figure it out myself. Not too hard but, I thought I’d include it here to help people out.

I picked the NuGet package System.Net.Pop3 by bizzehdee because it was the first result in NuGet, but then realised it didn’t even have a “hello world” example.

// https://www.nuget.org/packages/System.Net.Pop3/ (bizzehdee)
var pop3Client = new Pop3Client();
pop3Client.Connect(“mail.server.com”, 110, false);
pop3Client.SendAuthUserPass(“postmaster@server.com”, “Password!”);
var intEmails = pop3Client.GetEmailCount();
var emails = new List<Pop3Message>();
for (uint i = 1; i <= intEmails; i++)
{
var email = pop3Client.GetEmail(i);
emails.Add(email);
}

This particular code was tested against a MailEnable email server installed on an Azure Virtual machine, with a catch-all email address. As a little “Gotcha” during setup, on azure, you have to open an endpoint on port 110 before it will accept pop3 connections, regardless of what the firewall on the machine itself says.

Categories: Uncategorized

USA number plate lookup API #easteregg

usaThis is a bit of an Easter egg, since it’s not been officially released yet, but we’ve developed a lookup for vehicle number plates that works across all 50 states of the US.

It’s located at http://www.regcheck.org.uk/api/reg.asmx?op=CheckUSA

It requires an account from RegCheck.org.uk – but you can get a free one with 10 credits for testing purposes.

The USA requires two parameters, the registration number, and the state where the vehicle was registered. The state is a two letter abbreviation of one of the 50 states, or DC (District of Columbia), GU (Guam), PR (Puerto Rico) or VI (Virgin Islands).

It returns the following information about the vehicle

  • Description
  • Body Style
  • VIN
  • Engine Size
  • Country of Assembly

Sample Json:

{“Description”:”2003 Harley-Davidson FLHR/I Road King “,”BodyStyle”:{“CurrentTextValue”:””},”VechileIdentificationNumber”:”1HD1FWW1X3Y746238″,”Assembly”:”United States”,”EngineSize”:{“CurrentTextValue”:”1450CC 2 Unleaded Gas”}}

Categories: Uncategorized

Schedule work for the future in C# with #HangFire

Sometimes you don’t want a ASP.NET website do something immediately, perhaps you’d like to do it at a certain time, or after a delay, or every night at 5am.

IIS will kill any process that runs over 90 seconds by default, and will recycle every 20 minutes by default, destroying any in-memory data.

So, I investegated HangFire, a free open source management system of out-of-process c# execution.

You install it using NuGet PM (PM> Install-Package Hangfire), then you have to add a code file to your application called StartUp.cs as follows

using Hangfire;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(MyWebApplication.Startup))]

namespace MyWebApplication
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
GlobalConfiguration.Configuration
.UseSqlServerStorage(“server=localhost; database=dbname; integrated security=yes”);

app.UseHangfireDashboard();
app.UseHangfireServer();
}
}
}

Then, it’s a matter of calling it using something like

var jobId = BackgroundJob.Schedule(
() => BackgroundWork.SomeFunction(),
TimeSpan.FromSeconds(7));

Where BackgroundWork.SomeFunction is defined in a seperate class with  qualified namespace

public static void SomeFunction()
{
System.Diagnostics.Debug.WriteLine(“IT WORKED!!!”);
}

If it doesn’t work, then you can access the hangfire interface at localhost/hangfire – which gives you the exception details – which are generally not very helpful, but a start.

Now, the reason why I bolded the “seperate class with qualified namespace” is that if you don’t do this, you get this error:

Failed An exception occurred during processing of a background job.

System.Reflection.TargetInvocationException

Exception has been thrown by the target of an invocation.

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Web.UI.Page.get_Server()
   at ASP.default_aspx..ctor() in c:\Users\Fiach\Documents\Visual Studio 2013\HangFireResearch\Default.aspx.cs:line 912304
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at Hangfire.JobActivator.ActivateJob(Type jobType)
   at Hangfire.JobActivator.SimpleJobActivatorScope.Resolve(Type type)
   at Hangfire.Server.CoreBackgroundJobPerformer.Perform(PerformContext context)
   at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_0.<PerformJobWithFilters>b__0()
   at Hangfire.Server.BackgroundJobPerformer.InvokePerformFilter(IServerFilter filter, PerformingContext preContext, Func`1 continuation)
   at Hangfire.Server.BackgroundJobPerformer.<>c__DisplayClass8_1.<PerformJobWithFilters>b__2()
   at Hangfire.Server.BackgroundJobPerformer.PerformJobWithFilters(PerformContext context, IEnumerable`1 filters)
   at Hangfire.Server.BackgroundJobPerformer.Perform(PerformContext context)
   at Hangfire.Server.Worker.PerformJob(BackgroundProcessContext context, IStorageConnection connection, String jobId)

 

Categories: Uncategorized