Thursday, March 29, 2007

After my post on mobile pages not rendering nicely using Pocket Internet Explorer,   Microsoft made public today its plans for 'Deepfish'   fresh out of the labs,   a new way to browse web-pages:

http://labs.live.com/deepfish/default.aspx

(www.msmobiles.com mentions that if you type a promotion code of DFPRESS, you can download a copy)

 

I guess my approach is always to build pages that render correctly and quickly on a small screen device.   The approach Deepfish and other mobile browsers (like ZenZui ) try and achieve is to make the full screen browser experience fit on a small form factor display providing panning and scrolling of web-pages.   I guess technologies like Deepfish are the future, but surely building web pages with mobile in users in mind is still appropriate until this technology is mainstream?   

Deepfish's web site mentions that it is a few releases away from Beta quality missing a few things like cookies, AJAX and ActiveX.    I wonder why the existing Pocket IE code base hasn't been used  ?    

Next problem to solve is how to key those darn long url's in on a phone keypad.... :-) (I wait for the comments to come flooding in :-) )

Thursday, March 29, 2007 8:53:31 AM UTC  #    Comments [0]  | 
Wednesday, March 28, 2007

Its quite interesting surfing the web from a PDA/Smartphone,  just to see who's homepages recognises that you are connecting in from a mobile device.

I took the top 10 most popular websites globally as listed at -

http://www.alexa.com/site/ds/top_500

 

So here's the results(using Windows Mobile 6 emulator QVGA Landscape, with a locale of English US and set to single column view.

 

1. Yahoo  http://www.yahoo.com

Doesn't look very mobile friendly to me...

 

2. Microsoft Network (MSN)  http://www.msn.com

Wow...   Not nice at all..

 

3. Google http://www.google.com

Hooray...   A proper mobile page...

 

4. YouTube http://www.youtube.com

I don't know whether my luck or design, but this looks pretty mobile friendly..

 

5. Myspace http://www.myspace.com

Looks good to me...   

 

6. Windows Live http://www.live.com

Phew, a mobile page.   However doesn't seem to be branded as Live.

 

7. Baidu.com www.baidu.com

OK, Baidu is a Chinese search engine (you learn something everyday),  so maybe on a Chinese device this will look fantastic.  I'll reserve comment.

 

8. Orkut.com http://www.orkut.com

Looks pretty good to me.

 

9. QQ.Com www.qq.com

QQ, Chinese focused instant messaging site, looks mobile friendly to me.

 

10. Wikipedia http://www.wikipedia.com

Hard to tell but on scrolling down didn't appear to be particularly mobile friendly.

 

 

I appreciate that lots of the listed companies do have mobile specific url's, i.e mobile.msn.com,  but just wondered on first hit to theses popular sites what the user experience would be.

 

I posted some time back, about a simple bit of code to detect if your at least connecting in with a Windows CE based device to a web page,  hint hint offenders above :-)

Click Here For Posting

Wednesday, March 28, 2007 5:52:53 AM UTC  #    Comments [0]  | 

Just a quick one.   Ever want to quickly launch a mobile device emulator without having to launch Visual Studio.    Simply make a shortcut to -

"<INSTALLED DRIVE>:\Program Files\Microsoft Device Emulator\1.0\dvcemumanager.exe"

Boom...

 

Wednesday, March 28, 2007 5:16:45 AM UTC  #    Comments [0]  | 
Saturday, March 24, 2007

I like to show to our mobile users exactly how much data is in the SQL Compact database.  This can give a really quick view of just how much data is on the mobile device and serves as a great tool for quickly providing support to users (e.g to quickly find if the sales rep standing in a field really has sent all sales orders back to to the server).   My form normally looks something like this (this is one from a recent Dynamic Nav mobility project) -

 

The code to do this is as follows -

 

protected DataTable TableSizes(ref bool haveprefixes) // prefixes is whether we had to split table for clarity on screen
{

DataTable dt = new DataTable();
dt.Columns.Add("Prefix");
dt.Columns.Add("ShortTableName");
dt.Columns.Add("TableName");
dt.Columns.Add("Rows");

// only open connection if its not open already

bool isopen = (cn != null && cn.State == ConnectionState.Open);  // cn is a globally defined SQLCeConnection

try
{
if (!isopen) cn.Open();    
}
catch
{
if (!isopen) cn.Close();
return dt;
}

SqlCeResultSet reader = this.Sql("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE='TABLE' ORDER BY TABLE_NAME");  // this is a shortcut function that just quickly return sqlceresultset

haveprefixes = false;
if (reader != null)
{
while (reader.Read())
{
string strname = reader["TABLE_NAME"].ToString();
DataRow ourrow = dt.NewRow();
ourrow["TableName"] = strname;
string[] elems = strname.Split('$');
if (elems.Length == 2)
{
ourrow["Prefix"] = elems[0];
ourrow["ShortTableName"] = elems[1];
haveprefixes = true;
}
else
{
ourrow["Prefix"] = ""
ourrow["ShortTableName"] = strname;
}
ourrow["Rows"] = 0;
dt.Rows.Add(ourrow);
}
reader.Close();
reader.Dispose();
}

foreach (DataRow ourrow in dt.Rows)
{
ourrow.BeginEdit();
ourrow["Rows"] = SqlQuickValue("SELECT count(1) from [" + ourrow["TableName"] + "]");    // Please see post on SQL images for definition of this.
ourrow.EndEdit();

}

 

// only closed connection if you had to open it already
if (!isopen) cn.Close();
return dt;
}

Saturday, March 24, 2007 9:35:46 PM UTC  #    Comments [0]  | 
Friday, March 23, 2007

I spent the morning explaining to a SQL Server DBA of many years just why I wanted to add mobile functionality to his database by switching on SQL Merge replication, and all that this entails (creating a distributor, setting up snapshot shares etc).

It was like asking for his first born!

So maybe its time to look at ADO Sync services...

http://www.microsoft.com/downloads/details.aspx?FamilyId=75FEF59F-1B5E-49BC-A21A-9EF4F34DE6FC&displaylang=en

Friday, March 23, 2007 12:26:57 AM UTC  #    Comments [1]  | 
Thursday, March 22, 2007

Ok, yesterday,  I almost (thank you Bryan) put up a set of definitive code to retrieve images from a SQL Compact database.   Note I edited the code to incorporate comments received,

So today I'll put up the flip side to insert/update records into a SQL Compact database.   This works great for applications like signature recording, biometrics or photo capture:

 

StringBuilder sbsql = new StringBuilder();

sbsql.Append("INSERT INTO ");
sbsql.Append("[OUR TABLE] ");
sbsql.Append("(");
sbsql.Append("[label pic] "); // image field in our database
sbsql.Append(") ");
sbsql.Append("VALUES ");
sbsql.Append("(");
sbsql.Append("@label_pic "); // Maps To Database Field - [label pic]
sbsql.Append(") ");

 

cn.Open();//  note cn - is a sqlceconnection object

SqlCeCommand cmd = new SqlCeCommand(sbsql.ToString(), cn);

cmd.CommandType = CommandType.Text;

SqlCeParameter tempparam = new SqlCeParameter(); tempparam.ParameterName = "@label_pic"
tempparam.SqlDbType = System.Data.SqlDbType.Image;
if (label_pic == null)
{
tempparam.Value = DBNull.Value;
}
else
{
MemoryStream mslabel_pic = new System.IO.MemoryStream();
label_pic.Save(mslabel_pic, System.Drawing.Imaging.ImageFormat.Bmp); // label pic is the Bitmap variable that holds our picture
Byte[] bitslabel_pic = mslabel_pic.ToArray();
mslabel_pic.Close();
tempparam.Value = bitslabel_pic;
}

 

cmd.Parameters.Add(tempparam);

cmd.ExecuteNonQuery();

cmd.Dispose();

cn.Close();

 

So I hope I've shared with you,  what we all agree is the way to get pictures both in and out of a SQL Compact database.     I certainly have found having a generic way to get images in and out of SQL Compact saves lots of time and I hope this helps you too.

Thursday, March 22, 2007 8:27:19 PM UTC  #    Comments [0]  | 

Ok, lots of people have asked the question and I want to clear this up good and proper.   Here is how under Compact Framework 2, you can both insert images into a SQL Compact database and pull them out again.   This is particularly useful for putting camera images or signatures reliably (I feel the need to say reliably again), into and out the database.

Lots has been written about this, but comrades this really does work -

 

Today we'll do getting images out of the database and into a nice Bitmap variable.

To get an image from the database the only way I've found that works reliably

is using the ExecuteScalar like -

 

public void Main() // Main Entrypoint of program

{

Bitmap ourbmp=null;

MemoryStream ms=null;

ourbitmap=GetOurImage(ref ms);

 

// do stuff with our bitmap

 

ms.Close();

ourbmp.Dispose();

}

 

public Bitmap GetOurImage(ref MemoryStream msimageblob )

{

StringBuilder sbsql = new StringBuilder();
sbsql.Append("SELECT ");
sbsql.Append("[Picture] "); // This is an image field in the database
sbsql.Append("FROM ");
sbsql.Append("[SOME TABLE]");

 

object y = SqlQuickValue(sbsql.ToString()); // little helper function as I'm lazy
msimageblob = new MemoryStream((byte[])y);
Bitmap picture = new Bitmap(msimageblob);

return picture;

}

 

protected object SqlQuickValue(string strsql)
{

SqlCeCommand cmd = null;
object ret = null;

try
{
cn.Open();
cmd = new SqlCeCommand(strsql, cn); // note cn - is a sqlceconnection object
cmd.CommandType = CommandType.Text;
}
catch
{
if (cmd != null) cmd.Dispose();
cn.Close();
return ret;
}

try
{
ret = cmd.ExecuteScalar();
}
catch (SqlCeException e)
{
}
finally
{
cmd.Dispose();

}

cn.Close();
return ret;
}

 

Tomorrow, I'll show you how we can insert records into the database.

Thursday, March 22, 2007 3:06:30 PM UTC  #    Comments [2]  | 
Wednesday, March 21, 2007

Ok, lots of people have asked the question and I want to clear this up good and proper.   Here is how under Compact Framework 2, you can both insert images into a SQL Compact database and pull them out again.   This is particularly useful for putting camera images or signatures reliably (I feel the need to say reliably again), into and out the database.

Lots has been written about this, but comrades this really does work -

 

Today we'll do getting images out of the database and into a nice Bitmap variable.

To get an image from the database the only way I've found that works reliably

is using the ExecuteScalar like -

 

public Bitmap GetOurImage()

{

StringBuilder sbsql = new StringBuilder();
sbsql.Append("SELECT ");
sbsql.Append("[Picture] "); // This is an image field in the database
sbsql.Append("FROM ");
sbsql.Append("[SOME TABLE]");

 

object y = SqlQuickValue(sbsql.ToString()); // little helper function as I'm lazy
MemoryStream msimageblob = new MemoryStream((byte[])y);
Bitmap picture = new Bitmap(msimageblob);
msimageblob.Close();

return picture;

}

 

protected object SqlQuickValue(string strsql)
{

SqlCeCommand cmd = null;
object ret = null;

try
{
cn.Open();
cmd = new SqlCeCommand(strsql, cn); // note cn - is a sqlceconnection object
cmd.CommandType = CommandType.Text;
}
catch
{
if (cmd != null) cmd.Dispose();
cn.Close();
return ret;
}

try
{
ret = cmd.ExecuteScalar();
}
catch (SqlCeException e)
{
}
finally
{
cmd.Dispose();

}

cn.Close();
return ret;
}

 

Tomorrow, I'll show you how we can insert records into the database.

Wednesday, March 21, 2007 8:48:03 PM UTC  #    Comments [2]  | 
Tuesday, March 20, 2007

This, is so cool, I just have to spread the word.    So I've been playing around with location based applications in the past few posts.     I thought (as you do),  wouldn't it be great to be able to continually find things of interest around your current location,  i.e Pizza restaurants, coffee shops that kind of stuff.

Seeing the superb job, of how Windows Live Search Mobile I wondered how they achieved this functionality, and further more could it be 'mashed' into a Line of business application.   Of course the answer is YES...

Windows Live Search is exposed as a set of web-services,  how cool..   Even better still it is also possible to search by proximity.  So a little digging on MSDN, I found out how to search for things near me.    First stop,  MSDN article, to setup the web-service and talks you through the basics:

http://msdn2.microsoft.com/en-us/library/bb251794.aspx

From this guide, weaned the following.     I firstly added a web-reference to a Windows Mobile 6 Project.  The web-reference URL is

http://soap.search.msn.com/webservices.asmx?wsdl

Then, I created an application ID,  by going to the following -

http://search.msn.com/developer

(steps lifted from getting started guide)

  • Click Create and Manage Application IDs.
  • Sign in with your Windows Live ID. If you do not have a Live ID, click Sign Up Now to create one. Live ID authentication is required to use the Developer Provisioning System.
  • Once you're signed in, click Get a new App ID to create a new Application ID for your application.
  • Type a friendly name for your application in the Application Name text box.
  • Read the Terms of Use and click I Accept to agree to these terms. If you do not agree to the Terms of Use, click I Do Not Accept. The Application ID that appears on the page will not be activated if you choose not to accept the Terms of Use.
  • Once you've accepted the Terms of Use, select and copy the Application ID and paste it into your code as the value for the AppID field
  •  

    Ok, so once done,  I then wrote the following method,  which will lookup from a given longitude and latitude of where you are a description of your choice, i.e Pizza's.

    Again this C# code is proof of concept adapted from one of the MSDN examples.   It returns everything as a big string, but gives you an idea for how the API works.

     

    public string SearchIt(string searchfor,double latitude,double longitude)
    {
    StringBuilder sbret=new StringBuilder();

    try
    {

    MSNSearchService s = new MSNSearchService();

    SearchRequest searchRequest = new SearchRequest();
    int arraySize = 1;
    SourceRequest[] sr = new SourceRequest[arraySize];

    sr[0] = new SourceRequest();
    sr[0].Source = SourceType.PhoneBook;
    sr[0].SortBy = SortByType.Distance;

    searchRequest.Query = searchfor;
    searchRequest.Requests = sr;
    searchRequest.AppID = "<YOUR ID, YOU WILL NEED TO GET ONE OF YOUR OWN, SEE GETTING STARTED GUIDE";
    searchRequest.CultureInfo = "en-US"
    Location l = new Location();
    l.Latitude = latitude;
    l.Longitude = longitude;
    l.Radius = 1000;

    searchRequest.Location = l;
    SearchResponse searchResponse;

    searchResponse = s.Search(searchRequest);

    foreach (SourceResponse sourceResponse in searchResponse.Responses)
    {
    Result[] sourceResults = sourceResponse.Results;
    if (sourceResponse.Total > 0)
    {
    sbret.AppendLine(sourceResponse.Source.ToString() + " - Total Results: " + sourceResponse.Total.ToString());
    sbret.AppendLine();
    }
    foreach (Result sourceResult in sourceResults)
    {
    if ((sourceResult.Title != null) && (sourceResult.Title != String.Empty))
    sbret.AppendLine("Title: " + sourceResult.Title);
    if ((sourceResult.Description != null) && (sourceResult.Description != String.Empty))
    sbret.AppendLine("Description: " + sourceResult.Description);
    if ((sourceResult.Url != null) && (sourceResult.Url != String.Empty))
    sbret.AppendLine("URL: " + sourceResult.Url);

    if (sourceResult.Location != null)
    sbret.AppendLine("Location: " + sourceResult.Location.Latitude + "," + sourceResult.Location.Longitude + " radius" + sourceResult.Location.Radius + ",");
    sbret.AppendLine("*****************************************************");
    }
    }
    }
    catch (SoapException fault)
    {
    sbret.AppendLine(fault.Detail.InnerText.ToString());
    }
    catch (WebException webx)
    {
    sbret.AppendLine(webx.ToString());
    }
    /* This is the end of the try...catch block. */
    return sbret.ToString();
    }

     

    And that my friends, is pretty much it.    The data is restricted to US and UK content at the moment,  but it should give you a flavor of what's possible.

    I was amazed as to how easy this was to get going,   let me know if I've missed some big step, or something but it works like magic for me.

    Tuesday, March 20, 2007 1:38:57 PM UTC  #    Comments [0]  | 
    Monday, March 19, 2007

    I've spent much of my recent life extending the Windows Mobile experience beyond the confines of the Pocket Office apps.    Once people get the idea that they can get their mail, contacts, calendar and task on a mobile device its amazing how this serves to get them into the thought process for other line of business applications.   Certain themes popup again and again namely:

    Timesheet recording
    Expense logging
    Logging mileage and travel
    Booking leave
    Purchase order approval
    Mobile CRM

    I must have now done several  different versions for all of the above.    However needless to say for each audience I have created these applications they lend them self so well to be used from mobile devices.   I think getting the infrastructure in to support Outlook, to facilitate the mobile messaging side of things is a great first step.  Once done this is a great platform to extend and build top quality Mobile LOB applications.

    If you don't believe me look at

    http://www.Microsoft.com/casestudies/casestudy.aspx?casestudyid=53683

    Monday, March 19, 2007 4:07:01 PM UTC  #    Comments [0]  | 
    Sunday, March 18, 2007

    So correct me (please) if I am wrong, but I have never witnessed a non IT person typing a URL (i.e http://www.xxxx.com)  into a phone.

    Until someone comes up with a way (where has Windows Live Barcode gone ?(but that's another story ! )) of easily putting URL's into a phone this is a real stumbling block for making the reality of the mobile Internet/intranet work.

    To draw an audience into the world of mobile web-access, adding corporate home pages to the list of favorites on each device is one way.   This is a step closer to your non IT user getting online however its still two or three steps to get someone to your content.   So wouldn't it be great to be able to speed dial with one keypress straight to your mobile web page of choice.  So this wouldn't be much of a blog post, if this wasn't possible.  Well it is...

     

    Following Mike Halls article on creating Windows CE shortcuts, see:

    http://msdn2.Microsoft.com/en-us/embedded/aa731295.aspx

    To create this functionality on a Windows Mobile Smartphone, this is what I did -

    First create a text file on your desktop PC, called anything you like with the extension .lnk,  i.e BRF.lnk

    This contains the URL you need.   Note the first two characters are the number of characters of the command, i.e everything apart from first three characters.

    54#"\Windows\iexplore.exe" http://www.binaryrefinery.com

    Next step, using Active-Sync or WMSC copy the file to your start menu on the device,  i.e \Windows\Start Menu

    A quick reboot of the device and you will see your shortcut appearing on the start menu.      Final step is to press the menu key on the phone to assign a shortcut key.    Hey presto that's it...  You can now press and hold the shortcut key and it will now jump straight to the URL of choice.

    Perfect to get people quickly to your mobile line of business application, or mobile web portal.  At Anglia all Windows Mobile phones we provision have key '6' assigned to go straight to our mobile portal.   It works really nicely.

    Sunday, March 18, 2007 9:14:32 PM UTC  #    Comments [0]  | 

    I've been wondering why one of the mobile web-pages has slowed down loading.   After a little investigation,   one of the drop-down lists on the page had gained lots and lots of values.    The overhead of pulling down all the drop-down values was causing the overhead.    So a little re-design to move the selection list to another page was all that was needed to speed up the application and lower every users GPRS/3G charges.

    Once done the application is noticeably quicker.

    Its amazing that something as simple as optimising values on a drop down list can improve the user experience so significantly.      This serves to illustrate that the process of building mobile web-pages has subtle differences than designing for the full desktop browser.

    Sunday, March 18, 2007 8:59:19 AM UTC  #    Comments [0]  | 
    Thursday, March 15, 2007

    This bit of ASP.Net C# code, I love.    Put this in the root of your website in a page called default.aspx

    It redirects mobile users to one place and normal (i.e desktop browsers to another).   Simple but really does the trick.

     

     

    <%@ Page Language="C#" Trace="false" %>

    <SCRIPT LANGUAGE="C#" RUNAT=SERVER>

    protected void Page_Load(Object sender, EventArgs e)
    {
    System.Web.Mobile.MobileCapabilities cur = (System.Web.Mobile.MobileCapabilities) Request.Browser;

    // this block of code is to detect if users are running Pocket PC 2003
    bool isce=false;

    try {
    isce = (Request.UserAgent.IndexOf("Windows CE")!=-1);
    }
    catch
    {

    }
    if (cur.IsMobileDevice||isce)
    {
    Response.Redirect("mobile"); // MOBILE HOME PAGE
    }
    else
    {
    Response.Redirect("main"); // NORMAL HOME PAGE
    }
    }

    </SCRIPT>

    Thursday, March 15, 2007 9:35:11 PM UTC  #    Comments [0]  | 

    I've been using Windows Mobile Live Search ,  with my Bluetooth GPS on a Windows Mobile 5 Smartphone.   For those who haven't seen it check out Jason's blog and Loke's video at -

    http://blogs.msdn.com/jasonlan/archive/2007/02/16/windows-mobile-live-search-released-for-the-uk-and-us.aspx

    Its a superb bit of kit.    However I'd like to be able to combine the ability to send your current location to an email contact.   We'll Windows Mobile 5 Smartphone has always had the GPS intermediate driver available which allows for one GPS to be shared between different applications.

    However, to be able to switch this on the phone you previously needed to do some some massaging of the registry.    However Windows Mobile 6, ships with a nifty utility to do this from a small application.

    To get the tool you need the Windows Mobile 6 SDK at -

    http://www.microsoft.com/downloads/details.aspx?FamilyID=06111A3A-A651-4745-88EF-3D48091A390B&displaylang=en

    * Note Windows Mobile 6 Standard SDK is what you need for this project.

    Once installed the settings tool can be found in DRIVE:\Program Files\Windows Mobile 6 SDK\Tools\GPS

    This works just great under Windows Mobile 5, Smartphone and looks like -

     

     

    So, in my case,   the real port the GPS is connected on COM8  however all applications can now simultaneously access the device on COM7. Fab!

    All good so far.      Next step is to port the application for posting your current location.   I previously posted for Windows Mobile the source for this,  so all we need is a simple port over to Smartphone.    I won't bore you again with the details but the source is here (with Smartphone version)-

    http://www.binaryrefinery.com/main/content/binary/gps1.zip

    So that's it,  best of all worlds the power of Windows Mobile Live Search and the ability to send your current locations to your friends and colleagues.    

    Next step is to make the application update your email signature so watch this space....

    Thursday, March 15, 2007 9:18:49 PM UTC  #    Comments [0]  | 

    Software as a Service (SAAS), has been a buzz word for hosted solutions for the past year or so.   I think we all called it Application service provider (ASP) provided software before that...

    Windows Mobile LOB lend them selves perfectly to the SAAS model as essentially the centralised model with remote 'mobile' clients is a perfect example of this model.

    We recently proved this saving our customer a small fortune by deploying a mobile solution (yes its G's again) with line of business applications built using .Net CF.

    The customer was facing the expense of installing an ERP in Spain, but instead opted for a Mobile LOB solution with Spanish Sim cards installed in each mobile device.

    This is a great model, and makes lots of sense to include mobility as the spearhead of the SAAS revolution (or whatever its called next year) :-) ...

    Thursday, March 15, 2007 9:42:33 AM UTC  #    Comments [0]  | 

    Offtopic but -

    On 19th December 2006 the media regulator, Ofcom, announced plans to auction publicly owned spectrum to the highest bidder. If the auction takes place as planned the millions of consumers who have purchased, or plan to purchase HD TVs may never be able enjoy high definition TV on the Freeview platform.

     

    Gather here citizens, to petition for Freeview HD

    http://www.hdforall.org.uk/

    Thursday, March 15, 2007 9:24:03 AM UTC  #    Comments [0]  | 
    Tuesday, March 13, 2007

    I've spent the past few months building the mobility solution for G's marketing as part of my role at Anglia Business Solutions (www.angliabs.com)

    Microsoft have just filmed this as a mobility case study, with some impressive ROI stats  like the £50k solution saved £10m in the first year.

    Video is at

    http://private.angliabs.com/webextension/video/Gs_marketing_prog_evo13a.wmv

    A description of the supermarket label check solution can be found at -

    http://www.angliabs.com/news/GS0506/

     

    Building the tools and designing the solution is what earned me the title of BCS Developer of the Year.

    + of course this wasn't a solo mission.    Neil Robertson, Tony Rose, Trevor Hurley, Dave Missen,  and the crew at G's were all very much key parts of pulling this together.

    Tuesday, March 13, 2007 1:35:50 PM UTC  #    Comments [0]  | 

    Over the past few years, I'm sure I have lost a good few hours of my life configuring the Windows Mobile device emulator to give me Internet connectivity.

    I work on lots of different client sites using different networks and sometimes no network at all (i.e on the train)

    The Windows Mobile device emulator is a fantastic bit of kit, once up and running but switching between different networks has caused lots of pain for me in the past (think you are on stage in half an hour to demonstrate SQL Compact and the emulator wont connect to Internet, kind of scary)

    So really pleased to see the release of the Device Emulator version 2.0

    Download link and info here -

    http://blogs.msdn.com/anandba/archive/2007/03/13/device-emulator-v2-is-live.aspx

    The other great bit of news,  is that Anand Balachanran has put up a post that seems to resolve the working with different networking scenario's on Vista.

    Here

    http://blogs.msdn.com/anandba/archive/2007/03/13/networking-support-on-device-emulator-in-vista.aspx

    So will I save hours of my life,  well I'll report back in a day or so...

    Tuesday, March 13, 2007 12:48:03 PM UTC  #    Comments [0]  | 
    Monday, March 12, 2007

    So by everything you've got,  I mean today I have unpacked the toolbox to try and resolve a design issue one of my clients is looking to resolve.

    A large ERP system on SQL 2000 exposes lots of functionality as COM objects.    To further make this interesting the parameters for these COM calls, read values from temporary SQL tables.    The primary parameter to the COM calls is the name of the temporary table.

    OK, first person that tells me what ERP system that is, gets a mention (best I can do)...

    So here's the rub.   Customer would like a mobile solution that in realtime can communicate with the backend ERP.

    Customer in question only has port 443 opened to that mobile devices can only communicate via an SSL connection.

     

    So I'm thinking Web-Service that talks to the COM objects and database.     COM interop is fab in Visual Studio 2005 so this shouldn't be two much of an issue (and easier than rolling com calls into stored procedures).    + its very elegant to add web-references to a mobile app.

    I think the only thing I will have to-do is add some transaction management stuff at the mobile end to ensure that my calls to the web-service always complete (mobile patterns and practices can help with that one).

    It these kind of issues that keep it interesting and makes mobile applications a unique challenge.

     

    Will keep you posted...

    Monday, March 12, 2007 10:09:25 AM UTC  #    Comments [0]  | 
    Sunday, March 11, 2007

    Off topic,  the Sinclair ZX Spectrum is 25 this week!   Without you I wouldn't be here (well doing a blog about development anyway).

    I actually started my development career (?) on a Sinclair ZX81 at the age of 8, but it was the Spectrum that opened my eyes to what has become a lifelong passion!

     

    n.b Symbol Shift + J,   was actually the keystroke that gave you the LOAD command...   ahh, back in the day...

    A big thank you Sir Clive!

    Sunday, March 11, 2007 10:08:51 PM UTC  #    Comments [1]  | 

    Due to lots and lots of email requesting the code to send your location to a named contact,   I thought I would oblige and post the code.    I've adapted the GPS sample that ships with the Windows Mobile 6 SDK to include a send location option as shown below:

     

     

    The code behind the button is very straight forward using the Windows Mobile POOM integration.   The user is prompted for a contact and then sends an email.    The email is sent using the default Outlook account (easy to change if using another service.

    So here's the added code -

     

    private void mnusendlocation_Click(object sender, EventArgs e)
    {
    GpsPosition pos = gps.GetPosition();
    if (!(pos.LatitudeValid || pos.LongitudeValid))
    {
    DialogResult ret = MessageBox.Show("Position Is Not Currently Valid, Send Anyway?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
    if (ret == DialogResult.No) return;

    }
    Microsoft.WindowsMobile.Forms.ChooseContactDialog c = new Microsoft.WindowsMobile.Forms.ChooseContactDialog();
    DialogResult dr = c.ShowDialog();
    if (dr != DialogResult.OK)
    {
    c.Dispose();
    return;
    }

    string emailaddr = c.SelectedContact.Email1Address;
    c.Dispose();

    EmailMessage message = new EmailMessage();
    message.Subject = "My Current Location"

    message.BodyText = "http://maps.live.com/default.aspx?v=2&cp="+pos.Latitude+"~"+pos.Longitude+"&style=r&lvl=14&tilt=-90&dir=0&alt=-1000"

    Recipient client = new Recipient(emailaddr);
    message.To.Add(client);

    OutlookSession currentSession = new OutlookSession();
    currentSession.EmailAccounts[0].Send(message);
    MessageBox.Show("Message sent!");

    }

     

    Download Source Here

    Sunday, March 11, 2007 8:10:02 PM UTC  #    Comments [0]  | 
    Friday, March 09, 2007

    I've just found a great way of sending my location to friends/family etc.    i.e know that situation when your stuck stationary in traffic having a conversation (handsfree of course) about how you haven't moved in 45 minutes.     With a GPS connected Windows Mobile device its easy to email your location by sending an email containing a link with a url formed like -

    http://maps.live.com/default.aspx?v=2&cp=52.262573~0.19683&style=r&lvl=14&tilt=-90&dir=0&alt=-1000

    Note the long/lat co-ordinate embedded in the URL.

    It works great.   Happy to share the source of my app that sends the mail if anyone is interested.

    Friday, March 09, 2007 10:13:25 PM UTC  #    Comments [0]  | 
    Thursday, March 08, 2007

    Picking up from my last post where I showed the simple web-server for retrieving the time at the server.

    He' re the bit of C# Compact Framework code that is used to set the base clock of the device.

    Its a Pinvoke, that sets the base time of the device.   Note someone cleverer than me worked out the structures and things and it does work very well.

     

    [StructLayout(LayoutKind.Sequential)]
    private struct SYSTEMTIME
    {
    public short year;
    public short month;
    public short dayOfWeek;
    public short day;
    public short hour;
    public short minute;
    public short second;
    public short milliseconds;
    }

    [DllImport("coredll.dll")]
    private extern static bool SetSystemTime(ref SYSTEMTIME lpSystemTime);

    public static void SetBaseTime(DateTime ourtime)
    {
    SYSTEMTIME st = new SYSTEMTIME();
    st.year = (short)ourtime.Year;
    st.month = (short)ourtime.Month;
    st.dayOfWeek = (short)ourtime.DayOfWeek;
    st.day = (short)ourtime.Day;
    st.hour = (short)ourtime.Hour;
    st.minute = (short)ourtime.Minute;
    st.second = (short)ourtime.Second;
    st.milliseconds = (short)ourtime.Millisecond;
    if (!SetSystemTime(ref st))
    {
    throw new Exception("Time Not Set");
    }

    }

     

    So now we have a nice way of setting the clock on the device, from the web-service.     I'll leave it to you to join the dots up and work out how to call the above with the result from the web-service.   

    It also works nicely when dealing with a multi-timezone deployment as all base clocks are set to UTC.

    Thursday, March 08, 2007 8:48:39 PM UTC  #    Comments [0]  | 
    Wednesday, March 07, 2007

    Often when creating SQL Compact applications,  I need to record the current date and time into the database.   This can be a bit of an issue if the clock of the mobile device is out of sync with the main database server.

    So every 10th time my mobile apps sync with the base database server (its merge replication I usually use), I call a web-service to get the time at the server.  I use a web-service as I don't need to open up any further ports ontop of what I need for merge replication over http/https.

    My web-service is very simple and comprises of just the following code -

     

    <%@ WebService Language="C#" Class="TimeService" %>

    using System;
    using System.Web.Services;

    public class TimeService : WebService
    {
    [WebMethod]
    public string GetDateTimeString()
    {
    DateTime utime = DateTime.Now.ToUniversalTime();
    string ret=""
    ret+=utime.Year+","
    ret+=utime.Month+","
    ret+=utime.Day+","
    ret+=utime.Hour+","
    ret+=utime.Minute+","
    ret+=utime.Second;

    return ret;

    }
    }

     

    I place this web-service in the same IIS virtual share as the sql compact server tools,  to ease setup.

     

    The web-method GetDateTimeString() returns a string with the UTC date and time.   I return as a string to avoid any timezone conversion issues.

     

    Tomorrow, I'll let you know how I consume the web-service and set the clock of the mobile device...

    Wednesday, March 07, 2007 8:50:24 PM UTC  #    Comments [0]  | 
    Monday, March 05, 2007

    Ok, a few posts ago,  I put up a screenshot showing a asp.net web application that I use to hold all cab files that comprise a mobile line of business application.

    However one of the biggest challenges we face is how to configure a mobile device with all those settings for database connection strings, URL for SQL Compact Server tools etc.

    Additionally  how do you easily allow end user to move from your dev to test to live environment without having to deploy new cab files?

    For a while we we have been doing the following,  in mobile application we add a text file (we use the name application.config) configured as content.

    It contains all of our configuration keys prefixed with a profile number like -

     

    <configuration>
    <appSettings>

    <!--Profile On Lan CRP -->
    <add key="1 profilename" value="CRP LAN" />
    <add key="1 interneturl" value="http://10.2.102.16/sqlmobile/sqlcesa30.dll" />
    <add key="1 upgradeurl" value="http://10.2.102.16/handheld/CRPSetupMobileLabelling.CAB" />
    <add key="1 RepServerName" value="GSERP01" />
    <add key="1 RepDbName" value="JDE_CRP" />
    <add key="1 RepPubName" value="JDE_CRP" />
    <add key="1 AutoLogonBarCode" value="1" />

    <!--Profile Remote CRP -->
    <add key="2 profilename" value="CRP REMOTE" />
    <add key="2 interneturl" value="https://mobile.gs-marketing.com/sqlmobile/sqlcesa30.dll" />
    <add key="2 upgradeurl" value="https://mobile.gs-marketing.com/handheld/CRPSetupMobileLabelling.CAB" />
    <add key="2 RepServerName" value="GSERP01" />
    <add key="2 RepDbName" value="JDE_CRP" />
    <add key="2 RepPubName" value="JDE_CRP" />
    <add key="2 AutoLogonBarCode" value="" />

    SNIPPED HERE....

     

    Then on a screen in our mobile application we enumarte each settings key, and display a drop down list of available profiles.     Using a screen like the following:

    Top part of screen sets the AD account mobile device uses and subscriber.  The admin password at the bottom as we don't want any old user being able to change this :-)

    These settings are stored i.e subscriber, AD credentials (encrypted) and profile selected are stored in the registry.   The dropdown list shows our profiles like 'CRP Remote', 'Live Environment', 'Testing on Laptop'.   To enumarte the profiles we use the following code:

     

    public Hashtable GetAllProfiles()
    {
    Hashtable ret = new Hashtable();
    foreach (string key in _list.Keys)
    {
    if (key.ToLower().EndsWith("profilename"))
    {
    string val = key.Substring(0, key.IndexOf(" "));
    string ourkey = this.GetString(key);
    ret.Add(ourkey,val);
    }
    }
    return ret;
    }

     

    The final step is that we create a method for retrieving our settings from the config file that references the selected profile.  Like so:

     

     

    public static string AppSetting(string key)
    {

    AppSettings oAppSet = new AppSettings();

    string profilename = ""
    profilename = oAppSet.GetString("currentprofile");  // READ SELECTED PROFILE FROM REGISTRY

    if (Settings.Profile != "")
    {
    profilename = Settings.Profile;
    }

    if (profilename.Length > 0) profilename += " "  // NOTE IF WE DON'T HAVE A PROFILE SELECTED STILL RETURN A VALUE

    string result = oAppSet.GetString(profilename + key);

    if (result != "") return result;

    return oAppSet.GetString(key);

    }

     

    So there you have it, we can deploy one CAB with all of our profiles let an authenticated user move from test to live etc.  without requiring a new cab.    It works great and makes mobile deployment work very smoothly.

    Monday, March 05, 2007 10:08:46 PM UTC  #    Comments [0]  | 
    Friday, March 02, 2007

    So just got the Windows Mobile 6 SDK.     Installation was very straight forward and a simple blank form application up and running very quickly 1.5 mins from the install finishing).    Try doing that in J2ME :-)

     

    Have access to the emulators is great;  this was certainly my first chance to look at Windows Mobile 6.   All the new UI looks very polished.   However to my dismay the network management window is still present.  Now I know Windows Mobile 6 is built on Windows CE 5 and things will change when we get a Windows Mobile on the CE 6 OS.   Am I the only one who finds this dialog confusing and irrelevant in these days of jump on jump off networking?

     

     

    However enough said I cant wait to roll my sleeves up and do some development under Windows Mobile 6.    A great product has just got even better....

    Friday, March 02, 2007 9:50:16 AM UTC  #    Comments [0]  | 
    Thursday, March 01, 2007

    Bring It On...

    http://blogs.msdn.com/windowsmobile/archive/2007/03/01/windows-mobile-6-sdks-available-for-download.aspx

    Thursday, March 01, 2007 8:55:08 PM UTC  #    Comments [0]  | 

    So it used to be an easy choice when developing mobile applications.   If you didn't have good enough network access to your backend systems or required offline access to data then Compact Framework or Native development was the way to go with the application running on the mobile device.

    However now that ubiquitous anywhere you go wireless is becoming more of a reality the idea of putting apps.  out on the device seems less relevant.

    However their are still a few gotcha's for delivering applications out via the mobile web browser.   Here are my top pain points for why the standard Windows mobile browser (PIE) falls a little short of being a perfect environment for building line of business applications.-

    Barcode Readers RFID
    No support - for getting input from devices such as Keyboard or RFID reader - I know there are workarounds like keyboard wedge technology but this is hardly generic.

    Its still a bit slow - Not the browser but the network

    Using a mobile web-browser for the majority of UK users means 2G GPRS.   This is certainly the case with ruggedised devices.   Although 3G/HSDPA are all available this is limited to large cities in my experience.   I know free WIFI hotspots are supposed to be on every corner, but this really isn't the case certainly in the Uk.

    The Tools
    Microsoft has had the Mobile Internet toolkit in its utility belt for a few years now.   Its now rolled into Visual studio 2005.   Although a great bit of kit that lets you build mobile web applications irrespective of the target devices screensize and capabilities it does look a little dated now.

    URLs
    Have you ever watched a non IT user typing a URL into a mobile phone/pda.  

    A few bells and whistles
    It would be great from the web-browser if we could upload video or camera phone images.   This seems like an obvious value add that is currently not part of the Windows mobile browser.   The ability to also pass easily co-ordinates from a GPS, or users phone number (both with user permission) over to a web-page would also be a very nice.

    Passwords and security
    Getting users to sign on to mobile LOB applications is a little painful.   A standard mechanism for PIN authentication in AD would be great.   Maybe this is already there, but I haven't found it yet.

     

    Don't get me wrong,   I believe building browser based applications  are fantastic.   We have a case study up on Microsoft.Com where we built a mobile portal with an ROI payback of a week,  so I do believe the hype. 

    http://www.microsoft.com/casestudies/casestudy.aspx?casestudyid=53683

     

    But it just would be great to make this really-great browser platform just a little better. 

     

    What do you think?

    Thursday, March 01, 2007 3:20:17 PM UTC  #    Comments [1]  | 

    Theme design by Jelle Druyts

    Pick a theme: