1

下面的代码使用 SP Server OM,我想知道如何使用 Client OM 检索任务扩展属性。

list = web.Lists["Tasks"];
 SPQuery tasksQuery = new SPQuery();
            tasksQuery.Query = @"<Where>
                               <Or>
                                   <Eq>
                                       <FieldRef Name='Status' /><Value Type='Choice'>In Progress</Value>
                                   </Eq>
                                   <Eq>
                                       <FieldRef Name='Status' /><Value Type='Choice'>Not Started</Value>
                                   </Eq>
                               </Or>
                           </Where>";
SPListItemCollection tasksListItemCollection =list.GetItems(tasksQuery);
foreach (SPListItem item in tasksListItemCollection)
{
    Hashtable extendedProperties = SPWorkflowTask.GetExtendedPropertiesAsHashtable(item);
}

先感谢您。

4

1 回答 1

2

中没有SPWorkflowTask.GetExtendedPropertiesAsHashtable 方法的模拟CSOM,但它可以实现(救援反射器)。

如何通过 SharePoint Managed CSOM 获取表示任务扩展属性集合的哈希表

    /// <summary>
    /// Gets a hash table that represents the task’s extended properties collection
    /// </summary>
    /// <param name="task"></param>
    /// <returns></returns>
    public static Hashtable GetExtendedPropertiesAsHashtable(ListItem task)
    {
        if (task == null)
        {
            throw new ArgumentNullException();
        }
        Hashtable properties = new Hashtable();
        string extProperties = (string)task["ExtendedProperties"];
        if (!string.IsNullOrEmpty(extProperties))
        {
            var reader = new XmlTextReader(new StringReader("<Root " + extProperties + " />"))
            {
                WhitespaceHandling = WhitespaceHandling.Significant
            };
            reader.MoveToContent();
            if (!reader.HasAttributes)
            {
                return properties;
            }
            while (reader.MoveToNextAttribute())
            {
                string propName = reader.Name.Substring(4);
                properties[propName] = reader.Value;
            }
        }
        return properties;
    }
于 2014-01-29T22:02:33.550 回答