Presentation is loading. Please wait.

Presentation is loading. Please wait.

Microsoft Office System UK Developers Conference Radisson Edwardian, Heathrow 29 th & 30 th June 2005.

Similar presentations


Presentation on theme: "Microsoft Office System UK Developers Conference Radisson Edwardian, Heathrow 29 th & 30 th June 2005."— Presentation transcript:

1 Microsoft Office System UK Developers Conference Radisson Edwardian, Heathrow 29 th & 30 th June 2005

2 Developing InfoPath Forms Using Managed Code Jessica Gruber Microsoft Consulting Services

3 Problem Statement How can you use Visual Studio to add the power of managed code to your forms in a secure way?

4 InfoPath Business Logic Most Forms Do Not Need Code XML Schema Rules Formulas Data Validation Data Connections Conditional Formatting C# VB.NET

5 Machine Setup Developers – To create the form Visual Studio.NET 2003 InfoPath 2003 SP1 InfoPath Toolkit for Visual Studio.NET http://www.microsoft.com/downloads/details.a spx?FamilyId=7E9EBC57-E115-4CAC-9986- A712E22879BB&displaylang=en End Users – To fill out the form.Net Framework 1.1 InfoPath 2003 SP1

6 Visual Studio Integration

7 Form Template And Project Source Code (CS, VB) Project Definition (*PROJ) Form Template Files Visual Studio Project Assemblies (DLL and PDB) Template Definition (XSF) Default Data (XML) Schema (XSD) Views (XSLT) InfoPath Form Template (XSN) Publish / Preview Form Data User Fills Out Form.XML

8 Event Framework Open Edit Submit Close User C# VB.NET JScript VBScript Event Handlers OnLoad OnBeforeChange OnValidate OnAfterChange OnClick Events OnSubmitRequest

9 Windows XDocuments Application View Window Errors TaskPanes CommandBars MailEnvelope Application lifecycle XDocument lifecycle User XDocument DOM Object Model Overview DataAdapters

10 Document Object Model sales XMLDOM name items item priceunits Form’s View

11 Form Editing Events sales name items item priceunits price OnAfterChange(DataDOMEvent e) Bubbling Event Handler XMLDOM

12 Form Editing Events sales name items item priceunits price OnAfterChange(DataDOMEvent e) Bubbling Bubbling hides source Use e.Site and e.Source Events fire twice! Use e.Operation Check for “Insert” Event Handler XMLDOM

13 Referencing Nodes With XPath sales name items item priceunits XMLDOM /ns:sales/ns:items /ns:sales /ns:sales/ns:items/ns:item

14 Referencing Nodes With XPath sales name items item priceunits XMLDOM /ns:sales Namespaces Every node has one Prefix = short hand DOM and Node Methods selectSingleNode(Str) selectNodes(Str) Use “text” property DOM.selectSingleNode(“/ns:sales”);

15 Contains pre-configured Data Connections Supports all built in adapters Primary methods on each: Query / Submit DataAdapters da =thisXDocument.DataAdapters; // Query pre-configured web service ((WebServiceAdapter) da["My WS"]).Query(); // Submit to pre-configured WSS form library ((DAVAdapter) da["My SharePoint"]).Submit(); Data Adapters Collection

16 Offline Submit And Cache Offline Submit OnSubmitRequest If online, submit using DataAdapter Else, save XML locally OnLoad Swap each cached file with main DOM, and submit Example on MSDN: http://msdn.microsoft.com/library/en- us/odc_ip2003_ta/html/odc_InfoPath_submitting_form s.asp?frame=true Offline Cache of Secondary Data Sources OnLoad If online, update cache with new local copies Else, use cached copies instead

17 Dynamic Help In Task Pane Use OnContextChange Event Update HTML in Task Pane Lab 14 shows how to do this in script http://msdn.microsoft.com/library/default.asp?url= /library/en- us/odc_ip2003_tr/html/odc_INF_Lab_14.asp http://msdn.microsoft.com/library/default.asp?url= /library/en- us/odc_ip2003_tr/html/odc_INF_Lab_14.asp Blogged how to do this in managed code http://blogs.msdn.com/infopath/archive/2004/09/2 7/234911.aspx http://blogs.msdn.com/infopath/archive/2004/09/2 7/234911.aspx CHM files also possible but not dynamic http://blogs.msdn.com/infopath/archive/2004/09/0 7/226572.aspx http://blogs.msdn.com/infopath/archive/2004/09/0 7/226572.aspx

18 Digital Signatures Bypass InfoPath Wizard to Sign Form Implement OnSign event (requires Full Trust) OM: SignedDataBlocks, Signatures, Certificate Remove the xml:lang attribute before signing Add and Validate Signatures on Server System.Security.Cryptography.Xml.SignedXml More info on MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en- us/odc_ip2003_ta/html/ODC_INFDigitallySigningData2.asp http://msdn.microsoft.com/library/default.asp?url=/library/en- us/odc_ip2003_ta/html/ODC_INFDigitallySigningData2.asp

19 Encryption And Decryption Scenario: sensitive values, not entire DOM Use System.Security.Cryptography When Encrypt during OnSaveRequest Decrypt during OnLoad Example on MSDN: http://msdn.microsoft.com/library/en- us/odc_ip2003_ta/html/odc_InfoPath_extendin g_save.asp?frame=true

20 Security and Managed Code Form Template Trust Levels  Restricted: No Managed Code  Domain: LocalIntranet Policy Offline Submit and Data with IsolatedStorage Dynamic Help in Task Pane  Full Trust: Install, Sign, or Add Code Group Use.NET Configuration snap-in Add “InfoPath Form Templates” code group Examples: Active Directory, WSE

21 Two Steps to Debug Full Trust  Remove the publishURL from the XSF  Use this script to register the template: strXSF = "C:\\...path…\manifest.xsf"; strName = "InfoPath.ExternalApplication"; oApp = WScript.CreateObject(strName); oApp.RegisterSolution(strXSF,"overwrite"); http://msdn.microsoft.com/library/default.asp?url=/library/en- us/odc_ip2003_tr/html/odc_INF_Lab_15.asp

22 Quick Tips And OM Highlights Prevent user from deleting existing rows Use OnBeforeChange, e.ReturnStatus = false Open a form with parameters XDocuments.NewFromSolutionWithData() Or use command line: infopath.exe /new parameters.xml Suggesting a save location and name XDocument.UI.SetSaveAsDialogFileName() XDocument.UI.SetSaveAsDialogLocation()

23 Session Summary Most forms do not need code Events = hooks that plug into your code Gotchas: bubbling and double-firing Code against the DOM Different ways to implement security Resources: http://blogs.msdn.com/infopath http://msdn.microsoft.com/library/en- us/dnanchor/html/odc_ancInfo.asp?frame=true http://blogs.msdn.com/jessicagruber

24 © 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "Microsoft Office System UK Developers Conference Radisson Edwardian, Heathrow 29 th & 30 th June 2005."

Similar presentations


Ads by Google