Thursday, May 31, 2007

I still love this site on MSDN UK,  MSDN Nuggets.

I quote -

"Don't have the time to read a 10-page how-to article or watch a full length webcast? Try an MSDN Nugget, a webcast that takes you step-by-step to discovering new functionality or exploring a hot developer topic, all in 10-15 minutes. View them online now or download for later reference."

http://www.microsoft.com/uk/msdn/events/nuggets.aspx

Its a great reference for all sorts of Microsoft related development, like creating managed code stored procedures, writing mobile application.   All in bite size chunks...

Technorati tags:
Thursday, May 31, 2007 2:43:02 PM UTC  #    Comments [0]  | 
Technorati tags:
I use Windows Live Writer to post to my Blog,  I've just downloaded Beta 2.    Go get it 
here
Maybe its the improved UI, of Beta 2,    but prominently placed is the add plugin button.  
I found this plugin, that lets you paste formatted text from Visual Studio.
Click Paste From Visual Studio Plugin
 
image 
 
I hope to use this to make my code snippets a bit more legible in upcoming posts.
Thursday, May 31, 2007 6:47:39 AM UTC  #    Comments [0]  | 
Wednesday, May 30, 2007

Often when building a store and forward SQL Compact mobile application I need to establish early on in the project  how long it will take for the device to synchronise with the base SQL Server.   Knowing how long syncrhonisation will take over GPRS, or WIFI can be one of the main go/no go points of whether a SQL Compact solution is best. 

So I came up with this simple way to establish the initial syncrhonisation time to fully populate the mobile database.   Obviously this calculation is based on the bandwidth we have available.

This is what I came up with, give it the path to an SDF SQL Compact database and off you go -

 

public string SyncTimes(string strfileofsdffile)

{

FileInfo f = new FileInfo(strfileofsdffile);
long bits= f.Length*8;
decimal elevenb = Math.Round((decimal) (bits / 11000000),1); // 11mbs
decimal gprs = Math.Round((decimal)(bits / 80000), 1); // 8kbs
decimal hsdpa = Math.Round((decimal)(bits / 3600000), 1);  // 3.6mbs

return "802.11b (11Mbs)=" + timelabel(elevenb) + ",GPRS/2G (8Kkbs)=" + timelabel(gprs) + ",HSDPA/3.5G (3.6mbs)=" + timelabel(hsdpa);

}

 

private string timelabel(decimal seconds)
{
string ret = ""
decimal decseconds = seconds;
if (decseconds < 60)
{
ret += decseconds + " seconds"
}
else
{
decimal decminutes = Math.Round(decseconds / 60);
decseconds = (decminutes * 60)-seconds;
ret += decminutes.ToString("00")+":"+decseconds.ToString("00");
}
return ret;
}

 

Obviously this is only serves as a guide to show the initial syncrhonisation and subsequent syncs.  will just be transmission of any data changes.    However I find it invaluable to just get a feel of how long it till take to get started.

Technorati tags:
Wednesday, May 30, 2007 7:24:18 PM UTC  #    Comments [0]  | 
Monday, May 28, 2007

The majority of mobile applications I build are on SQL Compact using Merge replication.    Merge replication although a little 'fun' to get your head around the first couple of times.   Once setup it up is really a remarkable bit of kit.

 

The ability to construct store and forward partially connected applications with the minimum (well by the time you've done it for the 3rd time) of fuss.

Seeing Click  last week I got thinking today about the one laptop per child project( http://www.laptop.org/ ),   3rd world mesh networks and other situations where low cost/low power and low bandwidth were all the order of the day; SQL compact and merge replication on Windows CE could be a great fit.

Producing applications that work sensibly with low bandwidth and low power is what Windows CE has been about for the last 11 years.   Plus I've still to do merge replication over a satellite link :-)

Technorati tags: ,
Monday, May 28, 2007 9:52:44 PM UTC  #    Comments [0]  | 
Friday, May 25, 2007

So today I had an idea,  could SQL Compact be used to record data in pretty much realtime?    So I needed to look at raw insert performance and the best way to really make SQL Compact cook.

So this baby using the SqlCeCommand.Prepare method shoots through multiple record inserts.    The Prepare method tells the SQL Compact to expect more sql parameters and backs off trying to interpret the query (this is over simplifying the process).

Putting things in a SQL transaction also gives us the ability to roll everything back if we have problem.    I think the answer to our realtime recording is pretty much a YES.

 

* Note, I pass in a 2 dimensional array of SQLCE parameters each representing a row of multiple columns.

public object BulkInsert(SqlCeParameter[,] ourparams)
{
object ret=null;
if (ourparams.GetLength(0) == 0) return ret;
StringBuilder sbsql = new StringBuilder();
sbsql.Append("INSERT INTO ");
sbsql.Append(tablename+" ");
sbsql.Append("(");
sbsql.Append(" [COLORCODE] ");
sbsql.Append(",[COMMENTS] ");
sbsql.Append(") ");
sbsql.Append("VALUES ");
sbsql.Append("(");
sbsql.Append(" @colorcode "); // Maps To Database Field - [COLORCODE]
sbsql.Append(",@comments "); // Maps To Database Field - [COMMENTS]
sbsql.Append(")");
bool isopen = (Cn!=null && Cn.State == ConnectionState.Open);
SqlCeCommand cmd = null;
SqlCeTransaction trans = null;
bool allok = true;
try
{
if (!isopen) this.Open();
trans = Cn.BeginTransaction();
cmd = new SqlCeCommand(sbsql.ToString(),this.Cn,trans);
}
catch
{
if (cmd!=null) cmd.Dispose();
if (trans != null) trans.Dispose();
if (!isopen) Close();
showexception("Sql - Could Not Open Db Connection", sbsql.ToString());
return null;
}
for (int intcount = 0; intcount < ourparams.GetLength(1); intcount++)
cmd.Parameters.Add(ourparams[0, intcount]);
// see if we are really inserting multiple records
if (ourparams.GetLength(0)>1)
{
try
{
cmd.Prepare();
}
catch
{
if (cmd!=null) cmd.Dispose();
if (trans != null) trans.Dispose();
if (!isopen) Close();
showexception("Sql - Could Not Prepare Parameters", sbsql.ToString());
return ret;
}
for (int rowcount = 0; rowcount < ourparams.GetLength(0); rowcount++)
{
if (rowcount > 0) // first row has already been setup
for (int intcount = 0; intcount < ourparams.GetLength(1); intcount++)
cmd.Parameters[intcount].Value = ourparams[rowcount, intcount].Value;
try
{
cmd.ExecuteNonQuery();
}
catch (SqlCeException e)
{
allok = false;
trans.Rollback();
showerrors(e, cmd.CommandText);
}
}
}
else
{
try
{
cmd.ExecuteNonQuery();
cmd.CommandText = "SELECT @@IDENTITY"
ret = CoreDb.DbToString(cmd.ExecuteScalar());
}
catch (SqlCeException e)
{
allok = false;
trans.Rollback();
showerrors(e, cmd.CommandText);
}
}
if (allok)
if (trans != null) trans.Commit();
if (cmd!=null) cmd.Dispose();
if (trans!=null) trans.Dispose();
if (!isopen) this.Close();
return ret;
}

 

Friday, May 25, 2007 8:53:49 PM UTC  #    Comments [0]  | 

In Orange's wisdom they have taken Live Messenger off of their build of the HTC VOX (E650).

I'm trying to work out how to copy messenger onto an E650, using the files on an HTC VOX,  this is very much work in progress.   However to make up for this shortfall,  I found this -

http://get.live.com/betas/messengermobile_betas

Works really nicely...

Friday, May 25, 2007 2:12:22 PM UTC  #    Comments [0]  | 
Wednesday, May 23, 2007

So another day spent  knee deep in Compact Framework programming.    It still amazes me that with little work some amazing solutions can be produced.   From nothing to a fully fledged mobile application takes a couple of hours rather than days of traditional development.

Working the detail of a mobile application is always a challenge but having the correct tools (Visual Studio 2005, Anglia DataMaker) makes the effort shift to mostly interpreting customer requirements rather than solving technical issues.

Today's hot tip from me is to always show the customer lots of screenshots of the proposed solution well ahead of the build.   Customers usually don't know what they are going to get from a mobile solution so some upfront story- boarding lakes much of the pain out of the build process as expectations are already set.

 

Technorati tags:
Wednesday, May 23, 2007 10:07:08 PM UTC  #    Comments [0]  | 
Sunday, May 20, 2007

OK, off topic,  but my weekend have been spent playing around with some HIFI kit and I'm....

Dismayed that HDMI switching amplifiers still need an optical or co-ax audio connection for each HD video source.   I thought that HDMI carried all the digital audio you needed?    So the simplistic bliss of having one cable from digital AV components is still not a reality (in my test).  You need an HDMI and a separate digital audio cable still.

Dismayed that the user interface of AV amplifiers still looks like something from the early 80's.

Dismayed, that I now have more remotes than fingers.   Surely a dedicated remote for each device is a thing of the past.   Windows media Centrex goes along way but its hard to control  every aspect of 3rd party equipment from the remote.   (yes, know multi-function remotes are good, but this should happen out of the box)

Dismayed that speakers require cables,  subs have their own set of control, power options and other complex settings I don't understand.

UPNP where are you?   I don't do proprietary multi-room..

 

Come on guys its 2007...

However,   just watched 24, and it don't half sound good...

 

Technorati tags: ,
Sunday, May 20, 2007 8:58:59 PM UTC  #    Comments [0]  | 
Friday, May 18, 2007

So I've been training a whole bunch of people in the black art of Microsoft Office Sharepoint Server 2007 this week.   Man...  this is a cool product.   Sharepoint has really come of age.   Lots of nice new stuff, like RSS, Wiki's and a full overall to make this really look and feel truly Web 2.0 all packed into a nice commercial supported shrink wrapped product.

So the mobile rendering of pages is a little bit to be desired (hell I'm not slagging it),  but it is  really a serious bit of kit.  

So thinking glass half full,   Its a robust ready to roll and strong bit of kit.   So go grab yourself an evaluation version, you won't be disappointed.

http://www.Microsoft.com/downloads/details.aspx?FamilyId=2E6E5A9C-EBF6-4F7F-8467-F4DE6BD6B831&displaylang=en

p.s - did you know I went to school with Kate Moss (yes really)

 

Technorati tags:
Friday, May 18, 2007 10:48:10 PM UTC  #    Comments [0]  | 

When building windows mobile forms,  you need to know where you are.   You need to know when to display, next buttons, indicate when no records are found and tightly control the user experience.     Controlling when things are displayed hidden etc.  can take a while to perfect and an age to debug.    The approach I take is as follows.

// Firstly I setup a enumeration, of what states a particular form can be in, for example -

private enum windowstates
{

undefined,
opening,
notfound,
foundmultiple,
foundone

}

// Next I store the current state our form is in and the previous state, to avoid any unnecessary repainting

private windowstates currentstate = windowstates.opening;
private windowstates previousstate = windowstates.undefined;

 

// Whenever I need to switch on and off different form elements, I set the state and call a button_handler()

private void something_happened()
{
currentstate=windowstates.foundmultiple;
button_handler()
}

 

// Finally, the button handler switches on and off the various form elements in one place

private void button_handler()
{

if (currentstate == previousstate) return;
previousstate = currentstate;


switch (currentstate)
{
case windowstates.opening:

// switch on and off form elements
// set focus on controls etc.
break;

case windowstates.notfound:
// switch on and off form elements
// set focus on controls etc.
break;

case windowstates.foundone:

// switch on and off form elements
// set focus on controls etc.

break;

}
}

This approach means that I only have to get the button handler routine correct once, and all forms are then extremely easy to maintain.    I know techniques like databinding also help with this but for simple and effective reliable form building this works a treat.

 

Technorati tags:
Friday, May 18, 2007 3:02:34 PM UTC  #    Comments [0]  | 
Thursday, May 17, 2007

Today's been a great day for me.  I spoke tonight at a Cambridge Network Event speaking on the highs and low's of mobile line of business.

After speaking for an hour and showing some of the solutions that I have been building for the past 6 months.   The questions rained in....

Thursday, May 17, 2007 11:06:53 PM UTC  #    Comments [0]  | 
Tuesday, May 15, 2007

So working in the Fresh Produce industry I get to work with some cool bits of kit.  I've been working for several years with the latest mobile devices which progressively gets smaller and faster.   However at the other end of the spectrum I get to work with some very BIG devices, like weighbridge's and multi million pound grading machines.

So unlike mobile devices something like a weighbridge requires a site visit to maintain.  In addition connecting up a weighbridge to reliably record calibrated readings into a database can be challenging.

The biggest issue with weighbridge's is their physical location.   They are usually out in exposed areas away from any IT.    For the past few installations we have used Microsoft Message Queue (MSMQ) as the perfect way to reliably instruct a P.C connected via a serial port to the weighbridge to take a steady weight reading.   The weight reading is then returned on another queue for later processing.   The P.C application runs as a service and monitoring a message queue is totally network independent and pretty bullet proof.

So MSMQ, great technology in my view forgotten about by the world.    I encourage you to consider it when looking at challenging networking solutions.

Technorati tags:

Tuesday, May 15, 2007 8:53:53 PM UTC  #    Comments [0]  | 

Anglia have just won another award for the Label Check mobile application, that has been my life for the past 6 months.    We won the 'Innovation of the Year' in the Re:Fresh award for Fresh Produce Solutions.    I'm particularly pleased because once again, it proves that mobile line of business can make a big difference.

http://www.refresh.eu/index.php?zr=awards

Details of Solution at -

http://www.binaryrefinery.com/main/PermaLink,guid,0c94a6de-04e3-45a6-b5ff-abf3c65f7f53.aspx

Tuesday, May 15, 2007 1:16:47 PM UTC  #    Comments [0]  | 
Monday, May 14, 2007

So the GPS intermediate driver adds a nice wrapper around the messages received from a connected GPS device.     So I got thinking today,  this could form the basis of simple way to make a network connected timesource.    We get sent from the GPS device a time that is derived from the atomic clocks in the orbiting satellites.

Now I know what you're all thinking, why don't you just use an Internet time service,   but what's the fun in that....

+ this could be another great example of an old pocket PC making a great server...

So I just happen to have a Imate JasJar with a cracked screen lying around.    Windows Mobile 5, added the GPS intermediate driver,  so maybe base this project around this platform.

So, cool project?  

Monday, May 14, 2007 10:36:11 PM UTC  #    Comments [0]  | 
Sunday, May 13, 2007

Following -

http://blogs.msdn.com/sqlservercompact/rss.xml

I thought I would build a generic Compact Framework method that would determine if we have any rows to send back to Sql Sever.   This should save lots of those unnecessary sync's and hence GPRS/3G charges.

I came up with the following code snippet.

 

public bool AnyRowsToUpload(string tablename)
{
StringBuilder sbsql = new StringBuilder();
sbsql.Append("SELECT MAX(__sysIG),MAX(__sysCG) ");
sbsql.Append("FROM ");
sbsql.Append(tablename + " ");
sbsql.Append("UNION ALL ");
sbsql.Append("SELECT LastUploadedGen,SentGen80 ");
sbsql.Append("FROM ");
sbsql.Append("__sysMergeSubscriptions");

SqlCeDataReader rdr = Sql(sbsql.ToString());   // < helper function to just execute the SQL, search my blog for source
int maxig = 0;
int maxcg = 0;
int lastuploadedgen = 0;
int sentgen80 = 0;
if (rdr != null)
{
if (rdr.Read())
{
maxig = CoreDb.DbToInt(rdr[0]); // < helper function to just quickly turn reader value to int, seach my blog for source
maxcg = CoreDb.DbToInt(rdr[1]);
rdr.Read();
lastuploadedgen = CoreDb.DbToInt(rdr[0]);
sentgen80 = CoreDb.DbToInt(rdr[1]);
}
rdr.Dispose();
rdr.Close();
}
// for SQL Server 2005, uncomment the below
return maxig > lastuploadedgen || maxcg > lastuploadedgen;
// for SQL Server 2000, uncomment the below
// return maxig > sentgen80 || maxcg > sentgen80;
}

 

I'm particularly pleased with this (excuse my lack of modesty), because the whole thing is executed within a single call to SQL Compact.

 

Sunday, May 13, 2007 3:59:55 PM UTC  #    Comments [0]  | 
Thursday, May 10, 2007

In the middle of summer our village hosts a feast see

http://www.beachnews.org/Feast/Feast_1.htm

This year as ever there is a balloon race.   For those of you that don't know what I'm talking about (normally a large percentage :-) ) .    A balloon race is lots of helium filled balloons launched from a central location each carrying a little (paid for) mail reply card.   The finder of furthest balloon returning a reply card by post (yawn),   and the purchaser of the balloon wins a prize.

I'm in charge of drawing the maps, and registering the finds:-)   Virtual Eath BRING IT ON.....

(Launch Date 9th June)

 

Technorati tags:
Thursday, May 10, 2007 8:12:01 PM UTC  #    Comments [0]  | 
Tuesday, May 08, 2007

Andy Wigley, Peter Foot and Daniel Moth have just finished what looks to be an epic book on Windows Mobile programming.

These guys seriously know their stuff and hats off to them for putting in the hours and dedication to bring book to fruition.

http://www.amazon.com/Microsoft-Mobile-Development-Handbook-Pro/dp/0735623589/ref=sr_1_5/104-5668948-5434354?ie=UTF8&s=books&qid=1178575782&sr=1-5

Look no further for a definite mobile programming bible.

 

Tuesday, May 08, 2007 10:11:07 PM UTC  #    Comments [0]  | 
Saturday, May 05, 2007

Looks like Dr Neil's and my prayers (yes I am exaggerating a bit) have been answered,

The Windows Sideshow team have released the latest version of the their simulator as a standalone download.   If you want a cool thing to play with this weekend, try it out (you won't be sorry).

http://blogs.msdn.com/sideshow/archive/2007/04/27/device-simulator-version-1-3-3-0-released.aspx

 

 

Technorati tags:
Saturday, May 05, 2007 2:54:36 PM UTC  #    Comments [0]  | 

So its been a bit of a rollercoaster ride,   here are my niggles after the first week

  1. I've seen the E Edge icon ONCE.   What a moment that was!
  2. I initially had an issue, with installing software and the installer hanging.    I note from comments that other people have had this issue too.   I think unlocking the phone, may have cured this, but can't be 100%
  3. Why oh, why is messenger taken off by Orange?
  4. People can't hear me properly on my car-kit,   (its a Nokia Bluetooth car-kit).   This seemed to work much better on an Imate SP5, On Vodafone.    I don't think its a reception issue as I can hear people fine.
  5. Doh.   I've scratched the screen a little bit.   Stupidly I had the phone in my pocket with my keys.
  6. GPS Intermediate driver, no easy way of setting other than registry or the Settings program that comes with the Windows Mobile 6 SDK.   This is hardly ideal for end users.

 

OK, so that's the niggles over with.    On a positive -

  1. Screen great.
  2. It business as usual - everything feels very familiar.   Which makes it very easy to get on with.
  3. Improvements to Outlook look great,   the one touch delete of mail is really useful.   Lots and lots of enhancements.
  4. Popout keyboard, is great.
  5. .Net CF and SQL Compact in ROM which is superb.
  6. Build quality and battery life seems good so far.
Saturday, May 05, 2007 9:11:30 AM UTC  #    Comments [0]  | 
Friday, May 04, 2007

So, today was a bit of a landmark in the evolution of our Anglia DataMaker technology.    For those not familiar with the project.   DataMaker is a tool that lets you automatically generate either .Net Framework or Compact Framework based code by simply pointing the tool at a SQL Table, View or Stored Procedure.     See -

http://www.binaryrefinery.com/main/PermaLink,guid,c3b341dc-02ed-4531-a61e-50fa39f1cef9.aspx

The landmark event was due to DataMaker now being able to not only look at tables and views in a SQL Server table, but can connect directly to a SQL Compact publication.   So picture the scene -

I'm sitting at a customers site (customer A),   I am behind their firewall and my only means of connecting to the Internet is through a proxy server.

 

Customer B, is also behind a firewall and they have a SQL Mobile application that publishes tables out to a mobile sales rep. application onto the Internet.

I have been requested to make a change to Customer B's mobile application.       So with DataMaker   I can traverse securely customer A's firewall,  connect securely to customer B's publication.    Pull down the SQL Compact publication.    Using the schema information in the SQL Compact database (see pervious post),  I can then build .Net code from the table definitions.    I   can then upload my revised Cab containing all changes using an application manager web-page see -

http://www.binaryrefinery.com/main/PermaLink,guid,0bf1ef05-1d62-4018-8335-d65209c2291e.aspx

Finally I can auto deploy the application, (once tested)  using an auto update tool, that compares a version number held in a published table against the version number of the users application.   This pulls down the latest Cab file when each sales rep. syncrhonises back with the publication.

I can do all of this, securely behind someone other than our customer's firewall. This all saves me having to have copies of customers databases for such eventualities.    Happy customers,   happy me....

 

Friday, May 04, 2007 12:38:51 PM UTC  #    Comments [0]  | 

I've been looking for a simple way, to enumerate tables within a SQL Compact database,  using the following, I found out how -

http://msdn2.microsoft.com/en-us/library/aa274908(SQL.80).aspx

From this I came up with the following bits of SQL to get at useful bits of the SQL Compact database.

To list tables and views -

SELECT TABLE_NAME,TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE in ('TABLE','VIEW') ORDER BY TABLE_NAME

 

To list fields within a table/view use -

SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME='YOUR TABLEORVIEWNAME'

 

To list the keys in a given table/view use -

SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE TABLE_NAME='YOUR TABLEORVIEWNAME'

 

 

Technorati tags: ,
Friday, May 04, 2007 10:14:53 AM UTC  #    Comments [0]  | 
Wednesday, May 02, 2007

On the evening 17th of May,  I am the headline speaker for the Cambridge Network on Business Mobility

It should be a fun filled evening.    So if your a regular reader of my Blog and want to see some of this stuff for real,  then please come along.

Event details are here -

http://www.cambridgenetwork.co.uk/events/article/default.aspx?objid=33503

I believe its free to Cambridge Network members,  or an entrance fee for non-members.    Its worth paying the fee for the nice reception afterwards.

 

 

Technorati tags: ,
Wednesday, May 02, 2007 1:16:54 PM UTC  #    Comments [0]  | 

As I've done in previous posts,  I've been using longitude and latitude from a GPS or other location service (like geo-encoding postcodes),  to be able to show locations on a map.

I've been trying to find a simple way to send a link to Live Maps with a pushpin,  but I think I have the definitive answer.

Here is the URL string I have come up with

http://maps.live.com/default.aspx?v=2&cp=LONGITUDEHERE~LATITUDEHERE&dir=0&alt=-1000&encType=1&lvl=17&tilt=-90&sp=an.PUSHPINLONGITUDEHERE_-PUSHPINLATITUDEHERE_PINNAMEHERE_PINDESCRIPTIONHERE

i.e

http://maps.live.com/default.aspx?v=2&cp=51.625128~-0.150448&dir=0&alt=-1000&encType=1&lvl=17&tilt=-90&sp=an.51.625128_-0.150448_Location%20Of%20N111HB

 

I found out this information here at -

http://help.live.com/help.aspx?mkt=en-gb&project=wl_local&querytype=keyword&query=qaf

Click Table of contents->Information For Developers->Build Your Own Url

 

Wednesday, May 02, 2007 10:31:23 AM UTC  #    Comments [0]  | 
Tuesday, May 01, 2007

Get it while its hot...

Quote from site -
The Windows Mobile 6 SDK Refresh adds documentation, sample code, header and library files, emulator images and tools to Visual Studio that let you build applications for Windows Mobile 6.

http://www.microsoft.com/downloads/details.aspx?FamilyID=06111a3a-a651-4745-88ef-3d48091a390b&DisplayLang=en#filelist

Tuesday, May 01, 2007 7:15:27 PM UTC  #    Comments [0]  | 

Theme design by Jelle Druyts

Pick a theme: