使用SharePoint web服务获取工作流状态



我需要一些帮助,也许有人面临类似的任务。我想找到使用SharePoint 2010 web服务状态为"发生错误"的所有工作流。我想知道这个任务可行吗?谢谢。

使用CAML可以使用web服务进行查询。

使用方法getlisttitems和CAML查询与WorkflowStatus = 3(错误发生)。

public XmlNode _nodes;
string _ListID = "";
string _ViewID = "";
XmlDocumento _xmlDoc = new System.Xml.XmlDocument();
XmlElement _query = _xmlDoc.CreateElement("Query");
XmlElement _queryOptions = _xmlDoc.CreateElement("QueryOptions");
XmlElement _viewFields = _xmlDoc.CreateElement("ViewFields");
_query.InnerXML = @"
   <Where>
     <Eq>
       <FieldRef Name='WorkflowNameColumn' />
       <Value Type='WorkflowStatus'>3</Value>
     </Eq>
   </Where>";
_queryOptions.InnerXml = "<QueryOptions>   <IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns></QueryOptions>";
_viewFields.InnerXml = "";
// SharepointListWS is the name i use in Web References
SharepointListsWS.Lists _lst = new SharepointListsWS.Lists();
_nodes = _lst.GetListItems(_listID, _ViewID, _query, _viewFields, "300", _queryOptions, null);
foreach (XmlNode node in _nodes) {
  if (node.Name.ToLower() == "rs:data") {
    for (int i = 0; i < node.ChildNodes.Count; i++) {
      if (node.ChildNodes[i].Name.ToLower() == "z:row") {
        // you can debug here
        XmlNode AllNodes = node.ChildNodes[i];
        // Find at Attributes
        for (int a = 0;a < AllNodes.Attributes.Count; a++) {
           string field = AllNodes.Attributes[a].Value.Trim();
           string name = AllNodes.Attributes[a].Name;
           string colName = XmlConvert.DecodeName(name).ToLower().Replace("ows_", "");
        }
      }
    }
  }
}

状态列表可在此处找到

最新更新