Quantcast
Channel: Project Customization and Programming forum
Viewing all articles
Browse latest Browse all 5347

Question on PSI: Setting Constraint Type

$
0
0
 

In our current project, we are using the PSI to copy multiple tasks from one section of the project and paste at the end in order to create new set of tasks within the project. Below is the code snippet from our solution. We, first, create a new task object. And then we unto newly created blank task, we copy the task from the source task (from another section of the project). Then, we assign new task ID GUID. Everything gets copied correctly when comparing the original task and newly created task. One property we have question is Task_Contraint_Type. The source task’s Task_Contraint_Type is “As soon as possible” and when we make the copy (as in the code below and upon saving the project data back to Project Server and publish/check-in the project, when we open the project, the newly created task’s constraint type is “This task has a ‘Start No Earlier Than’ constraint on Date” (See image below). We expected “As soon as possible” because the source task was “As soon as possible” However, this was not the case.

As a result, we modified the code (see bold) so that during the copy/create new task, we set Task_Constaint_Type to “As soon as possible”. However, this still resulted, again, in “This task has a ‘Start No Earlier’…” constraint. The workaround for now was after we finish copy all tasks, we then grab the dataset again and then update all tasks once again to set the Task_Constraint_Type to “As soon as possible”. However, this results in doing the work twice and can be potential performance hit as we noticed that calling “QueueAddToProject” took a lot of time as project gets fairly large (we create project of size 25k tasks). Do you know why setting Task_Constaint_Type  duing the initial task creation yields different value?

// Create a new task object
Project.ProjectDataSet.TaskRow newTask = _tasksDataset.Task.NewTaskRow();

// Copy data from the source task to newly created task
newTask.ItemArray = _tasksDataset.Task[i].ItemArray.Clone() as object[];

// Make a new GUID to be the new task's GUID
Guid taskId = Guid.NewGuid();

// Assign differentiating properties to the new task
newTask.PROJ_UID = _projectUid;
newTask.TASK_UID = taskId;
newTask.TASK_DUR = (int)PSLibrary.Task.DurationFormat.Day;
newTask.TASK_CONSTRAINT_TYPE = 0;                                 // 0 = As soon as possible
newTask.StatusManager = _projectOwnerUid;


Viewing all articles
Browse latest Browse all 5347

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>