• 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. 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();

  • 相关阅读:
    11.14 mii-tool:管理网络接口的状态
    11.15 dmidecode:查询系统硬件信息
    11.11 ntsysv:管理开机服务
    HDU 2476 String painter 刷字符串(区间DP)
    HDU 1085 Holding Bin-Laden Captive! 活捉本拉登(普通型母函数)
    母函数的应用
    HDU 1028 Ignatius and the Princess III伊格和公主III(AC代码)母函数
    HDU 1059 Dividing 分配(多重背包,母函数)
    HDU 2955 Robberies抢劫案(01背包,变形)
    HDU 1011 Starship Troopers星河战队(树形dp)
  • 原文地址:https://www.cnblogs.com/2018/p/2368127.html
Copyright © 2020-2023  润新知