2012-01-30 71 views
1

有人可以檢查我的InfoPath按鈕中的.NET代碼,看看我做錯了什麼?我試圖將我的InfoPath表單發佈到SharePoint 2007.InfoPath 2007:提交按鈕代碼

該按鈕(單擊)的自定義代碼未被執行。 TDAPIOLEib是質量中心的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 

回答

0

1.設置窗體的安全級別爲 '全部'

(2007年InfoPath):工具 - >表格選項 - >安全和信任(類) - >取消選中「自動確定安全級別' - >手動檢查'完全信任' - >點擊'確定'完成後。

2.創建並分配一個表單模板簽名

(2007年InfoPath):工具 - >表格選項 - >安全和信任(類) - >檢查 '註冊此表單模板' - >點擊「選擇證書」 - >完成後點擊「確定」。

*注#2:您可能需要谷歌搜索「添加的InfoPath證書」或通過使用這個鏈接開始:MSDN - Deploying Signed Infopath Form Templates