Demonstration Video and Source Code

Source code is for version 1.2.1

Basic source for a console client, download here:

static void Main(string[] args)
{
	AsyncContext.Run(() => DoStuff());
}

static async Task DoStuff()
{
	var client = IsonasAccessControlClient.Create(hostname: "weezwinsvr");
	IIsonasConnection connection;
	using (var key = new SecureString())
	{
		"2D381400325FCF24A0D9AC16094E47622D381400325FCF24A0D9AC16094E4762".ToList().ForEach(key.AppendChar);
		connection = await client.OpenEncrypted(key: key);
		// controller.Open() returns an unencrypted connection
	}
	IISonasSession session;
	using (var password = new SecureString())
	{
		"sapient".ToList().ForEach(password.AppendChar);
		session = await connection.Logon(username: "admin",
										 password: password);
	}
	await session.UsingAsync(async s => { await WorkWithSession(s); });
}

static async Task WorkWithSession(IISonasSession session)
{
	var id = new IdFile(lastName: "Doe",
						firstName: "John",
						personIdString: "auto_200",
						area: "COMMON",
						ssn: "123456789");
	await session.AddIdFile(id);
	Exception uncaught = null;
	var shift = new Shift(shiftName: "the shift",
						  days: new[]
								{
									new ShiftDay(dayOfWeek: IsoDayOfWeek.Wednesday,
												 start: new LocalTime(hour: 17,
																	  minute: 0),
												 end: new LocalTime(hour: 17,
																	minute: 30))
								});
	try
	{
		var allIds = await session.QueryAllIdFiles();
		Console.WriteLine("IDs are {0}",
						  JsonConvert.SerializeObject(allIds));
		var retrievedId = await session.QueryIdFile(id.PersonIdString);
		Console.WriteLine("Retrieved ID file {0}",
						  JsonConvert.SerializeObject(retrievedId));
		await session.AddShift(shift);
		var retrievedShift = await session.QueryShift(shiftName: shift.ShiftName);
		Console.WriteLine("Retrieved shift {0}",
						  JsonConvert.SerializeObject(retrievedShift));
		Console.WriteLine("\nPress Enter to continue...");
		Console.ReadLine();
	}
	catch (Exception e)
	{
		uncaught = e;
	}
	await session.DeleteIdFile(id.PersonIdString);
	await session.DeleteShift(shift);
	// C# 6 will support awaits inside a catch block
	if (uncaught != null)
	{
		ExceptionDispatchInfo.Capture(uncaught).Throw();
	}
}

 

Video of output (using version 1.0):