Ejemplo n.º 1
0
        public IEnumerable <Message> GetByFilter(TaskFilter filter)
        {
            var messages = messageDao.GetByFilter(filter, ProjectSecurity.CurrentUserAdministrator, ProjectSecurity.IsPrivateDisabled);

            var commentsCount = commentDao.Count(messages.Select(r => (ProjectEntity)r).ToList());

            return(messages.Select((message, index) =>
            {
                message.CommentsCount = commentsCount[index];
                return message;
            }));
        }
Ejemplo n.º 2
0
        public List <Message> GetByFilter(TaskFilter filter)
        {
            var isAdmin = ProjectSecurity.IsAdministrator(SecurityContext.CurrentAccount.ID);

            var messages = messageDao.GetByFilter(filter, isAdmin);

            var commentsCount = commentDao.GetCommentsCount(messages.Select(r => (ProjectEntity)r).ToList());

            return(messages.Select((message, index) =>
            {
                message.CommentsCount = commentsCount[index];
                return message;
            }).ToList());
        }
Ejemplo n.º 3
0
        public List <Message> GetByFilter(TaskFilter filter)
        {
            var listMessages = new List <Message>();

            while (true)
            {
                var messages = _messageDao.GetByFilter(filter).Where(CanRead).ToList();

                var lastMessageIndex = messages.FindIndex(r => r.ID == filter.LastId);

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

                listMessages.AddRange(messages);

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

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

                if (listMessages.Count == filter.Max || messages.Count == 0)
                {
                    break;
                }

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

                filter.Offset += filter.Max;
            }

            var commentsCount = _commentDao.GetCommentsCount(listMessages.Select(r => (ProjectEntity)r).ToList());

            return(listMessages.Select((message, index) =>
            {
                message.CommentsCount = commentsCount[index];
                return message;
            }).ToList());
        }