MOS2010中集成Infopath表单点滴

简介: 表单发布 表单发布后,会产生一个Feature在系统的TEMPLATESFEATURES目录下,FT开头 What Happens When a Form Is Uploaded? When a form is uploaded, it generates a feature for your SharePoint farm.

表单发布

表单发布后,会产生一个Feature在系统的TEMPLATESFEATURES目录下,FT开头

What Happens When a Form Is Uploaded?

When a form is uploaded, it generates a feature for your SharePoint farm. The feature

files are generated in the SharePoint 14 hive under TEMPLATESFEATURES. The feature folder is prefixed with FT for form-template.

The feature is deployed globally to your site collections and can be activated just like

any other feature. The form feature appears in the Site Collection Features list,

What Happens When a Form Is Activated to a Site Collection?

表单Feature激活到站点后,作为一个站点的Content Type使用

When a form is activated to a site collection, the site collection feature for the form

is activated, as shown in Figure 19.11. The form is now available as a content type in

your form library.

 

XSN结构

  • Infopath设计模式下打开XSN文件,从菜单File Save as Source Files,XSN中内容就会保存在一个目录下
  • 或者使用Winzip,winrar打开xsn文件,可以看到里面的内容

manifest.xsf,就是表单的主要文件

表单重新打包

偶尔使用这个功能,在设计工具产生的表单包含了不必要的内容时,或者想知道其细节时使用,两个方法

  • 使用文件的关联使用Infopath打开manifest.xsf 然后另存为XSN
  • 使用makecab tool【C:\WINDOWS\system directory】使用类似如下的cab定义文件

; directives for <YourFormTemplate>.xsn

.Set CabinetNameTemplate=<FormName>.xsn

;** These files will be stored in cabinet files

.Set Cabinet=on

.Set Compress=off

manifest.xsf

myschema.xsd

sampledata.xml

template.xml

view1.xsl

Invoice.xsd

; Replace this line with other files that should be included in the xsn

; end of directives

运行makecab /f settings.txt 就可以生成xsn文件

表单中的代码

由于表单本身是xml文件的,因此可以使用xml的技术访问表单内容,详细参考infopath sdk,例子如下

XPathNavigator formData = this.CreateNavigator();

XPathNavigator expenseGroup = formData

.SelectSingleNode("/my:SPWFiAExpenseReport/my:Expenses",

NamespaceManager);

XPathNodeIterator expenses = expenseGroup.SelectDescendants(

"Expense",

expenseGroup.NamespaceURI,

false);

double total = 0;

foreach (XPathNavigator expense in expenses)

{

string value = expense.SelectSingleNode(

"my:Amount", NamespaceManager).Value;

double amount = double.Parse(value);

total += amount;

}

formData.SelectSingleNode(

"/my:SPWFiAExpenseReport/my:TotalAmount", NamespaceManager)

.SetValue(total.ToString());

 

工作流或事件中处理表单

使用如下的命令可以生成表单的强类型定义

xsd myschema.xsd /c /l:cs /namespace:demo

然后再工作流或者事件中可以使用这个强类型处理表单文件,如

SPFile file = onWorkflowActivated1.WorkflowProperties.Item.File;

XmlTextReader reader = new XmlTextReader(file.OpenBinaryStream());

XmlSerializer serializer = new XmlSerializer(

typeof(SPWFiAExpenseReport));

SPWFiAExpenseReport fields = (SPWFiAExpenseReport)serializer

.Deserialize(reader);

double total = 0;

foreach (Expense expense in fields.Expenses)

{

total += expense.Amount;

}

file.Item["Total Again"] = total;

file.Item.Update();

相关文章
|
23天前
|
NoSQL Java Redis
SpringBoot集成Redis解决表单重复提交接口幂等(亲测可用)
SpringBoot集成Redis解决表单重复提交接口幂等(亲测可用)
246 0
|
16天前
|
消息中间件 Java Kafka
Springboot集成高低版本kafka
Springboot集成高低版本kafka
|
28天前
|
NoSQL Java Redis
SpringBoot集成Redis
SpringBoot集成Redis
393 0
|
1月前
|
NoSQL Java Redis
小白版的springboot中集成mqtt服务(超级无敌详细),实现不了掐我头!!!
小白版的springboot中集成mqtt服务(超级无敌详细),实现不了掐我头!!!
263 1
|
1月前
|
XML Java 关系型数据库
【SpringBoot系列】SpringBoot集成Fast Mybatis
【SpringBoot系列】SpringBoot集成Fast Mybatis
|
2月前
|
Java
【极问系列】springBoot集成elasticsearch出现Unable to parse response body for Response
【极问系列】springBoot集成elasticsearch出现Unable to parse response body for Response
|
2天前
|
Java 关系型数据库 数据库
【SpringBoot系列】微服务集成Flyway
【4月更文挑战第7天】SpringBoot微服务集成Flyway
【SpringBoot系列】微服务集成Flyway
|
16天前
|
SQL Java 调度
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
SpringBoot集成quartz定时任务trigger_state状态ERROR解决办法
|
24天前
|
NoSQL Java Redis
SpringBoot集成Redis
SpringBoot集成Redis
53 1
|
27天前
|
Java 测试技术 Maven
SpringBoot集成Elasticsearch
SpringBoot集成Elasticsearch
23 0

热门文章

最新文章