Archive

Archive for October, 2010

Creating a GUI in Powershell

October 29, 2010 Leave a comment

[System.Reflection.Assembly]::LoadWithPartialName(“System.windows.forms”)
$form = new-object System.Windows.Forms.form
$Form.text = “Hello World!”
$form.showdialog()

There you go, a bit of powershell script that shows a graphical user interface… Not elegant, but possible.

Categories: Uncategorized

401 Not Authorized For MSDEPLOY‏ (msdeployAgentService)

October 29, 2010 18 comments

When you get this error from msdeploy:

“Error: The remote server returned an error: (401) Unauthorized.”

you need to give the remote user elevated rights to get authorization.

http://support.microsoft.com/kb/951016
http://blogs.msdn.com/b/vistacompatteam/archive/2006/09/22/766945.aspx

To disable UAC remote restrictions, follow these steps:

  1. Click Start, click Run, type regedit, and then press ENTER.
  2. Locate and then click the following registry subkey: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  3. If the LocalAccountTokenFilterPolicy registry entry does not exist, follow these steps:
    1. On the Edit menu, point to New, and then click DWORD Value.
    2. Type LocalAccountTokenFilterPolicy, and then press ENTER.
  4. Right-click LocalAccountTokenFilterPolicy, and then click Modify.
  5. In the Value data box, type 1, and then click OK.
  6. Exit Registry Editor.
Categories: Uncategorized

Cannot serialize member because it implements IDictionary.

October 29, 2010 Leave a comment

If you ever get an error like Cannot serialize member x of type T, because it implements IDictionary. or something similar whenever you try to return an serialize object with xmlserializer.

Note: This isn’t suitable for webservice use, since the schema is lost.

using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Soap;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

/// <summary>
/// A Web-service friendly version of the  object
/// </summary>
public class XmlSerializable<T> : IXmlSerializable
{
    [NonSerialized]
    public T RawObject;

    public XmlSchema GetSchema()
    {
        return null;
    }

    public void ReadXml(XmlReader reader)
    {
        //deserialization
        var formatter = new SoapFormatter();
        var strXML = reader.ReadInnerXml();
        var msXML = new MemoryStream(Encoding.Default.GetBytes(strXML));
        RawObject = (T)formatter.Deserialize(msXML);
    }

    public void WriteXml(XmlWriter writer)
    {
        //serialization
        var formatter = new SoapFormatter();
        var ms = new MemoryStream();
        formatter.Serialize(ms, RawObject);
        ms.Position = 0;
        var sr = new StreamReader(ms);
        var strXml = sr.ReadToEnd();
        writer.WriteRaw(strXml);
    }
}

Then,  instead of returning T, returns XmlSerializable<T>, and the client accesses the RawObject member of this class to read the return value.

Categories: Uncategorized

Customizing Tem Web Access for TFS2010

October 28, 2010 Leave a comment

Here are a few tips that I’ve learnt on how to customize Team Web Access for TFS2010

  • To Add a new page:

using Microsoft.TeamFoundation.WebAccess.UI;

then inherit from WebAccessPage

Then use  the MasterPageFile=”~/UI/Masters/Content.master”

 

  • To Select a tab within the page use:

ActiveTab = “Some Tab Name“;

  • To Get the logged in username

Connection.AuthorizedUserDisplayName;

 

Categories: Uncategorized

Default controller cannot be deleted because there are builds in progress

October 27, 2010 2 comments

If you’re working with TFS 2010, and you get this message “default controller cannot be deleted because there are builds in progress” when trying to remove a build controller, you should of course check first to see if you can stop the build through the interface, but you can force the issue by running this query in the TFS_DefaultCollection database

update tbl_BuildQueue set status=16

This sets all builds to a status of cancelled.

Or if you prefer, do a select from tbl_buildQueue, and find any one that has a status of 1 (in progress) or 2 (Queueud).

Here are all the statuses

0 – None

1 – In progress

2 – Queued

4- Postboned

8 – Completed

16 – Cancelled

 

 

 

 

Categories: Uncategorized

How page load times can affect conversion rates

October 14, 2010 Leave a comment

I spotted that over the last two weeks my conversion rate had dropped from 21% to 18%, meaning that on average 3% less people were actually using my website after they came to it.

For me, conversion rate either stayed within a +/- 1% range unless the site crashed completely, when it would drop to 0%. A slow decline in conversion rate was very unusual. Note that conversion rates have nothing to do with visitor numbers, so whether this applied to 100 ot 1,000 users, it’s always the same.

One thing that had happened about a month ago, was that my Users database exceded the 4GB limit of SQL express, and was unfortunately lost in a failed backup-restore procedure, the new Users database was hastily constructed to get the site back up and running quickly.

At the start, no problems occurred, but since there is now 1.3 Million rows in the users table, lookups became increasingly slow. A single update took 10 seconds to complete, and the front page performs one update, therefore slowing the front page by 10 seconds.

To my mind, 10 seconds is too long to wait for a web page, and 3% of people must have got tired, and left the site before using it.

So, I went into the database, ran an sp_help on the users table, and found no index on the ID column, which lookups were being perfomed, so

create index idxUsersId on users (id)

Sped up the update from 10 seconds to under 1 second, and the front page now loads in 1.09 seconds, rather than 10.

Update:

The following day, conversion rates have risen back to 21.63%, the second-highest all month, and recorded traffic increased by 500 users.

 

 

Categories: Uncategorized

Running an App from Ares to a real Palm Pre

October 9, 2010 Leave a comment

How cool is this, there is an “easter egg” in the palm pre, if you type upupdowndownleftrightleftrightbastart you enter developer mode

Which allows you run apps direct from Palm ares to the palm pre via a USB cable.

I’ve also updated my app, so that it can run in multiple orientations, has validation, and responds properly once the AJAX call returns…

Palm App store awaits

 

function MainAssistant(argFromPusher) {}

MainAssistant.prototype = {
setup: function() {
Ares.setupSceneAssistant(this);
},
cleanup: function() {
Ares.cleanupSceneAssistant(this);
},
btnSendTap: function(inSender, event) {
// Make an Ajax call to FreebieSMS.co.uk
Mojo.Log.info(“btnSendTap invoked”);
var xref=this;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState!=4) return;
if (xmlhttp.status != 200)
{
Mojo.Controller.errorDialog(xmlhttp.responseText.split(“\n”)[0]);
Mojo.Log.info(xmlhttp.responseText);
xref.controller.get(‘btnSend’).mojo.deactivate();
// hide spinner
}
if (xmlhttp.status == 200)
{
xref.controller.showAlertDialog({
onChoose: function(value) {},
title: “Success”,
message: “SMS message sent successfully”,
choices:[
{label: “OK”, value:””},
]
});
xref.controller.get(‘btnSend’).mojo.deactivate();
}
}
// Ensure that a Destination is provided
if (this.$.tfTo.getValue().indexOf(“0044”)!=0)
{
Mojo.Controller.errorDialog(“Recipients phone number must start with 0044.”);
xref.controller.get(‘btnSend’).mojo.deactivate();
return false;
}
// Ensure From-Mobile number is international format
if (this.$.tfFrom.getValue().indexOf(“00”)!=0)
{
Mojo.Controller.errorDialog(“Your phone number must begin with an international prefix (0044 for UK).”);
xref.controller.get(‘btnSend’).mojo.deactivate();
return false;
}

// Ensure names are filled in
if (this.$.tfFromName.getValue().length<3 || this.$.tfFromName.getValue().length>11)
{
Mojo.Controller.errorDialog(“Your name must be between 3 and 11 letters long.”);
xref.controller.get(‘btnSend’).mojo.deactivate();
return false;
}

// Ensure message is not blank
if (this.$.tfMessage.getValue().length==0)
{
Mojo.Controller.errorDialog(“Your message is blank. Please type a message in the box provided”);
xref.controller.get(‘btnSend’).mojo.deactivate();
return false;
}

if (this.$.tfFrom.getValue() == this.$.tfTo.getValue())
{
Mojo.Controller.errorDialog(“You cannot send a text to yourself”);
xref.controller.get(‘btnSend’).mojo.deactivate();
return;
}
var strUrl = “http://www.freebiesms.co.uk/sendsms.asmx/SendSms?&#8221;;
strUrl += “FromName=” + this.$.tfFromName.getValue();
strUrl += “&FromNumber=” + this.$.tfFrom.getValue();
strUrl += “&ToNumber=” + this.$.tfTo.getValue();
strUrl += “&Message=” + this.$.tfMessage.getValue();
strUrl += “&locale=en-GB”;
xmlhttp.open(“GET”,strUrl,true);
xmlhttp.send();
// Show waiting spinner
}
};

Categories: Uncategorized