Using PSI Filter objects from Python
I'm working with SharePoint and ProjectServer 2007 via PSI with Python.
I can't find any documentation on how Filter Class (Microsoft.开发者_JAVA百科Office.Project.Server.Library) objects work internally to emulate its behaviour in Python.
Any ideas?
Take a look at Colby Africa's blog post. Also, msdn docs are here.
Edit
The generated filter is just XML. Here is a filter that returns the data from the "LookupTables" table (list of all the lookup tables):
<?xml version="1.0" encoding="utf-16"?>
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" filterTableName="LookupTables" xmlns="http://microsoft.com/ProjectServer/FilterSchema.xsd">
<Fields>
<Field tableName="" fieldName="LT_UID" />
<Field tableName="" fieldName="LT_NAME" />
<Field tableName="" fieldName="LT_SORT_ORDER_ENUM" />
<Field tableName="" fieldName="LT_PRIMARY_LCID" />
<Field tableName="" fieldName="LT_FILL_ALL_LEVELS" />
<Field tableName="" fieldName="LT_CHECKOUTBY" />
<Field tableName="" fieldName="LT_CHECKOUTDATE" />
<Field tableName="" fieldName="MOD_DATE" />
</Fields>
<Criteria />
</Filter>
Here is another example of the filters required for getting all the data for one table...
Step 1: Get the row for the LookupTable (general table info)
<?xml version="1.0" encoding="utf-16"?>
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" filterTableName="LookupTables" xmlns="http://microsoft.com/ProjectServer/FilterSchema.xsd">
<Fields>
<Field tableName="" fieldName="LT_UID" />
<Field tableName="" fieldName="LT_NAME" />
<Field tableName="" fieldName="LT_SORT_ORDER_ENUM" />
<Field tableName="" fieldName="LT_PRIMARY_LCID" />
<Field tableName="" fieldName="LT_FILL_ALL_LEVELS" />
<Field tableName="" fieldName="LT_CHECKOUTBY" />
<Field tableName="" fieldName="LT_CHECKOUTDATE" />
<Field tableName="" fieldName="MOD_DATE" />
</Fields>
<Criteria>
<FieldOperator fieldOperationType="Equal">
<Field fieldName="LT_UID" />
<Operand xmlns:q1="http://microsoft.com/wsdl/types/" xsi:type="q1:guid">20870732-12b6-48e2-acf4-94d934dfc27a</Operand>
</FieldOperator>
</Criteria>
</Filter>
Step 2: Get all the data from the LookupTableStructures table (hierarchy info)
<?xml version="1.0" encoding="utf-16"?>
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" filterTableName="LookupTableStructures" xmlns="http://microsoft.com/ProjectServer/FilterSchema.xsd">
<Fields>
<Field tableName="" fieldName="LT_STRUCT_UID" />
<Field tableName="" fieldName="LT_UID" />
<Field tableName="" fieldName="LT_PARENT_STRUCT_UID" />
<Field tableName="" fieldName="LT_STRUCT_COOKIE" />
</Fields>
<Criteria>
<FieldOperator fieldOperationType="Equal">
<Field fieldName="LT_UID" />
<Operand xmlns:q1="http://microsoft.com/wsdl/types/" xsi:type="q1:guid">20870732-12b6-48e2-acf4-94d934dfc27a</Operand>
</FieldOperator>
</Criteria>
</Filter>
Step 3: Get all of the values in this lookup table
<?xml version="1.0" encoding="utf-16"?>
<Filter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" filterTableName="LookupTableValues" xmlns="http://microsoft.com/ProjectServer/FilterSchema.xsd">
<Fields>
<Field tableName="" fieldName="LT_STRUCT_UID" />
<Field tableName="" fieldName="LCID" />
<Field tableName="" fieldName="LT_UID" />
<Field tableName="" fieldName="LT_VALUE_DUR" />
<Field tableName="" fieldName="LT_VALUE_NUM" />
<Field tableName="" fieldName="LT_VALUE_DUR_FMT" />
<Field tableName="" fieldName="LT_VALUE_DATE" />
<Field tableName="" fieldName="LT_VALUE_TEXT" />
<Field tableName="" fieldName="LT_VALUE_PHONETIC" />
<Field tableName="" fieldName="LT_VALUE_FULL" />
<Field tableName="" fieldName="LT_VALUE_DESC" />
<Field tableName="" fieldName="LT_VALUE_SORT_INDEX" />
<Field tableName="" fieldName="LT_VALUE_LOCALIZED_COOKIE" />
</Fields>
<Criteria>
<FieldOperator fieldOperationType="Equal">
<Field fieldName="LT_UID" />
<Operand xmlns:q1="http://microsoft.com/wsdl/types/" xsi:type="q1:guid">20870732-12b6-48e2-acf4-94d934dfc27a</Operand>
</FieldOperator>
</Criteria>
</Filter>
It requires three separate filters to get all this data because it is split across three separate tables. In C#, I am calling the ReadLookupTablesMultiLang
function with each of these filters and then merging the returned datatables.
精彩评论