Ejemplo n.º 1
0
        public IEnumerable <Message> GetFilter(FiltersFlds filterFlds, List <Message> messages)
        {
            var        param      = Expression.Parameter(typeof(Message), "name");
            Expression filterCond = FilterByDate(param, filterFlds.minDate, filterFlds.maxDate);

            if (filterFlds.selectedNumber != null)
            {
                Expression filterNumber = FilterByNumber(param, filterFlds.selectedNumber);
                filterCond = joinExpressions(filterCond, filterNumber, filterFlds.filterLgc);
            }

            if (filterFlds.filterMsg != null)
            {
                Expression filterText = FilterByMsg(param, filterFlds.filterMsg);
                filterCond = joinExpressions(filterCond, filterText, filterFlds.filterLgc);
            }

            var results = Expression.Lambda <Func <Message, bool> >(
                filterCond,
                new ParameterExpression[] { param });

            var queMessages = messages.AsQueryable();
            var query       = queMessages.Where(results);

            return(query);
        }
Ejemplo n.º 2
0
        public void ShowMessages(List <Message> messages)
        {
            var         selectedNumber = selectNumber?.SelectedItem?.ToString();
            var         minDate        = fromDate.Value;
            var         maxDate        = toDate.Value;
            var         filterMsg      = filterMessage?.Text?.ToString();
            var         filterLgc      = filterLogic?.Text?.ToString();
            FiltersFlds filterFlds     = new FiltersFlds(selectedNumber, minDate, maxDate, filterMsg, filterLgc);
            Filters     filter         = new Filters();
            var         query          = filter.GetFilter(filterFlds, messages);

            var selectedFormat = selectFormatting.SelectedItem.ToString();

            FormatterDel = GetFormatter(selectedFormat);
            foreach (var message in query)
            {
                var messageItem = new ListViewItem(new[] { message.User, message.Number, FormatterDel(message.Text), message.ReceivingTime.ToString() });
                OnSMSRecieved(messageItem);
            }
        }