在Workflow 中读取提交的申请单的内容

22 篇文章 0 订阅
10 篇文章 0 订阅

可以通过提升申请单的field,然后通过操作SPListItem来操作字段 (workflowProperties.Item 为对应的 SPListItem)

 

也可以通过直接读取源xml文件来处理.

http://topic.csdn.net/u/20090904/16/2ca275ec-cbe7-4a8c-88d0-d2f7d54f05a1.html

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();
}
}
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值