on 03-19-2014 1:57 PM
Buen día,
Desarrolle un addon y tengo una duda con la licencia de SAP.
Cuando me conecto yo empleo la siguiente linea de código para obtener la conexión actual:
sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
sin embargo, cuando quiero hacer operaciones hacia las empresas, debo emplear esto de igual manera y pasarle los datos de acceso más el usuario SAP.
oCompany.Server = Server;
oCompany.LicenseServer = LicenseServer ;
oCompany.DbServerType = BoDataServerTypes.dst_MSSQL2012;
oCompany.CompanyDB = nApellido2;
oCompany.DbUserName = DbUserName ;
oCompany.DbPassword = DbPassword ;
oCompany.UserName = UserName ;
oCompany.Password = Password ;
oCompany.UseTrusted = true;
oCompany.language = BoSuppLangs.ln_Spanish_La;
i = oCompany.Connect();
Esto me está causando un problema puesto que debo tener una licencia solo para el addon y en realidad me gustaría que empleara la del usuario actual conectado. Como puedo hacerlo?
estas creando mal, debes tomar el ejemplo de las ayudas del SDK, de cualquier manera aca coloca el codigo de como se inicializa, para crear un objeto company con la conexion actual.
Private oCompany As SAPbobsCOM.Company
Private WithEvents SBO_Application As SAPbouiCOM.Application
Public sErrMsg As String
Public lErrCode As Integer
Public lRetCode As Integer
''''''''''''''''''
' Connect to SBO '
''''''''''''''''''
Private Sub SetApplication()
Dim SboGuiApi As SAPbouiCOM.SboGuiApi
Dim sConnectionString As String
SboGuiApi = New SAPbouiCOM.SboGuiApi
sConnectionString = Environment.GetCommandLineArgs.GetValue(1)
SboGuiApi.Connect(sConnectionString)
SBO_Application = SboGuiApi.GetApplication()
End Sub
''''''''''''''''''''''''''''''''''
' Connect with connection string '
''''''''''''''''''''''''''''''''''
Private Function SetConnectionContext() As Integer
Dim sCookie As String
Dim sConnectionContext As String
Dim lRetCode As Integer
oCompany = New SAPbobsCOM.Company
sCookie = oCompany.GetContextCookie
sConnectionContext = SBO_Application.Company.GetConnectionContext(sCookie)
If oCompany.Connected = True Then
oCompany.Disconnect()
End If
SetConnectionContext = oCompany.SetSboLoginContext(sConnectionContext)
End Function
''''''''''''''''''
' Connect to SBO '
''''''''''''''''''
Private Function ConnectToCompany() As Integer
'// Establecer conexion con SBO
ConnectToCompany = oCompany.Connect
End Function
''''''''''''''''''
' Inicializacion de Clases
''''''''''''''''''
Public Sub New()
MyBase.New()
Try
SetApplication()
If Not SetConnectionContext() = 0 Then
SBO_Application.MessageBox("Falló conexión con DI API")
End ' NO se pudo conectar al SBO termina
End If
Dim CodigoError As Integer = ConnectToCompany()
Dim MensajeError As String = ""
If Not CodigoError = 0 Then
oCompany.GetLastError(CodigoError, MensajeError)
SBO_Application.MessageBox("Falló conexión con BD de Cliente. " & CodigoError.ToString & "-" & MensajeError)
Application.Exit() ' Terminating the Add-On Application
End If
End sub
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
96 | |
10 | |
9 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.