Create New Project From Template (2007)
Finally code samples for Project Server 2007 J.
When you are integrating an application to Project Server its common to create new projects on Project Server. These projects correspond to some process in your application. This could be from provisioning a new network tap to constructing a building. There are always certain commonalities within the project. To take advantage of this you want to create your new project based on a template.
The following procedure is where we start
private Guid CallCreateProject(string projectName)
Guid templateUid = GetProjectTemplateGUID("InstallNetworkTap”);
Guid newProject = myProject.CreateProjectFromTemplate(templateUid, projectName);
// Change some data in the new project
templateProject = myProject.ReadProject(newProject);
string startDate = DateTime.Now.ToString("yyyyMMdd");
ProjectDataSet.ProjectRow projectRow = (ProjectDataSet.ProjectRow)templateProject.Project.Rows;
projectRow.PROJ_INFO_START_DATE = DateTime.Now;
Guid jobGuid = Guid.NewGuid();
Guid sessionGuid = Guid.NewGuid();
myProject.QueueUpdateProject(jobGuid, sessionGuid, templateProject, false);
I left the extra code in there to change the start date as some more code for the reader to play with. When using the PDS in Project Server 2003 you provided the template name and new project name. With PSI in Project Server 2007 its similar, with the big difference being GUIDs. All entities within Project Server are uniquely identified by GUID, which also includes the template. So this brings us to the hole in the code above GetProjectTemplateGUID. That is actually a call I made up, with the code for it below.
private Guid GetProjectTemplateGUID(string templateName)
Guid tempateGuid = Guid.NewGuid();
ProjectWS.ProjectDataSet myProjectList = myProject.ReadProjectList();
foreach (DataRow row in myProjectList.Project)
if ((string)row["PROJ_NAME"] == templateName)
tempateGuid = (Guid)row["PROJ_UID"];