/// <summary>
        /// Initializes the broker.
        /// </summary>
        /// <exception cref="Exception">Failed creating Documentum client</exception>
        private void InitializeBroker()
        {
            //File.AppendAllText("DqlConnect.log", sessionId + " InitalizeBroker\r\n\r\n");

            _clientx = new DfClientX();
            _client  = _clientx.getLocalClient();
            if (_client == null)
            {
                throw new Exception("Failed creating Documentum client");
            }

            IDfTypedObject config = _client.getClientConfig();

            builder = new DqlConnectionStringBuilder(this.ConnectionString);

            config.setString("dfc.docbroker.host", DefaultBrokerHost ?? SetDefaultBrokerHost());
            //File.AppendAllText("DqlConnect.log", sessionId + " Broker set to: " + DefaultBrokerHost + Environment.NewLine);

            builder.SetExtendedProperties(config);

            //builder.GetExtendedProperties().ForEach(item =>
            //{ config.setString(item.Key, item.Value); });

            IDfDocbaseMap map = _client.getDocbaseMap();

            Catalogs = new List <string>();
            int count = map.getDocbaseCount();

            for (int i = 0; i < count; i++)
            {
                Catalogs.Add(map.getDocbaseName(i));
            }
            map    = null;
            config = null;
        }
 /// <summary>
 /// Changes the current database for an open connection.
 /// </summary>
 /// <param name="databaseName">Specifies the name of the database for the connection to use.</param>
 /// <exception cref="System.NotImplementedException"></exception>
 public override void ChangeDatabase(string databaseName)
 {
     builder = new DqlConnectionStringBuilder(connectionString)
     {
         ["Repository"] = Database
     };
     connectionString = builder.ConnectionString;
 }
        /// <summary>
        /// Opens a database connection with the settings specified by the <see cref="P:System.Data.Common.DbConnection.ConnectionString" />.
        /// </summary>
        /// <exception cref="System.Exception">Failed conecting to Documentum</exception>
        public override void Open()
        {
            if (state == ConnectionState.Open || state == ConnectionState.Connecting)
            {
                return;
            }

            state = ConnectionState.Connecting;

            if (builder == null)
            {
                builder = new DqlConnectionStringBuilder();
                builder.ConnectionString = this.ConnectionString;
            }

            _loginInfoObj = _clientx.getLoginInfo();
            _loginInfoObj.setUser(builder.UserId);
            _loginInfoObj.setPassword(builder.Password);
            //File.AppendAllText("DqlConnect.log", sessionId + " login success\r\n");

            try
            {
                // Create a new session to the requested DocBase
                _session = _client.newSession(builder.Repository, _loginInfoObj);
                if (_session == null && !_session.isConnected())
                {
                    state = ConnectionState.Closed;
                    throw new DqlSessionException("Failed conecting to Documentum");
                }
                state = ConnectionState.Open;
            }
            catch (Exception ex)
            {
                state = ConnectionState.Closed;
                throw new DqlSessionException("Unable to create session. Make sure the repository is available.\r\n" + connectionString, ex);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DqlConnection"/> class.
 /// </summary>
 /// <param name="builder">The builder.</param>
 public DqlConnection(DqlConnectionStringBuilder builder)
     : this()
 {
     this.builder = builder;
     InitializeBroker();
 }