简体   繁体   English

使用 mpxj 从 mpp 文件中读取任务企业自定义字段值

[英]Reading task enterprise custom field values from mpp file using mpxj

I'm trying to read task details from a mpp file using net.sf.mpxj library.我正在尝试使用 net.sf.mpxj 库从 mpp 文件中读取任务详细信息。 However, when trying to read custom fields, I get a byte array which I do not know what to do with.但是,当尝试读取自定义字段时,我得到了一个我不知道如何处理的字节数组。 It is not the exact value of the custom field from that specific task?这不是该特定任务的自定义字段的确切值吗? Can anyone tell me what to do?谁能告诉我该怎么做?

ProjectReader reader = new MPPReader();
ProjectFile project = reader.read(@"C:\EPM\test2.mpp");
foreach (net.sf.mpxj.Task task in project.Tasks)
{
       var Value = task.GetFieldByAlias("My Custom Field Name");
}

The "Value" will be a byte array and I do not know how to get the real value from it. “值”将是一个字节数组,我不知道如何从中获取实际值。

UPDATED ANSWER: As of MPXJ 10.7.0 you can retrieve correctly typed values for enterprise custom fields.更新的答案:从 MPXJ 10.7.0 开始,您可以检索正确键入的企业自定义字段值。 You'll also find a CustomFieldDataType attribute as part of the CustomField class which indicates what type you'll be retrieving.您还可以在CustomField class 中找到一个CustomFieldDataType属性,该属性指示您将检索的类型。

(One interesting "gotcha" is that if your MPP file contains an enterprise custom field which is based on a lookup table, ie the user can only select from a fixed set of values, the user-visible text is NOT stored in the MPP file. You'll only get back a GUID representing the value the user has selected. Microsoft Project itself has this same issue... if you open the MPP file when you're not connected to Project Server, these values will appears as blanks...) (一个有趣的“陷阱”是,如果您的 MPP 文件包含基于查找表的企业自定义字段,即用户只能从一组固定值中获取 select,则用户可见文本不会存储在 MPP 文件中。您只会得到一个代表用户选择的值的 GUID。Microsoft Project 本身也有同样的问题...如果您在未连接到 Project Server 时打开 MPP 文件,这些值将显示为空白。 ..)

ORIGINAL ANSWER: The main problem is unfortunately that MPXJ doesn't currently offer the same level of support for Enterprise Custom Fields as it does for other fields.原始答案:不幸的是,主要问题是 MPXJ 目前没有为企业自定义字段提供与其他字段相同级别的支持。 While it is able to identify Enterprise Custom Fields and the aliases they've been given, at the moment it is only able to read the raw bytes representing the field data.虽然它能够识别企业自定义字段和给定的别名,但目前它只能读取表示字段数据的原始字节。

Enterprise Custom Fields are not as commonly used as other field types so there hasn't been as much time invested in locating the definitions of these fields in the MPP file.企业自定义字段不像其他字段类型那样常用,因此没有花费太多时间在 MPP 文件中查找这些字段的定义。 The field definition will contain the type information necessary to convert from the raw bytes to the expected data type.字段定义将包含从原始字节转换为预期数据类型所需的类型信息。

Improved support for Enterprise Custom Fields is on the "to do" list for MPXJ.对企业自定义字段的改进支持位于 MPXJ 的“待办事项”列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM