Project Server Recycle Bin

I found it strange the Project Server does not have a recycle bin for cases of accidental deletion of a project. One of my clients also found this strange and so I setup a project recycle bin. It works fairly simply by taking advantage of the archiving system of project server. This worked pretty well except that there is no way to specify how long a project will stay in the archive. So I figured the simplest way of accomplishing this was to setup a timer job that will access all of the projects in the archive and check for the custom description set when the project is sent to the “Recycle Bin”. It would then check when the project was deleted to see if it needed to be flushed from the archive. So far so good. Project server provides a method for programmatically deleting a project from the archive. The documentation seems fairly clear, it can be found at http://msdn.microsoft.com/en-us/library/office/gg204474.aspx. So I had my timer job call this method on the projects that needed to be removed. The documentation says to call the function passing the following parameters in this order:

  1. Guid JobUID
  2. Guid ProjectUID
  3. Guid ArchiveUID

So I used the following line of code.

archiveSvc.QueueDeleteArchivedProject(JobId, project.PROJ_UID, project.PROJ_VERSION_UID);

Well when ever the job ran nothing was getting removed. I pulled my hair out trying to figure out why this wasn’t working. Then I had an epiphany, maybe the parameters are reversed. So I created a test console app where I could try changing the values around. What I found was that if I reversed that last two parameters the project gets deleted as expected. So I changed the code in my timer job to:

archiveSvc.QueueDeleteArchivedProject(JobId, project.PROJ_VERSION_UID, project.PROJ_UID);

Now everything works as expected. So what happens is that you are passing the VersionID as the project ID and the Project ID as the Archive ID. Go figure.