/// <summary> /// AUTHOR: Ashok Kolwal /// COMPANY: VITRANA /// Version: 1.0 /// Description: This method is used for get the session variable based on documentum server info. /// Last Modified date: 11 Jul,2017 /// </summary> /// <param name="sessionVariableObject"></param> /// <returns></returns> public object GetSessionManager(GetSessionEntity sessionVariableObject) { object sessionVariable = null; try { IDfClientX clientX = new DfClientX(); // Console.WriteLine("[GetSessionManager] IDfClientX instance created"); IDfClient client = clientX.getLocalClient(); // Console.WriteLine("[GetSessionManager] IDfClient instance created"); IDfSessionManager sMgr = client.newSessionManager(); // Console.WriteLine("[GetSessionManager] IDfSessionManager instance created"); IDfLoginInfo loginInfo = clientX.getLoginInfo(); // Console.WriteLine("[GetSessionManager] IDfLoginInfo instance created"); loginInfo.setUser(sessionVariableObject.UserName); loginInfo.setPassword(sessionVariableObject.Password); loginInfo.setDomain(""); sMgr.setIdentity(sessionVariableObject.RepositoryName, loginInfo); // Console.WriteLine("[GetSessionManager] LoginInfo identity is set"); IDfSession session = sMgr.getSession(sessionVariableObject.RepositoryName); // Console.WriteLine("[GetSessionManager] IDfSession instance created"); switch (sessionVariableObject.SessionVariableType) { case IDFSessionVariableType.IDfSession: sessionVariable = session; break; case IDFSessionVariableType.IDfSessionManager: sessionVariable = sMgr; break; } ; } catch (Exception ex) { throw new Exception("Error in [GetSessionManager] ", ex); } return(sessionVariable); }
/// <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); } }