Beispiel #1
0
        public List <TimeSpend> GetByFilter(TaskFilter filter)
        {
            var listTimeSpend = new List <TimeSpend>();
            var isAdmin       = ProjectSecurity.CurrentUserAdministrator;
            var anyOne        = ProjectSecurity.IsPrivateDisabled;

            while (true)
            {
                var timeSpend = timeSpendDao.GetByFilter(filter, isAdmin, anyOne);
                timeSpend = GetTasks(timeSpend).Where(r => r.Task != null).ToList();

                if (filter.LastId != 0)
                {
                    var lastTimeSpendIndex = timeSpend.FindIndex(r => r.ID == filter.LastId);

                    if (lastTimeSpendIndex >= 0)
                    {
                        timeSpend = timeSpend.SkipWhile((r, index) => index <= lastTimeSpendIndex).ToList();
                    }
                }

                listTimeSpend.AddRange(timeSpend);

                if (filter.Max <= 0 || filter.Max > 150000)
                {
                    break;
                }

                listTimeSpend = listTimeSpend.Take((int)filter.Max).ToList();

                if (listTimeSpend.Count == filter.Max || timeSpend.Count == 0)
                {
                    break;
                }

                if (listTimeSpend.Count != 0)
                {
                    filter.LastId = listTimeSpend.Last().ID;
                }

                filter.Offset += filter.Max;
            }

            return(listTimeSpend);
        }
Beispiel #2
0
        public List <TimeSpend> GetByFilter(TaskFilter filter)
        {
            var listTimeSpend = new List <TimeSpend>();

            while (true)
            {
                var timeSpend = _timeSpendDao.GetByFilter(filter);
                timeSpend = GetTasks(timeSpend).FindAll(r => ProjectSecurity.CanRead(r.Task));

                if (filter.LastId != 0)
                {
                    var lastTimeSpendIndex = timeSpend.FindIndex(r => r.ID == filter.LastId);

                    if (lastTimeSpendIndex >= 0)
                    {
                        timeSpend = timeSpend.SkipWhile((r, index) => index <= lastTimeSpendIndex).ToList();
                    }
                }

                listTimeSpend.AddRange(timeSpend);

                if (filter.Max <= 0 || filter.Max > 150000)
                {
                    break;
                }

                listTimeSpend = listTimeSpend.Take((int)filter.Max).ToList();

                if (listTimeSpend.Count == filter.Max || timeSpend.Count == 0)
                {
                    break;
                }

                if (listTimeSpend.Count != 0)
                {
                    filter.LastId = listTimeSpend.Last().ID;
                }

                filter.Offset += filter.Max;
            }

            return(listTimeSpend);
        }