0

ライブラリ MPXJ を使用してリソースをタスクおよびサブタスクに割り当てようとすると問題が発生します。実際、リソースをサブタスクに割り当てると、すべてのタスクの期間が変更され、その理由がわかりません。リソースを割り当てない場合、期間は適切に設定されます (サブタスクごとに 4 日間) が、割り当てると 0 になります。

誰かが理由を理解するのを手伝ってくれますか? ここにVB.netのコードがあります.c#で試してみましたが、同じ問題があります:

    Dim xmlwriter As New MSPDIWriter
    Dim projectfile As New ProjectFile
    Dim personcount = 1
    Dim pre As Task = Nothing

    'Filling file file with some dummy data
    For i As Integer = 1 To 10

        Dim task As Task = projectfile.addTask
        task.setName("Example Task" & i)
        Dim presub As Task = Nothing

        'Add some subtasks
        For j As Integer = 1 To 10

            Dim subtask As Task = task.addTask()
            subtask.setName("Sub Task" & j)

            'Set the subtasks duration = ' hours for every sub task
            subtask.setDuration(Duration.getInstance(4, TimeUnit.DAYS))


            'add Resources to the subtask = one resource for every task ^^
            ' 1) add resource to the general projectfile
            Dim res As Resource = projectfile.addResource()
            res.setName("person" & personcount)
            personcount += 1

            'Asociate the resource with the courent task
            Dim assgmnt As ResourceAssignment = subtask.addResourceAssignment(res)


            'Concatenate the subtasks, so that one subtask is performed after
            'another in the timeline
            'The first task has no predecessor
            If j = 1 Then
                presub = subtask
            Else
                subtask.addPredecessor(presub, RelationType.FINISH_START, Duration.getInstance(0, TimeUnit.DAYS))
                presub = subtask

            End If
            'presub.setDuration(Duration.getInstance(4, TimeUnit.DAYS))
        Next

        'Concatenate the tasks, son that one main task is performed after
        'another on the timeline
        'The first task has no predecessor,
        If i = 1 Then
            'set the start date of the project
            Dim rightnow As java.util.Calendar = java.util.Calendar.getInstance()
            rightnow.set(2014, 11, 1)
            task.setStart(rightnow.getTime())
            pre = task
        Else
            task.addPredecessor(pre, RelationType.FINISH_START, Duration.getInstance(0, TimeUnit.DAYS))
            pre = task
        End If

    Next

    'Writng the project file

    xmlwriter.write(projectfile, "C:\temp\exo.xml")

ありがとう!

4

1 に答える 1