Esempio n. 1
0
        private MonitoredAgentViewModel CreateAgentViewModel(agentType agent)
        {
            MonitoredAgentViewModel avm = new MonitoredAgentViewModel(_monitoringChannel);

            avm.DisplayName = agent.displayname;
            //TODO:Ask stephane to send a number, ticks

            Int64 startTime;

            if (Int64.TryParse(agent.statuschangedtime, out startTime))
            {
                avm.StartTime = new DateTime(startTime).ToLocalTime();
            }

            if (agent.mediatypes != null)
            {
                foreach (string m in agent.mediatypes)
                {
                    avm.MediaTypes.Add(m);
                }
            }


            avm.Status = agent.status;
            avm.Uri    = agent.uri;

            return(avm);
        }
Esempio n. 2
0
        private SupervisedAgentViewModel CreateAgentViewModel(agentType agent)
        {
            SupervisedAgentViewModel avm = new SupervisedAgentViewModel(Model);

            avm.DisplayName = agent.displayname;

            Int64 startTime;

            if (Int64.TryParse(agent.statuschangedtime, out startTime))
            {
                avm.StartTime = new DateTime(startTime).ToLocalTime();
            }


            if (agent.mediatypes != null)
            {
                foreach (string m in agent.mediatypes)
                {
                    avm.MediaTypes.Add(m);
                }
            }

            avm.Status = agent.status;
            avm.Uri    = agent.uri;

            return(avm);
        }
Esempio n. 3
0
        private void SendFullAgentActivityStatus()
        {
            List <agentType> listOfAgentInfo = new List <agentType>();

            _listOfTrackedAgents.ForEach(agent =>
            {
                agentType agentInfo = Agent.Convert(agent, null);
                listOfAgentInfo.Add(agentInfo);
            });

            try
            {
                _supervisorControlChannel.BeginUpdateAgents(listOfAgentInfo,
                                                            null,
                                                            upa =>
                {
                    try
                    {
                        _supervisorControlChannel.EndUpdateAgents(upa);
                        _forceAgentActivityRefresh = false;
                    }
                    catch (RealTimeException rtex)
                    {
                        _logger.Log("AcdSupervisorSession failed to end refresh the full activity deltas of the agents", rtex);
                        _forceAgentActivityRefresh = true;
                    }
                },
                                                            null);
            }
            catch (InvalidOperationException ivoex)
            {
                _logger.Log("AcdSupervisorSession failed to begin refresh the full activity deltas of the agents", ivoex);
                _forceAgentActivityRefresh = true;
            }
        }
Esempio n. 4
0
        static public agentType Convert(Agent agent, ConversationParticipant participant)
        {
            agentType agentT = new agentType();

            if (null != participant)
            {
                agentT.displayname = participant.DisplayName;
                agentT.uri         = participant.Uri;

                int numberOfActiveModalities = participant.GetActiveMediaTypes().Count;

                if (numberOfActiveModalities != 0)
                {
                    agentT.mediatypes = new string[numberOfActiveModalities];

                    int i = 0;
                    foreach (String mediaType in participant.GetActiveMediaTypes())
                    {
                        agentT.mediatypes[i++] = mediaType;
                    }
                }
            }
            else
            {
                agentT.displayname = new SipUriParser(agent.SignInAddress).User;
                agentT.uri         = agent.SignInAddress;
            }
            KeyValuePair <DateTime, bool> allocated = agent.GetWhetherAllocated();

            agentT.status            = allocated.Value ? "Active" : "Idle";
            agentT.statuschangedtime = allocated.Key.Ticks.ToString();

            return(agentT);
        }
Esempio n. 5
0
        private void RefreshAgentActivity(object sender, EventArgs args)
        {
            if (_forceAgentActivityRefresh)
            {
                this.SendFullAgentActivityStatus();
            }
            else
            {
                //Filtering out the agents that have not changed during the polling TimeSpan
                List <agentType> listOfAgentInfo = new List <agentType>();

                _listOfTrackedAgents.ForEach(agent =>
                {
                    if (agent.GetWhetherPropertiesChanged())
                    {
                        agentType agentInfo   = new agentType();
                        agentInfo.uri         = agent.SignInAddress;
                        agentInfo.displayname = new SipUriParser(agent.SignInAddress).User;
                        KeyValuePair <DateTime, bool> activityStatus = agent.GetWhetherAllocated();
                        agentInfo.status            = activityStatus.Value ? "Allocated" : "Idle";
                        agentInfo.statuschangedtime = activityStatus.Key.Ticks.ToString();
                        listOfAgentInfo.Add(agentInfo);
                    }
                });


                try
                {
                    _supervisorControlChannel.BeginUpdateAgents(listOfAgentInfo,
                                                                null,
                                                                upa =>
                    {
                        try
                        {
                            _supervisorControlChannel.EndUpdateAgents(upa);
                            _forceAgentActivityRefresh = false;
                        }
                        catch (RealTimeException rtex)
                        {
                            _logger.Log("AcdSupervisorSession failed to end refresh the partial activity deltas of the agents", rtex);
                            _forceAgentActivityRefresh = true;
                        }
                    },
                                                                null);
                }
                catch (InvalidOperationException ivoex)
                {
                    _logger.Log("AcdSupervisorSession failed to begin refresh the partial activity deltas of the agents", ivoex);
                    _forceAgentActivityRefresh = true;
                }
            }

            _tmrItem.Reset();
        }