65.9K
CodeProject 正在变化。 阅读更多。
Home

自动化 Office InfoPath 表单模板的部署

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0投票)

2007 年 4 月 20 日

1分钟阅读

viewsIcon

45034

downloadIcon

382

此工具将先前发布的 InfoPath 表单模板移动到新的位置。

引言

您是否有多个 InfoPath 表单并部署到一个位置(服务器)?您想将它们移动到另一个位置吗?这很麻烦,不是吗?这里有一个工具可以将 InfoPath 表单部署到任何其他网络位置。

Screenshot - forms_publishing_tool.jpg

背景

我知道,有些人可能会想为什么我们需要多个表单;不能在一个表单中使用多个视图并将其部署到服务器吗?这里是我们遇到的问题,多个视图共享同一个数据源。如果您有一个被多个视图共享的数据字段,并且每个视图以不同的方式使用该字段,如果一个视图更改了字段值,其他视图也会受到影响。因此,我们决定为每个视图使用不同的表单。接下来的繁琐工作就是部署它们。特别是当您有多个环境,如开发、QA 和生产环境时,手动发布到每个环境非常困难。我在 Microsoft 网站上找到了一篇文章,用于自动化表单发布。不幸的是,代码是用 Jscript 编写的,然后我决定开发一个工具。

使用代码

Sub FixupXSN(ByVal xsnInputPath As String, ByVal xsnOutputPath As String, ByVal publishUrl As String)

Try

If Not File.Exists(xsnInputPath) Then

MessageBox.Show("File does not exist: " + xsnInputPath)

Exit Sub

End If

' Create temporary folder and explode the XSN

'Dim tempFolderPath = Directory.CreateDirectory(PathCombine(Path.GetTempPath, Path.GetTempFileName)).FullName

Dim tempFolderPath = PathCombine(Path.GetTempPath, Path.GetFileNameWithoutExtension(Path.GetTempFileName))

tempFolderPath = Directory.CreateDirectory(tempFolderPath).FullName

ExtractFilesFromXSN(xsnInputPath, tempFolderPath)

' Modify the XSF in place 

Dim xsfPath As String = PathCombine(tempFolderPath, "manifest.xsf")

Dim hsAttributesAndValues As New Hashtable

hsAttributesAndValues.Add("publishUrl", publishUrl)

hsAttributesAndValues.Add("publishSaveUrl", xsnOutputPath)

' Generate the new XSN

CreateXSNFromFiles(tempFolderPath, "manifest.xsf", xsnOutputPath)

' Cleanup

'File.Delete(tempFolderPath)

Catch ex As Exception

ShowMessage(ex.Message)

Trace(ex.StackTrace)

End Try

End Sub

关注点

我在这个开发过程中学习了如何使用 CABSDK 工具。

参考文献

http://msdn2.microsoft.com/en-us/library/aa192521(office.11).aspx

历史

2007/4/20 创建。

© . All rights reserved.