public GlobalServerComponent Open() { if (IsConnected()) { return(_connection); } var loginCode = _connection.bcLogon(_clientName, _user, _password, _bapiKey); if (loginCode != 0) { Log.ForCurrent.ErrorFormat("Failed to open connection to Visma Global. ErrorCode: {0}", loginCode); throw new ApplicationException("Failed to open connection to Visma Global"); } return(_connection); }