InfoPath 2007:提交按钮代码

时间:2012-01-30 16:12:00

标签: .net sharepoint sharepoint-2007 infopath

有人可以在InfoPath按钮中检查我的.NET代码,看看我做错了什么?我正在尝试将我的InfoPath表单发布到SharePoint 2007。

未执行按钮(单击)的自定义代码。 TDAPIOLEib是Quality Center的COM组件,已添加为参考。我也尝试将代码放在表单提交中,但也不起作用。

非常感谢,我会给你尽可能多的代表点。

Imports Microsoft.Office.InfoPath
Imports System
Imports System.Xml
Imports System.Xml.XPath
Imports TDAPIOLELib
Imports System.Security.AllowPartiallyTrustedCallersAttribute



Namespace InfoPath_QC_Submit_4
    Public Class FormCode
        ' Member variables are not supported in browser-enabled forms.
        ' Instead, write and read these values from the FormState
        ' dictionary using code such as the following:
        '
        ' Private Property _memberVariable() As Object
        '     Get
        '         _memberVariable = FormState("_memberVariable")
        '     End Get
        '     Set
        '         FormState("_memberVariable") = value
        '     End Set
        ' End Property

        ' NOTE: The following procedure is required by Microsoft Office InfoPath.
        ' It can be modified using Microsoft Office InfoPath.
        Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup
            AddHandler DirectCast(EventManager.ControlEvents("btnSubmit"), ButtonEvent).Clicked, AddressOf btnSubmit_Clicked
        End Sub

        Public Sub btnSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
            Try
                Dim qcconn As New TDAPIOLELib.TDConnection
                Dim qcserver As String

                qcserver = "http://qualitycenterurl/qcbin/"

                qcconn.InitConnectionEx(qcserver)
                qcconn.Login("username", "password")
                qcconn.Connect("Domain", "Project")

                Dim BugF As TDAPIOLELib.BugFactory
                Dim bug1 As TDAPIOLELib.Bug


                BugF = qcconn.BugFactory
                bug1 = BugF.AddItem(DBNull.Value)

                Dim xnDoc As XPathNavigator = Me.MainDataSource.CreateNavigator()


                bug1.Field("BG_Summary") = xnDoc.Select("/my:myFields/Issue_Summary")
                bug1.Field("bg_Description") = xnDoc.Select("/my:myFields/Issue_Description")
                bug1.Field("bg_Priority") = xnDoc.Select("/my:myFields/Priority")
                bug1.Field("bg_detection_date") = xnDoc.Select("/my:myFields/Reported_Date")
                bug1.Field("bg_user_57") = xnDoc.Select("/my:myFields/Requestor")

                bug1.Field("bg_user_64") = "Incident"
                bug1.Field("bg_severity") = "Low"
                bug1.Field("bg_user_55") = "N"
                bug1.Field("bg_detected_by") = "SharePoint"
                bug1.Field("bg_user_31") = "Other"

                bug1.Post()

                If qcconn.Connected Then
                    qcconn.Disconnect()
                End If

                If qcconn.LoggedIn Then
                    qcconn.Logout()
                End If

            Catch ex As Exception
            End Try
        End Sub
    End Class
End Namespace

1 个答案:

答案 0 :(得分:0)

1。将表单的安全级别设置为“完整”

(InfoPath 2007):工具 - >表格选项 - >安全和信任(类别) - >取消选中“自动确定安全级别” - >手动检查'完全信任' - >完成后点击“确定”。

2。创建并分配表单模板签名

(InfoPath 2007):工具 - >表格选项 - >安全和信任(类别) - >选中“签署此表单模板” - >点击“选择证书” - >完成后点击“确定”。

*注意#2:您可能需要谷歌搜索“添加InfoPath证书”或使用以下链接开始:MSDN - Deploying Signed Infopath Form Templates