Example #1
0
        private void LaunchSingleSessionFromDB()
        {
            BusinessModelManager manager = new BusinessModelManager();
            List <Guid>          runningSessionGroups = manager.GetActiveSessionGroupUniqueIds();

            // If we are self hosting, use the IMigrationService interface
            // to start some sessions before trying to list the active ones.
            if (!runningSessionGroups.Contains(SingleSessionStartInfo.SessionGroupId))
            {
                return;
            }

            if (m_commandSwitch.CommandSwitchSet)
            {
                Configuration configuration = manager.LoadConfiguration(SingleSessionStartInfo.SessionGroupId);
                preAuthorizeRules(configuration);
            }

            m_pipeProxy.StartSingleSessionInSessionGroup(SingleSessionStartInfo.SessionGroupId, SingleSessionStartInfo.SessionId);

            while (true)
            {
                try
                {
                    runningSessionGroups.Clear();
                    runningSessionGroups.AddRange(m_pipeProxy.GetRunningSessionGroups());

                    // uncomment the following lines for richer debugging message
                    // Console.WriteLine(String.Format("Received {0} entries", runningSessionGroups.Count));
                    //foreach (Guid guid in runningSessionGroups)
                    //{
                    //    Console.WriteLine(guid.ToString());
                    //}

                    if (runningSessionGroups.Count() == 0)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    // Ugly, but this approach lets us start the test app
                    // before the endpoint is ready to service requests.
                    Console.WriteLine("Error: {0}", e.Message);

                    // re-initialize proxy
                    InitializeProxy();
                }

                Thread.Sleep(RunningSessionPollingIntervalMillisec);
            }
        }
Example #2
0
        void m_refreshBW_DoWork(object sender, DoWorkEventArgs e)
        {
            IMigrationService migrationService      = (IMigrationService)MigrationServiceManager.GetService(typeof(IMigrationService));
            SessionGroupInitializationStatus status = SessionGroupInitializationStatus.Unknown;

            if (DataModel != null && DataModel.Configuration != null)
            {
                status = migrationService.GetSessionGroupInitializationStatus(DataModel.Configuration.SessionGroupUniqueId);
            }
            switch (status)
            {
            case SessionGroupInitializationStatus.Initialized:
                if (migrationService.GetRunningSessionGroups().Contains(DataModel.Configuration.SessionGroupUniqueId))
                {
                    ISyncStateManager stateManager     = SqlSyncStateManager.GetInstance();
                    PipelineState     newPipelineState = stateManager.GetCurrentState(OwnerType.SessionGroup, DataModel.Configuration.SessionGroupUniqueId);
                    if (s_canTransitionFrom[(int)m_currentPipelineState, (int)newPipelineState])
                    {
                        e.Result = newPipelineState;
                    }
                    else
                    {
                        Console.WriteLine("Cannot transition from " + m_currentPipelineState + " to " + newPipelineState);
                    }
                    IsCompleted = false;
                }
                else
                {
                    e.Result = PipelineState.Default;
                    using (Microsoft.TeamFoundation.Migration.EntityModel.RuntimeEntityModel context = Microsoft.TeamFoundation.Migration.EntityModel.RuntimeEntityModel.CreateInstance())
                    {
                        var query = from sg in context.RTSessionGroupSet
                                    where sg.GroupUniqueId.Equals(DataModel.Configuration.SessionGroupUniqueId)
                                    select sg.State;
                        int?state = query.FirstOrDefault();
                        if (state != null && (Microsoft.TeamFoundation.Migration.BusinessModel.BusinessModelManager.SessionStateEnum)state == BusinessModelManager.SessionStateEnum.Completed && ConflictManager != null && ConflictManager.TotalConflicts == 0)
                        {
                            IsCompleted = true;
                        }
                        else
                        {
                            IsCompleted = false;
                        }
                    }
                }
                break;

            case SessionGroupInitializationStatus.Initializing:
                IsCompleted = false;
                break;

            case SessionGroupInitializationStatus.NotInitialized:
            case SessionGroupInitializationStatus.Unknown:
                e.Result    = PipelineState.Default;
                IsCompleted = false;
                break;
            }
        }