主页
  新闻
    InfoJet Service
  介绍
  支持特性
  程序截图
  API文档
  如何整合
  表单代码
  系统需求
  配置
  常见问题
    InfoJet POM
    InfoJet Rules
    InfoJet EditPart
    InfoJet QuickFill
    试用
  下载
  Java
    购买
  价格
  如何购买
    支持
  联系我们
如何将InfoJet Service整合到ASP.NET应用程序中
请参考下列步骤将InfoJet Service整合到ASP.NET应用程序中:
添加InfoJetSoft.Service.dll引用
请在VS.NET中点击"填加引用..."菜单, 在目录 C:\Inetpub\wwwroot\InfoJetServiceDemo\bin(InfoJet Service Demo Web应用程序的安装位置) 中找到InfoJetSoft.Service.dll, 把它添加到项目中。
请注意: 当新版本的InfoJet Service发布了, 请更新InfoJetSoft.Service.dll的引用。
InfoJetSoft.Service.dll还引用下列程序集合:
Interop.MSScriptControl.dll
Microsoft.Office.Interop.InfoPath.SemiTrust.dll
Microsoft.Office.InfoPath.Permission.dll
拷贝css,images和js文件
请在ASP.NET应用程序根目录中创建分别名为"css","../images"和"js"的目录。
之后请将相应文件拷贝到其中:
css -
    calendar-blue.css
images -
    infojet_calendar.gif
    infojet_collection_arrow.gif
    infojet_menu_check.gif
    infojet_menu_group.gif
    infojet_menu_right_arrow.gif
    infojet_optional_arrow.gif
    infojet_progress_circle.gif
    infojet_separator_left.gif
    infojet_separator_middle.gif
    infojet_separator_right.gif
    infojet_transparent.gif
    infojet_menu_xcollection_focus_arrow.gif
    infojet_menu_xcollection_over_arrow.gif
    infojet_menu_xoptional_focus_arrow.gif
    infojet_menu_xoptional_over_arrow.gif
    infojet_menu_xreplace_focus_arrow.gif
    infojet_menu_xreplace_over_arrow.gif
    infojet_red_star.gif
    (一些图片属于Microsoft InfoPath。)
js -
    unauthorized_dialog.htm
    uploadfile_dialog.htm
    uploadpicture_dialog.htm
    calendar.js
    calendar-en.js
    calendar-setup.js
    infojet.js
当InfoJet Service新版本发布时,这些文件(尤其是infojet.js)可能被修改,请更新它们。
创建xdoc.aspx
请在Web应用程序根目录中创建一个名为xdoc.aspx的ASP.NET页面。 并将下列代码拷贝到xdoc.aspx.cs中:
using InfoJetSoft.Service;
protected override void Render(HtmlTextWriter output) {
    try{
        InfoJetForm form = InfoJetService.UpdateForm(this.Context);
        output.Write(form.Xhtml);
        output.Close();
    }catch(Exception e){
        output.Write(e.Message + "<br>");
        output.Write(e.StackTrace);
        output.Close();
    }
}
最后请将ValidateRequest="false"页面属性添加到xdoc.aspx中。
注册一个表单模板(.xsn)
在调用InfoJetService上的其它方法之前,请使用
string InfoJetService.Register(HttpContext context, byte[] xsnContent)
注册InfoPath表单模板。 参数xsnContent是表单模板文件的二进制内容。 这个方法将返回表单模板的publish url, publish url将在方法BuildFormByTemplate()和BuildFormByXML()中作为一个参数使用。
请最好在一个单独的ASP.NET页面(比如名为Manager.aspx)中调用Register()方法, 因为Register()方法会调用extrac32.exe并访问磁盘目录,当impersonation开启时它需要更多的权限。
请注意,试用版的InfoJet Service只支持一个InfoPath表单模板,如果您在试用版中注册更多的表单模板,Regiter()方法将返回Null
显示一个XML文档的Web表单
(1). 请在Web应用程序中创建一个名为EditDoc.aspx的ASP.NET页面。
(2). 在页面中添加一下列Label控件:
<asp:Label ID="xDocView" runat="server" EnableViewState="False"
        Text="InfoPath Web Form will be shown here." ></asp:Label>
禁用Label控件的ViewState,可以改进Web表单的性能。
然后在Page_Load事件中添加下列代码:
using InfoJetSoft.Service;
InfoJetForm form = InfoJetService.BuildFormByTemplate(this.Context, publishUrl);
this.xDocView.Text = form.Xhtml;
InfoJetService.BuildFormByTemplate()方法的参数publishUrl是
InfoJetService.Register(HttpContext context, byte[] xsnContent)方法的返回值。
(3). 在EditDoc.aspx中添加下列css和javascript文件引用:
<link rel="stylesheet" type="text/css" media="all" href="css/calendar-blue.css" title="winter"></link>
<script type="text/javascript" src="js/calendar.js"></script>
<script type="text/javascript" src="js/calendar-en.js"></script>
<script type="text/javascript" src="js/calendar-setup.js"></script>
<script type="text/javascript" src="js/infojet.js"></script>
(4). 在页面EditDoc.aspx的onload事件中调用infojet.js中的InfoJet_Init()方法:
<body onload="InfoJet_Init();">
(5). 在EditDoc.aspx中添加页面属性ValidateRequest="false"
(6). 请删除EditDoc.aspx的HTML文档类型声明(例如<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">), 因为在某些HTML文档类型下InfoJet Service不能准确定位HTML元素位置。

现在,模板XML文档的Web表单视图(form.Xhtml)将能显示在页面上。
您可以使用下列代码显示一个已存XML文档的Web表单:
using InfoJetSoft.Service;
InfoJetForm form = InfoJetService.BuildFormByXML(this.Context, publishUrl, xml);
this.xDocView.Text = form.Xhtml;
参数xml是已存XML文档的string内容。
准备提交文档
请将下列代码添加到EditDoc.aspx中:
<form name="form1" action="SaveDoc.aspx" method="post">
    <asp:Label ID="xDocView" runat="server" EnableViewState="False"
            Text="InfoPath Web Form will be shown here." ></asp:Label>
    <input type="button" value="Submit Doc"
            onclick="document.forms['form1'].submit();"></input>
</form>
当用户点击"Submit Doc"按钮,用户编辑过的XML数据将被提交到SaveDoc.aspx。
保存提交的XML
请创建一个名为SaveDoc.aspx的ASP.NET页面。
然后在Page_Load事件中添加下列代码:
using InfoJetSoft.Service;
InfoJetForm form = InfoJetService.ReloadForm(this.Context);
//...保存form.Xml到磁盘或数据库
您可以编写一些代码将form.Xml属性保存到磁盘或数据库。
更多信息
请参考 配置常见问题 来提高集成了InfoJet Service的应用程序的稳定性和启用更多功能。
如果您有任何问题,请通过 support@infojetsoft.com 联系我们。

Copyright © 2005 - 2010 InfoJetSoft all rights reserved