Friday, May 30, 2008

The City Most Distant from Snow in the World

Now how's that for a tortured title!

Anyway .... as some of you know, I like to think of myself as a snowboarder. In my case, this means I might, if I am very lucky, get to the snow for 5 days once a year. A long time ago, I purchased a snowboard (and posted about that snowboard) for my occasional snow trips, and although it has been used a few times, it now reclines lazily on a shelf in my laundry, doing very little to earn its keep.

It occurred to me the other day while meditating on the laziness of my snowboard, that my snowboard, which currently lives in Perth, Western Australia, could well be the snowboard most distant from snow, anywhere in the world. So I tried to work out where was the most snow deprived place on earth.

As it turns out, this is not as easy as it sounds. I am around 2900km from the nearest snow (the Alpine National Park in Victoria, Australia). So I was trying to find a location more than 2900km from snow.

Anywhere in Europe is in spitting distance from snow, so I've ignored Europe in this post. Africa, one would think, is pretty snow deprived, but using the National Geographic's very cool Map Machine to work out where snow fell on an average year, I worked out that there is nowhere in Africa more distant from snow than I am. This is largely due to small area of snow fall in Kenya, Morocco and South Africa that mean that all of Africa is close to snow than me.

Some spots in Asia would seem a bit snowless, but the side is let down by Vietnam with it's occasional snowfall, Myanmar's Himalaya, and Indonesia's glaciers.

At the end of the day, the only spots I could work out that would be further from snow might be some areas in Brazil on the Eastern coast and maybe somewhere like the Cook Islands in the middle of the Pacific. Even Fiji is nearer to NZ's snow fields than I am to Australias. So there it is. Unless someone in Brazil has a snowboard in their shed, my snowboard in Perth is the world's most distant from snow. Now there's a sorry distinction.

Note: The final map on this page shows Perth (the blue flag) and range circles of 2900km around areas of snow fall in red. If a city falls inside a red circle then it is less than 2900km from snow and therefore closer to snow than Perth. Just bear in mind that from Turkey to China is range of mountains continually capped in snow, most of Europe has snow fall and nowhere in the US is more than 2000km from snow.

Attribution: I used Free Map tools with Google Maps and the
National Geographic's Map Machine to decide if my snowboard was the most snow deprived.

Thursday, May 22, 2008

Problems Uploading Documents with Workflow in WSS

I've been working on my first Sharepoint 2007 site. Actually, it's a WSS site as I am not using Sharepoint. The site I have created has very limited functionality, and is intended to allow the company I am working for centrally maintain a register of a certain type of action they are qualified to perform and provide a link to all of the documents related to this action, and WSS is sufficient for this.

So what I have is the Sharepoint equivalent of an Excel spreadsheet (a custom list), which lists the actions and all the associated attributes, and I have a Document Repository, broken into folders. Each document in the Document Repository has two custom attributes - a action type flag and a business unit flag. Each action in the custom list has an action type attribute and a business unit attribute, and when a user selects "Related Documents" from the customised Actions drop down for a list item, Sharepoint does a search in the Document Repository for documents where the business unit and action type flags match the data in the selected action in the custom list.

So far so good. However, to make the experience within Sharepoint similar to what the users are used to and easier, I have made a custom workflow that fires when a new document is created and works out what folder within the Document Repository the new document is being uploaded to. In other words, I am trying to make the document itself explicitly aware of its location, and specifically the folder it is in. Each of the folders in the document repository are named for one of the business units. So the idea is that the document metadata will automatically contain the business unit name that owns the document.

This is where the problem emerges. A user enters the Document Repository, and begins to upload a document. At this point, the workflow fires off. Before the workflow has completed, the screen refreshes to allow the user to edit the metadata for the document, in this case the title, name, action type flag and business unit flag. The metadata displayed is the metadata that the document was uploaded with, but meanwhile, in the background, the workflow has updated the document's business unit flag attribute. The user clicks the check in button, and because the metadata that the document had when the page was rendered and the metadata it has now the workflow is finished is different (irrespective of whether the user entered any changes for these fields), the process errors.

Server Error in '/' Application.
--------------------------------------------------------------------------------

The file Document Repository/
BusinessUnit/Document.JPG has been modified by SHAREPOINT\system on 22 May 2008 11:36:50 +0800.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The file
Document Repository/BusinessUnit/Document.JPG has been modified by SHAREPOINT\system on 22 May 2008 11:36:50 +0800.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[COMException (0x81020037): The file
Document Repository/BusinessUnit/Document.JPG has been modified by SHAREPOINT\system on 22 May 2008 11:36:50 +0800.]
Microsoft.SharePoint.Library.SPRequestInternalClass.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish) +0
Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish) +199

[SPException: The file
Document Repository/BusinessUnit/Document.JPG has been modified by SHAREPOINT\system on 22 May 2008 11:36:50 +0800.]
Microsoft.SharePoint.Library.SPRequest.AddOrUpdateItem(String bstrUrl, String bstrListName, Boolean bAdd, Boolean bSystemUpdate, Boolean bPreserveItemVersion, Boolean bUpdateNoVersion, Int32& plID, String& pbstrGuid, Guid pbstrNewDocId, Boolean bHasNewDocId, String bstrVersion, Object& pvarAttachmentNames, Object& pvarAttachmentContents, Object& pvarProperties, Boolean bCheckOut, Boolean bCheckin, Boolean bMigration, Boolean bPublish) +240
Microsoft.SharePoint.SPListItem.AddOrUpdateItem(Boolean bAdd, Boolean bSystem, Boolean bPreserveItemVersion, Boolean bNoVersion, Boolean bMigration, Boolean bPublish, Boolean bCheckOut, Boolean bCheckin, Guid newGuidOnAdd, Int32& ulID, Object& objAttachmentNames, Object& objAttachmentContents, Boolean suppressAfterEvents) +933
Microsoft.SharePoint.SPListItem.UpdateInternal(Boolean bSystem, Boolean bPreserveItemVersion, Guid newGuidOnAdd, Boolean bMigration, Boolean bPublish, Boolean bNoVersion, Boolean bCheckOut, Boolean bCheckin, Boolean suppressAfterEvents) +182
Microsoft.SharePoint.SPListItem.UpdateOverwriteVersion() +88
Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext itemContext, Boolean uploadMode, String checkInComment) +178
Microsoft.SharePoint.WebControls.SaveButton.SaveItem() +58
Microsoft.SharePoint.WebControls.SaveButton.OnBubbleEvent(Object source, EventArgs e) +249
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746
Not good, huh!

Anyway, it turns out this is a fairly well known problem (even though Googling the error doesn't come up with much). Two good posts that started to lead me in the right direction are here and here. It turns out, that for me, the solution was as easy as making sure I had a mandatory or required field/column with no default value entered for the uploaded documents. The workflow would then have to wait until the user entered the requisite information and checked the document in, before firing. Problem solved.

Thursday, May 15, 2008

Cheap Glasses for the Yearning Australian Masses

Me, I am determined to never need glasses, no matter how blind I become. I'm not quite sure how I am going to manage this, but I am confident that sometime soon someone smart will invent a "Driving By Braille" system for people like me.

One recent development that is chipping away at my steely resolve to remain sans spectacles is the growing availability of cheap glasses. More and more sites pop up that allow you to merely enter the details of your prescription and order a fresh yet affordable set of optics to suit your mood at crazy prices.

Actually, a friend of mine has recently started just such a optometrist bankrupting venture, called GetFramed. He is selling prescription specs to the discerning Australian clientele, starting for the frivolous sum of $30, climbing to the dizzying heights of $70 for the "flash ones". I'm not entirely sure how he is managing this (I am visualising hundreds of feverish gnomes hard at work in his shed), but hey, why look a gift horse in the mouth (unless of course, you like me are so blind you thought it was a drinking fountain).

Anyway, if you are in the market for some reasonably priced spectacles, give him a try at www.GetFramed.com.au.

BTW - Weird aside - I've noticed this post is showing up on a site called ikox dot net. Not sure whats happening there but looks like whoever is behind this site is ripping off my post. Weird.