Exemple #1
0
        /// <summary>
        /// Initiates the Acd portal start up operation
        /// </summary>
        internal IAsyncResult BeginStartUp(AsyncCallback userCallback, object state)
        {
            StartupAsyncResult asyncResult = new StartupAsyncResult(userCallback, state, this);

            bool firstTime = false;

            lock (_syncRoot)
            {
                if (_portalState == PortalState.Created)
                {
                    this.UpdatePortalState(PortalState.Starting);
                    _matchMaker  = this.Platform.MatchMaker;
                    _agentHunter = new AcdAgentHunter(this, _matchMaker, _logger);
                    firstTime    = true;
                }
                else
                {
                    throw new InvalidOperationException("AcdPortal is already being started");
                }
            }

            if (firstTime)
            {
                ThreadPool.QueueUserWorkItem((waitState) =>
                {
                    var tempAr = waitState as StartupAsyncResult;
                    tempAr.Process();
                }, asyncResult);
            }

            return(asyncResult);
        }
Exemple #2
0
            /// <summary>
            /// To complete the start up operation it is essential that the match maker be started correctly.
            /// </summary>
            /// <param name="ar"></param>
            private void OnMatchMakerStartUpComplete(IAsyncResult ar)
            {
                AcdAgentMatchMaker matchMaker = ar.AsyncState as AcdAgentMatchMaker;

                try
                {
                    matchMaker.EndStartup(ar);

                    _acdPlatform._platform.UnregisterForApplicationEndpointSettings(OnMatchMakerFound);
                    _acdPlatform.RegisterForPlatformAutoProvisioningEvents();

                    _acdPlatform.UpdateAcdPlatformState(AcdPlatformState.Started);
                    this.SetAsCompleted(null, false);
                }
                catch (RealTimeException ex)
                {
                    _acdPlatform._logger.Log("AcdPlatform could not start the match maker", ex);
                    _acdPlatform.BeginShutdown(_acdPlatform.OnPlatformShutdownComplete, null);
                    this.SetAsCompleted(ex, false);
                    return;
                }
                catch (InvalidOperationException ivoex)
                {
                    _acdPlatform._logger.Log("AcdPlatform could not start the match maker", ivoex);
                    _acdPlatform.BeginShutdown(_acdPlatform.OnPlatformShutdownComplete, null);
                    this.SetAsCompleted(new OperationFailureException("AcdPlatform could not start the match maker", ivoex), false);
                    return;
                }
            }
Exemple #3
0
            internal void Process()
            {
                _matchMaker = _huntForAgentAsyncResult.AgentHunter.Matchmaker;

                AcdPortal portal = _huntForAgentAsyncResult.AgentHunter.Portal;

                _agent.AllocationStatus = AgentAllocationStatus.CommittingTheAgent;

                Dictionary <string, object> inputParameters = new Dictionary <string, object>();

                string agentSkillPrompt = _huntForAgentAsyncResult.GetAgentSkillPrompt();

                inputParameters.Add("AgentUri", _agent.SignInAddress);
                inputParameters.Add("QaAgentOfferMainPrompt", String.Format(_matchMaker.Configuration.OfferToAgentMainPrompt, _agent.PublicName, agentSkillPrompt));
                inputParameters.Add("QaAgentOfferNoRecognitionPrompt", _matchMaker.Configuration.OfferToAgentNoRecoPrompt);
                inputParameters.Add("QaAgentOfferSilencePrompt", _matchMaker.Configuration.OfferToAgentNoRecoPrompt);
                inputParameters.Add("Owner", this);
                inputParameters.Add("ApplicationEndPoint", portal.Endpoint);
                try
                {
                    //Start commit agent dialog
                    CommitAgentDialog commitAgent = new CommitAgentDialog();
                    Guid instanceId = commitAgent.InstanceId;
                    commitAgent.InitializeParameters(inputParameters);
                    commitAgent.Completed += _huntForAgentAsyncResult.AgentHunter.AgentHuntCompleteHandler;
                    commitAgent.Run();
                    _huntForAgentAsyncResult.AgentHunter.AddDialogInstance(instanceId, this);
                }
                catch (Exception ex)
                {
                    this.SetAsCompleted(ex, false);
                }
            }
Exemple #4
0
 internal AcdAgentHunter(AcdPortal portal, AcdAgentMatchMaker matchMaker, AcdLogger logger)
 {
     _portal           = portal;
     _matchMaker       = matchMaker;
     _logger           = logger;
     _averageQueueTime = new AcdAverageQueueTime(portal);
 }
Exemple #5
0
 internal FindAgentAsyncResult(AsyncCallback asyncCallback, Object state, AcdCustomerSession requestor, AcdAgentMatchMaker matchMaker, List <Agent> exclusionList, List <AgentSkill> requestedSkills)
     : base(asyncCallback, state)
 {
     _matchMaker      = matchMaker;
     _configuration   = matchMaker._configuration;
     _exclusionList   = exclusionList;
     _requestedSkills = requestedSkills;
     _requestor       = requestor;
 }
 internal AcdMusicOnHoldServer(AcdAgentMatchMaker matchMaker, string mohFilePath, AcdLogger logger)
 {
     _matchMaker    = matchMaker;
     _mohFilePath   = mohFilePath;
     _logger        = logger;
     _mohFileSource = new WmaFileSource(mohFilePath);
     _mohPlayer     = new Player();
     _mohPlayer.SetMode(PlayerMode.Manual);
     _mohPlayer.SetSource(_mohFileSource);
     this.UpdateState(MusicOnHoldServerState.Created);
 }
Exemple #7
0
            private void FindAgentCompleted(IAsyncResult result)
            {
                AcdAgentMatchMaker matchMaker = result.AsyncState as AcdAgentMatchMaker;

                try
                {
                    if (_tentativeAgent != null &&
                        _tentativeAgent.Owner == _session &&
                        _tentativeAgent.IsAllocated)
                    {
                        _tentativeAgent.Deallocate(_session);
                        _agentHunter._logger.Log("AcdAgentHunter failed to deallocate the previous agent of the hunt");
                    }
                    _tentativeAgent = matchMaker.EndFindAgent(result);

                    _session.AddAgentToExclusionList(_tentativeAgent);

                    if (_session.State != CustomerSessionState.Terminating &&
                        _session.State != CustomerSessionState.Terminated)
                    {
                        this.BeginTryCommitAgent(_tentativeAgent,
                                                 this.TryCommitAgentCompleted,
                                                 null);
                    }
                    else
                    {
                        _tentativeAgent.Deallocate(_session);
                        _agentHunter.Matchmaker.HandleNewAvailableAgent(_tentativeAgent);
                        _session.Anchor.DisallowParticipant(_tentativeAgent.SignInAddress);
                        this.SetAsCompleted(new TimeoutException("AcdAgentHunter realized that the customer session ended"), false);
                        return;
                    }
                }
                catch (TimeoutException toex)
                {
                    // We are re-evaluating the average queue time by taking into account this time out.
                    _agentHunter.AverageQueueTime.ReEvaluate(new TimeSpan(0, 0, 0, _agentHunter.Matchmaker.Configuration.MaxWaitTimeOut));

                    this.SetAsCompleted(toex, false);
                }
                catch (OperationFailureException ofex)
                {
                    this.SetAsCompleted(ofex, false);
                }
            }
Exemple #8
0
 internal AcdSupervisorSession(AcdAgentMatchMaker matchMaker, Supervisor supervisor, AcdLogger logger)
 {
     _matchMaker = matchMaker;
     _supervisor = supervisor;
     _logger     = logger;
 }
Exemple #9
0
 internal ShutdownAsyncResult(AsyncCallback asyncCallback, Object state, AcdAgentMatchMaker matchMaker)
     : base(asyncCallback, state)
 {
     _matchMaker = matchMaker;
 }