How to Create a Link to PRIEmpre

0

Good afternoon,

I needed to connect to ADM from VB.Net to list Companies and Users.

To make the normal connection use the following code:

motor = New ErpBS()
motor.AbreEmpresaTrabalho(EnumTipoPlataforma.tpEmpresarial, PRIEmpresa, PRIUser, PRIPass)

But for ADM I'm not getting it, how should I do it, I have the following code to give error:

Dim motor As AdmBS
motor.AbrePRIEMPRE(EnumTipoPlataforma.tpEmpresarial, PRIUser, PRIPass)
    
asked by anonymous 07.12.2018 / 15:46

1 answer

1

To get businesses and users you can use the following code:

Dim objAplConf As StdBSConfApl = New StdBSConfApl
Dim Plataforma As StdPlatBS = New StdPlatBS
Dim MotorLE As ErpBS = New ErpBS

With objAplConf
    .Instancia = "Default"
    .AbvtApl = "ERP"
    .PwdUtilizador = String.Empty
    .Utilizador = "primavera"
    .LicVersaoMinima = "9.00"
End With

'Abertura da PLATAFORMA
Plataforma.AbrePlataforma(EnumTipoPlataforma.tpEmpresarial, objAplConf)

'Obter a lista de empresas
Dim listaEmpresas As StdBELista = Plataforma.Administrador.ListaEmpresas.Lst_Empresas

'Listar as empresas
While Not listaEmpresas.NoFim
    Console.WriteLine($"{listaEmpresas.Valor("Codigo")} - {listaEmpresas.Valor("IDNome")}")

    listaEmpresas.Seguinte()
End While

'Obter a lista dos utilizadores
Dim utilizadores As clsUtilizadores = Plataforma.Administrador.ListaUtilizadores

'Listar os utilizadores
For Each utilizador As clsUtilizador In utilizadores
    Console.WriteLine($"{utilizador.Codigo} - {utilizador.Nome}")
Next

You should note the type of company, if Empresarial or Profissional , at the opening of PLATFORM.

    
07.12.2018 / 17:26