11-25-2016 2:56 PM - edited 02-03-2024 6:51 PM
Today I wanted to install the first version of our addon in our Company, but I found out that the addon have a dependency of a DI API Config file, while it shouldn't.
On the computer I developed the addon works fine, but after I added the addon in the addon manager and I tried to run it on a few other computer (it installed fine), it threw an exception 'Couldn't connect to the Licence server..'. After a few tries and a version which prints to the console, I figured it it tires to connect with 'localhost:30000'. This address is provided to the SAP in the config file here: ''C:\Program Files (x86)\SAP\SAP Business One DI API\Conf\b1-local-machine.xml', saying:
<leaf kind="single" name="LicenseServer" type="String">
<value>localhost:30000</value>
</leaf>
If I change it to our company's server ip, my addon works. My problem is that every new installation of the SAP B1 client will have the DI API's config set to localhost and I need to manually change it everytime. It is bothersome at least.
Other thing is we have two other addons which are not developed by me and are perfectly fine with the localhost address. So I am guessing I am doing something wrong (I followed the sample file though)
Here is the class I am using as a base class and every class that would use DI API inherit this:
public class SAPDIDao
{
private static Company savedCompany = null;
protected SAPbouiCOM.Application SBOApp = null;
protected Company oCompany = null;
public SAPDIDao(SAPbouiCOM.Application SBOApp)
{
this.SBOApp = SBOApp;
this.oCompany = GetCompany(SBOApp);
}
public static Company GetCompany(SAPbouiCOM.Application SBOApp)
{
if (savedCompany == null)
{
Company tmpCompany = new Company();
int contextCode = SetConnectionContext(SBOApp, tmpCompany);
int errorCode = tmpCompany.Connect();
Console.WriteLine("Connection to Licence server: " + tmpCompany.LicenseServer);
if (errorCode != 0)
{
string lastException = "";
tmpCompany.GetLastError(out errorCode, out lastException);
Console.WriteLine("Company connect error: " + errorCode + ", msg: " + lastException);
tmpCompany.GetLastError(out errorCode, out lastException);
Console.WriteLine("Context: " + contextCode + ", msg: " + lastException);
throw new Exception("Company connect error: " + errorCode + ", msg: " + lastException + "\nContext: " + contextCode + ", msg: " + lastException);
}
savedCompany = tmpCompany;
}
return savedCompany;
}
private static int SetConnectionContext(SAPbouiCOM.Application SBOApp, Company tmpCompany)
{
int setConnectionContextReturn = 0;
string sCookie = tmpCompany.GetContextCookie();
string sConnectionContext = SBOApp.Company.GetConnectionContext(sCookie);
if (tmpCompany.Connected)
{
tmpCompany.Disconnect();
}
setConnectionContextReturn = tmpCompany.SetSboLoginContext(sConnectionContext);
Console.WriteLine("DI API Connection, login context: " + setConnectionContextReturn);
return setConnectionContextReturn;
}
}
I am using SAP B1 9.2 and I tried with both the seperate ui/di dlls and the new one, which provides both as a single dll.
Also, I posted a Question about this already in the Past, but the solution there lead me to this problem:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Iit is the other way, GetDICompany() is the slower way.
Kind Regards
Ad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
This solution works, but the performance of DI-API calls will be less because every call is now a RPC call instead of a COM-call.
Kind Regerds,
Ad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
100 | |
11 | |
11 | |
6 | |
6 | |
5 | |
4 | |
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.