Hi
Now I have database backend is sqlserver 2005 (not database of blackpearl) and some activity in workflow want to check something in the database backend such as : check field finished = true . When the K2 know status finished equal true then goto next activity.
And Now I write .Net Trigger to check and hook it to database finished My sample code
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.SqlServer.Server
Partial Public Class MyFirstClrTrigger
'<Microsoft.SqlServer.Server.SqlTrigger("FOR INSERT", "checkUserRole", "UserTable")>
<Microsoft.SqlServer.Server.SqlTrigger(Event:="FOR INSERT", Name:="checkUserRole", target:="UserTable")> _
Public Shared Sub checkUserRole()
Dim triggContext As SqlTriggerContext = SqlContext.TriggerContext()
Dim userType As String = String.Empty
If triggContext.TriggerAction = TriggerAction.Insert Then
Using connection As New SqlConnection("context connection=true")
connection.Open()
Dim sqlComm As New SqlCommand
Dim sqlPipe As SqlPipe = SqlContext.Pipe()
sqlComm.Connection = connection
sqlComm.CommandText = "SELECT Type from INSERTED"
userType = sqlComm.ExecuteScalar.ToString()
If userType.ToUpper = "ADMIN" Then
sqlPipe.Send("Hello !!! You have the Admin role.")
sqlPipe.Send("We can use e-mail codes here to inform.")
Else
End If
End Using
End If
End Sub
End Class
And I want to Know:
- How to use server event code to call external source (such as .net trigger) and pass instance Id also.
- How I can use .net trigger call back process in K2
thanks