Monday, September 26, 2011

Live SkyDrive API: Get List of Folder's Files

The new Live Connect SkyDrive API, which was released in prelimary form at Build 2011, finally delivers an "official" way to manipulate files and folders on SkyDrive. For being a preview release, the docs look reasonably complete.

However, one thing that wasn't clear to me (from the docs) was how to iterate through the contents of a folder while, for example, searching for a particular file.

So...here's a bare-bones code snippet that shows how to search the root folder of the signed-in user's SkyDrive for the file "test.txt".


private void FindFileTestDotTxt()
{
    client.GetCompleted += 
        new EventHandler<LiveOperationCompletedEventArgs>(client_GetCompleted);
    client.GetAsync("me/skydrive/files");
}

void client_GetCompleted(object sender, LiveOperationCompletedEventArgs e)
{
    Dictionary<string, object> resultDict = 
        (Dictionary<string, object>) e.Result;

    List<object> items = (List<object>)resultDict["data"];

    foreach (object o in items)
    {
        Dictionary<string, object> item = (Dictionary<string, object>)o;

        if (item["name"].ToString() == "test.txt")
        {
            // found it 
            Console.WriteLine("File URL: {0}", item["source"].ToString());
            break;
        }
    }
}

Wednesday, June 1, 2011

Windows Phone 7 Emulator Saved-State Corrupted

This morning, quite out of the blue, the Windows Phone 7 emulator (Mango release) refused to initialize. The error message complained about a corrupted saved-state file and recommended that I delete a particular file named SOME_LONG_GUID.DES in C:\ProgramData\Microsoft\XDE.

After some poking around, I found the file (which actually ends in DESS, not DES), deleted it and restarted the emulator. No dice. Now I'm getting some sort of "internal error" message.

Next I deleted the SS file also found in C:\ProgramData\Microsoft\XDE. Still broken.

Restored the DESS file, but not the SS file. (SS == Shared State?). Now we have some progress, but the emulator is clearly booting from scratch and takes several minutes to initialize. Deploying apps from VS doesn't appear to work either.

As a hail mary, I restored the SS file and tried again. All's well!

Hope this helps someone else with the same issue.

Monday, July 12, 2010

503 Service Unavailable Errors

I was going through the same pain as this guy. In my case, I was trying to create a simple webapp on port 8080. But try as I may, I couldn't get around the 503 Service Unavailable response.

Luckily, the same guy also posted a response to his original blog entry.

Turns out the command netsh http show urlacl saves the day. In my case, another user on the same server had just happened to reserve port 8080 while doing some other work.

All's well...

Thursday, January 29, 2009

Wednesday, October 22, 2008

Thursday, September 18, 2008

SharePoint List Scalability

One-stop shopping for all things related to SharePoint list scalability and scalability in general.

Link saved for future use.

http://www.sharepointjoel.com/Lists/Posts/Post.aspx?ID=84

Wednesday, September 3, 2008

SearchBoxEx, FireFox and the Enter Key

Here's a problem with SearchBoxEx and FireFox that's easy to reproduce.

1) Create an out-of-the-box Publishing Portal. No customizations required.

2) With FireFox 2 or 3, go to the home page of the new site.

3) In the search box, enter a search phrase and press the enter key.

4) The home page simply refreshes instead of going to the search results page.

With IE 6/7 and Safari 3, everything works as expected. That is, the search results page is displayed.

I've reproduced this bug with three flavors of MOSS: MOSS RTM, with MOSS SP1 installed and finally with MOSS Infrastructure Update installed.

Looking at the traffic in Fiddler, it appears that *two* requests are being generated by FireFox. One to the search results page and one to the home page (in that order).

So...what's the fix?

After using http://www.rotary.com/ as inspiration, we came up with the following JavaScript that replaces the default key press event handler provided by MOSS.

To use the script, you'll need to supply the correct name of the submit method and input control id that is dynamically generated by SharePoint. After you do that, wrap the code in a script tag and place it on the page.

function replaceOnKeyPress()
{
var theFunction = "SDXXXXXXX_Submit();";
var theInputID = "ctl00_PlaceHolderSearchArea_SearchBox_SDXXXXXXX_InputKeywords";

var txt = document.getElementById(theInputID);
var browser=navigator.appName;

if (txt && (browser == "Netscape"))
{
txt.onkeypress = function(e)
{
var key = String.fromCharCode(e.keyCode);

if (key == "\n" key == "\r")
{
eval(theFunction);
return false;
}
}
}
}

replaceOnKeyPress();