Friday, October 28, 2011

Silverlight 4– MVVM – binding & dependency property injection

 

I am not going to try and explain MVVM in depth, there are loads of post about what it is and how it works In essence its splitting the code and UI into separate (and testable) layers within your application while trying to keep the business logic out of the UI.

What I thought I should do is a simple example of one way you could bind your data.

One of this problems I hit very early on, was how do I use MVVM and allow data to be passed through from parent to child UserControls (these have to be generic - one for the address, one for a single phone number, etc) that are coded to validate themselves without having to understand the data context they are being used in. The big plan is to use them across multiple projects without having to rewrite/create each from scratch every time.

I started by dumping everything into one massive view model, this was the wrong way – it was nearly impossible to manage the code and with each control only needing the field(s) to do its single job it proved tough.

I looked at all the MVVM frameworks around, all are great, but none do all of the tasks I seemed to need. I also wanted to understand how MVVM worked in the background and using a framework would hide this from me.

No framework this time, I just coded my own simple modelBase to manage the standard bits and bobs.

What I ended up doing with the databinding is an MVVM application that uses dependency properties in the control code behind to manage data binding to some UI elements while still using MVVM to do the logic and control data storage.

I am building a Silverlight control to manage/create new customers so they can be vetted/contracts created etc for a telecoms company.

I have broken the form up into a number UserControls to try and make development easier and hopefully make each UserControl useable in other parts of the application.

The control forms a part of a larger control/view that manages an entire customer account, so being able to access the same customer data across (possibly) multiple Views is important.

How I did it (this time)

I am using web services to build the objects/classes/observable collections, these are all stored in a set of static classes that are all run before the application loads the UI, I had issues with loading everything asynchronously as if the customer loaded before the list of categories for example it would crash (there is probably a work around for that).

The main page holds all user UserControls , each UserControl is populated with static data before I load the customer view and ViewModel which will set the selectedvalue on any databound controls or text property for text etc.

Injection into user control code behind;

I am adding a binding my Customer ViewModel object to the LayoutRoot grid’s DataContextProperty, however you could add this to any property on any control. Or you could add a single field from the DataContext as well to any UI property.

My child UserControl code behind =

namespace Project.Controls.Customer
{
    public partial class ContractDetails : UserControl
    {
        public ContractDetails()
        {
            InitializeComponent();
            LayoutRoot.SetBinding(Grid.DataContextProperty,
                  new System.Windows.Data.Binding
                  {
                      Source = this,
                      Path = new PropertyPath("PropName"),
                      Mode = System.Windows.Data.BindingMode.TwoWay  
                  });

        }

        public static DependencyProperty DataProperty =
                DependencyProperty.Register("PropName", typeof(GenericDataService.queueCustomer), typeof(ContractDetails), null);

        public GenericDataService.queueCustomer PropName
        {
            get { return (GenericDataService.queueCustomer)GetValue(DataProperty); }
            set
            {
                SetValue(DataProperty, value);
            }
        }
    }
}

I hva set the Mode to TwoWay, you could set this to OneWay, OneTime or change this at runtime depending who who is logged to force the binding to be readonly.

I then pass the data into the child UserControl above in the xaml of the parent control;

   <my:ContractDetails  PropName="{Binding TheData }" x:Name="contractDetails1" />

One last step is to set the text property of the textbox that is on the child UserControl , in this case it is the phone number, I use a text filter command to only allow numbers and there will be some UK phone number validation as well.

    <TextBox Text="{Binding ElementName=LayoutRoot, Path=DataContext.PhoneNumber, Mode=TwoWay}" />

<TextBox Text="{Binding ElementName=LayoutRoot, Path=DataContext.Fax, Mode=TwoWay}" />

<ComboBox Height="23"  Name="CBContractDuration" Width="120" Grid.Column="2"

ItemsSource="{Binding Path=ContractDuration, Source={StaticResource StaticData}, Mode=TwoWay}" 

DisplayMemberPath="Name"  
SelectedValuePath="id" 

SelectedValue="{Binding ElementName=LayoutRoot, Path=DataContext.ContractDuration, Mode=TwoWay}" 

/>

From the ComboBox sample above you can see the control is filled with data form my Static data class, however the selected item is set by the Customer ViewModel data passed in through the dependency property up in the first example,

(I have tried to show the linking between the three steps by colouring the keywords, sorry if this is confusing for anyone)

It is important to remember that even in Xaml the binding keys are case sensitive  so in the above example PropName="{Binding TheData }"  is okay, but PropName="{Binding Thedata }"  will not work.

The above works well, but there are instances where you end up doing the validation on the control within the ChildUserControl in the code behind rather than the ViewModel, this is not perfect MVVM, but it works, so is good enough for me – at least until I work out how to do it all in the view model.

Summary

From what I have seen so far, its only been a few months of a steep learning curve (decided to move form VB to C# at the same time – glad I did), but there is no limit to what you can do in MVVM/Silverlight/Xaml, its really down to working around the eccentricities of the framework to make it do what you want it to.
Databinding is one of them, which I hope the above example explains - at least one way to do it.
Please note this may not be the best way, however in the rough and tumble of agile development, it works and it has shipped.

Thursday, August 11, 2011

Silverlight 4 – error in FrameworkElementMetaData

Booted up my PC and opened the latest project only to find when I try and view any of the silverlight VStudio just gives me this error: The type initializer for 'Microsoft.Expression.Platform.Silverlight.SilverlightCommonDesignTimeProperties' threw an exception.   - Nice and helpful.

There was only 1 result on google that sent me to https://connect.microsoft.com/VisualStudio/feedback/details/669751/the-type-initializer-for-microsoft-expression-platform-silverlight-silverlightcommondesigntimeproperties-threw-an-exception#

Thanks to dgcaron for his workaround;

I had this very same issue when i installed the WP7.1 templates from the MVVM light toolkit. i was able to build and use my projects after i :
- removed the system.windows.interactivity.dll reference
- cleaned my sln
- readded the reference

 

Tuesday, August 09, 2011

Activity.log – visual studio 2010?

Every now and then I have a pop up saying that something went wrong in visual studio and it is probably an add-on component that did it and I should run visual studio in  /log  mode to see what is happening in the activity.log

After a little playing in the command line trying to get this so work, I found this; http://blogs.msdn.com/b/visualstudio/archive/2010/02/24/troubleshooting-with-the-activity-log.aspx by Bill Weinberger

A great post, explaining how to do it and what to look for!

Now to work out what is happening.

Tuesday, August 02, 2011

Identity theft how simple is it

Armed with a few spare minutes and nothing but a mobile number for an eBay seller I was picking some kit up of I wondered how much I could find out about this person?

Step 1 – Asked Google

Google gave me a few spammy hits plus a link to a page on Facebook called "I have lost my phone, please tell me your mobile number again", I mean come on people. There were about 90 mobile phone numbers alongside this persons ‘friends’ names.

Step 2 – Facebook

Following through to the person profile for my ebay seller, a quick skim through their wall showed a load of birthday wishes a few months back, whilst their profile details mentioned they graduated from XXX university in 2002.
He also had a picture of his pride and joy, a beat up VW polo with its number plate visible in the photo.
So some simple maths gave me their date of birth +/- a year.

Step 3 – some more public sites

A quick scout of Linkedin gave me a few more clues on where they worked and adding this to the Facebook data a rough idea of where they lived too.

Twitter had no results, so they weren’t a geek (he works in a hotel btw)

Via BT, whitepages and 123people, using name and rough location I got a hit on an address, same surname but different initials (maybe lived with parents?)

 

So in half an hour I had;

1. Full name
2. Date of Birth
3. Postal Address
4. List of friends,mobile numbers (and all their names too, possibly DOBs)
5. Current employer and their address
6. Car number plate, although not sure what I could use it for?

This is probably enough to do bad stuff with, or at least cause some havoc.
I really don’t think people understand how easy it is now to piece together a full identity of just about anyone.

Yes there are bad people on the net that look for this stuff, but we really need to make it hard for them don’t we?

 

Prelude

I picked up my eBay purchase (from the address I found above it happens – strike 1), from the sellers father (strike 2), when I asked how his son was getting on at his new job (maybe pushing it a bit far with this), he said good but then looked at me a little bemused.

But I had already paid for the items so all is fair in identity theft and eBay purchases.

Keep it locked away

Its a dirt internet, keep it clean and hide the data you don’t want people to know about. You wouldn’t write your PC password on a post-it note and stick it to your screen would you?

Tuesday, July 05, 2011

Running a developer event – sponsors

They may not come through when you think they will and even if they say they will, others though will come out of the wood work. But they will never find you first.

But don’t let that put you off!

There are a few or companies who support the UK MS development community that you could say will be guaranteed to help out in some way, make contact with these guys as early as possible as they always run their sponsorships on a first come (with the best idea) first served. And they take the longest to get money signed off and paid.

Now its the hard(er) bit, start sending emails out to every business contact you know, anyone could be a sponsor. I didn’t go for the give us cash or forget it, it was important for me to get ‘stuff’ that could keep the costs down and I never said no to a sponsorship offer.
The email that went out was heavily focused on what I was trying to do, not on how much cash I needed, actually for most first contact emails I never asked for cash. If there was a positive email, then I would send a gracious thanks and mentioning cash needed.

My initial thoughts were to ask for small amounts (trying to avoid a ‘no’), after speaking to someone who knows about running and organising a lot of successful events (Simon Sabin from SQLBits), I realised that I should be asking for the full amount from everyone and seeing what happens… First try on this was surprisingly effective.

Don’t stop looking for sponsors, you cannot be certain of anything until the cash arrives.

Be prepared to cover some(or all) of the costs for the event yourself, hopefully it wont come to that. But you do need to bear this in mind, this will also keep you focussed on finding both sponsorship and the right venue.

Phase1 – the people you know
Phase 2 – the people you know through people
Phase 3 – random companies that you have seen advertising in the magazines you read, who may or may not have any link to the event
Phase 4 – repeat 1,2,3

It takes balls (not literally) to run an event, if you approach people confidently and know what you want to achieve you will get a better response. If you know what the sponsors can get out of the event, you will get a better response.

My initial emails were basically crap, it took me awhile to get my story of what I was trying to achieve straight.

Once you have your sponsors, do keep them in the loop, now this is not something I did on the run up to dev4good, but I will be sending a thanks and summary to them all within a few days of the event finishing.
While the event is on, make sure every attendee knows who the sponsors are and what they paid for, I did a lot of this on day1, but forgot about this on day 2.

And most importantly don’t lie to sponsors, ie this is our 5th year, we have 200 people registered, your closest rival has given us £xxx etc It will only get you bad press when the truth comes out and you will find it very hard if not impossible to get these people to ever take you seriously.

Well that’s a few bits on sponsors, don’t hesitate to contact me if you want to find out more, tweet me @chillfire

Running a developer event - venue

My biggest piece of advice to anyone looking to run ANY event
Get your venue sorted FIRST

That’s about it really, except a few other things to consider;

suitable for the Event

Make sure you focus on venues that fit your event, there is no use chasing a venue that is not suitable, if you can go to the venue before you say yes or put cash down, expect to out a deposit down well in advance of the big day, to secure the booking.
Keep in contact with the venue, make sure you know what they need from you and that they know exactly what you are expecting them to do.
When you go to the venue, try and imagine how the event will run in your head, ask about everything you may need and make sure anything verbally agreed is also bounced around in emails too.

Location

This will set your cost per person straight off.
In London its going to be a lot more than in the sticks, saying that you wont get as many people travelling to somewhere that doesn’t have a train for example.

Infrastructure

Public transport is a must, if it’s out of range to walk, then is their parking?

Accommodation

If you plan to run the event over night or not, people may want to stay the night before to save an early trip. I used a hostel as an option for anyone who didn’t want to kip on the floor. Saying that a few said they would have crashed on the floor if they had to. Also I could have saved a lot of cash by booking beds rather than dorm rooms that were not full due to last minute drop outs.
I was very lucky when I found www.hammersmithriverside.co.uk, this was all down to an opportune email. They allowed me to use the venue overnight (this was the biggest hurdle for dev4good, I wanted people to be able to work through the night if they had to (or sleep for free). I spoke to a few businesses and insurance was the problem, so was security. I tried real estate agents as well, looking for empty buildings, but again insurance and security were the problem.
I also looked into YHA hostels, as the initial event idea was for it to be a code retreat, but there are very few that have an internet connection (even 3G) and even fewer that are close to civilisation – they are a very cheap option though.

Services

Can you get the internet, is their 3G, how many people are you planning to have on site?
We had 25 people using 2 wifi points on the same Adsl and we crashed this quite regularly. One team ended up in the pub next door using theirs for a few hours. If you are using a corporate venue this probably wont be an issue, but do go wandering around your venue and make note of any ‘public’ wifi spots, cafes etc

Food

After the venue itself this is the second biggest cost, at dev4good I covered all food costs + coffee/tea/biscuits through the venue’s kitchen. We ordered pizza in on day 2 as it is a pre-requisite for any coder event.

backup

I didn’t have one, but its always worth having a backup in mind, especially if you are booking a long way in advance, don’t stop looking for other venues, you never know hen you might need them.
If you have any questions, tweet @chillfire and I will see what I can help with

Saturday, July 02, 2011

dev4good day 1

Day one has been a great day for learning!

The 3 charities all came to us with completely different problems.

Hope and Play (www.hopeandplay.org) were looking for a way to locate and manage resources. And allow other charities or people to do the same.

The Ministry of Stories (www.ministryofstories.org) are looking for a way to get more young people writing stories and publishing these to the world. All while helping to generate a little more cash along the way.

The Design and Craft Council (www.craftanddesigncouncil.org.uk) want to be able to automate their awards processes

For me one of the big worries about the event was how to get the teams to work on all the projects.

Fortunately after much post it noting and milling about, the teams magically built themselves!

Then came much discussion and planning

Then the internet and wireless connections started to fail our multi user downloading of updates/platforms/frameworks. So much so that one of the teams retired to the pub next door to use their wireless (well that’s their story anyway)

More pics from day 1

http://www.flickr.com/photos/64749203@N03

Its been a great day and there will be more code and frivolity tomorrow.

Wednesday, June 22, 2011

These are not the mind waves you are looking for

A few weeks ago I was watching the ‘Best if the Gadget Show’ and one of the task they showed was how they controlled a gantry crane with nothing but the power of their minds.

This was in my mind something straight out of the Sci-Fi shows I watched (and still do) as a kid.

This coincided with me trying to find some cool kit for the volunteers coming to dev4good (www.dev4good.net), we had the Kinect, we had the MS Surface, mind control was definitely on the cards.

Two days ago my Neruosky Mindwave arrived, queue the Star Trek theme tune.

Out of the box

inbox

Un Boxing the toy was easy, getting the sticker off their USB dongle was tricky. Unboxed there is not much to the system.
A weird headset similar to the one used in universal soldier (maybe there is a hint of irony here) and the aforementioned USB dongle.

That it I thought, this is all I need to control the world?

I did need a single AAA battery though.

There was also a CD, installing this gave me the option to install the latest software which was 400mb…

The headset is fairly lightweight and feels fairly solid, although not sure about letting the kids use (as the pictures on the box show).
When its on your head, it feels a little odd at first, its not something I would wear in public, at least until I can get my Jedi mind tricks working to make people forget they saw it.

I am guessing the positioning of the main contact and the forehead pad is important, but it does feel weird.

Install

Simple, just agree to the Licence and its off, took about a minute and half to extract.
Plug in the dongle when told, 30 secs later and MindWave manager opens and asks you to add put a fresh battery into the headset.
Once on it auto searches and pairs itself to the headset and tells you the serial number.

Up and running

Once installed the ‘App Central’ application kicks off image

and the mindset becomes active.image

Using mind control in the real world

Okay its all a little more grey than I thought, there is a great set of free apps/games installed by default. But while playing them you never really know if its you actually doing anything. This I think because you are not interacting with things in the same way.

When I type on a keyboard, I can feel what is happening, I am thinking a millions times faster than my fingers can type – but I know that its me that is doing it.

Sounds strange, but the mindset reads you brainwave and there are you you use for most of the games

- Alpha waves for relaxation
- Beta waves for focus.

But as I don't know how to control them, its a ll a bit hit and miss.
I guess the more you use the hardware and apps the more you understand how your own brain functions.

Now all I need to do is find an application I can use this for!

 

good place to start for developing against the mindset

- http://developer.neurosky.com/
- http://thinkgearnet.codeplex.com/

 

more to follow as I start to code my world domination platform up"!

Saturday, May 28, 2011

dev4good - who what where why?

I have been asked quite a few times why I am organising dev4good and every time I answer that questions it seems there is a different reason.

History

The initial idea came to me while watching a short film a friend Dave Hawes made, while taking part in the PayPal charity hack last year. I thought ‘hey I could do that, but just not with a single platform/API’.
I had no time so the idea was filed into my “great idea, no time folder”
R.I.P Build bunny

Time flew by and we had our first codefest evening at Devevening where we (Matt Lacey usually) writes a player app (noughts and crosses) that everyone attending had to compete against with there own self written player. Everyone had 2 hours to work on it, at the end we had a play off and the winner got - bugger all actually.

But the point was it was quite impressive what you can achieve in under 2 hours, some of the guys paired up and worked as a team to build their player and even though it was a competitive event, everyone was happy to help those needing a point in the right direction.
We have had a few of these events now and they are by far the most enjoyable code events I have taken part in.
Fast forward to early 2011 and I find myself brainstorming exactly what this hack day will be.
It had to be a simple format, otherwise I would never get it sorted in time. And it had to be based around solving problems, I wanted people from different backgrounds involved, there must be a competitive edge in there, a time constraint, sleep will be optional and we will need a tonne of coffee.

We also needed something to work on, something that we would not work on during the normal 9 to 5 slog.
Lets face it if you work in IT, normally your job is to make something that does stuff that makes money for someone. Or you end up developing something to remove the need for human interaction.

I though that charities always have problems they need solving and most don’t have the funds to realise their dreams or the technical staff to help them do it.

ideas + skills = results

 Developer stereotypes

Personally I think developers (of the software variety) tend to have the reputation for working late, in the dark, illuminated by their multi screen setups hunched over their wireless keyboards, sipping on a cup of coffee mere mortals would have tipped out hours ago – or is this just me?
Joking aside, for a lot of us isn’t too far from the truth, at least a few night a week anyway.
Saying that I really like working with other people, however as a freelance developer up until very recently anyway, its usually just me, myself and I writing code and solving problems and trust me, never listen to I and myself can be a little flaky at 2 in the morning.
So having an event that forces developers to work with people they would never normally work with on projects that they would probably never work on – it’s got to be a good thing right?
So the question was “What would happen if we took our codefest idea, but this time threw in 30 developers. The problems would be real world ones form people who really need the help.
Most importantly if we solved any of these problems we would be directly helping a person somewhere.
It seemed like a win win situation to me.

Enter dev4good

In march I was lucky enough to meet a man who had a building in London that basically cried out ‘hack day’, it had a bar!
He was happy for us to use the place for an entire weekend (including overnight, which for most corporate venues as this is not allowed due to something called insurance).

That pretty much set the ball rolling, dates were set, websites were knocked up (literally), then the social network wheels started turning.
3 months later we have 30 registered developers, over £5000 worth of prizes (thanks to them all), people coming from all over the UK (plus one form Holland) and a tonne of free coffee (hmmmmmm).
Also we have (so far) 2 fantastic charities that really need our help;
- www.hopeandplay.org
- www.ministryofstories.org
Dev4good is a social experiment of sorts, lock 30 developers in building with some serious problems and see how they work their computer sorcery to solve them.

Revelation

During the last few months while organising dev4good, I have met some amazing people along the way and we haven’t even had the event yet!
It is so refreshing to work on a project that a) isn’t IT based for a change and b) allows you to meet and talk to really cool people.

So come on, why?

To make a difference (cheesy I know), but I really do believe that we  (that’s all 30 of us) can make a difference over the course of a single weekend and if we can help 1 person then all the hard work will be well worth it.
I am also fairly sure that everyone attending will gain a lot from just working with the other people there. It’s an awesome team of people who are coming.

Right I want to join in the fun

You can register over at dev4good.wemoot.com
There is a load of info on out wemoot portal, feel free to look around

If you cant come, but would like to be involved?

We are still on the lookout for sponsors contact dev4good (or ask@dev4good.net)  if you can help financially or have a product you think could help our team out.
Spread the word, we will be running these events every year in London, or if you would like to run one in your region/area/town/country get in touch.
You can also follow the event on twitter @devfourgood and the hash tag is #dev4good

Wednesday, March 30, 2011

dev4good – developing for a better world

One of the cool things about doing what I do, is the simple fact I can build something from nothing with nothing but an idea and notepad (okay I haven’t hand coded a website form scratch in a few years, but I could if I had to).

Another cool part of my job is the people I work with, the other IT professionals, designers and developers (other people are cool too).

I help run @Devevening (Surrey based developer user group) and a few weeks ago we had another hack night, where developers are given a problem and 2 hours to solve it. Every time we hold these events I am amazed at how much can be done in a very short amount of time (this time was a battleship client that you had to pit against a fellow developers client to see who would win)

I am getting to the point honest…

So I wondered what would happen if you got  a group of developers together for say a weekend, throw in some real world problems (donated by a few charities) and see what amazing stuff could be done.

This idea has grown slightly and I am in the process of setting up the UK’s first ever Developer/Charity hack event, called dev4good, check out the site www.dev4good.net for more details.

We have a venue in London, on the river Thames no less (www.hammersmithriverside.co.uk) which is awesome!

If you think you would enjoy a weekend of coding with developers from all over the UK in possibly the craziest working environment, register for updates and provisional places, follow @devfourgood on twitter for updates.
Anyone from any IT background, any platform can help, designers, IT professionals, hobbyists, get in touch, we need your skills.

If you are a UK charity and think you have a problem that only the “A-team” could help with, let us know.

Obviously all of this is going to cost money, so I am looking for sponsors to help out with food/drink costs. There are no costs for charities, there may be a small registration fee to stop the ‘no-show’ effect for developers, but that’s it.

 

So what do you think, do you have what it takes to help building something cool, that could change someone’s life?

Friday, March 25, 2011

Home media platform project

I was asked to setup a home music centre for a friend, nothing too hard I thought. The requirements seemed standard, so I said yes let me at it.

3 weeks later, I found myself still trying to piece together the components, none of which I had ever used before – fun!
(This was 3 weeks fulltime)

The requirements were;

  1. Must use optical out (its connecting to high end amp)
  2. Needs to look like it fits in and around high end audio gear
  3. Headphone out
  4. Low power
  5. CD drive play/burn
  6. Internet access
  7. Auto rip function
  8. Remote control for playlists etc
  9. External touch screen
  10. Silent
  11. Small footprint
  12. Easy to use for a non technical user

Server/Base unit

I went off looking first of all for a base unit, the mini-itx platform looked like the best of what is available. And the boards are cheap enough these days to make home cinema/media PCs available to everyone.

But what I found was although the boards are cheap, its the extra bits that add up. By the time I added an external power supply, remote control, ram, hard drive it was still looking at +/- £400 with a decent case.
Add to this the problem of adding a slim line CD drive to some ITX cases, it seemed that if you did this the case got big quick.

I did find that the Acer Revo PCs were a pretty good fit, add an external CD drive and bingo, but I really wanted an all in one unit.

I found it in the form of the Asus EeeBox EB1501P Net Top PC.
It had optical out, internal CD (one of those funky soft eject ones too), Windows 7 Home Premium, WiFi, HDMI, eSata and although ebuyer didn’t mention anything, it came with USB keyboard/mouse, Media Centre remote control and a vesa bracket.

All powered by an Atom D525, Dual Core 1.8Ghz with 2Gb Ram for £270 +vat (its dropped by £30 now….)

Base unit was sorted, the screen was a little more fun, I wanted something small enough to be usable and not too big that you would notice it in the room. There are a number of 10” USB driven touch screens on the market (be careful some don’t work on 64Bit OS)  and after a chat to the guys at New IT I went for the iMo Mini Monster a 10” wide screen, single touch  monitor. It has a built in stylus that is hidden in the bezel too.

So that was the PC side of things completed sorted.

Remote controls at the ready

I wanted a tablet for the remote, but not an iPad, they were just too expensive for this project. I opted for a 10” Android ePad (10.2" Android 2.1 ZT-180a Apad/ePad 1GHZ CPU 256RAM) and threw in a 4Gb micro SD card for good measures.
I headed off the the android market place for a remote control to control the music…. I installed and uninstalled every single ‘free’ remote control literally in the market. Both iTunes and Windows variants… All were basically crap they worked most of the time or did everything except display the media library.
I did find one app that was fantastic when you had under 100 or so tracks, however as soon as we broke this level on while ripping we saw a massive drop in speed. It doesn’t cache anything on the tablet, so EVERY time you go to load an artist, genre etc it goes off and asks the server for the list, then waits until everything has been sent. We were waiting for 5 mins for a screen update… uninstalled that pretty quick.

This was when I put my IT hat on and realised that there must be a remote desktop app, there were lods of them, all were paid for and because I am tight I didn’t buy them.

What I did, which I think when looking back was a genius move and I should have done it in the first place, was to install TightVNC on the PC with the android TightVNC app on the tablet.
Instant connectivity, full screen, lag-less (pretty much) experience.

To make this better we put a wireless AP in the room that the kit lives on and only the devices in that room use that network, for an extra £40 it was worth it, the tablet and PC chatter to their hearts content without losing out to any other traffic.
The other reason for the added AP was the house we were installing in was built in the 1700’s so had walls about 1m thick of stone, which have the ability to block WiFi.

I used 3 home plugs one at the router in the 3rd floor office to run the network down to the ground floor conservatory and to the kitchen to a second AP just for the kitchen/liveing area as the BT router upstairs was dropping to under 1 bar most of the time.
The home plugs where sitting around 20Mb throughput, but this was expected as the wiring itself is a little flaky from time to time.

Conclusion

This was a great little project, the client is over the moon, a few minutes on how to connect the tablet to the PC and he is instantly in an environment he knows.

We ripped just over 3500 tracks in 2 days (used the Asus + 2 laptops running in parallel, ripping to the shared media folder – the whole D drive). The rip speed of the Asus is about 70% of my old HP laptop, not sure why this is, I am guessing the speed of the soft eject CD drive may be the problem.

If I was to do it again and I will for myself at least, I would throw another 2Gb of Ram in the Asus. It streamed DivX films okay over my network using Home plugs (70-80Mb) while playing on my TV via the HDMI, but for video I think the more ram you have the better.
When SSDs come down in price these boxes will be perfect for them, they use net to no power anyway, heat is minimal, but with an SSD it will just be that little bit better.

I would probably fork out for an eSata drive as well, or at least a NAS box/home server setup to work alongside this, the storage is great for MP3s, but would get eaten quickly with video storage.

Pics

So we have the 10” screen next to the tablet running TightVNC!WP_000516

The 10” screen on its own
WP_000514

The Asus EeeBox

WP_000515

Nice to do something that doesn’t involve writing code for a change!

Thursday, February 24, 2011

The end of the IT department

My response to http://37signals.com/svn/posts/2785-the-end-of-the-it-department

That was a very interesting read, not what I would call a balanced view though and made me write;


My company is the IT department for a number of companies in the UK and I have been the IT manager in charge of departments in the past.
In part I agree there are parts of the corporate IT world that need to be relaxed, but most are based around very old fashioned thinking and cost of upgrading

The IT world is an ever changing industry, people with the right skills today need to upgrade these skills next week.

Also normally the people who work in the IT departments are not the same people that make the decisions to what can and cant be changed in the company.
If I had my way every PC, server would be replaced every year and always be patched to the latest versions of their software, this is however impractical to most companies as the cost of this is inhibitive.

Yes the 'cloud' is amazing and will lower the number of IT support staff in the building, however it just moves these people and their skills outside of the business, wont this just create a hole in the companies shared knowledge?

I have moved a number of companies to the cloud (not really the cloud, but they call it that, I call it dedicated outsourced server hosting) and they are all happy, but in doing this I had to upskill to understand the implications of these technologies for each company to make sure it will do what they need it to.
Now the big problem we are facing is the local adsl circuits are topping out and we are reliant on 100% uptime from not only an adsl line, but also the infrastructure at the other end.

So when a server goes down, exchange plays up, the problem is passed to an outsourced support company, who place the problem in their 'queue', then we wait.... we have no control or input... 9/10 I could fix the problem if I had access to the servers myself (10 years of IT support do count for something) but I cam not allowed access so we wait.....

The cloud idea is good, but I can see companies jumping on the 'save money' band wagon and then realising that moving their infrastructure outside of their control could cost them more in the long run.
one thing that no one ever asks is  "So if it goes wrong (the cloud) and doesn't work for us, how much will it cost to move everything back?" - the answer - LOTS, probably more than the move out as you will need new hardware, licensing, staff, skills...

The cloud is not for everyone, be very careful about what goes where and who controls what.

Wednesday, February 16, 2011

utilising the power of 'remote'

Among other jobs I manage the IT for a number of small businesses and in a bid to not be on site very often (save costs,fuel,carbon etc), I have been testing a few remote support platforms.

The 2 that remained after testing were Microsoft Remote Desktop and Teamviewer.

All of my clients are Microsoft based, so when working on their servers Remote Desktop just made sense.
The down side is that there needs to be a public IP address linked to the server you are trying to connect to if you don't use a VPN that is.
On hat note VPN's are great, however they don't always give you the best user experience, like trying to connect across a 3G dongle to fix a problem can be clunky, remote desktop does hog a lot of resources. It can be done though, don't get me wrong. While on holiday in Kefalonia I did connect into a server over a very ropey 3G connection using Remote Desktop.

Teamvier has a citrix(y)/go to my PC feel about it and for connecting adhoc to client PC's it is fantastic.
You dont need a VPN (although it has one built in anyway), your client connects to their server which managed the authentication and initial connection. As far as I can tell it then drops the 2 connections together like a VOIP call, dotn quote me on that I have not done mush research into this side of things.

What teamviewer does do is alleviate the need for public IP address and firewall routing, it uses port 80 from both ends of the connection and encrypts the data as well.

I have been saved on a number of occasions by teamviewer, as you can install it to run when windows starts up, I can remote into a PC and fix VPN's etc without too much hassle.

The other big seller for me is the client PC's do not need to have teamviewer installed, they can download and install a 'no install' client for windows/mac and just tell me the ID and secure password, presto I am in.

There is no downside for me anyway with using teamviewer, its free for non commercial or you can buy a lifetime licence.
When you add in its ability to allow you to do remote presentation, VPN, VOIP calls, chat, file transfer etc, the cost of a single licence is quite resonable +/-£440

Just checked and there are clients for PC, Mac, Android and IPhone and iPad.... 

The most complicated thing I have had to try and do is move some files to a secure web server and my access is IP based, so I only have access from my office.
This happened while on a train;
I used teamviewer to get onto my desktop in the office (had to call to have it turned on though
Then remote desktop'd onto my clients PC that is on their office network, copy the files from the designer's PC to the server in the DMZ through the PC I was logged into.
Long winded and slow, but I did it without having to break any security by telling someone how to do it and it meant the client didn't have to wait for the job to be done the next time I was 'passing by'

If you do IT support and need a remote support platform to use (did I mention you can white label it as your own?).

Teamviewer gets a thumbs up from me.

Friday, February 11, 2011

Nokia + Microsoft ?

This morning BBC breakfast announced that Nokia was going to make a big announcement, possibly that they are going to work with Google on their next range of phones....

1 hr later I get to work and in that time Uncle Steve (Boom baby thats what we are talking about) Ballmer announces that Microsoft and Nokia are forming a strategic alliance.
http://blogs.msdn.com/b/ukmsdn/archive/2011/02/11/windows-phone-and-nokia-enter-strategic-partnership.aspx?wa=wsignin1.0

http://www.microsoft.com/presspass/press/2011/feb11/02-11partnership.mspx

I like the nokia handsets, the OS has been getting increasingly out of date, so I moved to windows phone 7, as a developer the plan was to build some apps and get rich and famous.
I haven't done any of that, but I have realised that MS is onto a winner with their mobile OS, I thinks it really good and possible even better than the competition.

But what does this alliance really mean for the day to day phone user?
Probably not much unless you are a symbian OS developer, maybe more flexibility and choice as Nokia do make cool handsets.

WIll be interesting what Nokia say later on today.

Wednesday, February 09, 2011

Company acquires new business - Q: Do we run two website targeting the same people?

I was asked over a bottle of wine what I thought the best thing to do when 'Company A' buys 'Company B' and they now have 2 websites targeting the same consumers on the net.

This is a great question and although I can remember my exact answer (blame the wine), the question keeps popping up in conversations with other clients.

Some history on search engines (mainly google)
It used to be that if you had a site and somebody copied the content (think CTRL+C then CTRL_P) the SE would think its you trying to do bad stuff. Somtimes the new site would actually beat the older site in the ranking as it was new and fresh etc. Other time both sites would be penalised and would see their result standings drop, or disappear.
Index updates would be 'rolled out' every few months, and we would all sit and wait to see where we ended up in the results, and then have 3 months to fix it and wait, then fix, wait....

Duplicate content across multiple site's was bad and I would have said back then to drop one of the sites Company A owns and permanently redirect the traffic to the other, keep it neat and clean.

Fast forward to now
SE's are super smart, they update their index faster than the sites can be created.
The idea of sites of the same content is normal, sites are sharing XML feeds, mashing up data and content onto their own pages etc.

SE's can also check domain ownership, location of hosting server, location of company who owns the site, location of the people who visit the site.
Even if the sites have identical content, an SE can see they are different sites (okay there will be instances where they are the same but that's covered later *)

With 2 sites that are relatively the same  (the 2 sites are travel/trip based), Company A has a great opportunity to maximise their traffic, across two competing sites.
Both sites are already ranking okay in SE results and have their own brand that consumers are aware of, so is there really a benefit of combining them straight away - I don't think so.

There are a lot of caveats and maybes from here on in, so have that pinch of salt ready.

If it was me I would;

  • set up SiteA and SiteB to interlink where appropriate
  • link to/from other 'intra company sites'
  • each should (if possible) target slightly different customers
    • set them to target different demographics (one high value trips other low?)
    • find out if either of the sites is being hit from any particular geo location, if so use this site to target this area. (this is very easy to do)
    • if targeting geo location, use local phone numbers
  • use meta data and page control the content on both sites so it is NOT exactly the same
    • use different staff is possible to write the content for each site, sounds a bit extreme, but web content writers always have 'accents' in the copy they write
  • don't be afraid to send customers from A to B, add pages on each site that are specifically set up to send the customer to the other. If they buy, who cares which site they do it th
  • leave the sites hosted where they are for the time being
  • run regular benchmark reports to see if 
    • sites are working in harmony (traffic/ vs sales vs enquiry)
    • SE results are being helped by having 2 sites
    • customers are getting lost between 2 site
Once you know how the sites are working together you can decide where to go with the sites.

Obviously if one of the sites is new or has no SE value and no one ever uses it, then I would say kill it and focus on the other, but if the sites are both strong then its a waste of SE value to just get rid of it.
Its very hard to put a price on SE value, but it can cost a lot in time/£££ to get a site up to the level of a site that has 'some' value.



These are just my opinions, they could be wrong or they could help you, either way comment and ask questions.




* I see my site twice in the results
This can happen if you have sub domains that are displaying the same content ie public.site.com and www.site.com have the same content and are hsoted onthe same server, same owner etc.
In this instance I would shut down the duplicate sub domain and redirec the traffic to the main site.

There is no use setting your own site and sub domain as competitors

Tuesday, February 08, 2011

SQL Server does not handle comparison of NText, Text, Xml, or Image data types.

When adding XML to an XML field in SQL server via Linq to SQL it all works fine, however when you try and update this XML field, you get this error;

SQL Server does not handle comparison of NText, Text, Xml, or Image data types.

Fix to my solution was to edit the dbml and set the updatecheck to false

<column canbenull="true" dbtype="Xml" name="OrderXML" type="System.Xml.Linq.XElement" updatecheck="Never"></column>


Works like a dream now.

Friday, January 28, 2011

LinqSQL tip #2– linqDatasource binding funkyness

Binding controls via a datasource is nice and easy, however when you try and change the way the data is displayed in a dropdown for example, Linq can be a pain.

Example 1 – Add text variable flag to show what entry is a primary category and which are secondary categories

<asp:LinqDataSource ID="LDSRentalDefinition"
runat="server" ContextTypeName="DB"
Select="new (ID, (iif(isPrimary==true,' ','+') + Name)  as TextValue)"
TableName="Categories" OrderBy="iif(isPrimary==true,' ','+'),Name" >

Weird thing is in the SELECT, IF statements don’t work, but old fashioned IIF statements do.

Still gets me that some C# code works inside the LinqDataSource on a VB page, but some VB works as well.
( || does work where | doesn’t )

Its a nice visual thing for the users as they can see straight away that any child category has a + in front of it in the dropdownlist

Annoyingly I was only allowed a single character inside the ‘’, page would crash otherwise.

Example 2 – add multiple data fields to a single item in the listbox

This is an easier one, but still very powerful to make your UI make more sense to the user

Select="new (ID, (Name + ' ' + Description) as TextValue”

List box items are displayed as “Bob boss”, “John cleaner” rather than just a first name.

LinqSQL tip #1– dynamic queries

I had to build a reporting page for a client the other day that pulls a load support ticket data from the DB and makes it look nice on the screen.

Simple I thought, once the first version was done, I get the emails asking for date filters, easy.

Then the filters for member of staff, easy.

Then for the categories, easy

And then the sub categories, but sometimes we will want to filter by  one and sometimes all of them, or maybe one or two….

This got me stuck there didn’t seem to be anyway to look at a list of checkboxes and add a ‘where’ statement to the Linq statement for each subcategory selected.

In SQL you would build the query up, using and/or statements to get the data back you need, in Linq this is farily tough to do on the fly in standard Linq code.

After a fair old time on the net I came across the LinqKit which has a Predicate builder!
This is an awesome piece of code, I could have tried to build something like this (I would never have got there in the time I had), but why try and reinvent the wheel when there is a handy .dll that does it already!

All I needed to do was create an array of the categories I need to filter by and throw them at the Predicate builder.

Function FilterSubCategories(ByVal iQuery As IQueryable(Of DB.Issue), ByVal  _ searchTerms As ArrayList) As IQueryable(Of Issue)

    Dim predicate = PredicateBuilder.[False](Of Issue)()
    For Each keyword As String In searchTerms
        Dim temp As String = keyword
        predicate = predicate.[Or](Function(p As Issue) p.SubCategoryID.Equals(temp))
    Next
    Return iQuery.Where(predicate)
End Function

The function simply returns a queryable set of data that I can either bind to a control of continue to work with.

There are more extension sin the LinqKit, if you are looking for an easy way to deal with dynamic Linq clauses, this is definately worth a look.