martes, 1 de abril de 2008

Change Project Start Date once it's created through PSI

I've seen several posts on internet of people having problems changing the project start date once the project has been created.
Here is an example of how to do it:

1. Read the project

ProjectDataSet templateProject = projWS.ReadProject(projectUID, Project.DataStoreEnum.WorkingStore);

2. create a copy to store the changes

ProjectDataSet temporal = ((Project.ProjectDataSet)(templateProject.Copy()));

3. Store the new date (fechaInicio.SelectedDate is a Daytime parameter)

temporal.Tables[temporal.Project.TableName].Rows[0][temporal.Project.PROJ_INFO_START_DATEColumn] = fechaInicio.SelectedDate;

4. Get the changes and store them in another ProjectDatatSet

ProjectDataSet updateProjectDataSet = new ProjectDataSet(); updateProjectDataSet.Project.Merge(temporal.Tables[temporal.Project.TableName], true);
updateProjectDataSet = ((Project.ProjectDataSet)updateProjectDataSet.GetChanges(DataRowState.Modified));

5. Check-in and publish the project

projWS.QueueUpdateProject(jobGuid, sessionGuid, updateProjectDataSet, false);
jobGuid = Guid.NewGuid();
projWS.QueueCheckInProject(jobGuid, newProject, true, sessionGuid,"");
WaitForQueueJobCompletion(jobGuid, 1);
jobGuid = Guid.NewGuid();
projWS.QueuePublish(jobGuid, newProject, true, "");
WaitForQueueJobCompletion(jobGuid, 1);

3 comentarios:

Anónimo dijo...

Thank you for posting such a subject,plz, can you repost the full code ?

Anónimo dijo...

:) actually it worked well, thank you for this post

Anónimo dijo...

Thank you so much. this worked like a charm. You saved me a lot of headache