03/22: Create An External Library In .Net And Call It In Smarteam
Development Environment Setup
- Copy all files of Smarteam’s Assembly from Windows GAC to a specified folder (C:\Program Files\SmarTeam\Bin\Assembly)
- Register this folder under window registry
Copy.bat
if not exist "C:\Program Files\SmarTeam\Bin\Assembly" md "C:\Program Files\SmarTeam\Bin\Assembly"
for /R %WINDIR%\assembly\GAC_32 %%f in (SmarTeam.Std.*.dll) do copy %%f "C:\Program Files\SmarTeam\Bin\Assembly"
call regedit /s RegisterSmarTeamAssemblies.reg
copy "C:\Program Files\SmarTeam\Bin\DRLTools\*.dll" "C:\Program Files\SmarTeam\Bin\Assembly"
pause
RegisterSmarTeamAssemblies.reg
Windows Registry Editor Version 5.00
(c) 2006 SmarTeam Corp. Ltd
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\SMARTEAM]
@="C:\\Program Files\\SMARTEAM\\Bin\\Assembly"
Steps :
- Create a library file .net
- Add some smarteam reference
- Add class files
- Application.vb
Option Explicit On
Imports SmarTeam.Std.Interop.SmarTeam
Imports SmarTeam.Std.ConstantsPublic Class Application
Public Function MyExample(ByRef SmSession As SmApplic.SmSession, ByRef FirstRec As SmRecList.SmRecordList) As Short
With New clsExamples
MyExample = IIf(.MyExample(SmSession, FirstRec), BFERRPUB.Err_None_N, BFERRPUB.Err_Gen_N)
End With
End FunctionEnd Class
- clsExample.vb
Option Explicit On
Imports SmarTeam.Std.Interop.SmarTeam
Imports SmarTeam.Std.ConstantsFriend Class clsExamples
Public Function MyExample(ByRef SmSession As SmApplic.SmSession, _
ByRef FirstRec As SmRecList.SmRecordList) As Boolean
MsgBox("My login name is: " & SmSession.UserMetaInfo.UserLogin & vbNewLine & _
"There were " & CStr(FirstRec.RecordCount) & " objects selected.", _
MsgBoxStyle.Information, BFCOMPUB.NM_OUR_COMPANY_NAME)
MyExample = True
End Function
End Class
- Application.vb
- Add a strong key and Sign this assembly
- Deploy to server:
- Register:
- "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\RegAsm.exe" "C:\Customize2\Exercise 3\bin\DSSimpleTest..dll" /codebase
- Unregister:
- "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\RegAsm.exe" "C:\Customize2\Solution 1\bin\DSSimpleTest..dll" /unregister
- Register:
- Write script function to invoke this dll
- sdytest.ebs
Option Explicit
' This file contains sample functions for the Customize 2 training
'
' (c) 2006 SmarTeam Corp. Ltd
''=======================================================================================
' This function can be hooked as a user defined tool and demonstrates the usage
' of the Smart Basic Editor combined with a COM object
'
Function SDExample (ApplHndl As Long,Sstr As String,FirstPar As Long,SecondPar As Long,_
ThirdPar As Long ) As Integer
Dim SmSession As SmApplic.SmSession
Dim FirstRec As Object
Dim DSSimpleTest As Object
'
' Get the session and get the selected data
Set SmSession = SCREXT_ObjectForInterface(Applhndl)
CONV_RecListToComRecordList FirstPar, FirstRec
'
' Create a connection to our own object
Set DSSimpleTest = CreateObject("DSSimpleTest.Application")
' Note : Namespace_Name.Class_name of .net code
' Now call the method - procedure or function
DSSimpleTest.MyExample SmSession,FirstRec
'
' Release the dll object
Set DSSimpleTest = Nothing
End Function - Copy this file to smarteam script folder
- In script maintenance of admin console, invoke function with hooked event
- sdytest.ebs
0 Comments:
Post a Comment
<< Home