<CharlieDigital/> Programming, Politics, and uhh…pineapples

24Oct/12Off

Avoid West Elm

Posted by Charles Chen

It's hard to imagine how some e-tailers are still functioning like it's 1999 in the age of Overstock and Amazon.

I ordered an item from West Elm online on October 18th assuming that I'd have it in my possession within a week.

Nope!  A week later, and nary an email on the status of the order, which is still listed as "shipping soon" on their website.

Turns out on 11/09, I'll get a call to set up a delivery date....

I don't even get the privilege of setting up a delivery date until almost a full month later?  Are master craftsmen hand-crafting my headboard, right at this very moment?  Given the reviews of their quality (or lack thereof), I think not.

I'm not sure if their stock management system sucks or what but this seems pretty crazy (OK, I'm spoiled by Prime as well).  I think it's a bit silly that I had to contact a live person to get a status on my delivery.

Turns out that this is SOP for West Elm and would have avoided them from the start had I known.

Filed under: Rants No Comments
10Oct/12Off

SharePoint DirectoryNotFoundException (0×80070003)

Posted by Charles Chen

I've been dealing with an interesting SharePoint error for the better part of a day-and-a-half now and I thought it was worth sharing.

The error surfaced was a DirectoryNotFoundException (0x80070003) when attempting to call BreakRoleInheritance in an asynchronous event receiver.

The purpose of the receiver was to read a set of rules which specified how to configure permissions for objects based on metadata and content type. However, this would fail with the aforementioned error, but only for folders.

Of course, this was a weird error because I could certainly see the folder in the list.

It turns out that the root cause is how we were setting the titles/names on our folders.  One issue with folders is that depending on how you add the list item, you may have to go back and rename it.  Otherwise, it gets a title based on its ID.

Our original logic looked like this (note the use of the Name property) and it was raised after the item was created in the list:

if (entity.ContentTypeId.StartsWith("0x0120")) // Only for folders
{
    item = list.GetItemById(item.ID);
    item["Name"] = entity.Title;
    item.SystemUpdate(false);
}

(Assume that entity is simply a container that describes the list item to create.)

The exception occurs in the case where the rename executes before the asynchronous event receiver finishes executing, thus the directory -- as originally named -- no longer exists since it's been renamed by the code above.  This caused random errors on our systems based on the order of execution and of course, when the debugger is attached, it works perfectly fine (I think because it changes the threading model).

We've changed our code now to something like this instead:

private SPListItem AddItem<T>(T entity, SPList list, string parentFileRef) where T : CtmoModelBase, new()
{
    if (string.IsNullOrEmpty(parentFileRef)) //Add to sub-folders
    {
        parentFileRef = list.RootFolder.Url;
    }

    _log.DebugFormat("Saving object to container URL: {0}", parentFileRef);

    try
    {
        Web.AllowUnsafeUpdates = true;

        if (entity.ContentTypeId.StartsWith("0x0120"))
        {
            // Add a folder (same in all cases)
            return list.AddItem(parentFileRef, SPFileSystemObjectType.Folder, entity.Title);
        }

        if (list.BaseType == SPBaseType.DocumentLibrary)
        {
            // Add a file to a document library.
            SPFolder parentFolder = Web.GetFolder(parentFileRef);

            return parentFolder.Files.Add(entity.Title, entity.BinaryContents, true).Item;
        }
        else
        {
            // Add a list item to a custom list.
            return list.AddItem(parentFileRef, SPFileSystemObjectType.File, entity.Title);
        }
    }
    finally
    {
        Web.AllowUnsafeUpdates = false;
    }
}

Which has solved the issue as the name of folder and items created from folder based content types no longer need to be updated to set the display name.

Filed under: SharePoint No Comments
1Oct/12Off

The Pineapple Lives!

Posted by Charles Chen

I had always been under the impression that the pineapple plant itself dies after it bears fruit so after my pineapple bore fruit this summer, I pretty much ignored it -- rarely watering it at all.  I've even left it out at night in sub-60F evening weather thinking that I was going to dump it anyways.

Lo and behold, as I was walking past it yesterday, I noticed something...interesting:

Pineapple with two (three??) plants

Pineapple with two (three??) plants

I'm not quite sure what happened here as it appears as if there are now three plants in my pot with two of them growing out of the original (click the picture to see a larger one).  I also peeled back the dead leaves at the base.  Check out the root system:

Check out that root system.

For reference, here is a wider shot that shows the two new (?) plants, the original plant, and the root system:

Wide shot

The pineapple is indeed a fascinating plant!