Quantcast
Channel: Project Server General Questions and Answers forum
Viewing all articles
Browse latest Browse all 7942

Tasks created using PSI has incorrect duration

$
0
0

Hi,

I'm using the following code to create projects tasks within workflow using PSI. The start date and end date that I'm using to create tasks are "Start Date: 8/7/2012" and "End Date: 8/15/2012" so the duration will be 7 days but when I go to the project schedule, the end date will be "8/14/2012" which makes the duration 6 days.

What is wrong with that:

	Dim projectClient As SvcProject.ProjectClient = WorkflowHelper.PSIProxy.GetProjectClient(wfContext.Site.Url)
        Dim projectDataSet As SvcProject.ProjectDataSet = projectClient.ReadProject(projectSequence1.WorkflowContext.ProjectUid, SvcProject.DataStoreEnum.WorkingStore)
        Dim newProjectDataSet As New SvcProject.ProjectDataSet

        If projectDataSet.Task.Rows.Count = 1 AndAlso DelivrablesXML(0) IsNot Nothing AndAlso String.IsNullOrEmpty(DelivrablesXML(0).ToString()) = False Then


            Dim sessionUID As Guid = Guid.NewGuid()
            
            projectClient.CheckOutProject(projectSequence1.WorkflowContext.ProjectUid, sessionUID, "Settings Project Delivrables in session " + sessionUID.ToString())

            Dim jsSerializer As New System.Web.Script.Serialization.JavaScriptSerializer

            Dim arr As Object() = CType(jsSerializer.DeserializeObject(DelivrablesXML(0)), Object())

            If arr IsNot Nothing Then

                For Each a As Dictionary(Of String, Object) In arr

                    Dim newTask As SvcProject.ProjectDataSet.TaskRow = newProjectDataSet.Task.NewTaskRow

                    Dim startDate As Date = CDate(a("StartDate"))
                    Dim endDate As Date = CDate(a("EndDate"))

                    newTask.TASK_NAME = a("Name").ToString()
                    newTask.TASK_START_DATE = New DateTime(Year(startDate), Month(startDate), Day(startDate), 8, 0, 0)
                    newTask.TASK_FINISH_DATE = New DateTime(Year(endDate), Month(endDate), Day(endDate), 8, 0, 0)
                    newTask.TASK_DUR = 33600
                    'newTask.TASK_IS_MILESTONE = True
                    newTask.TASK_DUR_FMT = Microsoft.Office.Project.Server.Library.Task.DurationFormat.Day
                    newTask.TASK_CONSTRAINT_TYPE = CShort(Microsoft.Office.Project.Server.Library.Task.ConstraintType.AsSoonAsPossible)
                    newTask.TASK_DUR_IS_EST = True
                    newTask.TASK_LEVELING_DELAY_FMT = CShort(Microsoft.Office.Project.Server.Library.Task.DurationFormat.Day)
                    newTask.TASK_DUR_VAR = 0
                    newTask.TASK_ACT_START = CDate(a("StartDate"))
                    newTask.PROJ_UID = projectSequence1.WorkflowContext.ProjectUid
                    newTask.TASK_UID = Guid.NewGuid()

                    newProjectDataSet.Task.AddTaskRow(newTask)

                Next

                Dim updateJobUID As Guid = Guid.NewGuid()
                
                projectClient.QueueAddToProject(updateJobUID, sessionUID, newProjectDataSet, False)
                WaitForQueue(updateJobUID)
                
            End If

            Dim checkinJobUID As Guid = Guid.NewGuid()
                        
            projectClient.QueueCheckInProject(checkinJobUID, projectSequence1.WorkflowContext.ProjectUid, True, sessionUID, "Settings Project Delivrables in session " + sessionUID.ToString())
            WaitForQueue(checkinJobUID)
            

        End If


Viewing all articles
Browse latest Browse all 7942

Trending Articles



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