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

            if (runningSessionGroups.Count() == 0)
            {
                throw new NoActiveSessionGroupException();
            }

            if (m_commandSwitch.CommandSwitchSet)
            {
                Configuration configuration;
                foreach (Guid sessionGroupId in runningSessionGroups)
                {
                    configuration = manager.LoadConfiguration(sessionGroupId);
                    preAuthorizeRules(configuration);
                }
            }

            // If we are self hosting, use the IMigrationService interface
            // to start some sessions before trying to list the active ones.
            foreach (Guid sessionGroupId in runningSessionGroups)
            {
                m_pipeProxy.StartSessionGroup(sessionGroupId);
            }

            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 ||
                        AllRunningSessionGroupsAreInStoppedSyncState(runningSessionGroups.ToArray()))
                    {
                        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);
            }
        }
Beispiel #2
0
        void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorkerArgs args             = (BackgroundWorkerArgs)e.Argument;
            IMigrationService    migrationService = (IMigrationService)MigrationServiceManager.GetService(typeof(IMigrationService));

            switch (args.Task)
            {
            case BackgroundWorkerTask.Start:
                migrationService.StartSessionGroup(args.SessionGroupUniqueId);
                e.Result = args;
                break;

            case BackgroundWorkerTask.Resume:
                migrationService.ResumeSessionGroup(args.SessionGroupUniqueId);
                break;

            case BackgroundWorkerTask.Stop:
                migrationService.StopSessionGroup(args.SessionGroupUniqueId);
                break;

            case BackgroundWorkerTask.Pause:
                migrationService.PauseSessionGroup(args.SessionGroupUniqueId);
                break;
            }
        }