3,245
社区成员
发帖
与我相关
我的任务
分享
SPFile file = workflowProperties.Item.File;
if (file == null)
return;
// Get the binary data of the file
byte[] xmlFormData = null;
xmlFormData = file.OpenBinary();
// Load the data into an XPathDocument object
XPathDocument ipForm = null;
if (xmlFormData != null)
{
using (MemoryStream ms = new MemoryStream(xmlFormData))
{
ipForm = new XPathDocument(ms);
ms.Close();
}
}
if (ipForm == null)
return;
// Create an XPathNavigator object to navigate the XML
XPathNavigator ipFormNav = ipForm.CreateNavigator();
ipFormNav.MoveToFollowing(XPathNodeType.Element);
XmlNamespaceManager nsManager =
new XmlNamespaceManager(new NameTable());
foreach (KeyValuePair<string, string> ns
in ipFormNav.GetNamespacesInScope(XmlNamespaceScope.All))
{
if (ns.Key == String.Empty)
{
nsManager.AddNamespace("def", ns.Value);
}
else
{
nsManager.AddNamespace(ns.Key, ns.Value);
}
}
// Retrieve the value of the field in the InfoPath form
XPathNavigator nodeNav = ipFormNav.SelectSingleNode(
"//my:field1", nsManager);
string ipFieldValue = string.Empty;
if (nodeNav != null)
{
ipFieldValue = nodeNav.Value;
// Add an item to a list and use the value of the field
// as the title for the new item
if (!String.IsNullOrEmpty(ipFieldValue))
{
using (SPSite site = new SPSite(workflowProperties.SiteId))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.GetList("/Lists/Fruits");
if (list != null)
{
SPListItem item = list.Items.Add();
item["Title"] = ipFieldValue;
item.Update();
}
web.Close();
}
site.Close();
}
}
}
(1)SPListItem mylistitem = mysite.RootWeb.GetListItem(fileurl); 抛异常 null
(2)SPWorkflowAssociation mywfass = mylist.WorkflowAssociations.GetAssociationByName("Review", System.Globalization.CultureInfo.CurrentCulture);这里的Review是指什么?





