1、登入Smarteam系統
Private Function LoginSmarteam(ByVal Login As String, ByVal Password As String, ByRef RetMsg As String) As Boolean
Dim blnLogin As Boolean = False
Try
Dim SmEngine As SmEngine
Dim gvDBConn As SmDatabase
SmEngine = CreateObject("SmApplic.SmEngine")
SmEngine.Init("SmTeam32.ini")
SmSession = SmEngine.CreateSession("SmTeam32.ini", "SmTeam32.ini")
gvDBConn = SmEngine.Databases(0)
SmSession.OpenDatabaseConnection(gvDBConn.Alias, gvDBConn.Password, True)
If SmSession.UserLogin(Login, Password) = True Then
blnLogin = True
End If
Return blnLogin
Catch ex As Exception
RetMsg = ex.Message.ToString
Return blnLogin
Finally
CloseConnection()
End Try
End Function
''' <summary>
''' Close Connection to SmarTeam DB
''' </summary>
''' <remarks></remarks>
Public Sub CloseConnection()
Try
If Not SmEngine Is Nothing Then
If SmEngine.SessionsCount > 0 Then
SmSession.DatabaseConnection.CloseDatabaseConnection()
SmSession.Close()
SmEngine.Terminate()
End If
End If
Catch ex As Exception
Throw New Exception("CloseConnection : " & ex.Message)
End Try
End Sub
2、由Class Name 取得Class
Dim ProjectCls As ISmClass = SmSession.MetaInfo.SmClassByName("Project")
3、由欄位名稱取得RTC或Lookup類型的Class
Dim intLookupCID As Integer = ProjectCls.Attributes.ItemByName(欄位名稱).ReferencedClassId
4、新增一個流程
Dim SmProcess As SmartFlow.ISmFlowProcess = Nothing
Dim FlowStore As SmartFlow.SmFlowStore
FlowStore = SmSession.GetService("SmartFlow.SmFlowStore")
SmProcess = FlowStore.InitiateNewProcess(流程Class ID)
5、給流程添加物件
SmProcess.LinkObject(要添加的物件的OBJECT, Nothing)
SmProcess為流程
6、取得流程節點的下一節點
procSmNodeTo = procNodeStart.OutConnectors(j).ToNode
7、傳送流程至下一節點
傳送流程至下一節點
Dim SmResObj As SmartFlow.ISmResponse
Dim FlowSession As SmartFlow.SmFlowSession
FlowSession = FlowStore.FlowSession
SmResObj = procNodeStart.DefaultAcceptResponse
'Dim SmResObj1 As SmartFlow.ISmResponse = procNodeStart.OutConnectors.Item(0).Response()
SmProcess.InitiateProcess(FlowSession, SmResObj, "", Now)