Skip to main content

The power of Lightswitch - eyeQuu

HiringI was recently contacted by Thabo Letsoalo of eyeQuu, a South African software start-up, who has produced a SaaS (software as a service) offering built on top of Windows Azure & LightSwitch! The solution is a full work management tool, including task management & project management features! I am not going into too much detail here because the website does it far better than I can.

I often talk about LightSwitch and why it is perfect for many situations and this is a great example of a number of those situations:

  • It shows what is possible with LS, besides all the form stuff there is plenty of interesting systems like charts!
  • It shows off using LS as the basis for building a business. I think this is a really great LS feature because rather than being stuck into thousand of hours of development and ignoring growing the business, LS enables you to have more time to grow the business since it handles a lot of the development for you!
  • I love the fact it uses Azure, showing the power of the cloud, which allows it to offer a true multi-tenant service, scale massively and maintain the costs of a start-up all at the same time!

I really urge you to go and have a look at Thabo’s fantastic site!

Windows Store app Development Snack: InvalidOperationException for Share & Settings

For more posts in this series, see the series index.

With one of my earliest apps I kept having a problem with a COM exception being raised, when trying to setup the Share & Settings event handlers. A key factor is it didn’t happen all the time. I had it the following code on the constructor of my ViewModel class:

 

this.DTM = Windows.ApplicationModel.DataTransfer.DataTransferManager.GetForCurrentView();
DTM.DataRequested += ShareRequest;

Eventually I figured out that the exception was raised if the event was already attached, but this was in my view model class and this was in the constructor of the class (so should be new and fresh every time) – this didn’t make much sense to me. However the answer was in front of me the entire time: GetForCURRENTVIEW.

Windows 8 apps can be built in one of two ways:

  • Page Model – This is the same model as Windows Phone 7 where when you want a new UI you navigate to entire new page, or view.
  • Composition Model – In this model you have a single page, and you inject content in the form of user controls into the page. I am working with AtomicMVVM which follows this pattern.

The problem with the composition model, is that the events are tied to the page (or view) & since I never changed the page (just the content was swopped in and out), the event handlers were never being changed.

The solution for me was to make it possible for the view models to state if they have Share or Settings and then have a single place in the constructor to setup the configuration for the charms. I used a simple interface based system for this which the following code should illustrate. Since the event handler was attached once – the exception went away. This also allows my view to be very smart about the share & settings events and what it passes to those.

// during the startup I bind once to the event. Note that I onlt do this once the UI is up.
    bootstrapper.AfterStartCompletes += () =>
        {
            SettingsPane.GetForCurrentView().CommandsRequested += SettingCommandsRequested;
        };


void SettingCommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)
{
    var settings = Bootstrapper.CurrentViewModel as ISettings;
    args.Request.ApplicationCommands.Clear();

    // if the view model implements the interface then I can call the method to set the commands it needs.
    if (settings != null)
    {
        settings.LoadCommands(args.Request.ApplicationCommands);
    }
}

For a complete example of this see the Metro Demo in the AtomicMVVM samples: MetroDemo

Windows Store app Development Snack: Secondary tiles with text

For more posts in this series, see the series index.

The call to pin a secondary tile looks like this:

SecondaryTile(string tileId, string shortName, string displayName, string arguments, TileOptions tileOptions, Uri logoReference);

 

The important part for this post is the last parameter: Uri logoReference. This is the the path to the image you want to show on the tile – but I had a problem, I didn’t want to show an image! I just had some text I wanted to show on the tile. After a lot of digging the solution was non trivial – generate an image at runtime. This was made even harder as the Render method in WPF does not exist in the XAML implementation used in WinRT.

WinRT does include a WritableBitmap class which allows you to create a in memory bitmap, manipulate the pixels and save to a file format with the BitmapEncoder classes. The problem for me is I do not want to fiddle with pixels manually – this lead me to WritableBitmapEx which is a great library for having primitives (fill, line, circle etc…), the only down side was that I wanted text, not graphic primitives. 

titleMore searching lead to two posts on StackOverflow from XXX (post 1, post 2) which provided a solution:

  1. Create a sprite map using a free tool called  SpriteFont201
  2. Use the code provided in the answers with WritableBitmapEx to extract the sprites and combine them with a WritableBitmap.

I took the code and adjusted it slightly so text would always be centred and allowed me to play with font scaling. I’ve attached the modified code to the post below.

In the end the code I used looks like this:

public async Task<StorageFile> CreateImage()
{
    uint width = 512;
    uint height = 512;
    var writableBitmap = BitmapFactory.New((int)width, (int)height);
    writableBitmap.Clear((App.Current.Resources["SecondTileColour"] as SolidColorBrush).Color);
    
    writableBitmap.DrawStringHoriztonallyCentred(this.DisplayPostalCode, 50, "title", Colors.White, 4);
    writableBitmap.DrawStringHoriztonallyCentred(this.Town, 175, "title", Colors.White, 2);
    writableBitmap.DrawStringHoriztonallyCentred(this.City, 275, "title", Colors.White, 2);
    writableBitmap.DrawStringHoriztonallyCentred(string.Format("box code: {0}", this.BoxCode), 375, "title", Colors.White, 2);
    writableBitmap.DrawStringHoriztonallyCentred(string.Format("street code: {0}", this.StreetCode), 450, "title", Colors.White, 2);

    var file = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFileAsync(Guid.NewGuid().ToString("N"), Windows.Storage.CreationCollisionOption.ReplaceExisting);
    using (var fileStream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
    {
        var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, fileStream);

        encoder.SetPixelData(BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, width, height, 96, 96, writableBitmap.ToByteArray());

        await encoder.FlushAsync();
    }

    return file;
}

Windows Store app Development Snack: Being a sharing target while your app is running

For more posts in this series, see the series index.

imageBeing a share target seems like a great idea to get people to use your application more, however it does have a fairly complex problem: if I do a share to my application, while my application is running what happens – does it start a new instance or use the existing instance. You may say this can’t happen since Windows 8 doesn’t allow more than one application to run at a time… but you would be wrong.

Snap view in Windows 8 allows for two Metro style applications to run side by side thus allowing two apps to run at the same time. In fact you can run three apps at a time: one snapped, one filled and then you do a share target which launches a third app!

So back to the question, what happens if you app is say running in snapped view and you do a share from the filled app to your app which is currently snapped? The answer is it uses your existing application but from a separate thread.

To test this I put a simple Boolean field into the constructor of my App class which I set to true, then when the OnShareTargetActivated event was raised I checked the value of that Boolean field, and it was true if the app was running!

You should come up with a solution for this (or at least test it) – in my case the OnShareTargetActivated wrote to the application store and then my main UI which used that would poll for changes. I had to do this rather than triggering the UI because the OnShareTargetActivated was launched in a separate thread and trying to trigger caused a cross thread issue (I did try dispatcher fixes but that lead to a variety of COM issues).

Windows Store app development snack: Why is the store showing the wrong currency?

For more posts in this series, see the series index.

imageTo the right is a screen shot from the Windows 8 Store app on my machine, note the app called Cozy and in particular its price, it is in dollars… and I live in South Africa where we use Rands. :/

The store settings are controlled by the Windows Region settings, so to fix this you need to change the settings, which you can get by search for region:

image

Once in the region app go to location and change it from United States to South Africa, or where ever you are:

image

Next time you launch the store (you may need to do a reboot) it will be in the right country! Smile

Windows Store app Development Snack: A better architecture diagram

For more posts in this series, see the series index.

I have been talking a lot about Windows 8 recently and my slides have been using the architecture images Microsoft releases at Build 2011 & that awesome one Doug Seven created. However I have still found a lot of discussion exists even with those and they are showing their age.

I have tried to create a new one recently that addresses those issue:

  • Age: DirectX can be used by VB/C# in addition to C++ now.
  • Age: How does Windows Phone 8 fit the picture – note this may change, it is based on my assumptions and half info we have gotten.
  • Discussion: Is WinJS = WinRT?
  • Discussion: is .NET = WinRT?
  • Discussion: Can I use my own JavaScript libraries like jQuery?
  • Discussion: Can I use WinJS on the web?
  • Discussion: Can I build desktop apps on Windows 8?
  • Discussion: Can desktop apps run on Windows 8 ARM CPU's.
  • Discussion: How does the language projection fit in?

Clearly this wouldn’t work in a single image – so I have created a slide deck that has a great overview image and also has build up experiences where step-by-step it builds the image with information and hopefully during that answers all the questions.

Future of certification with Microsoft.

Over the next 10 months the learning & certification program at Microsoft will change drastically. This post is really just a cheat sheet of the new certifications and exams that are coming, as always for the latest source of news on this check out: http://www.microsoft.com/learning/en/us/default.aspx

High level

At a high level the three tiers will change as follows:

  • The MCP will certification will drop away and be replaced with MCSA (Microsoft Certified Solutions Associate). This applies to IT Pro’s & DBA’s – there is no MCSA for developers!
  • The MCPD & MCITP will be replaced with MCSD (Microsoft Certified Solutions Developer) & MCSE (Microsoft Certified Solutions Expert) - yes, those are the same names from about a decade ago.
  • The top level MCM will be replaced with MCSM (Solutions Master). I am not covering that in this post.

IT Pro’s

MCSA for IT Pro can be obtained in two ways:

  • MCSA - Server 2012. Made up three exams:
    • 410*: Installing and configuring Windows Server 2012
      411*: Administering Windows Server 2012
      412*: Configuring Advanced Windows Server 2012 Services
    • Can upgrade with the 417 exam from
      • MCSA: Windows Server 2008
        MCITP: Virtualisation Administrator
        MCITP: Enterprise Message Administrator
        MCITP: Lync Server Administrator
        MCITP: SharePoint Administrator
        MCITP: Enterprise Desktop Administrator
  • MCSA - Server 2008. Made up of three exams:
    • 640: Windows Server 2008 Active Directory, Configuring
      642: Windows Server 2008 Network Infrastructure, Configuring
      646: Windows Server 2008, Server Admin
    • Can upgrade with the 417 exam from
      • MCSA: Windows Server 2008
        MCITP: Virtualisation Administrator
        MCITP: Enterprise Message Administrator
        MCITP: Lync Server Administrator
        MCITP: SharePoint Administrator
        MCITP: Enterprise Desktop Administrator

There are three ways to get an MCSE as an ITPro:

  • MCSE Server Infrastructure: You need a MCSA – Server 2012 & the 413* (designing and implementing a server infrastructure) & 414* (implementing and advanced server infrastructure).
  • MCSE Private Cloud: You need a MCSA – Server 2012 or MCSA – Server 2008 & the 246 (monitoring and operating a private cloud with system centre 2012) & 247 (Configuring and deploying a private cloud with system centre 2012).
  • MCSE Desktop Infrastructure: You need a MCSA – Server 2012 & the 415* (implementing a desktop infrastructure) & 416* (implementing desktop application environments).

DBA’s

MCSA for a DBA can be obtained in one way:

  • MCSA - SQL 2012. Made up of three exams:
    • 461: Querying Microsoft SQL Server 2012
      462: Administering a Microsoft SQL Server 2012 Database
      463: Implementing Data Warehouses with Microsoft SQL Server 2012
    • Can upgrade by doing both the 457 & 458 exams from any MCTS on SQL Server 2008

There are two ways to get an MCSE as a DBA:

  • MCSE Data Platform: You need a MCSA – SQL Server 2012 & the 464 (developing Microsoft SQL Server 2012 databases) & 465 (designing databases solutions for SQL Server 2012).
  • MCSE BI: You need a MCSA – SQL Server 2012 & the 466 (Implementing Data Models and Reports with Microsoft SQL Server 2012) & 467 (Designing business intelligence solutions with Microsoft SQL Server 2012)

Developers

There is no MCSA for developers so the three ways to get a MCSD are:

Web Application Developers requires three exams:

  • 480: Programming with HTML 5 with JavaScript and CSS
  • 486: Developing ASP.NET 4.5 MVC Web Applications
  • 487: Developing Windows Azure and Web Services
  • You can also upgrade to this from MCPD: Web developer 4 by doing
    • 480: Programming with HTML 5 with JavaScript and CSS
    • 492: Upgrade exam

Windows Store Apps using HTML 5 requires three exams:

  • 480: Programming with HTML 5 with JavaScript and CSS
  • 481: Essentials of developing Windows Store Apps using HTML 5 and JavaScript
  • 482: Advanced Windows Store App Development using HTML 5 and JavaScript
  • You can also upgrade to this from MCPD: Windows developer 4 by doing
    • 480: Programming with HTML 5 with JavaScript and CSS
    • 490: Upgrade exam

Windows Store Apps using C# requires three exams:

  • 483: Programming with C#
  • 484: Essentials of developing Windows Store Apps using C#
  • 485: Advanced Windows Store App Development using C#
  • You can also upgrade to this from MCPD: Windows developer 4 by doing
    • 483: Programming with C#
    • 491: Upgrade exam


*Beta exams currently - will change.

SMS Subscription Service: the scam & how I got my money back

This post is a departure from my usual technology filled posts, it is rather a personal story that affects many people that I think is worth sharing my experience. It is about these SMS subscription services where people signup for a service, and get content via SMS and then get billed monthly for it via there cellphone provider. I was signed up without my knowledge, billed and this is how I found out about this scam industry and got my money back from them.

The Story

It starts

The first indication I had was the odd appearance of “Content Charge” on my July invoice from MTN (my service provider). MTN uses such complicated names for services that it could mean anything but something said I should find out what it is. I called MTN and was told it was for a subscription service! I told the call centre agent that I had never signed up and wanted my money back. Unfortunately MTN couldn’t help me – all they did was cancel it that day and give me the details of who to contact about this.

image

The interesting thing about this is that to run a subscription service in South Africa you must be a member of WASPA, Wireless Application Service Providers' Association. WASPA has excellent rules about what is allowed and what is not allowed and the company MTN told me to call about a refund is thus a WASPA member – that company is called Opera Interactive. (I am not linking to these companies not because I do not want you to know exactly who they are, but I do not want to give them any search engine love).

I phoned and spoke to their Opera’s call centre (by now the 25th July) and they told me they could not help – as they only do the billing. All they can do is cancel the service and give me the actual companies details. That is right, Opera is not the company they are a middle man and, from what I understand, they let non-WASPA members “pretend” to be them, handle the interaction for billing with the service providers and take a cut of the profit!

Opera then told me to contact Mobmatic who were incredibly rude & told me to email as they do not help on the phone with refunds because, while they have a South African phone number, they are based on the UK - eventually they just hung up up me after I asked to speak to a manager. So I emailed then and then immediately logged a complaint with WASPA.

Lies, damn Lies

Nothing until the 31st July when Mobmatic emailed me a document (below) as proof I had signed up and told me that they wouldn’t refund me. So I looked over it and checked the details.

  1. Checked my SMS’s on my phone to see if there were any @ the dates/time specified. There was only one the 3rd July one, but considering I have never signed up I ignored as it seemed like a scam – however the key confirmation signups were not there.
  2. The phone model & even the browser string features did not match my phone.

I responded again with that info and asked for a refund.

imageimageimage

Then nothing, no one responding until the 2nd August when WASPA said it had proof of me signing up from a company called Sprint (note: not Mobmatic), had asked for the service to be cancelled and then closed the case. Despite me asking for a refund, they ignored it – it really felt like WASPA had an automated system. I contacted them back and said I suspected the the “proof” was the same as sent to me and outlined the error in the “proof” and asked for a refund.

The scary part of the WASPA reply was “Since your unsubscribe request was not resolved using the informal process,” – informal?! What is informal about logging requests, getting reference numbers and so on. Just leads more proof that WASPA does it in an automated process.

WASPA contact Sprint again with the details I sent them and told them they had to provide a significant data in their response of they would have to go before an adjudicator.

image

The fight back

Oddly within 3 days of this I was phoned and offered a full refund and told I would be emailed and I could respond with my details. I got the email the next day (below) and it is almost what they said, except for a clause to protect themselves of any legal action if I accepted the refund.

image

I gave them the details and got my refund! WASPA contacted me a week later to confirm and I held responding for a further 3 days until the money actually arrived in my account (10 full days after I had spoken to them – what is this the 80’s). I told WASPA it is sorted out but urged them to launch an investigation into the companies and structures. That all was a few weeks ago and nothing has happened since.

Final Thoughts

Hopefully this shows you that it is possible to fight these people who are screwing the man in the street around and gives you some idea what to do. The short list of things to remember is:

  • Your mobile provider can’t do much – so do not fight with them. Be kind, and get them on your side so you can get as much info as possible.
  • Keep a log of all interactions, get names, reference numbers, times etc…
  • Once you have tried the direct route with the companies, contact WASPA immediately. While they seem to be a tick the check box type organisation, you will need their help too.
  • When you get “proof” go through it in detail. I would have likely just agreed with them that maybe it was a mistake, but the phone model was wrong & the ISP suspicious, gave me confidence that I was correct. These are not simple things to check, so maybe get your favourite geek to help.
  • Do not give up – if you are right there is plenty of routes. From speaking to MTN during this, if WASPA fails you can still escalate to the consumer commission which does give you a lot of power to fight them.

While WASPA is a good idea, it seems they are underfunded and employing everything they can to automate the system and deal with the load as much as possible. It is clear in the requirement you need a double opt-in, however the opt-in system does not need to be on the device and thus can be forged – this is just a sign that while the good idea is there, they are not able to keep up to date with techniques that bad companies are using to steal money.

Hopefully you never have this happen to you, and if you do I hope this helps you fight these scammers!

The new .NET 4.5 feature every XAML developer will love

If you develop using XAML and you are using .NET 4.5 (i.e. WPF or Windows 8) then there is a feature that will make you smile a bit, CallerMemberName. XAML developers often implement INotifyPropertyChanged to enable updating of data bound fields. If are smart, you often wrap the raising of the event into a simple method you can call, for example:

public void RaisePropertyChange(string propertyName)
{
    if (PropertyChanged != null)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

This leads to code that looks like this:

private int ticks;

public int Ticks
{
    get { return ticks; }
    set
    {
        if (ticks != value)
        {
            ticks = value;                    
            RaisePropertyChange("Ticks");
        }
    }
}

There are some problems with this

  1. Refactoring – rename the Ticks property and even if you use the VS refactoring tool it won’t find the string in the method call.
  2. Magic strings – It is just a string so there is nothing to make sure that you spelt Ticks in the string the same as Ticks in the property name.
  3. Copy & Paste – If you copy & paste another property, you must remember to rename this string too.

The solution: CallerMemberName

.NET 4.5 includes a new parameter attribute called System.Runtime.CompilerServices.CallerMemberName which will automatically place the name of the calling member (i.e. method or property) into the parameter. This enables us to change the method signature to:

public void RaisePropertyChange([CallerMemberName] string propertyName = "")

Note: The attribute in front of the property & note we have also given it a default value – when using this attribute your parameter must have a default value.

Now we can change the calling definition to

private int ticks;

public int Ticks
{
    get { return ticks; }
    set
    {
        if (ticks != value)
        {
            ticks = value;
            RaisePropertyChange();
        }
    }
}

Now we have solved all the problems with the string in the method call! Go and enjoy!

Below is a file with a sample application to get you started (everything is in MainPage.xaml.cs).

File attachments
demo.zip (21.69 KB)