惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
WordPress大学
WordPress大学
Help Net Security
Help Net Security
Jina AI
Jina AI
Security Latest
Security Latest
Y
Y Combinator Blog
Project Zero
Project Zero
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
Know Your Adversary
Know Your Adversary
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
NISL@THU
NISL@THU
Cisco Talos Blog
Cisco Talos Blog
博客园 - 司徒正美
MyScale Blog
MyScale Blog
Cyberwarzone
Cyberwarzone
D
Docker
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
C
CERT Recently Published Vulnerability Notes
B
Blog
L
LangChain Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
SecWiki News
SecWiki News
The Hacker News
The Hacker News
C
Check Point Blog
L
Lohrmann on Cybersecurity
V2EX - 技术
V2EX - 技术
S
Securelist
T
Threat Research - Cisco Blogs
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
Latest news
Latest news
人人都是产品经理
人人都是产品经理
L
LINUX DO - 最新话题
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Register - Security
The Register - Security
Webroot Blog
Webroot Blog
Simon Willison's Weblog
Simon Willison's Weblog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Microsoft Security Blog
Microsoft Security Blog
AWS News Blog
AWS News Blog
C
Cybersecurity and Infrastructure Security Agency CISA
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
小众软件
小众软件
T
Tailwind CSS Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
宝玉的分享
宝玉的分享
O
OpenAI News

博客园 - Ken Lin

Oracle VS Sql Server Asp.net常用的一些代码(转) - Ken Lin - 博客园 Sharepoint工作流任务权限问题 MOSS开发Tips WSS 扩展文件夹属性-应用场景一 内容查询Web 部件定制 How to submit data in InfoPath form services Form Services方式发布带有Managed Code的表单模板 WSS 代码执行的权限提升 STSADM 进行MOSS的备份与迁移 利用SharePoint Designer更改任务列表状态栏显示 MOSS 工作流(二)自定义开发 MOSS-自定义字段类型 通过Web Part Connection 在Web Part 之间传递数据(二) 通过Web Part Connection 在Web Part 之间传递数据(一) WebPart 生存周期 QuickPart中文字符显示问题 MOSS SP1 解决Ajax Extension 对Webpart的兼容性问题 MOSS 工作流(一)
用代码访问InfoPath表单内容
Ken Lin · 2008-05-08 · via 博客园 - Ken Lin

表单是MOSS的一个很重要的特性,特别是有了Form Services的支持后,我们在做表单解决方案的时候,经常会用到Infopath, 那么如何使用代码访问保存于SharePoint表单库中的InfoPath表单的内容,是必需知道的。
总结了下,有如下3种方式可实现代码对表单内容的访问:
1. 提升表单模板属性
2. 通过XmlDocument 对象对表单文件操作
3. 反序列化表单数据架构

接下来,分别简单谈谈这3种方法的简单实现步骤第一种方式: 提升表单模板属性表单操作:
在设计完表单模板,执行发布向导的过程中,发布希望通过代码访问的表单字段,且勾允许用户编辑

访问代码:
首先是获取当前List Item ,SPListItem item=infopath项,如
SPListItem item= workflowProperties.
Item;
 item ["WorkflowStatus"] = value; 
item.Update();

这种方式很简单,但是由于允许用户编辑,安全性不好。对一些敏感的数据,不建议用这方法。第二种方式: 通过XmlDocument 对象对表单文件操作Infopath 是以xml格式保存数据的,因此我们可以通过XML接口访问表单数据

SPFile myfile = item.File;
Stream stream = new MemoryStream(myfile.OpenBinary());
XmlTextReader reader = new XmlTextReader(stream);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(reader);

接下来就可以对xml进行分析了。

第三种方式: 反序列化表单数据架构

Infopath 表单模板文件.xsn 是一个压缩包,文件解压开后,里面有个描述表单数据架构的.xsd文件,然后通过.Net Framework的xsd.exe命令行工具,通过这个.xsd文件得到一个proxy类,然后在项目中使用这个类

比如在一个工作流的初始化窗体Init.xsn

/反序列化workflowProperties.InitiationData以得到初始窗体的实例
XmlSerializer xs = new XmlSerializer(typeof(Init));

XmlTextReader xtr = new XmlTextReader(new System.IO.StringReader(workflowProperties.InitiationData));

Init init = (Init)xs.Deserialize(xtr);

//InfoPath表单的内容反序列化成了一个对象init,然后直接访问这个对象的属性就行了
String s=init.comments;