Blog Stats
  • Posts - 157
  • Articles - 0
  • Comments - 36
  • Trackbacks - 0

 

Sunday, January 18, 2015

Apple Watch - DOES oData


Watch

This is cool!   I just got an Apple Watch App.  getting results live over the Internet from an oData database.   All realtime, and working really quickly.   Here’s how it works….

So using the following code in an Apple Watch app.

WKInterfaceController.openParentApplication(ourmsg, reply: { (replyValues, error) -> Void in dispatch_async(dispatch_get_main_queue(), { self.populate(replyValues) });

This makes a call into my iPhone app. which makes an oData request.

The results then come back and populate a table using a callback to main thread.

The iPhone app, has a very simple bit of code that responds to the watch request and looks like -

func application(application: UIApplication!, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]!, reply: (([NSObject : AnyObject]!) -> Void)!) {
var xx = Core().oDataQuery("Categories")
xx.invoke { (ret, error,status) -> () in
if error == nil
{
if var returndata:NSArray = ret
{
var ourreply=["Data":returndata]
reply(ourreply)
}
}
}

Final bit of code, is the stuff to populate the Apple Watch table
func populate(ret:[NSObject : AnyObject])
{

if let records=ret["Data"] as? NSArray
{

self.tvourdata.setNumberOfRows(records.count, withRowType: "default")
// Iterate over the rows and set the label for each one.
for var i = 0; i < records.count; i++
{
// Get the to-do item data.
if let record = records[i] as? NSDictionary
{

if let row = tvourdata.rowControllerAtIndex(i) as? OurRowController
{
var label=record.valueForKey("CategoryName") as String row.lblname.setText(label)
}

}
}
}
}

Friday, January 16, 2015

UK Top 40 in JSON format


http://ben-major.co.uk/labs/uk-top-40/?format=json

Wednesday, January 14, 2015

Offline & Online, so easy with oData


So today, I had to bite the bullet and realise that certain modules in my app. will only work online. Online and connected, able to see a server.... This meant I had to move away from pulling oData good stuff away from Core Data and just deal with the data that arrived by making a URL request. So this is interesting, first this feels slow. I had to put up iOS views with spinners... (never good). With offline, you can just presume stuff is there. Secondly you have to marshall data types on the fly. Bringing stuff in via core data, means you validate a date is a date, and a bool is a bool. So I'm getting there a couple of forms built and all appears to be working. I've had to build cliche little 'we could not get data from the server messages', but apart from that all good. Working with Swift feels that this is an alien world too. We're getting there....

Tuesday, January 13, 2015

oData the best tonic


Following on from last nights post. I'm now up-to a 42 entity/pages/tables (call it what you like) in an iOS app, synchronising effortlessly to NAV using oData. Its amazing what a partnership between an iPad and a heavyweight Dynamics solution can do to build truly compelling line of business app. iPad Stuff

Saturday, January 10, 2015

oData NAV Swift and Me


So the adventure continues. I've been building an iPad app that consumes data from Dynamics NAV. I use NAV pages which I bring down into iOS via oData, these are then saved into a Core Data database. I only bring back records that have been altered since the date/time of the last sync. minimising data volumes. I've written a few custom classes that marshall the oData JSON formatted data correctly into Core Data attributes (i.e date/time and numeric/boolean conversion). In addition I introspect indexes on Core Data entities to work out if I'm doing an insert/update or delete. Once this synchronisation has taken place our user is then free to work offline. I then track in iOS records have been modified, using two simple flags [New_Record] and [Synchronised]. Slightly reverse logic for Synchronised (or maybe a bad name), but this flag is set to indicate that a record need to be sent back to NAV. When the sync. process runs again it pushes back to NAV any changes. This process works very well, its lightweight and built entirely in SWIFT. Everything works without any complex session state handling. It doesn't do anything really smart like conflict resolution which you get with technologies like SQL merge replication. However for my purposes it works just fine. I've even got it to the stage where I can handle media (video, audio, images) using Hex Encoding. Finally... We have a fail safe. I have the option of emailing off of the device CSV's containing records that need to be sent back to the server. Just in case...

Saturday, December 20, 2014

Welcome under my tree


oData comes of age


So, very pleased to report, that YES. It is possible to create an iOS app. that can sync and work offline (via all SWIFT) client with Dynamics NAV. More details to follow. But early testing looks very encouraging...

Monday, April 14, 2014

JSON Odata, baby steps


So this is what I feel are some really constructive steps for next gen. mobile. Allow your App. to talk to your backend datasource via OData. I've spent a tonne of hours trying to make a combination of SQL Sever, .Net 4.5 all try to agree this is the way forward. Tonight, they are all not sharing the same vision. :-(

Saturday, January 11, 2014

SQL Server Compact; what gives!!


So I have many a customer using SQL Compact offline replication, you know like cool mobile apps. that just work offline (like they need to in real life). Last blog post on the Microsoft Embedded Technology Blog, was 4 years ago. I guess we all must have a permanent go anywhere Internet Connection now.... http://blogs.msdn.com/b/sqlservercompact/archive/2010/07/07/introducing-sql-server-compact-4-0-the-next-gen-embedded-database-from-microsoft.aspx

Saturday, January 4, 2014

CRUD for all?


CRUD, or Create, Read, Update, Delete is what you do with most databases or when working with a new bread of cloud based services (well all Dynamics products). However. I think we should not exclude Execute (i.e. run stuff). So I propose we extend the acronym to CRUD(E)....
 

 

Copyright © Richard Jones