We are currently in the early stages of planning the next version of Project. To help plan out the work, we are using Project 2007. To begin, we needed to create a number of projects in bulk and decided to use the PSI to help out with the process. We already had the name for all the projects and the PMs who would be the owners. So, I created an application that read from a text file and set the PM as the project owner and some custom fields to be able to identify the projects.
It was important to set the project owner so that PM can easily access and manipulate the project plan created by the application. This is a fairly easy task when working with the project dataset. To set the project owner, set ProjectOwnerID to the GUID of the resource. The following method may help to look up the resource GUID:
private Guid GetResourceGuid(string ls_name)
WSResource.Resource lo_resWS =
WSResource.ResourceDataSet lo_resDS = new WSResource.ResourceDataSet();
string nameColumn = lo_resDS.Resources.RES_NAMEColumn.ColumnName;
string resUID = lo_resDS.Resources.RES_UIDColumn.ColumnName;
PSLibrary.Filter.FieldOperationType equal =
PSLibrary.Filter lo_filter = new PSLibrary.Filter();
lo_filter.FilterTableName = lo_resDS.Resources.TableName;
lo_filter.Criteria = new PSLibrary.Filter.FieldOperator(equal, nameColumn, ls_name);
lo_resDS = lo_resWS.ReadResources(lo_filter.GetXml(), false);
Acourse, I knew all the PMs were resources on the Project Server instance and did not trap for errors for trying to access the dataset if no rows existed. If you use this method in general, you should put a try catch around:
This method also uses the connection object that I described in an early post for connecting to the PSI.