Friday, February 29, 2008

image

Make your mobile web page, appear correctly if an iPhone/iPod user decides to add your web page to the home screen (or whatever those guys call it).

57x57 icon size,   how default is that :-)

Keep up the good work chaps

http://developer.apple.com/documentation/AppleApplications/Reference/SafariWebContent/OptimizingforSafarioniPhone/chapter_3_section_4.html#//apple_ref/doc/uid/TP40006517-SW5

Friday, February 29, 2008 12:51:48 AM UTC  #    Comments [0]  | 
Thursday, February 28, 2008

So, I've been doing this blog for a bit.

You probably either know me,  know of me,  or have just found me by the search engine of your choice.

Anyway,  if you're interested in who I am,  I've just got round to updating my about me page.   Have a look by either clicking About Me, at the top of this page, if your looking at the website, or click this link.

http://www.binaryrefinery.com/main/richardjones.htm

Thursday, February 28, 2008 9:08:42 PM UTC  #    Comments [0]  | 
Tuesday, February 26, 2008

I've been seeing a shift.    In days gone by the majority of the mobile applications I have produced seem to be mostly disconnected; relying on partial network availability.

So its been a move from SQL Compact merge replication to web-service based solutions.   So as  you all know web-service invocation is a bit of a leap of faith.   Call a webmethod,  add some error handling and hope that you get a response back.     So how can you build fully transactional and reliable mobile applications using this technique?

Here's my 5 point rule of thumb.

1) Test you are actually on the network - I use this

public static bool OnNetwork()
       {
           IPHostEntry mydev = Dns.GetHostEntry(Dns.GetHostName());

           for (int nindex = 0; nindex < mydev.AddressList.Length; nindex++)
           {
               string aux = mydev.AddressList[nindex].ToString();
               if (aux != "127.0.0.1") return true;
           }
           return false;

       }

2) Build a generic handler to you webservice.   Make it easy to change the webmethod url,  I use something like this -

public static gsqa01.RA WS()
   {
       gsqa01.RA ret = new gsqa01.RA();   // our web service
       ret.Url = Core.AppSetting("interneturl"); // pull the url out of a config file
       ret.Credentials = WSCreds();
       ret.PreAuthenticate = true; // save some bandwidth use pre-authenticate
       ret.Proxy = new WebProxy();
       return ret;
   }
   private static System.Net.NetworkCredential WSCreds()
   {
       System.Net.NetworkCredential creds = null;
       if (Settings.User.IndexOf("\\") > -1)   // read our username out of the registry (execuse the shorthand method call)
       {
           string[] parts = Settings.User.Split('\\'); // see if we need to do a domain username split
           string domain = parts[0];
           string user = parts[1];
           creds = new System.Net.NetworkCredential(user, Settings.Password, domain);
       }
       else
       {
           creds = new System.Net.NetworkCredential(Settings.User, Settings.Password);
       }
       return creds;
   }

 

3) Call the webservice method (oh go on),  just use the above like this -

           gsqa01.RA ra = Elements.WS(); // this is the generic bit using the above
           bool loginerror = true;
           try
           {
               lr = ra.Login(user,password); // call the web service

               loginerror=false; // little trick
           }
           catch (Exception e)
           {
            }

4) Make sure when you design a web method the parameters you pass to the webmethod or minimal, optimise for SOAP on low bandwidth i.e keep parameter names nice and short.

5) Check, Check and Check again, your response to make sure you get a correct and validated response.  I normally return a class containing my responses and add some form of flag to indicate the webmethod actually performed the action.

 

I'm probably preaching to the converted.    But by the above five point plan,  I've got fast, reliable and dependable web-service responses working on Windows Mobile.

 

What a hobby...

Tuesday, February 26, 2008 11:55:20 PM UTC  #    Comments [1]  | 
Sunday, February 24, 2008

Peter Foot of Windows Mobile fame is also talking at Tech-ED too...

http://peterfoot.net/TechEd2008.aspx

Sunday, February 24, 2008 8:19:03 PM UTC  #    Comments [0]  | 
Monday, February 18, 2008

 

I'm pleased to announce that one of my talks have been approved for TechED 2008, in Florida.

http://www.microsoft.com/events/teched2008/default.mspx

I'm discussing building compelling user interfaces on Windows Mobile,  a topic close to all our hearts me thinks.

Monday, February 18, 2008 9:27:52 PM UTC  #    Comments [0]  | 
Friday, February 15, 2008

So  in the final part of all this LCD screen madness.

I came up with the concept of displaying -

* Flashes - things that popup on the LCD screen immediately and must be shown now,  I.e caller ID popups.

* Tiles - just background news,  things that just display on the LCD when the screen is idle.

* Intermissions - like real-time weather, local travel updates and a live summary of blog hits etc.  This is information that is important to display between tiles.

image

With this concept in mind, today I built two things.

1) A poster routine that lets me post via MSMQ messages of the above types to the LCD queue will subsequently be displayed.

2) A program to go grab RSS articles and post tiles, which will run as a scheduled task running periodically to keep things moving.

What I have now have is a continual moving news on the Crystal Fontz display, interrupted periodically with weather and travel information.  Finally if the phone rings the whole display instantly changes to give a view who's calling.

 

Again happy to share source.

Friday, February 15, 2008 12:29:49 AM UTC  #    Comments [0]  | 
Tuesday, February 12, 2008

So after yesterday's post about getting my 4 line LCD display to start displaying something interesting.   I have just got a step closer to LCD Nirvana.    (Yes I am over egging it).

If you remember, I left it last time that I wanted a nice simple way for the LCD Windows service to be notified of events.  My starting event was my Caller ID service telling me someone was calling the house.   This service drops a row into SQL 2005.   Within SQL 2005 using a managed code trigger I fire emails alerts, to let anyone who's interested know who's calling.

We'll I found the magic command that lets SQL 2005, trust other assemblies so that in managed code stored procedures/triggers you can start to make full use of the .Net Framework.

Now before I go on, I should point out that only a handful of standard .Net assemblies  are trusted by SQL, and for good reason too.   SQL needs to handle multiple transactions in a dependable fashion,  relying on outside .Net code may fudge the whole reliability of SQL.   Anyway throwing caution to the wind, and recognising I'm not exactly building a mission critical system I registered the system.messaging namespace in my SQL database with -

CREATE ASSEMBLY Messaging FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\system.messaging.dll'
WITH PERMISSION_SET = UNSAFE

 

Now from Visual Studio,  I can now add the System.Messaging assembly to my managed code trigger.   Mind you when I add reference it shows up as Messaging, but that's beside the point, it all works -

image

 

I added the following code to my trigger -

        string msmq=@".\PRIVATE$\LCD";

        SqlContext.Pipe.Send("MSMQ Start "+msmq_q);

                   System.Messaging.MessageQueue mq = new System.Messaging.MessageQueue(msmq_q);
                   System.Messaging.Message mess = new System.Messaging.Message();
                   Encoding ASCII = Encoding.ASCII;
                   string msg = "FLASH|" + phonenumber + "|" + identifier + "|" + calltype + "|" + timestamp;
                   byte[] ourbuf = ASCII.GetBytes(msg);
                   mess.BodyStream = new MemoryStream(ourbuf);
                   mess.Label = "";
                   mq.Send(mess);
                   SqlContext.Pipe.Send("MSMQ End " + msmq_q);

This, puts all the call information onto a private message queue called LCD with all the details of the incoming call.

 

Finally I just hooked the Windows Service that controls the LCD screen to just listen for any incoming message queue messages on the specific LCD queue.

Anyway, hope this all makes sense.    Obviously this is early days for this project.   But I now have a sub-second display showing me exactly who's calling the house.   I usually get the alert even before the first ring.

Here's a screen shot of what the LCD screen displays -

image

Tuesday, February 12, 2008 10:40:43 PM UTC  #    Comments [0]  | 
Monday, February 11, 2008

So, I'm on a mission.     I've hooked up a Crystal Fontz 4 Line LCD display to my small business server.   For a nice low cost LCD display for your every need go have a look at - http://www.crystalfontz.com/products/634usb/index.html

I've written a very simple wrapper class that opens a serial port connection to the screen and lets me send characters to the display.

I've added a 'dump' method that because my server is stuck on top of my kitchen fridge,  lets me see what's going on remotely, aka -

 

image

So having previously ported my mobile caller ID application from Windows Mobile onto the server, I thought (and why not) wouldn't it be cool to flash up who's calling the house,  local weather, news etc. on the LCD

So bringing this back down to earth.   The initial plan, is to implement a Windows Service that drives the LCD display, listening to events .    The next challenge is to have the display listen to a range of update sources such as MSMQ, RSS and the cat pushing through the cat-flap.

 

However tonight I've hit a stumbling block.    I have setup a managed code SQL trigger that when the caller ID service inserts a record,  fires an email and lets people know by popup alert who's calling the house.   However I can't (yet) get C# trigger to talk to MSMQ,  sending a message that the LCD service is listening for.

Oh well, early days...

 

But always happy to share source...

Monday, February 11, 2008 9:47:01 PM UTC  #    Comments [0]  | 
Sunday, February 10, 2008

So I've been looking at LINQ a little bit more in the context of building compelling mobile line of business applications.

I found out in my previous article that LINQ to Datasets is implemented in the .Net Compact Framework 3.5,    so I thought great,  lets have a go.   So after a  a bit of a fight (and help from Jim Wilson), I was able to get a mobile application up and running.

So I built a simple example building a .Net Compact Framework 3.5 application targeting Windows Mobile 6.   We're going to add a SQL Compact database to it,  then display data from a table on a datagrid using LINQ to Datasets.

If you add an SDF database to your project,   automatically Visual Studio will prompt you for wether you'd like to have Datasets created for you automatically.

In my case,  I elected to say 'Yes',  for a table name mobile_application_versions,  so cutting to the chase here's all you need to know,  this is the C# code for populating my datagrid -

using (mobappvesionds mn = new mobappvesionds())
           {
               using (Mob_application_versionsTableAdapter tableAdapter = new Mob_application_versionsTableAdapter())
                   tableAdapter.Fill(mn.Mob_application_versions);

               var query = from mob_application_versions in mn.Mob_application_versions
                           //where 1 == 1
                           select mob_application_versions;
               dataGrid1.DataSource = query.CopyToDataTable();
           }

You'll need to add a reference to System.Data.DataSetExtensions but that's about it.   Here's the end result -

image

So,  all good so far.   However I then got thinking.    The Datasets needs to get filled first and then LINQ queries the Datasets.   So in the case of applying queries using LINQ to Datasets your filtering the Datasets not the underlying database.    This is obviously very inefficient as your bringing the data all out of the database first into a Datasets then ignoring any indexes or query optimisation that SQL Compact/SQL does so well then just filtering the Dataset.    So I'm pleased that I got LINQ to Datasets working however careful thought needs to be made to ensure that LINQ really is the right way for building mobile line of business.   

 

Technorati Tags: ,
Sunday, February 10, 2008 7:57:30 PM UTC  #    Comments [0]  | 
Friday, February 01, 2008

I've just found this out the hard way...

I thought in an effort to simplify creation of Mobile Line Of Business applications,  I would look at LINQ.   Language Integrated Query (LINQ),  works in a similar way to Anglia Business Solutions DataMaker technology,  letting the developer concentrate on writing the application code rather than spending time on the plumbing of connecting an application to a database and writing long queries or calls to stored procedures etc..

So today, I thought I would give LINQ a try within the Compact Framework using a SQL Compact Database.

I ran SQLMetal to create the intermediate files required to begin with the wonderful world of LINQ.

All good so far.   However the .Net Compact Framework 3.5 doesn't support the namespace System.Data.Linq

This was pointed out by Daniel Moth, to be fare a while back -

http://geekswithblogs.net/steveclements/archive/2007/11/13/LINQ-to-SQL.compact.aspx

So,  I'll have to carry on using DataMaker for a while longer...

Technorati Tags:
Friday, February 01, 2008 3:54:59 PM UTC  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: