Ejemplo n.º 1
0
        private void InitializeCQClient()
        {
            Microsoft.TeamFoundation.Migration.BusinessModel.MigrationSource migrationSourceConfig = m_configurationService.MigrationSource;
            string dbSet  = migrationSourceConfig.ServerUrl;
            string userDb = migrationSourceConfig.SourceIdentifier;

            ICredentialManagementService credManagementService =
                m_serviceContainer.GetService(typeof(ICredentialManagementService)) as ICredentialManagementService;

            ICQLoginCredentialManager loginCredManager =
                CQLoginCredentialManagerFactory.CreateCredentialManager(credManagementService, migrationSourceConfig);

            // connect to user session
            UserSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.UserName,
                                                                   loginCredManager.Password,
                                                                   userDb,
                                                                   dbSet);
            m_userSession = CQConnectionFactory.GetUserSession(UserSessionConnConfig);

            #region we won't need admin session until we start syncing cq schema
            //// connect to admin session
            //if (!string.IsNullOrEmpty(loginCredManager.AdminUserName))
            //{
            //    AdminSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.AdminUserName,
            //                                                                loginCredManager.AdminPassword ?? string.Empty,
            //                                                                userDb,
            //                                                                dbSet);
            //    m_adminSession = CQConnectionFactory.GetAdminSession(AdminSessionConnConfig);
            //}
            #endregion
            MigrationContext = new ClearQuestMigrationContext(m_userSession, migrationSourceConfig);
        }
Ejemplo n.º 2
0
        public static Session GetUserSession(ClearQuestConnectionConfig connConfig)
        {
            string idStr = GenerateSessionIdStr(connConfig);

            lock (s_userSessionLock)
            {
                if (s_userSessions.ContainsKey(idStr))
                {
                    return(s_userSessions[idStr]);
                }

                // create and initialize session object
                Session userSession = CQWrapper.CreateSession();
                TraceManager.TraceInformation("Connecting to CQ User Session");
                CQWrapper.UserLogon(userSession,
                                    connConfig.User,
                                    connConfig.Password,
                                    connConfig.UserDB,
                                    (int)CQConstants.SessionType.PRIVATE,
                                    connConfig.DBSet);
                TraceManager.TraceInformation("Connected to CQ User Session");

                s_userSessions.Add(idStr, userSession);

                return(userSession);
            }
        }
Ejemplo n.º 3
0
        public static AdminSession GetAdminSession(ClearQuestConnectionConfig connConfig)
        {
            string idStr = GenerateSessionIdStr(connConfig);

            lock (s_adminSessionLock)
            {
                if (s_adminSessions.ContainsKey(idStr))
                {
                    return(s_adminSessions[idStr]);
                }

                // create and initialize admin session object
                AdminSession adminSession = CQWrapper.CreateAdminSession();
                TraceManager.TraceInformation("Connecting to CQ Admin Session");
                CQWrapper.AdminLogon(adminSession,
                                     connConfig.User,
                                     connConfig.Password,
                                     connConfig.DBSet);
                TraceManager.TraceInformation("Connected to CQ Admin Session");
                OAdUser cqUser = CQWrapper.GetUser(adminSession, connConfig.User);
                try
                {
                    if (!CQWrapper.IsSuperUser(cqUser))
                    {
                        string errMsg = UtilityMethods.Format(CQResource.CQ_NO_ADMIN_RIGHT,
                                                              connConfig.User ?? string.Empty);
                        TraceManager.TraceError(errMsg);
                        throw new MigrationException(errMsg);
                    }
                }
                catch (System.Runtime.InteropServices.COMException ex)
                {
                    string errMsg = UtilityMethods.Format(CQResource.CQ_NO_ADMIN_RIGHT,
                                                          connConfig.User ?? string.Empty);
                    TraceManager.TraceException(ex);
                    TraceManager.TraceError(errMsg);
                    throw new MigrationException(errMsg);
                }

                s_adminSessions.Add(idStr, adminSession);

                return(adminSession);
            }
        }
Ejemplo n.º 4
0
        private void InitializeCQClient()
        {
            MigrationSource migrationSourceConfig = m_configurationService.MigrationSource;
            string          dbSet  = migrationSourceConfig.ServerUrl;
            string          userDb = migrationSourceConfig.SourceIdentifier;

            ICredentialManagementService credManagementService =
                m_serviceContainer.GetService(typeof(ICredentialManagementService)) as ICredentialManagementService;

            ICQLoginCredentialManager loginCredManager =
                CQLoginCredentialManagerFactory.CreateCredentialManager(credManagementService, migrationSourceConfig);

            // connect to user session
            UserSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.UserName,
                                                                   loginCredManager.Password,
                                                                   userDb,
                                                                   dbSet);
            m_userSession = CQConnectionFactory.GetUserSession(UserSessionConnConfig);

            #region admin session is not needed until we sync context
            //// connect to admin session
            //if (!string.IsNullOrEmpty(loginCredManager.AdminUserName))
            //{
            //    AdminSessionConnConfig = new ClearQuestConnectionConfig(loginCredManager.AdminUserName,
            //                                                                loginCredManager.AdminPassword ?? string.Empty,
            //                                                                userDb,
            //                                                                dbSet);
            //    m_adminSession = CQConnectionFactory.GetAdminSession(AdminSessionConnConfig);
            //}
            #endregion

            // parse the filter strings in the configuration file
            m_filters = new CQRecordFilters(m_configurationService.Filters, m_userSession);

            m_migrationContext = new ClearQuestMigrationContext(m_userSession, migrationSourceConfig);
        }
Ejemplo n.º 5
0
 private static string GenerateSessionIdStr(ClearQuestConnectionConfig connConfig)
 {
     return(connConfig.DBSet + connConfig.UserDB + connConfig.User);
 }