Deleting Large Amounts of Items in Sitecore

I’ve wasted a lot of time this week. It’s unforunate because I’ve had a lot of work to do yet I spend a lot of time waiting for items in Sitecore to delete. Sometimes I have to wrestle with it, it keeps timing out and I keep telling the page to wait. Sometimes I try to load up a new tab but the whole site locks up. Eventually if it doesn’t come back alive I restart the app pool. Fun times.

So what’s the better way to handle this? It turns out it’s a convuluted one that is most effective. I would have thought a bit of custom code with a delete action would be the fastest way but from what I’ve discovered it’s not.

Start off by going into Content Editor

If you haven’t already, enable the Developer tool bar by right clicking the toolbar and checking off Developer

Enable Developer Toolbar

Next, in the navigation tree on the left find your way to the folder with lots of sub items you want to delete. In this example I am using /sitecore/templates/Common/BigFolder.

With BigFolder selected in the navigation tree you’ll want to go up to the Developer toolbar and click Serialize Tree.

This part may stil take a minute or two, but I promise you it will be faster and it wont time out. Once it is done you will find this folder in your file system, as what we’ve done is taken your item structure from the database and have created another representation of it as text files in your file system. For example look in C:\inetpub\wwwroot\YourWebsite\Data\Serialization\master\ with YourWebsite being the name of the Sitecore instance you are using. From there we will see a familiar structure representing your item tree. So for this example we used /sitecore/templates/Common/BigFolder so we should that same structure in here giving you C:\inetpub\wwwroot\YourWebsite\Data\Serialization\master\sitecore\templates\Common\BigFolder and then inside BigFolder you will see a file for every item you had in your tree. If you’ve used TDS you will be familiar with this Serialization process however if you are not don’t worry about it too much. Each record has been stored as a .item file which you could now in theory backup with WinZip or even push out in SVN or Git. But in our case we don’t want these files at all, so we’re going to delete them.

So why go through all this effort if we’re goign to delete them? Well we need to create the rest of the structure which happens when we serialize the whole tree. Now we can go in there, delete everything in this folder, then go back to Content Editor under our Developer toolbar and click Revert Tree. This will attempt to rebuild the tree from your selected item downward (so make sure you stil have /sitecore/templates/Common/BigFolder selected) and because it doesn’t see an item file it assumes this item should not exist and it deletes it from the database.

Fantastically this is faster than just deleting them through the right click menu, or even the DB Browser. Within a few seconds your screen will refresh and BigFolder will have no content in it. Even if moments before it had thousands of items under it. Woohoo!

Tags: , ,

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS
read comments

Removing a Windows 7 Registration Key

I was recently writing about setting up a VM with my development environment that I could hand out to other developers and how one of the challenges was removing the license keys. This post will be a continuation of that process, this time we’ll be resetting the registration in Windows 7 so that the next time it boots up it will request a registration key just like it was it’s first boot.

First, open command prompt as an Administrator and enter the following commands:

  1. slmgr /upk
  2. slmgr /cpky
  3. slmgr /rearm

After that you should almost immediately be prompted to enter a new registration key, just click Activate Later and it will continue to pop up periodically until you are ready to enter a new key.

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS
read comments

Resolving the “Server Error in ‘/’ Application” Error in ASP.Net

I’ve been doing a lot more MVC in ASP.net lately and I’m running into all sorts of new challenges as I learn things like Razor scripting.

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: "-" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.

Source Error: 

Line 498:        msViewportStyle.appendChild(
Line 499:                document.createTextNode(
Line 500:                        '@-ms-viewport{width:auto!important}'
Line 501:                )
Line 502:        );

Well that’s not good, at the end of my body was a script block for bootstrap that was causing some issues. It was injecting some CSS using javascript and the @ symbol was being interpreted as an opening code block and then would error out because what it found after that was not valid code. This made sense, but was the solution? My first instinct was to escape it somehow, so I played with putting a backslash and then a double backslash in front of it, but that didn’t work. So I then went and researched what the escape character was, and found that there wasn’t a clear answer to this.

I found many posts on Stack Overflow and various other blocks and forums. Here’s a list of some of the suggestions I found:

@@
@:
@(“@”)
@Html.Raw(‘@’)

Those were just the more succinct options. Many people suggestion wrapping the whole script block inside of a razor code block and spitting it back out as just text. I really wasn’t sure which was the best option so I tried the @ option and found it did work for me, but if for some reason it doesn’t work for you try one of the others! Here’s what my code looked like in the end:

Line 498:        msViewportStyle.appendChild(
Line 499:                document.createTextNode(
Line 500:                        '@@-ms-viewport{width:auto!important}'
Line 501:                )
Line 502:        );

Tags: , ,

  • Del.icio.us
  • StumbleUpon
  • Reddit
  • Twitter
  • RSS
read comments
 Page 1 of 71  1  2  3  4  5 » ...  Last »