通过 C# 的 MPXJ 读取 P6 Activity ID(.xer 和 xml)

Reading P6 Activity ID (.xer and xml) via MPXJ for C#

MPXJ Version:5.1.17

Q1:如果我将 p6 文件导出为 .xer 。当我使用 MPXJ 读取文件时,我在 c# 中得到乱码。(它原本是中文文本),但是如果我将 p6 文件导出为 XML 格式,我可以在 c# 中使用 MPXJ 获得正确的中文文本。有人有过这样的经历吗?

Q2:如何使用 MPXJ 获取 P6 Activity ID? Task.ID 的 return 类型是 Integer.. 但 P6 中的 ID 是字符串。 当我打电话给 MPXJ 时,我得到了

ID:6 // 在XML中是"A1010",如何得到"A1010"?

样本XML片段

<Activity>
        <ActualDuration>0</ActualDuration>
        <ActualFinishDate xsi:nil="true" />
        <ActualLaborCost>0</ActualLaborCost>
        <ActualLaborUnits>0</ActualLaborUnits>
        <ActualNonLaborCost>0</ActualNonLaborCost>
        <ActualNonLaborUnits>0</ActualNonLaborUnits>
        <ActualStartDate xsi:nil="true" />
        <ActualThisPeriodLaborCost>0</ActualThisPeriodLaborCost>
        <ActualThisPeriodLaborUnits>0</ActualThisPeriodLaborUnits>
        <ActualThisPeriodNonLaborCost>0</ActualThisPeriodNonLaborCost>
        <ActualThisPeriodNonLaborUnits>0</ActualThisPeriodNonLaborUnits>
        <AtCompletionDuration>8</AtCompletionDuration>
        <AtCompletionExpenseCost>0</AtCompletionExpenseCost>
        <AtCompletionLaborCost>0</AtCompletionLaborCost>
        <AtCompletionLaborUnits>0</AtCompletionLaborUnits>
        <AtCompletionNonLaborCost>0</AtCompletionNonLaborCost>
        <AtCompletionNonLaborUnits>0</AtCompletionNonLaborUnits>
        <AutoComputeActuals>0</AutoComputeActuals>
        <CalendarObjectId>178</CalendarObjectId>
        <DurationPercentComplete>0</DurationPercentComplete>
        <DurationType>Fixed Duration and Units</DurationType>
        <ExpectedFinishDate xsi:nil="true" />
        <ExternalEarlyStartDate xsi:nil="true" />
        <ExternalLateFinishDate xsi:nil="true" />
        <Feedback />
        <FinishDate>2016-01-18T16:00:00</FinishDate>
        <GUID>{255EF498-16AB-5041-B86B-F6F027FB3DF0}</GUID>
        <Id>A1010</Id>
        <IsNewFeedback>0</IsNewFeedback>
        <LevelingPriority>Normal</LevelingPriority>
        <Name>使用教學語系整合</Name>
        <NonLaborUnitsPercentComplete>0</NonLaborUnitsPercentComplete>
        <NotesToResources />
        <ObjectId>101718</ObjectId>
        <PercentComplete>0</PercentComplete>
        <PercentCompleteType>Duration</PercentCompleteType>
        <PhysicalPercentComplete>0</PhysicalPercentComplete>
        <PlannedDuration>8</PlannedDuration>
        <PlannedFinishDate>2016-01-18T16:00:00</PlannedFinishDate>
        <PlannedLaborCost>0</PlannedLaborCost>
        <PlannedLaborUnits>0</PlannedLaborUnits>
        <PlannedNonLaborCost>0</PlannedNonLaborCost>
        <PlannedNonLaborUnits>0</PlannedNonLaborUnits>
        <PlannedStartDate>2016-01-18T08:00:00</PlannedStartDate>
        <PrimaryConstraintDate xsi:nil="true" />
        <PrimaryConstraintType />
        <PrimaryResourceObjectId xsi:nil="true" />
        <ProjectObjectId>4508</ProjectObjectId>
        <RemainingDuration>8</RemainingDuration>
        <RemainingEarlyFinishDate>2016-01-18T16:00:00</RemainingEarlyFinishDate>
        <RemainingEarlyStartDate>2016-01-18T08:00:00</RemainingEarlyStartDate>
        <RemainingLaborCost>0</RemainingLaborCost>
        <RemainingLaborUnits>0</RemainingLaborUnits>
        <RemainingLateFinishDate xsi:nil="true" />
        <RemainingLateStartDate xsi:nil="true" />
        <RemainingNonLaborCost>0</RemainingNonLaborCost>
        <RemainingNonLaborUnits>0</RemainingNonLaborUnits>
        <ResumeDate xsi:nil="true" />
        <ReviewStatus>OK</ReviewStatus>
        <SecondaryConstraintDate xsi:nil="true" />
        <SecondaryConstraintType />
        <StartDate>2016-01-18T08:00:00</StartDate>
        <Status>Not Started</Status>
        <SuspendDate xsi:nil="true" />
        <Type>Task Dependent</Type>
        <UnitsPercentComplete>0</UnitsPercentComplete>
        <WBSObjectId>26012</WBSObjectId>
    </Activity>

请参阅我上面关于报告读取任务名称错误的评论。要回答你的第二个问题,Activity ID 被映射到任务的 Text1 属性中:task.getText(1) 应该可以得到你想要的。