|
Add InfoJetSoft.Service.dll reference
|
|
Please click "Add Reference..." menu item in VS.NET, and find
InfoJetSoft.Service.dll in the folder
C:\Inetpub\wwwroot\InfoJetServiceDemo\bin(the installation location of InfoJet Service Demo web application), and add it to the project.
Please Note: while an InfoJet Service new build version released, you need to
update the reference to InfoJetSoft.Service.dll.
InfoJetSoft.Service.dll references the following assemblies also:
Interop.MSScriptControl.dll
Microsoft.Office.Interop.InfoPath.SemiTrust.dll
Microsoft.Office.InfoPath.Permission.dll
|
|
Copy css, images and js files
|
|
Please create three folders named as "css", "images" and "js" in the root
folder of the ASP.NET application.
Then please copy the following files into them:
css -
calendar-win2k-cold-1.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
(Some of images are owned by Microsoft InfoPath.)
js -
unauthorized_dialog.htm
uploadfile_dialog.htm
uploadpicture_dialog.htm
calendar.js
calendar-en.js
calendar-setup.js
infojet.js
While a new build version of InfoJet Service released, these files(especially infojet.js) maybe were
modified, please update them also.
|
|
|
Please create an empty ASP.NET page named xdoc.aspx in the root folder of the web application. And please copy the
following codes into 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();
}
}
At last, please add the page property ValidateRequest="false" to xdoc.aspx.
|
|
Register a form template(.xsn)
|
|
Before call other methods on InfoJetService class, please register the InfoPath form
template with
string InfoJetService.Register(HttpContext context, byte[] xsnContent).
The xsnContent is the binary content of the xsn file.
The method will return the publish url of the form template,
it will be used as a parameter in the method BuildFormByTemplate() and BuildFormByXML().
You'd better call the method Register() in an individual ASP.NET page named such as Manager.aspx,
for Register() method will call extrac32.exe and access the disc folder, more privilege is requried when impersonation is enabled.
Please note, the trial version of InfoJet Service only could service for ONE InfoPath form template,
while you try to register more form templates into the trial version, the method Register() will return Null.
|
|
Show the web form of an xml document
|
|
(1). Please create an ASP.NET page named such as EditDoc.aspx in the root folder of the web application.
(2). Add the following label control into the page:
<asp:Label ID="xDocView" runat="server" EnableViewState="False"
Text="InfoPath Web Form will be shown here." ></asp:Label>
To improve the performance of the web form, please disable the label's view state.
Then add the following codes into the Page_Load method:
using InfoJetSoft.Service;
InfoJetForm form = InfoJetService.BuildFormByTemplate(this.Context, publishUrl);
this.xDocView.Text = form.Xhtml;
The parameter publishUrl is the return value of the method InfoJetService.Register(HttpContext context, byte[] xsnContent).
(3). Add the following css and javascript file reference to the page EditDoc.aspx also:
<link rel="stylesheet" type="text/css" media="all" href="css/calendar-win2k-cold-1.css" title="win2k-cold-1"></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). Call the javascript method InfoJet_Init() in infojet.js in the event onload of the page EditDoc.aspx:
<body onload="InfoJet_Init();">
(5). Add the page property ValidateRequest="false" to EditDoc.aspx also.
(6).
Please remove the html document type declaration(such as
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">)
at the top of the page EditDoc.aspx, for InfoJet Service cannot locate the html element's position properly with some html document type.
Now, the web form view(form.Xhtml) of the template xml document in the form template will be displayed on the page.
And you could use the following codes to show the web form of an existing xml document:
using InfoJetSoft.Service;
InfoJetForm form = InfoJetService.BuildFormByXML(this.Context, publishUrl, xml);
this.xDocView.Text = form.Xhtml;
The parameter xml is the string content of the existing xml document.
|
|
Prepare to submit the document
|
|
Please add the following codes into 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>
While the button clicked, the xml data edited by users will be post to SaveDoc.aspx.
|
|
|
Please create an ASP.NET page named such as SaveDoc.aspx.
Then please add the following code to the Page_Load method:
using InfoJetSoft.Service;
InfoJetForm form = InfoJetService.ReloadForm(this.Context);
//...save form.Xml to the disk or a database
You could write some codes to save the attribute form.Xml to the disk or database.
|
|
Please contact us for any problem
|
|
|
If you have any problem about it, please contact us via
support@infojetsoft.com.
|
|