Пример #1
0
        private List <AgentStatusTerm> GetACDEvents(IList <IAgentStatus> acdList, DateTime start, DateTime end, double blockResolution, DateTime watchPoint)
        {
            List <AgentStatusTerm> results = new List <AgentStatusTerm>();

            if (acdList == null || acdList.Count == 0)
            {
                results.Add(new AgentStatusTerm()
                {
                    Start     = DateTime.MinValue,
                    End       = watchPoint > end ? end : watchPoint,
                    OnService = false
                });
                return(results);
            }

            if (acdList[0].TimeStamp > start)
            {
                acdList.Insert(0,
                               new AgentStatus()
                {
                    TimeStamp       = start,
                    AgentStatusType = new AgentStatusType()
                    {
                        OnService = false
                    }
                });
            }

            int          i           = 0;
            IAgentStatus preACDEvent = acdList[i];

            for (i = 1; i < acdList.Count; i++)
            {
                if (acdList[i].OnService != preACDEvent.OnService)
                {
                    double length = acdList[i].TimeStamp.Subtract(preACDEvent.TimeStamp).TotalSeconds;
                    if (blockResolution > length)
                    {
                        if (results.Count > 0)
                        {
                            results.RemoveAt(results.Count - 1);
                        }
                    }
                    else
                    {
                        AgentStatusTerm acdBlock = new AgentStatusTerm()
                        {
                            Start     = preACDEvent.TimeStamp,
                            End       = preACDEvent.TimeStamp.AddSeconds(length),
                            OnService = preACDEvent.OnService
                        };
                        results.Add(acdBlock);

                        preACDEvent = acdList[i];
                    }
                }
            }

            results.Add(new AgentStatusTerm()
            {
                Start     = preACDEvent.TimeStamp,
                End       = end,
                OnService = preACDEvent.OnService
            });
            return(results);
        }
Пример #2
0
        private List<AgentStatusTerm> GetACDEvents(IList<IAgentStatus> acdList, DateTime start, DateTime end, double blockResolution, DateTime watchPoint)
        {
            List<AgentStatusTerm> results = new List<AgentStatusTerm>();

            if (acdList == null || acdList.Count == 0)
            {
                results.Add(new AgentStatusTerm()
                {
                    Start = DateTime.MinValue,
                    End = watchPoint > end ? end : watchPoint,
                    OnService = false
                });
                return results;
            }

            if (acdList[0].TimeStamp > start)
            {
                acdList.Insert(0,
                               new AgentStatus()
                               {
                                   TimeStamp = start,
                                   AgentStatusType = new AgentStatusType() { OnService = false }
                               });
            }

            int i = 0;
            IAgentStatus preACDEvent = acdList[i];

            for (i = 1; i < acdList.Count; i++)
            {
                if (acdList[i].OnService != preACDEvent.OnService)
                {
                    double length = acdList[i].TimeStamp.Subtract(preACDEvent.TimeStamp).TotalSeconds;
                    if (blockResolution > length)
                    {
                        if (results.Count > 0)
                        {
                            results.RemoveAt(results.Count - 1);
                        }
                    }
                    else
                    {
                        AgentStatusTerm acdBlock = new AgentStatusTerm()
                        {
                            Start = preACDEvent.TimeStamp,
                            End = preACDEvent.TimeStamp.AddSeconds(length),
                            OnService = preACDEvent.OnService
                        };
                        results.Add(acdBlock);

                        preACDEvent = acdList[i];
                    }
                }
            }

            results.Add(new AgentStatusTerm()
            {
                Start = preACDEvent.TimeStamp,
                End = end,
                OnService = preACDEvent.OnService
            });
            return results;
        }